Skip to content

Commit 1af7154

Browse files
warrenclaude
andcommitted
Simplify: CI/CD, test quality, and source modernisation
CI/CD (ci.yml, release.yml): - Remove redundant single-entry matrix in ci.yml; use literal '25' throughout - Collapse three separate Maven invocations in release.yml (test → package → javadoc) into one: `mvn verify javadoc:javadoc`, eliminating two full compile cycles and two JVM startups Test quality (KMLExportTest, ShapeAttributesTest, layer tests): - KMLExportTest: extract attribute setup into @BeforeAll so data() is a pure data provider with no setup side-effects; remove @SuppressWarnings("unused") - ShapeAttributesTest.testRestoreNullDocument: replace broken try/catch/fail with assertThrows(IllegalArgumentException.class, ...) - AnnotationLayerTest, IconLayerTest, RenderableLayerTest: replace 14 try/catch/fail patterns with assertThrows; replace `e.printStackTrace()` in malicious-getter tests with `ignored` + explanatory comment Source modernisation (ZebraInputHandler, AbstractSceneController): - Add missing @OverRide annotations; convert iterator while-loop to enhanced for-each; use diamond operator on generic constructors Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 23b34ab commit 1af7154

9 files changed

Lines changed: 57 additions & 193 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,18 @@ on:
88

99
jobs:
1010
build:
11-
name: Build & Test (Java ${{ matrix.java }})
11+
name: Build & Test (Java 25)
1212
runs-on: ubuntu-latest
1313

14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
java: [ '25' ]
18-
1914
steps:
2015
- name: Check out source
2116
uses: actions/checkout@v4
2217

23-
- name: Set up JDK ${{ matrix.java }}
18+
- name: Set up JDK 25
2419
uses: actions/setup-java@v4
2520
with:
2621
distribution: temurin
27-
java-version: ${{ matrix.java }}
22+
java-version: '25'
2823
cache: maven
2924

3025
# JOGL opens a display connection during class initialisation even in
@@ -45,6 +40,6 @@ jobs:
4540
if: failure()
4641
uses: actions/upload-artifact@v4
4742
with:
48-
name: surefire-reports-java${{ matrix.java }}
43+
name: surefire-reports-java25
4944
path: target/surefire-reports/
5045
retention-days: 7

.github/workflows/release.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,10 @@ jobs:
2626
- name: Install Xvfb
2727
run: sudo apt-get install -y xvfb
2828

29-
# Run the full test suite before publishing — refuse to release a broken build.
30-
- name: Test
31-
run: xvfb-run --auto-servernum mvn --batch-mode --no-transfer-progress test
32-
33-
# Package produces target/worldwind-java-<version>.jar
34-
- name: Package
35-
run: mvn --batch-mode --no-transfer-progress -DskipTests package
36-
37-
# Generate Javadoc into target/site/apidocs/
38-
- name: Javadoc
39-
run: mvn --batch-mode --no-transfer-progress -DskipTests javadoc:javadoc
29+
# Compile, test, package, and generate Javadoc in one Maven invocation.
30+
# Tests run before packaging — refuse to release a broken build.
31+
- name: Build, test, and package
32+
run: xvfb-run --auto-servernum mvn --batch-mode --no-transfer-progress verify javadoc:javadoc
4033

4134
# Zip the Javadoc tree so it can be attached as a single release asset.
4235
- name: Zip Javadoc

src/com/zebraimaging/ZebraInputHandler.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,16 @@ public class ZebraInputHandler extends AWTInputHandler
2222

2323
final static TimerTask repaintContextsTask = new TimerTask()
2424
{
25+
@Override
2526
public void run()
2627
{
27-
Iterator<ZebraInputHandler> itr = instances.iterator();
28-
while (itr.hasNext())
29-
{
30-
ZebraInputHandler h = itr.next();
31-
if (h.NeedsRefresh() == true)
32-
{
33-
h.SetRefresh(false);
34-
h.getWorldWindow().redraw();
35-
}
36-
}
28+
for (ZebraInputHandler h : instances) {
29+
if (h.NeedsRefresh() == true)
30+
{
31+
h.SetRefresh(false);
32+
h.getWorldWindow().redraw();
33+
}
34+
}
3735
}
3836
};
3937

@@ -77,6 +75,7 @@ private synchronized boolean NeedsRefresh()
7775
return refresh;
7876
}
7977

78+
@Override
8079
public void keyPressed(KeyEvent e)
8180
{
8281
boolean consumed = false;
@@ -88,6 +87,7 @@ public void keyPressed(KeyEvent e)
8887
super.keyPressed(e);
8988
}
9089

90+
@Override
9191
public void keyReleased(KeyEvent e)
9292
{
9393
boolean consumed = false;
@@ -99,6 +99,7 @@ public void keyReleased(KeyEvent e)
9999
super.keyReleased(e);
100100
}
101101

102+
@Override
102103
public void mouseClicked(MouseEvent e)
103104
{
104105
boolean consumed = false;
@@ -110,6 +111,7 @@ public void mouseClicked(MouseEvent e)
110111
super.mouseClicked(e);
111112
}
112113

114+
@Override
113115
public void mousePressed(MouseEvent e)
114116
{
115117
boolean consumed = false;
@@ -121,6 +123,7 @@ public void mousePressed(MouseEvent e)
121123
super.mousePressed(e);
122124
}
123125

126+
@Override
124127
public void mouseReleased(MouseEvent e)
125128
{
126129
boolean consumed = false;

src/gov/nasa/worldwind/AbstractSceneController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public abstract class AbstractSceneController extends WWObjectImpl implements Sc
6868
* #doResolveTopPick(gov.nasa.worldwind.render.DrawContext, java.awt.Rectangle)}. This map is used only when a pick
6969
* rectangle is specified. Initialized to a new HashMap.
7070
*/
71-
protected Map<Integer, PickedObject> pickableObjects = new HashMap<Integer, PickedObject>();
71+
protected Map<Integer, PickedObject> pickableObjects = new HashMap<>();
7272
protected long frame = 0;
7373
protected long timebase = System.currentTimeMillis();
7474
protected double framesPerSecond;
@@ -87,7 +87,7 @@ public abstract class AbstractSceneController extends WWObjectImpl implements Sc
8787
protected boolean deepPick = false;
8888
protected GpuResourceCache gpuResourceCache;
8989
protected TextRendererCache textRendererCache = new TextRendererCache();
90-
protected Set<String> perFrameStatisticsKeys = new HashSet<String>();
90+
protected Set<String> perFrameStatisticsKeys = new HashSet<>();
9191
protected Collection<PerformanceStatistic> perFrameStatistics = new ArrayList<PerformanceStatistic>();
9292
protected Collection<Throwable> renderingExceptions = new ArrayList<Throwable>();
9393
protected ScreenCreditController screenCreditController;

test/gov/nasa/worldwind/layers/AnnotationLayerTest.java

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ public void testMaliciousGetAnnotations()
187187
}
188188
}
189189
}
190-
catch (UnsupportedOperationException e)
190+
catch (UnsupportedOperationException ignored)
191191
{
192-
e.printStackTrace();
192+
// An immutable view is acceptable — what matters is that layer state is unchanged below.
193193
}
194194

195195
// Test that the layer contents do not change, even if the returned list can be modified.
@@ -233,16 +233,8 @@ public void testAddAnnotationFail()
233233
AnnotationLayer layer = new AnnotationLayer();
234234
layer.setAnnotations(annotations);
235235

236-
try
237-
{
238-
// Expecting an IllegalStateException here.
239-
layer.addAnnotation(new GlobeAnnotation("", Position.ZERO));
240-
fail("");
241-
}
242-
catch (IllegalStateException e)
243-
{
244-
e.printStackTrace();
245-
}
236+
assertThrows(IllegalStateException.class,
237+
() -> layer.addAnnotation(new GlobeAnnotation("", Position.ZERO)));
246238
}
247239

248240
@Test
@@ -253,16 +245,7 @@ public void testAddAnnotationsFail()
253245
AnnotationLayer layer = new AnnotationLayer();
254246
layer.setAnnotations(annotations);
255247

256-
try
257-
{
258-
// Expecting an IllegalStateException here.
259-
layer.addAnnotations(annotations);
260-
fail("");
261-
}
262-
catch (IllegalStateException e)
263-
{
264-
e.printStackTrace();
265-
}
248+
assertThrows(IllegalStateException.class, () -> layer.addAnnotations(annotations));
266249
}
267250

268251
@Test
@@ -273,16 +256,8 @@ public void testRemoveAnnotationFail()
273256
AnnotationLayer layer = new AnnotationLayer();
274257
layer.setAnnotations(annotations);
275258

276-
try
277-
{
278-
// Expecting an IllegalStateException here.
279-
layer.removeAnnotation(new GlobeAnnotation("", Position.ZERO));
280-
fail("");
281-
}
282-
catch (IllegalStateException e)
283-
{
284-
e.printStackTrace();
285-
}
259+
assertThrows(IllegalStateException.class,
260+
() -> layer.removeAnnotation(new GlobeAnnotation("", Position.ZERO)));
286261
}
287262

288263
@Test
@@ -293,16 +268,7 @@ public void testRemoveAllAnnotationsFail()
293268
AnnotationLayer layer = new AnnotationLayer();
294269
layer.setAnnotations(annotations);
295270

296-
try
297-
{
298-
// Expecting an IllegalStateException here.
299-
layer.removeAllAnnotations();
300-
fail("");
301-
}
302-
catch (IllegalStateException e)
303-
{
304-
e.printStackTrace();
305-
}
271+
assertThrows(IllegalStateException.class, () -> layer.removeAllAnnotations());
306272
}
307273

308274
//////////////////////////////////////////////////////////

test/gov/nasa/worldwind/layers/IconLayerTest.java

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ public void testMaliciousGetIcons()
187187
}
188188
}
189189
}
190-
catch (UnsupportedOperationException e)
190+
catch (UnsupportedOperationException ignored)
191191
{
192-
e.printStackTrace();
192+
// An immutable view is acceptable — what matters is that layer state is unchanged below.
193193
}
194194

195195
// Test that the layer contents do not change, even if the returned list can be modified.
@@ -233,16 +233,8 @@ public void testAddIconFail()
233233
IconLayer layer = new IconLayer();
234234
layer.setIcons(icons);
235235

236-
try
237-
{
238-
// Expecting an IllegalStateException here.
239-
layer.addIcon(new UserFacingIcon("", Position.ZERO));
240-
fail("");
241-
}
242-
catch (IllegalStateException e)
243-
{
244-
e.printStackTrace();
245-
}
236+
assertThrows(IllegalStateException.class,
237+
() -> layer.addIcon(new UserFacingIcon("", Position.ZERO)));
246238
}
247239

248240
@Test
@@ -253,16 +245,7 @@ public void testAddIconsFail()
253245
IconLayer layer = new IconLayer();
254246
layer.setIcons(icons);
255247

256-
try
257-
{
258-
// Expecting an IllegalStateException here.
259-
layer.addIcons(icons);
260-
fail("");
261-
}
262-
catch (IllegalStateException e)
263-
{
264-
e.printStackTrace();
265-
}
248+
assertThrows(IllegalStateException.class, () -> layer.addIcons(icons));
266249
}
267250

268251
@Test
@@ -273,16 +256,8 @@ public void testRemoveIconFail()
273256
IconLayer layer = new IconLayer();
274257
layer.setIcons(icons);
275258

276-
try
277-
{
278-
// Expecting an IllegalStateException here.
279-
layer.removeIcon(new UserFacingIcon("", Position.ZERO));
280-
fail("");
281-
}
282-
catch (IllegalStateException e)
283-
{
284-
e.printStackTrace();
285-
}
259+
assertThrows(IllegalStateException.class,
260+
() -> layer.removeIcon(new UserFacingIcon("", Position.ZERO)));
286261
}
287262

288263
@Test
@@ -293,16 +268,7 @@ public void testRemoveAllIconsFail()
293268
IconLayer layer = new IconLayer();
294269
layer.setIcons(icons);
295270

296-
try
297-
{
298-
// Expecting an IllegalStateException here.
299-
layer.removeAllIcons();
300-
fail("");
301-
}
302-
catch (IllegalStateException e)
303-
{
304-
e.printStackTrace();
305-
}
271+
assertThrows(IllegalStateException.class, () -> layer.removeAllIcons());
306272
}
307273

308274
//////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)