Changeset 36064 in osm for applications/editors/josm/plugins
- Timestamp:
- 2023-03-21T14:49:10+01:00 (21 months ago)
- Location:
- applications/editors/josm/plugins
- Files:
-
- 79 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideAbstractImageTest.java
r34432 r36064 2 2 package org.openstreetmap.josm.plugins.streetside; 3 3 4 import static org.junit. Assert.assertFalse;5 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 6 7 import org.junit. Test;7 import org.junit.jupiter.api.Test; 8 8 import org.openstreetmap.josm.data.coor.LatLon; 9 9 10 public class StreetsideAbstractImageTest { 11 12 /*@Rule 13 public JOSMTestRules rules = new StreetsideTestRules().platform();*/ 14 10 class StreetsideAbstractImageTest { 15 11 @Test 16 publicvoid testIsModified() {12 void testIsModified() { 17 13 StreetsideImage img = new StreetsideImage("key___________________", new LatLon(0, 0), 0); 18 14 assertFalse(img.isModified()); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideDataTest.java
r34434 r36064 2 2 package org.openstreetmap.josm.plugins.streetside; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertThrows; 5 8 6 9 import java.util.Arrays; 7 10 import java.util.concurrent.ConcurrentSkipListSet; 8 11 9 import org.junit. Before;10 import org.junit. Ignore;11 import org.junit. Test;12 import org.junit.jupiter.api.BeforeEach; 13 import org.junit.jupiter.api.Test; 14 import org.junit.jupiter.api.condition.DisabledIf; 12 15 import org.openstreetmap.josm.data.coor.LatLon; 13 16 … … 18 21 * @see StreetsideData 19 22 */ 20 public class StreetsideDataTest { 23 @DisabledIf(value = "org.openstreetmap.josm.plugins.streetside.utils.TestUtil#cannotLoadImages", disabledReason = "At JOSM maintainer request (flaky?)") 24 class StreetsideDataTest { 21 25 22 26 /*@Rule … … 33 37 * objects and a {@link StreetsideSequence} object. 34 38 */ 35 @Before 39 @BeforeEach 36 40 public void setUp() { 37 41 img1 = new StreetsideImage("id1__________________", new LatLon(0.1, 0.1), 90); … … 51 55 * another one in the database, the one that is being added should be ignored. 52 56 */ 53 @Ignore54 57 @Test 55 public void addTest() {58 void testAdd() { 56 59 data = new StreetsideData(); 57 60 assertEquals(0, data.getImages().size()); … … 69 72 * Test that the size is properly calculated. 70 73 */ 71 @Ignore72 74 @Test 73 public void sizeTest() {75 void testSize() { 74 76 assertEquals(4, data.getImages().size()); 75 77 data.add(new StreetsideImage("id5__________________", new LatLon(0.1, 0.1), 90)); … … 81 83 * and {@link StreetsideData#getHighlightedImage()} methods. 82 84 */ 83 @Ignore84 85 @Test 85 public void highlighTest() {86 void testHighlight() { 86 87 data.setHighlightedImage(img1); 87 88 assertEquals(img1, data.getHighlightedImage()); 88 89 89 90 data.setHighlightedImage(null); 90 assert Equals(null,data.getHighlightedImage());91 assertNull(data.getHighlightedImage()); 91 92 } 92 93 … … 94 95 * Tests the selection of images. 95 96 */ 96 @Ignore97 97 @Test 98 public void selectTest() {98 void testSelect() { 99 99 data.setSelectedImage(img1); 100 100 assertEquals(img1, data.getSelectedImage()); … … 104 104 105 105 data.setSelectedImage(null); 106 assert Equals(null,data.getSelectedImage());106 assertNull(data.getSelectedImage()); 107 107 } 108 108 … … 111 111 * {@link StreetsideData#selectPrevious()} methods. 112 112 */ 113 @Ignore114 113 @Test 115 public void nextAndPreviousTest() {114 void testNextAndPrevious() { 116 115 data.setSelectedImage(img1); 117 116 … … 126 125 } 127 126 128 @Ignore 129 @Test(expected=IllegalStateException.class) 130 public void nextOfNullImgTest() { 127 @Test 128 void testNextOfNullImg() { 131 129 data.setSelectedImage(null); 132 data.selectNext();130 assertThrows(IllegalStateException.class, data::selectNext); 133 131 } 134 132 135 @Ignore 136 @Test(expected=IllegalStateException.class) 137 public void previousOfNullImgTest() { 133 @Test 134 void testPreviousOfNullImg() { 138 135 data.setSelectedImage(null); 139 data.selectPrevious();136 assertThrows(IllegalStateException.class, data::selectPrevious); 140 137 } 141 138 … … 144 141 * multiselected List should reset. 145 142 */ 146 @Ignore147 143 @Test 148 public void multiSelectTest() {144 void testMultiSelect() { 149 145 assertEquals(0, data.getMultiSelectedImages().size()); 150 146 data.setSelectedImage(img1); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideLayerTest.java
r34434 r36064 2 2 package org.openstreetmap.josm.plugins.streetside; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertNotNull;7 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 8 8 9 import org.junit.Ignore; 10 import org.junit.Rule; 11 import org.junit.Test; 9 import org.junit.jupiter.api.Test; 10 import org.junit.jupiter.api.condition.DisabledIf; 12 11 import org.openstreetmap.josm.data.coor.LatLon; 13 12 import org.openstreetmap.josm.data.imagery.ImageryInfo; … … 15 14 import org.openstreetmap.josm.gui.layer.Layer; 16 15 import org.openstreetmap.josm.plugins.streetside.cubemap.CubemapUtils; 17 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;18 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 18 import org.openstreetmap.josm.testutils.annotations.Main; 19 import org.openstreetmap.josm.testutils.annotations.Projection; 19 20 20 public class StreetsideLayerTest { 21 22 @Rule 23 public JOSMTestRules rules = new StreetsideTestRules().main().preferences().projection(); 24 21 @BasicPreferences 22 @Main 23 @Projection 24 @DisabledIf(value = "org.openstreetmap.josm.plugins.streetside.utils.TestUtil#cannotLoadImages", disabledReason = "At JOSM maintainer request (flaky?)") 25 class StreetsideLayerTest { 25 26 private static Layer getDummyLayer() { 26 27 return ImageryLayer.create(new ImageryInfo("dummy", "https://example.org")); 27 28 } 28 29 29 @Ignore30 30 @Test 31 publicvoid testGetIcon() {31 void testGetIcon() { 32 32 assertNotNull(StreetsideLayer.getInstance().getIcon()); 33 33 } 34 34 35 @Ignore36 35 @Test 37 publicvoid testIsMergable() {36 void testIsMergable() { 38 37 assertFalse(StreetsideLayer.getInstance().isMergable(getDummyLayer())); 39 38 } 40 39 41 @Ignore 42 @Test(expected = UnsupportedOperationException.class) 43 public void testMergeFrom() { 44 StreetsideLayer.getInstance().mergeFrom(getDummyLayer()); 40 @Test 41 void testMergeFrom() { 42 StreetsideLayer layer = StreetsideLayer.getInstance(); 43 Layer dummyLayer = getDummyLayer(); 44 assertThrows(UnsupportedOperationException.class, () -> layer.mergeFrom(dummyLayer)); 45 45 } 46 46 47 @Ignore48 47 @Test 49 publicvoid testSetVisible() {48 void testSetVisible() { 50 49 StreetsideLayer.getInstance().getData().add(new StreetsideImage(CubemapUtils.TEST_IMAGE_ID, new LatLon(0.0, 0.0), 0.0)); 51 50 StreetsideLayer.getInstance().getData().add(new StreetsideImage(CubemapUtils.TEST_IMAGE_ID, new LatLon(0.0, 0.0), 0.0)); … … 56 55 StreetsideLayer.getInstance().setVisible(false); 57 56 for (StreetsideAbstractImage img : StreetsideLayer.getInstance().getData().getImages()) { 58 assert Equals(false,img.isVisible());57 assertFalse(img.isVisible()); 59 58 } 60 59 … … 62 61 StreetsideLayer.getInstance().setVisible(true); 63 62 for (StreetsideAbstractImage img : StreetsideLayer.getInstance().getData().getImages()) { 64 assert Equals(true,img.isVisible());63 assertTrue(img.isVisible()); 65 64 } 66 65 } 67 66 68 @Ignore69 67 @Test 70 publicvoid testGetInfoComponent() {68 void testGetInfoComponent() { 71 69 Object comp = StreetsideLayer.getInstance().getInfoComponent(); 72 70 assertTrue(comp instanceof String); … … 74 72 } 75 73 76 @Ignore77 74 @Test 78 publicvoid testClearInstance() {75 void testClearInstance() { 79 76 StreetsideLayer.getInstance(); 80 77 assertTrue(StreetsideLayer.hasInstance()); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideSequenceTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNull; 6 import static org.junit.Assert.assertTrue; 7 import static org.junit.Assert.fail; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNull; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 8 7 9 8 import java.util.Arrays; 10 9 11 import org.junit.Before; 12 import org.junit.Test; 13 10 import org.junit.jupiter.api.BeforeEach; 11 import org.junit.jupiter.api.Test; 14 12 import org.openstreetmap.josm.data.coor.LatLon; 15 13 … … 20 18 * @see StreetsideSequence 21 19 */ 22 publicclass StreetsideSequenceTest {20 class StreetsideSequenceTest { 23 21 24 22 private final StreetsideImage img1 = new StreetsideImage("key1", new LatLon(0.1, 0.1), 90); … … 33 31 * {@link StreetsideSequence} object. 34 32 */ 35 @Before 33 @BeforeEach 36 34 public void setUp() { 37 35 seq.add(Arrays.asList(img1, img2, img3, img4)); … … 43 41 */ 44 42 @Test 45 public void nextAndPreviousTest() {43 void testNextAndPrevious() { 46 44 assertEquals(img2, img1.next()); 47 45 assertEquals(img1, img2.previous()); … … 60 58 // Test IllegalArgumentException when asking for the next image of an image 61 59 // that is not in the sequence. 62 try { 63 seq.next(imgWithoutSeq); 64 fail(); 65 } catch (IllegalArgumentException e) { 66 assertTrue(true); 67 } 60 assertThrows(IllegalArgumentException.class, () -> seq.next(imgWithoutSeq)); 61 68 62 // Test IllegalArgumentException when asking for the previous image of an 69 63 // image that is not in the sequence. 70 try { 71 seq.previous(imgWithoutSeq); 72 fail(); 73 } catch (IllegalArgumentException e) { 74 assertTrue(true); 75 } 64 assertThrows(IllegalArgumentException.class, () -> seq.previous(imgWithoutSeq)); 76 65 } 77 66 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cache/CachesTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.cache; 3 3 4 import org.junit.Test;5 4 5 import org.junit.jupiter.api.Test; 6 6 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil; 7 7 8 publicclass CachesTest {8 class CachesTest { 9 9 10 10 @Test 11 publicvoid testUtilityClass() {11 void testUtilityClass() { 12 12 TestUtil.testUtilityClass(Caches.class); 13 13 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cache/StreetsideCacheTest.java
r34386 r36064 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.streetside.cache; 3 //License: GPL. For details, see LICENSE file.4 3 5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertNotNull;7 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertNull; 8 7 9 import org.junit.Rule; 10 import org.junit.Test; 8 import org.junit.jupiter.api.Test; 9 import org.openstreetmap.josm.plugins.streetside.cache.StreetsideCache.Type; 10 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 11 11 12 import org.openstreetmap.josm.plugins.streetside.cache.StreetsideCache.Type; 13 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules; 14 import org.openstreetmap.josm.testutils.JOSMTestRules; 15 16 public class StreetsideCacheTest { 17 18 @Rule 19 public JOSMTestRules rules = new StreetsideTestRules().preferences(); 12 @BasicPreferences 13 class StreetsideCacheTest { 20 14 21 15 @Test 22 public void test() {16 void testCache() { 23 17 StreetsideCache cache = new StreetsideCache("00000", Type.FULL_IMAGE); 24 18 assertNotNull(cache.getUrl()); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapUtilsTest.java
r34432 r36064 1 1 package org.openstreetmap.josm.plugins.streetside.cubemap; 2 2 3 import static org.junit.Assert.assertEquals;4 3 5 import org.junit.Ignore; 6 import org.junit.Test; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 7 5 8 public class CubemapUtilsTest { 6 import org.junit.jupiter.api.Disabled; 7 import org.junit.jupiter.api.Test; 9 8 10 @SuppressWarnings("static-method") 9 class CubemapUtilsTest { 10 11 11 @Test 12 public finalvoid testConvertDecimal2Quaternary() {13 final long decimal0 = 680730040 l;14 final long decimal1 = 680931568 l;12 void testConvertDecimal2Quaternary() { 13 final long decimal0 = 680730040L; 14 final long decimal1 = 680931568L; 15 15 String res = CubemapUtils.convertDecimal2Quaternary(decimal0); 16 16 assertEquals("220210301312320", res); … … 19 19 } 20 20 21 @SuppressWarnings("static-method")22 21 @Test 23 public finalvoid testConvertQuaternary2Decimal() {22 void testConvertQuaternary2Decimal() { 24 23 final String quadKey0 = "220210301312320"; 25 24 final String quadKey1 = "220211203003300"; … … 30 29 } 31 30 32 @SuppressWarnings("static-method") 33 @Ignore 31 @Disabled 34 32 @Test 35 public finalvoid testGetFaceNumberForCount() {33 void testGetFaceNumberForCount() { 36 34 String faceNrFront = CubemapUtils.getFaceNumberForCount(0); 37 35 String faceNrRight = CubemapUtils.getFaceNumberForCount(1); … … 48 46 } 49 47 50 @SuppressWarnings("static-method") 51 @Ignore 48 @Disabled 52 49 @Test 53 public finalvoid testGetCount4FaceNumber() {50 void testGetCount4FaceNumber() { 54 51 int count4Front = CubemapUtils.getCount4FaceNumber("01"); 55 52 int count4Right = CubemapUtils.getCount4FaceNumber("02"); … … 66 63 } 67 64 68 @SuppressWarnings("static-method")69 65 @Test 70 public finalvoid testConvertDoubleCountNrto16TileNr() {66 void testConvertDoubleCountNrto16TileNr() { 71 67 String x0y0 = CubemapUtils.convertDoubleCountNrto16TileNr("00"); 72 68 String x0y1 = CubemapUtils.convertDoubleCountNrto16TileNr("01"); … … 92 88 assertEquals(x1y0, "02"); 93 89 assertEquals(x1y1, "03"); 94 assertEquals(x1y2, "12");90 assertEquals(x1y2, "12"); 95 91 assertEquals(x1y3, "13"); 96 92 assertEquals(x2y0, "20"); … … 99 95 assertEquals(x2y3, "31"); 100 96 assertEquals(x3y0, "22"); 101 assertEquals(x3y1, "23");97 assertEquals(x3y1, "23"); 102 98 assertEquals(x3y2, "32"); 103 99 assertEquals(x3y3, "33"); 104 100 } 105 106 101 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cubemap/TileDownloadingTaskTest.java
r34428 r36064 1 1 package org.openstreetmap.josm.plugins.streetside.cubemap; 2 2 3 import static org.junit.Assert.assertEquals; 4 import static org.junit. Assert.fail;3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.util.ArrayList; … … 11 11 import java.util.concurrent.Future; 12 12 13 import org.junit. Ignore;14 import org.junit. Test;13 import org.junit.jupiter.api.Disabled; 14 import org.junit.jupiter.api.Test; 15 15 16 public class TileDownloadingTaskTest { 16 @Disabled 17 class TileDownloadingTaskTest { 17 18 18 @SuppressWarnings("static-method")19 @Ignore20 19 @Test 21 public final void testCall(){20 final void testCall() throws InterruptedException { 22 21 ExecutorService pool = Executors.newFixedThreadPool(1); 23 22 List<Callable<List<String>>> tasks = new ArrayList<>(1); 24 23 tasks.add(new TileDownloadingTask("2202112030033001233")); 25 try { 26 List<Future<List<String>>> results = pool.invokeAll(tasks); 27 assertEquals(results.get(0),"2202112030033001233"); 28 } catch (InterruptedException e) { 29 e.printStackTrace(); 30 fail("Test threw an exception."); 31 } 24 List<Future<List<String>>> results = pool.invokeAll(tasks); 25 assertEquals(results.get(0), "2202112030033001233"); 32 26 } 33 27 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/ImageDisplayTest.java
r34432 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.gui; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.awt.GraphicsEnvironment; … … 11 11 import javax.swing.JFrame; 12 12 13 import org.junit.Rule; 14 import org.junit.Test; 15 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules; 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 13 import org.junit.jupiter.api.Test; 14 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 17 15 18 16 /** 19 17 * Tests {@link StreetsideImageDisplay} 20 18 */ 21 public class ImageDisplayTest { 22 23 @Rule 24 public JOSMTestRules rules = new StreetsideTestRules().preferences(); 19 @BasicPreferences 20 class ImageDisplayTest { 25 21 26 22 private static final BufferedImage DUMMY_IMAGE = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); 27 23 28 24 @Test 29 publicvoid testImagePersistence() {25 void testImagePersistence() { 30 26 StreetsideImageDisplay display = new StreetsideImageDisplay(); 31 27 display.setImage(DUMMY_IMAGE, null); … … 39 35 40 36 @Test 41 publicvoid testMouseWheelMoved() {37 void testMouseWheelMoved() { 42 38 if (GraphicsEnvironment.isHeadless()) { 43 39 return; … … 65 61 */ 66 62 @Test 67 publicvoid testMouseClicked() {63 void testMouseClicked() { 68 64 if (GraphicsEnvironment.isHeadless()) { 69 65 return; -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/StreetsidePreferenceSettingTest.java
r34434 r36064 1 1 package org.openstreetmap.josm.plugins.streetside.gui; 2 2 3 import static org.junit.Assert.assertEquals; 4 import static org.junit.Assert.assertFalse; 3 import static org.junit.jupiter.api.Assertions.assertEquals; 5 4 import static org.openstreetmap.josm.plugins.streetside.utils.TestUtil.getPrivateFieldValue; 6 5 … … 11 10 import javax.swing.SpinnerNumberModel; 12 11 13 import org.junit. Ignore;14 import org.junit. Rule;15 import org.junit. Test;12 import org.junit.jupiter.api.Assertions; 13 import org.junit.jupiter.api.Disabled; 14 import org.junit.jupiter.api.Test; 16 15 import org.openstreetmap.josm.data.preferences.BooleanProperty; 17 16 import org.openstreetmap.josm.data.preferences.StringProperty; 18 17 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 19 18 import org.openstreetmap.josm.plugins.streetside.io.download.StreetsideDownloader.DOWNLOAD_MODE; 20 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules; 21 import org.openstreetmap.josm.testutils.JOSMTestRules; 19 import org.openstreetmap.josm.testutils.annotations.Main; 22 20 23 public class StreetsidePreferenceSettingTest { 24 25 @Rule 26 public JOSMTestRules rules = new StreetsideTestRules().main(); 27 21 @Main 22 @Disabled 23 class StreetsidePreferenceSettingTest { 28 24 // TODO: repair broken unit test from Mapillary 29 @Ignore30 25 @Test 31 publicvoid testAddGui() {26 void testAddGui() { 32 27 if (GraphicsEnvironment.isHeadless()) { 33 28 return; … … 42 37 } 43 38 44 @Ignore45 39 @Test 46 publicvoid testIsExpert() {47 assertFalse(new StreetsidePreferenceSetting().isExpert());40 void testIsExpert() { 41 Assertions.assertFalse(new StreetsidePreferenceSetting().isExpert()); 48 42 } 49 43 50 44 @SuppressWarnings("unchecked") 51 @Ignore52 45 @Test 53 publicvoid testOk() {46 void testOk() { 54 47 StreetsidePreferenceSetting settings = new StreetsidePreferenceSetting(); 55 48 -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/boilerplate/SelectableLabelTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.gui.boilerplate; 3 3 4 import static org.junit. Assert.assertFalse;5 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 6 7 import org.junit. Test;7 import org.junit.jupiter.api.Test; 8 8 9 public class SelectableLabelTest { 9 10 class SelectableLabelTest { 10 11 @Test 11 public void test() {12 void testSelectableLabel() { 12 13 SelectableLabel l1 = new SelectableLabel(); 13 14 assertFalse(l1.isEditable()); … … 15 16 assertTrue(l2.getText().contains("some text")); 16 17 assertFalse(l2.isEditable()); 17 18 18 } 19 19 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/history/StreetsideRecordTest.java
r34433 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.history; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.fail; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 6 7 7 8 import java.util.Arrays; … … 9 10 import java.util.concurrent.ConcurrentSkipListSet; 10 11 11 import org.junit.Before; 12 import org.junit.Ignore; 13 import org.junit.Rule; 14 import org.junit.Test; 12 import org.junit.jupiter.api.BeforeEach; 13 import org.junit.jupiter.api.Disabled; 14 import org.junit.jupiter.api.Test; 15 15 import org.openstreetmap.josm.data.coor.LatLon; 16 16 import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage; … … 22 22 import org.openstreetmap.josm.plugins.streetside.history.commands.CommandUnjoin; 23 23 import org.openstreetmap.josm.plugins.streetside.history.commands.StreetsideCommand; 24 import org.openstreetmap.josm. plugins.streetside.utils.TestUtil.StreetsideTestRules;25 import org.openstreetmap.josm.testutils. JOSMTestRules;24 import org.openstreetmap.josm.testutils.annotations.Main; 25 import org.openstreetmap.josm.testutils.annotations.Projection; 26 26 27 27 /** … … 30 30 * @author nokutu 31 31 */ 32 public class StreetsideRecordTest { 33 34 @Rule 35 public JOSMTestRules rules = new StreetsideTestRules().main().projection(); 32 @Main 33 @Projection 34 @Disabled 35 class StreetsideRecordTest { 36 36 37 37 private StreetsideRecord record; … … 44 44 * objects. 45 45 */ 46 @Before 46 @BeforeEach 47 47 public void setUp() { 48 48 record = new StreetsideRecord(); … … 58 58 * Test commands in general. 59 59 */ 60 @Ignore 61 @Test 62 public void commandTest() { 60 @Test 61 void testCommand() { 63 62 StreetsideCommand cmd12 = new CommandMove( 64 63 new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)), … … 115 114 * Tests {@link CommandMove} class. 116 115 */ 117 @Ignore 118 @Test 119 public void commandMoveTest() { 116 @Test 117 void testCommandMove() { 120 118 CommandMove cmd1 = new CommandMove( 121 119 new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)), … … 150 148 * Tests {@link CommandTurn} class. 151 149 */ 152 @Ignore 153 @Test 154 public void commandTurnTest() { 150 @Test 151 void testCommandTurn() { 155 152 CommandTurn cmd1 = new CommandTurn( 156 153 new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)), … … 182 179 * Tests {@link CommandJoin} class. 183 180 */ 184 @Ignore 185 @Test 186 public void commandJoinClass() { 181 @Test 182 void testCommandJoinClass() { 187 183 CommandJoin cmd1 = new CommandJoin(img1, img2); 188 184 CommandJoin cmd2 = new CommandJoin(img2, img3); … … 199 195 } 200 196 201 @Ignore 202 @Test(expected=NullPointerException.class) 203 public void commandJoinNull1() { 204 new CommandJoin(img1, null); 205 } 206 207 @Ignore 208 @Test(expected=NullPointerException.class) 209 public void commandJoinNull2() { 210 new CommandJoin(null, img1); 197 @Test 198 void testCommandJoinNull1() { 199 assertThrows(NullPointerException.class, () -> new CommandJoin(img1, null)); 200 } 201 202 @Test 203 void commandJoinNull2() { 204 assertThrows(NullPointerException.class, () -> new CommandJoin(null, img1)); 211 205 } 212 206 … … 214 208 * Tests {@link CommandUnjoin} class. 215 209 */ 216 @Ignore 217 @Test 218 public void commandUnjoinClass() { 210 @Test 211 void testCommandUnjoinClass() { 219 212 CommandJoin join1 = new CommandJoin(img1, img2); 220 213 CommandJoin join2 = new CommandJoin(img2, img3); … … 237 230 assertEquals(1, img2.getSequence().getImages().size()); 238 231 239 try { 240 record.addCommand(new CommandUnjoin(Arrays.asList(new StreetsideAbstractImage[]{img1, img2, img3}))); 241 fail(); 242 } catch (IllegalArgumentException e) { 243 // Expected output. 244 } 232 CommandUnjoin command = new CommandUnjoin(Arrays.asList(new StreetsideAbstractImage[]{img1, img2, img3})); 233 assertThrows(IllegalArgumentException.class, () -> record.addCommand(command)); 245 234 } 246 235 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/io/download/SequenceDownloadRunnableTest.java
r34577 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.io.download; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 6 7 import java.lang.reflect.Field; … … 9 10 import java.util.function.Function; 10 11 11 import org.junit.AfterClass; 12 import org.junit.Ignore; 13 import org.junit.Rule; 14 import org.junit.Test; 12 import org.junit.jupiter.api.Disabled; 13 import org.junit.jupiter.api.Test; 15 14 import org.openstreetmap.josm.data.Bounds; 16 import org.openstreetmap.josm.gui.MainApplication;17 15 import org.openstreetmap.josm.plugins.streetside.StreetsideLayer; 18 16 import org.openstreetmap.josm.plugins.streetside.utils.StreetsideProperties; 19 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules; 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 import org.openstreetmap.josm.testutils.annotations.LayerManager; 21 18 22 public class SequenceDownloadRunnableTest { 23 24 @Rule 25 public JOSMTestRules rules = new StreetsideTestRules(); 19 @Disabled 20 @LayerManager 21 class SequenceDownloadRunnableTest { 26 22 27 23 private static final Function<Bounds, URL> SEARCH_SEQUENCES_URL_GEN = b -> { … … 30 26 private Field urlGenField; 31 27 32 @AfterClass33 public static void tearDown() {34 MainApplication.getLayerManager().resetState();35 }36 28 37 @Ignore38 29 @Test 39 publicvoid testRun1() throws IllegalArgumentException, IllegalAccessException {30 void testRun1() throws IllegalArgumentException, IllegalAccessException { 40 31 testNumberOfDecodedImages(4, SEARCH_SEQUENCES_URL_GEN, new Bounds(7.246497, 16.432955, 7.249027, 16.432976)); 41 32 } 42 33 43 @Ignore44 34 @Test 45 publicvoid testRun2() throws IllegalArgumentException, IllegalAccessException {35 void testRun2() throws IllegalArgumentException, IllegalAccessException { 46 36 testNumberOfDecodedImages(0, SEARCH_SEQUENCES_URL_GEN, new Bounds(0, 0, 0, 0)); 47 37 } 48 38 49 @Ignore50 39 @Test 51 publicvoid testRun3() throws IllegalArgumentException, IllegalAccessException {40 void testRun3() throws IllegalArgumentException, IllegalAccessException { 52 41 testNumberOfDecodedImages(0, b -> { 53 42 try { return new URL("https://streetside/nonexistentURL"); } catch (MalformedURLException e) { return null; } … … 55 44 } 56 45 57 @Ignore58 46 @Test 59 publicvoid testRun4() throws IllegalArgumentException, IllegalAccessException {47 void testRun4() throws IllegalArgumentException, IllegalAccessException { 60 48 StreetsideProperties.CUT_OFF_SEQUENCES_AT_BOUNDS.put(true); 61 49 testNumberOfDecodedImages(4, SEARCH_SEQUENCES_URL_GEN, new Bounds(7.246497, 16.432955, 7.249027, 16.432976)); 62 50 } 63 51 64 @Ignore65 52 @Test 66 publicvoid testRun5() throws IllegalArgumentException, IllegalAccessException {53 void testRun5() throws IllegalArgumentException, IllegalAccessException { 67 54 StreetsideProperties.CUT_OFF_SEQUENCES_AT_BOUNDS.put(true); 68 55 testNumberOfDecodedImages(0, SEARCH_SEQUENCES_URL_GEN, new Bounds(0, 0, 0, 0)); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/ImageUtilTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 6 7 import java.awt.image.BufferedImage; … … 8 9 import javax.swing.ImageIcon; 9 10 10 import org.junit. Test;11 import org.junit.jupiter.api.Test; 11 12 12 public class ImageUtilTest { 13 14 class ImageUtilTest { 13 15 14 16 @Test 15 publicvoid testUtilityClass() {17 void testUtilityClass() { 16 18 TestUtil.testUtilityClass(ImageUtil.class); 17 19 } 18 20 19 21 @Test 20 publicvoid testScaleImageIcon() {22 void testScaleImageIcon() { 21 23 ImageIcon largeLandscape = new ImageIcon(new BufferedImage(72, 60, BufferedImage.TYPE_4BYTE_ABGR)); 22 24 ImageIcon largePortrait = new ImageIcon(new BufferedImage(56, 88, BufferedImage.TYPE_4BYTE_ABGR)); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/PluginStateTest.java
r34583 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertFalse; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 5 8 6 9 import javax.swing.JOptionPane; 7 10 8 import org.junit. Test;11 import org.junit.jupiter.api.Test; 9 12 import org.openstreetmap.josm.TestUtils; 10 13 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; … … 16 19 * @see PluginState 17 20 */ 18 publicclass PluginStateTest {21 class PluginStateTest { 19 22 20 23 /** … … 22 25 */ 23 26 @Test 24 public void downloadTest() {25 assert Equals(false,PluginState.isDownloading());27 void testDownload() { 28 assertFalse(PluginState.isDownloading()); 26 29 PluginState.startDownload(); 27 assert Equals(true,PluginState.isDownloading());30 assertTrue(PluginState.isDownloading()); 28 31 PluginState.startDownload(); 29 assert Equals(true,PluginState.isDownloading());32 assertTrue(PluginState.isDownloading()); 30 33 PluginState.finishDownload(); 31 assert Equals(true,PluginState.isDownloading());34 assertTrue(PluginState.isDownloading()); 32 35 PluginState.finishDownload(); 33 assert Equals(false,PluginState.isDownloading());36 assertFalse(PluginState.isDownloading()); 34 37 } 35 38 … … 38 41 */ 39 42 @Test 40 public void uploadTest() {43 void testUpload() { 41 44 TestUtils.assumeWorkingJMockit(); 42 45 JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(); … … 45 48 JOptionPane.OK_OPTION 46 49 ); 47 assert Equals(false,PluginState.isUploading());50 assertFalse(PluginState.isUploading()); 48 51 PluginState.addImagesToUpload(2); 49 52 assertEquals(2, PluginState.getImagesToUpload()); 50 53 assertEquals(0, PluginState.getImagesUploaded()); 51 assert Equals(true,PluginState.isUploading());54 assertTrue(PluginState.isUploading()); 52 55 PluginState.imageUploaded(); 53 56 assertEquals(1, PluginState.getImagesUploaded()); 54 assert Equals(true,PluginState.isUploading());57 assertTrue(PluginState.isUploading()); 55 58 PluginState.imageUploaded(); 56 assert Equals(false,PluginState.isUploading());59 assertFalse(PluginState.isUploading()); 57 60 assertEquals(2, PluginState.getImagesToUpload()); 58 61 assertEquals(2, PluginState.getImagesUploaded()); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideColorSchemeTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 5 4 6 import javax.swing.JComponent; 5 7 6 import org.junit. Test;8 import org.junit.jupiter.api.Test; 7 9 8 publicclass StreetsideColorSchemeTest {10 class StreetsideColorSchemeTest { 9 11 10 12 @Test 11 publicvoid testUtilityClass() {13 void testUtilityClass() { 12 14 TestUtil.testUtilityClass(StreetsideColorScheme.class); 13 15 } 14 16 15 17 @Test 16 publicvoid testStyleAsDefaultPanel() {17 StreetsideColorScheme.styleAsDefaultPanel();18 StreetsideColorScheme.styleAsDefaultPanel((JComponent[]) null);18 void testStyleAsDefaultPanel() { 19 assertDoesNotThrow(() -> StreetsideColorScheme.styleAsDefaultPanel()); 20 assertDoesNotThrow(() -> StreetsideColorScheme.styleAsDefaultPanel((JComponent[]) null)); 19 21 } 20 22 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsidePropertiesTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import org.junit.Rule; 5 import org.junit.Test; 6 7 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules; 8 import org.openstreetmap.josm.testutils.JOSMTestRules; 4 import org.junit.jupiter.api.Test; 9 5 10 6 public class StreetsidePropertiesTest { 11 12 @Rule13 public JOSMTestRules rules = new StreetsideTestRules();14 15 7 @Test 16 public void test () {8 public void testUtilityClass() { 17 9 TestUtil.testUtilityClass(StreetsideProperties.class); 18 10 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideURLTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNull;6 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNull; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 7 8 8 import java.lang.reflect.InvocationTargetException; … … 11 11 import java.net.URL; 12 12 13 import org.junit.Ignore; 14 import org.junit.Test; 13 import org.junit.jupiter.api.Assertions; 14 import org.junit.jupiter.api.Disabled; 15 import org.junit.jupiter.api.Test; 15 16 16 publicclass StreetsideURLTest {17 class StreetsideURLTest { 17 18 // TODO: replace with Streetside URL @rrh 18 19 private static final String CLIENT_ID_QUERY_PART = "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"; … … 44 45 45 46 @Test 46 publicvoid testParseNextFromHeaderValue() throws MalformedURLException {47 void testParseNextFromHeaderValue() throws MalformedURLException { 47 48 String headerVal = 48 49 "<https://a.streetside.com/v3/sequences?page=1&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2>; rel=\"first\", " + 49 50 "<https://a.streetside.com/v3/sequences?page=2&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2>; rel=\"prev\", " + 50 51 "<https://a.streetside.com/v3/sequences?page=4&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2>; rel=\"next\""; 51 assertEquals( 52 new URL("https://a.streetside.com/v3/sequences?page=4&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2"), 53 StreetsideURL.APIv3.parseNextFromLinkHeaderValue(headerVal) 54 ); 52 assertEquals(new URL("https://a.streetside.com/v3/sequences?page=4&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2"), StreetsideURL.APIv3.parseNextFromLinkHeaderValue(headerVal)); 55 53 } 56 54 57 55 @Test 58 publicvoid testParseNextFromHeaderValue2() throws MalformedURLException {56 void testParseNextFromHeaderValue2() throws MalformedURLException { 59 57 String headerVal = 60 58 "<https://urlFirst>; rel=\"first\", " + … … 66 64 67 65 @Test 68 publicvoid testParseNextFromHeaderValueNull() {69 assert Equals(null,StreetsideURL.APIv3.parseNextFromLinkHeaderValue(null));66 void testParseNextFromHeaderValueNull() { 67 assertNull(StreetsideURL.APIv3.parseNextFromLinkHeaderValue(null)); 70 68 } 71 69 72 70 @Test 73 publicvoid testParseNextFromHeaderValueMalformed() {74 assert Equals(null,StreetsideURL.APIv3.parseNextFromLinkHeaderValue("<###>; rel=\"next\", blub"));71 void testParseNextFromHeaderValueMalformed() { 72 assertNull(StreetsideURL.APIv3.parseNextFromLinkHeaderValue("<###>; rel=\"next\", blub")); 75 73 } 76 74 … … 85 83 }*/ 86 84 87 @ Ignore85 @Disabled 88 86 @Test 89 public void testBrowseImageURL() throws MalformedURLException { 90 assertEquals( 91 new URL("https://www.streetside.com/map/im/1234567890123456789012"), 92 StreetsideURL.MainWebsite.browseImage("1234567890123456789012") 93 ); 87 void testBrowseImageURL() throws MalformedURLException { 88 assertEquals(new URL("https://www.streetside.com/map/im/1234567890123456789012"), StreetsideURL.MainWebsite.browseImage("1234567890123456789012")); 94 89 } 95 90 96 @Test (expected = IllegalArgumentException.class)97 publicvoid testIllegalBrowseImageURL() {98 StreetsideURL.MainWebsite.browseImage(null);91 @Test 92 void testIllegalBrowseImageURL() { 93 assertThrows(IllegalArgumentException.class, () -> StreetsideURL.MainWebsite.browseImage(null)); 99 94 } 100 95 101 @ Ignore96 @Disabled 102 97 @Test 103 publicvoid testConnectURL() {98 void testConnectURL() { 104 99 /*assertUrlEquals( 105 100 StreetsideURL.MainWebsite.connect("http://redirect-host/ä"), … … 128 123 } 129 124 130 @ Ignore125 @Disabled 131 126 @Test 132 publicvoid testUploadSecretsURL() throws MalformedURLException {127 void testUploadSecretsURL() throws MalformedURLException { 133 128 /*assertEquals( 134 129 new URL("https://a.streetside.com/v2/me/uploads/secrets?"+CLIENT_ID_QUERY_PART), … … 137 132 } 138 133 139 @ Ignore134 @Disabled 140 135 @Test 141 publicvoid testUserURL() throws MalformedURLException {136 void testUserURL() throws MalformedURLException { 142 137 /*assertEquals( 143 138 new URL("https://a.streetside.com/v3/me?"+CLIENT_ID_QUERY_PART), … … 147 142 148 143 @Test 149 publicvoid testString2MalformedURL()144 void testString2MalformedURL() 150 145 throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { 151 146 Method method = StreetsideURL.class.getDeclaredMethod("string2URL", String[].class); 152 147 method.setAccessible(true); 153 assertNull(method.invoke(null, new Object[]{new String[]{"malformed URL"}})); // this simply invokes string2URL("malformed URL")154 assertNull(method.invoke(null, new Object[]{null})); // invokes string2URL(null)148 Assertions.assertNull(method.invoke(null, new Object[]{new String[]{"malformed URL"}})); // this simply invokes string2URL("malformed URL") 149 Assertions.assertNull(method.invoke(null, new Object[]{null})); // invokes string2URL(null) 155 150 } 156 151 157 152 @Test 158 publicvoid testUtilityClass() {153 void testUtilityClass() { 159 154 TestUtil.testUtilityClass(StreetsideURL.class); 160 155 TestUtil.testUtilityClass(StreetsideURL.APIv3.class); … … 173 168 parameterIsPresent |= actualParams[acIndex].equals(expectedParams[exIndex]); 174 169 } 175 assertTrue( 176 expectedParams[exIndex] + " was expected in the query string of " + actualUrl.toString() + " but wasn't there.", 177 parameterIsPresent 178 ); 170 Assertions.assertTrue(parameterIsPresent, expectedParams[exIndex] + " was expected in the query string of " + actualUrl.toString() + " but wasn't there."); 179 171 } 180 172 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideUtilsTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import org.apache.commons.imaging.common.RationalNumber; 7 7 import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants; 8 import org.junit. Test;8 import org.junit.jupiter.api.Test; 9 9 10 10 /** … … 15 15 * 16 16 */ 17 publicclass StreetsideUtilsTest {17 class StreetsideUtilsTest { 18 18 19 19 @Test 20 publicvoid testUtilityClass() {20 void testUtilityClass() { 21 21 TestUtil.testUtilityClass(StreetsideUtils.class); 22 22 } … … 27 27 */ 28 28 @Test 29 public void degMinSecToDoubleTest() {29 void testDegMinSecToDouble() { 30 30 RationalNumber[] num = new RationalNumber[3]; 31 31 num[0] = new RationalNumber(1, 1); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/TestUtil.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertTrue;6 import static org.junit. Assert.fail;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 import static org.junit.jupiter.api.Assertions.fail; 7 7 8 8 import java.awt.GraphicsEnvironment; … … 15 15 16 16 import org.junit.runners.model.InitializationError; 17 17 import org.openstreetmap.josm.plugins.streetside.StreetsidePlugin; 18 import org.openstreetmap.josm.spi.preferences.Config; 19 import org.openstreetmap.josm.spi.preferences.MemoryPreferences; 18 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 import org.openstreetmap.josm.tools.ImageProvider; 19 22 import org.openstreetmap.josm.tools.Logging; 20 23 import org.openstreetmap.josm.tools.Utils; … … 27 30 private TestUtil() { 28 31 // Prevent instantiation 32 } 33 34 /** 35 * Check if we can load images 36 * @return {@code true} if the {@link StreetsidePlugin#LOGO} could be loaded 37 */ 38 public static boolean cannotLoadImages() { 39 // The class-level @DisabledIf seems to be run prior to any possible setup code 40 if (Config.getPref() == null) { 41 Config.setPreferencesInstance(new MemoryPreferences()); 42 } 43 return new ImageProvider("streetside-logo").setOptional(true).getResource() == null; 29 44 } 30 45 -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/api/JsonDecoderTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils.api; 3 3 4 import static org.junit.Assert.assertNull; 4 5 import static org.junit.jupiter.api.Assertions.assertNull; 5 6 6 7 import java.io.ByteArrayInputStream; … … 11 12 import javax.json.JsonObject; 12 13 13 import org.junit.Test; 14 14 import org.junit.jupiter.api.Test; 15 15 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil; 16 16 17 publicclass JsonDecoderTest {17 class JsonDecoderTest { 18 18 19 19 @Test 20 publicvoid testUtilityClass() {20 void testUtilityClass() { 21 21 TestUtil.testUtilityClass(JsonDecoder.class); 22 22 } 23 23 24 24 @Test 25 publicvoid testDecodeDoublePair() {25 void testDecodeDoublePair() { 26 26 assertNull(JsonDecoder.decodeDoublePair(null)); 27 27 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/api/JsonSequencesDecoderTest.java
r34432 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils.api; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNotNull; 6 import static org.junit.Assert.assertNull; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 6 import static org.openstreetmap.josm.plugins.streetside.utils.api.JsonDecoderTest.assertDecodesToNull; 8 7 … … 19 18 import javax.json.JsonValue; 20 19 21 import org.junit.Ignore; 22 import org.junit.Test; 20 import org.junit.jupiter.api.Assertions; 21 import org.junit.jupiter.api.Disabled; 22 import org.junit.jupiter.api.Test; 23 23 import org.openstreetmap.josm.data.coor.LatLon; 24 24 import org.openstreetmap.josm.plugins.streetside.StreetsideImage; … … 27 27 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil; 28 28 29 publicclass JsonSequencesDecoderTest {30 31 @ Ignore32 @Test 33 publicvoid testDecodeSequences() {29 class JsonSequencesDecoderTest { 30 31 @Disabled 32 @Test 33 void testDecodeSequences() { 34 34 Collection<StreetsideSequence> exampleSequences = JsonDecoder.decodeFeatureCollection( 35 35 Json.createReader(this.getClass().getResourceAsStream("test/data/api/v3/responses/searchSequences.json")).readObject(), … … 51 51 assertEquals(329.94820000000004, seq.getImages().get(3).getHe(), 1e-10); 52 52 53 assertEquals(new LatLon(7.246497, 16.432958), 54 assertEquals(new LatLon(7.246567, 16.432955), 55 assertEquals(new LatLon(7.248372, 16.432971), 56 assertEquals(new LatLon(7.249027, 16.432976), 53 assertEquals(new LatLon(7.246497, 16.432958), seq.getImages().get(0).getLatLon()); 54 assertEquals(new LatLon(7.246567, 16.432955), seq.getImages().get(1).getLatLon()); 55 assertEquals(new LatLon(7.248372, 16.432971), seq.getImages().get(2).getLatLon()); 56 assertEquals(new LatLon(7.249027, 16.432976), seq.getImages().get(3).getLatLon()); 57 57 58 58 assertEquals(1_457_963_093_860L, seq.getCd()); // 2016-03-14T13:44:53.860 UTC … … 60 60 61 61 @Test 62 publicvoid testDecodeSequencesInvalid() {62 void testDecodeSequencesInvalid() { 63 63 // null input 64 64 assertEquals(0, JsonDecoder.decodeFeatureCollection(null, JsonSequencesDecoder::decodeSequence).size()); … … 76 76 77 77 @Test 78 publicvoid testDecodeSequencesWithArbitraryObjectAsFeature() {78 void testDecodeSequencesWithArbitraryObjectAsFeature() { 79 79 assertNumberOfDecodedSequences(0, "{\"type\": \"FeatureCollection\", \"features\": [{}]}"); 80 80 } 81 81 82 82 private static void assertNumberOfDecodedSequences(int expectedNumberOfSequences, String jsonString) { 83 assertEquals( 84 expectedNumberOfSequences, 85 JsonDecoder.decodeFeatureCollection( 86 Json.createReader(new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8))).readObject(), 87 JsonSequencesDecoder::decodeSequence 88 ).size() 89 ); 90 } 91 92 @Ignore 93 @Test 94 public void testDecodeSequence() { 83 assertEquals(expectedNumberOfSequences, JsonDecoder.decodeFeatureCollection( 84 Json.createReader(new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8))).readObject(), 85 JsonSequencesDecoder::decodeSequence 86 ).size()); 87 } 88 89 @Disabled 90 @Test 91 void testDecodeSequence() { 95 92 StreetsideSequence exampleSequence = JsonSequencesDecoder.decodeSequence( 96 93 Json.createReader(this.getClass().getResourceAsStream("/api/v3/responses/sequence.json")).readObject() … … 100 97 assertEquals(2, exampleSequence.getImages().size()); 101 98 102 assertEquals( 103 new StreetsideImage("76P0YUrlDD_lF6J7Od3yoA", new LatLon(16.43279, 7.246085), 96.71454), 104 exampleSequence.getImages().get(0) 105 ); 106 assertEquals( 107 new StreetsideImage("Ap_8E0BwoAqqewhJaEbFyQ", new LatLon(16.432799, 7.246082), 96.47705000000002), 108 exampleSequence.getImages().get(1) 109 ); 110 } 111 112 @Test 113 public void testDecodeSequenceInvalid() { 99 assertEquals(new StreetsideImage("76P0YUrlDD_lF6J7Od3yoA", new LatLon(16.43279, 7.246085), 96.71454), exampleSequence.getImages().get(0)); 100 assertEquals(new StreetsideImage("Ap_8E0BwoAqqewhJaEbFyQ", new LatLon(16.432799, 7.246082), 96.47705000000002), exampleSequence.getImages().get(1)); 101 } 102 103 @Test 104 void testDecodeSequenceInvalid() { 114 105 // null input 115 assertNull(JsonSequencesDecoder.decodeSequence(null));106 Assertions.assertNull(JsonSequencesDecoder.decodeSequence(null)); 116 107 // `properties` key is not set 117 108 assertDecodesToNull(JsonSequencesDecoder::decodeSequence, "{\"type\": \"Feature\"}"); … … 150 141 */ 151 142 @Test 152 publicvoid testDecodeJsonArray()143 void testDecodeJsonArray() 153 144 throws NoSuchMethodException, SecurityException, IllegalAccessException, 154 145 IllegalArgumentException, InvocationTargetException { 155 146 Method method = JsonSequencesDecoder.class.getDeclaredMethod("decodeJsonArray", JsonArray.class, Function.class, Class.class); 156 147 method.setAccessible(true); 157 assertEquals( 158 0, 159 ((String[]) method.invoke(null, null, (Function<JsonValue, String>) val -> null, String.class)).length 160 ); 161 } 162 163 @Test 164 public void testDecodeCoordinateProperty() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { 148 assertEquals(0, ((String[]) method.invoke(null, null, (Function<JsonValue, String>) val -> null, String.class)).length); 149 } 150 151 @Test 152 void testDecodeCoordinateProperty() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { 165 153 Method decodeCoordinateProperty = JsonSequencesDecoder.class.getDeclaredMethod( 166 154 "decodeCoordinateProperty", … … 172 160 decodeCoordinateProperty.setAccessible(true); 173 161 174 assertEquals( 175 0, 176 ((String[]) decodeCoordinateProperty.invoke( 177 null, null, "key", (Function<JsonValue, String>) val -> "string", String.class 178 )).length 179 ); 180 181 assertEquals( 182 0, 183 ((String[]) decodeCoordinateProperty.invoke( 184 null, JsonUtil.string2jsonObject("{\"coordinateProperties\":{\"key\":0}}"), "key", (Function<JsonValue, String>) val -> "string", String.class 185 )).length 186 ); 187 } 188 189 @Test 190 public void testDecodeLatLons() 162 assertEquals(0, ((String[]) decodeCoordinateProperty.invoke( 163 null, null, "key", (Function<JsonValue, String>) val -> "string", String.class 164 )).length); 165 166 assertEquals(0, ((String[]) decodeCoordinateProperty.invoke( 167 null, JsonUtil.string2jsonObject("{\"coordinateProperties\":{\"key\":0}}"), "key", (Function<JsonValue, String>) val -> "string", String.class 168 )).length); 169 } 170 171 @Test 172 void testDecodeLatLons() 191 173 throws NoSuchMethodException, SecurityException, IllegalAccessException, 192 174 IllegalArgumentException, InvocationTargetException { … … 206 188 )).readObject()); 207 189 assertEquals(3, example.length); 208 assertNull(example[0]);209 assertNull(example[1]);210 assertNull(example[2]);211 } 212 213 @Test 214 publicvoid testUtilityClass() {190 Assertions.assertNull(example[0]); 191 Assertions.assertNull(example[1]); 192 Assertions.assertNull(example[2]); 193 } 194 195 @Test 196 void testUtilityClass() { 215 197 TestUtil.testUtilityClass(JsonSequencesDecoder.class); 216 198 } -
applications/editors/josm/plugins/alignways/test/unit/org/openstreetmap/josm/plugins/alignways/geometry/AlignWaysGeomLineTest.java
r34489 r36064 2 2 package org.openstreetmap.josm.plugins.alignways.geometry; 3 3 4 import static org.junit.Assert.assertTrue;5 4 6 import org.junit.Before; 7 import org.junit.Test; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertSame; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 8 9 import org.junit.jupiter.api.BeforeEach; 10 import org.junit.jupiter.api.Test; 8 11 import org.openstreetmap.josm.plugins.alignways.geometry.AlignWaysGeomLine.IntersectionStatus; 9 12 … … 11 14 * Tests of {@link AlignWaysGeomLine} 12 15 */ 13 publicclass AlignWaysGeomLineTest {16 class AlignWaysGeomLineTest { 14 17 private AlignWaysGeomLine line_x1y1x2y2, line_par_x1y1x2y2; 15 18 private AlignWaysGeomLine line_abc; … … 18 21 private AlignWaysGeomLine line_horiz, line_vert; 19 22 20 @Before 21 publicvoid setUp() {23 @BeforeEach 24 void setUp() { 22 25 line_x1y1x2y2 = new AlignWaysGeomLine(-2.0, -1.0, 4.0, 3.0); 23 26 line_abc = new AlignWaysGeomLine(2.0/3, -1.0, 1.0/3); … … 30 33 31 34 @Test 32 public voidLineLineEquiv() {33 assert True(line_x1y1x2y2.equals(line_line));35 void testLineLineEquiv() { 36 assertEquals(line_x1y1x2y2, line_line); 34 37 } 35 38 36 39 @Test 37 public voidLineAbcLineEquiv() {38 assert True(line_x1y1x2y2.equals(line_abc));40 void testLineAbcLineEquiv() { 41 assertEquals(line_x1y1x2y2, line_abc); 39 42 } 40 43 41 44 @Test 42 public voidLineMbLineEquiv() {43 assert True(line_x1y1x2y2.equals(line_mb));45 void testLineMbLineEquiv() { 46 assertEquals(line_x1y1x2y2, line_mb); 44 47 } 45 48 46 49 @Test 47 public voidLineAbcMbEquiv() {48 assert True(line_abc.equals(line_mb));50 void testLineAbcMbEquiv() { 51 assertEquals(line_abc, line_mb); 49 52 } 50 53 51 54 @Test 52 public voidLineLineParallel() {55 void testLineLineParallel() { 53 56 line_x1y1x2y2.getIntersection(line_par_x1y1x2y2); 54 assert True(line_x1y1x2y2.getIntersectionStatus() ==IntersectionStatus.LINES_PARALLEL);57 assertSame(line_x1y1x2y2.getIntersectionStatus(), IntersectionStatus.LINES_PARALLEL); 55 58 } 56 59 57 60 @Test 58 public voidLineAbcOverlap() {61 void testLineAbcOverlap() { 59 62 line_x1y1x2y2.getIntersection(line_abc); 60 assert True(line_x1y1x2y2.getIntersectionStatus() ==IntersectionStatus.LINES_OVERLAP);63 assertSame(line_x1y1x2y2.getIntersectionStatus(), IntersectionStatus.LINES_OVERLAP); 61 64 } 62 65 63 66 @Test 64 public voidLineMbOverlap() {67 void testLineMbOverlap() { 65 68 line_x1y1x2y2.getIntersection(line_mb); 66 assert True(line_x1y1x2y2.getIntersectionStatus() ==IntersectionStatus.LINES_OVERLAP);69 assertSame(line_x1y1x2y2.getIntersectionStatus(), IntersectionStatus.LINES_OVERLAP); 67 70 } 68 71 69 72 @Test 70 public voidAbcMbOverlap() {73 void testAbcMbOverlap() { 71 74 line_abc.getIntersection(line_mb); 72 assert True(line_abc.getIntersectionStatus() ==IntersectionStatus.LINES_OVERLAP);75 assertSame(line_abc.getIntersectionStatus(), IntersectionStatus.LINES_OVERLAP); 73 76 } 74 77 75 78 @Test 76 public voidGetXOnHoriz() {79 void testGetXOnHoriz() { 77 80 assertTrue(line_horiz.getXonLine(2.0).isNaN()); 78 81 } 79 82 80 83 @Test 81 public voidGetYOnVert() {84 void testGetYOnVert() { 82 85 assertTrue(line_vert.getYonLine(2.0).isNaN()); 83 86 } 84 87 85 88 @Test 86 public void StatusUndefAfterConstruct() throws Exception{89 void testStatusUndefAfterConstruct() { 87 90 AlignWaysGeomLine newLine = new AlignWaysGeomLine(1.0, 2.0); 88 assertTrue(newLine.getIntersectionStatus() == IntersectionStatus.UNDEFINED); 89 91 assertSame(newLine.getIntersectionStatus(), IntersectionStatus.UNDEFINED); 90 92 } 91 93 -
applications/editors/josm/plugins/cadastre-fr/test/unit/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoRecordTest.java
r33773 r36064 2 2 package org.openstreetmap.josm.plugins.fr.cadastre.edigeo; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.util.Arrays; 7 7 8 import org.junit. Test;8 import org.junit.jupiter.api.Test; 9 9 import org.openstreetmap.josm.TestUtils; 10 10 import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoRecord.Format; … … 16 16 * Unit test of {@link EdigeoRecord}. 17 17 */ 18 publicclass EdigeoRecordTest {18 class EdigeoRecordTest { 19 19 20 20 /** … … 22 22 */ 23 23 @Test 24 publicvoid testEdigeoRecord() {24 void testEdigeoRecord() { 25 25 EdigeoRecord r = new EdigeoRecord("SCPCP27:TEST01;SeSD;OBJ;PARCELLE_id"); 26 26 assertEquals("SCP", r.name); … … 35 35 */ 36 36 @Test 37 publicvoid testEqualsContract() {37 void testEqualsContract() { 38 38 TestUtils.assumeWorkingEqualsVerifier(); 39 39 EqualsVerifier.forClass(EdigeoRecord.class).usingGetClass() -
applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/AsyncEventBusTest.java
r34000 r36064 17 17 package org.openstreetmap.josm.eventbus; 18 18 19 import static org.junit. Assert.assertEquals;20 import static org.junit. Assert.assertTrue;19 import static org.junit.jupiter.api.Assertions.assertEquals; 20 import static org.junit.jupiter.api.Assertions.assertTrue; 21 21 22 22 import java.util.ArrayList; … … 24 24 import java.util.concurrent.Executor; 25 25 26 import org.junit.Before; 27 import org.junit.Test; 28 import org.openstreetmap.josm.eventbus.AsyncEventBus; 26 import org.junit.jupiter.api.BeforeEach; 27 import org.junit.jupiter.api.Test; 29 28 30 29 /** … … 33 32 * @author Cliff Biffle 34 33 */ 35 publicclass AsyncEventBusTest {34 class AsyncEventBusTest { 36 35 private static final String EVENT = "Hello"; 37 36 … … 41 40 private AsyncEventBus bus; 42 41 43 @Before 44 public void setUp() throws Exception{42 @BeforeEach 43 void setUp() { 45 44 executor = new FakeExecutor(); 46 45 bus = new AsyncEventBus(executor); … … 48 47 49 48 @Test 50 publicvoid testBasicDistribution() {49 void testBasicDistribution() { 51 50 StringCatcher catcher = new StringCatcher(); 52 51 bus.register(catcher); … … 56 55 57 56 List<String> events = catcher.getEvents(); 58 assertTrue( "No events should be delivered synchronously.", events.isEmpty());57 assertTrue(events.isEmpty(), "No events should be delivered synchronously."); 59 58 60 59 // Now we find the task in our Executor and explicitly activate it. 61 60 List<Runnable> tasks = executor.getTasks(); 62 assertEquals( "One event dispatch task should be queued.", 1, tasks.size());61 assertEquals(1, tasks.size(), "One event dispatch task should be queued."); 63 62 64 63 tasks.get(0).run(); 65 64 66 assertEquals( "One event should be delivered.", 1, events.size());67 assertEquals( "Correct string should be delivered.", EVENT, events.get(0));65 assertEquals(1, events.size(), "One event should be delivered."); 66 assertEquals(EVENT, events.get(0), "Correct string should be delivered."); 68 67 } 69 68 -
applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/DispatcherTest.java
r34000 r36064 27 27 import java.util.concurrent.CyclicBarrier; 28 28 29 import org.junit.Ignore; 30 import org.junit.Test; 31 import org.openstreetmap.josm.eventbus.Dispatcher; 32 import org.openstreetmap.josm.eventbus.EventBus; 33 import org.openstreetmap.josm.eventbus.Subscribe; 34 import org.openstreetmap.josm.eventbus.Subscriber; 29 import org.junit.jupiter.api.Disabled; 30 import org.junit.jupiter.api.Test; 35 31 36 32 /** … … 40 36 */ 41 37 42 publicclass DispatcherTest {38 class DispatcherTest { 43 39 44 40 private final EventBus bus = new EventBus(); … … 66 62 67 63 @Test 68 @ Ignore("FIXME")69 publicvoid testPerThreadQueuedDispatcher() {64 @Disabled("FIXME") 65 void testPerThreadQueuedDispatcher() { 70 66 dispatcher = Dispatcher.perThreadDispatchQueue(); 71 67 dispatcher.dispatch(1, integerSubscribers.iterator()); … … 87 83 88 84 @Test 89 @ Ignore("FIXME")90 publicvoid testLegacyAsyncDispatcher() {85 @Disabled("FIXME") 86 void testLegacyAsyncDispatcher() { 91 87 dispatcher = Dispatcher.legacyAsync(); 92 88 … … 95 91 96 92 new Thread( 97 new Runnable() { 98 @Override 99 public void run() { 100 try { 101 barrier.await(); 102 } catch (Exception e) { 103 throw new AssertionError(e); 104 } 93 () -> { 94 try { 95 barrier.await(); 96 } catch (Exception e) { 97 throw new AssertionError(e); 98 } 105 99 106 dispatcher.dispatch(2, integerSubscribers.iterator()); 107 latch.countDown(); 108 } 100 dispatcher.dispatch(2, integerSubscribers.iterator()); 101 latch.countDown(); 109 102 }) 110 103 .start(); 111 104 112 105 new Thread( 113 new Runnable() { 114 @Override 115 public void run() { 116 try { 117 barrier.await(); 118 } catch (Exception e) { 119 throw new AssertionError(e); 120 } 106 () -> { 107 try { 108 barrier.await(); 109 } catch (Exception e) { 110 throw new AssertionError(e); 111 } 121 112 122 dispatcher.dispatch("foo", stringSubscribers.iterator()); 123 latch.countDown(); 124 } 113 dispatcher.dispatch("foo", stringSubscribers.iterator()); 114 latch.countDown(); 125 115 }) 126 116 .start(); … … 135 125 136 126 @Test 137 @ Ignore("FIXME")138 publicvoid testImmediateDispatcher() {127 @Disabled("FIXME") 128 void testImmediateDispatcher() { 139 129 dispatcher = Dispatcher.immediate(); 140 130 dispatcher.dispatch(1, integerSubscribers.iterator()); -
applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/EventBusTest.java
r34000 r36064 17 17 package org.openstreetmap.josm.eventbus; 18 18 19 import static org.junit.Assert.assertEquals; 20 import static org.junit.Assert.fail; 19 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 20 import static org.junit.jupiter.api.Assertions.assertEquals; 21 import static org.junit.jupiter.api.Assertions.assertThrows; 21 22 22 23 import java.util.ArrayList; 23 import java.util. Arrays;24 import java.util.Collections; 24 25 import java.util.List; 25 26 import java.util.concurrent.CopyOnWriteArrayList; … … 29 30 import java.util.concurrent.atomic.AtomicInteger; 30 31 31 import org.junit.Before; 32 import org.junit.Test; 33 import org.openstreetmap.josm.eventbus.DeadEvent; 34 import org.openstreetmap.josm.eventbus.EventBus; 35 import org.openstreetmap.josm.eventbus.Subscribe; 36 import org.openstreetmap.josm.eventbus.SubscriberExceptionContext; 37 import org.openstreetmap.josm.eventbus.SubscriberExceptionHandler; 32 import org.junit.jupiter.api.BeforeEach; 33 import org.junit.jupiter.api.Test; 38 34 39 35 /** … … 42 38 * @author Cliff Biffle 43 39 */ 44 publicclass EventBusTest {40 class EventBusTest { 45 41 private static final String EVENT = "Hello"; 46 42 private static final String BUS_IDENTIFIER = "test-bus"; … … 48 44 private EventBus bus; 49 45 50 @Before 51 public void setUp() throws Exception{46 @BeforeEach 47 void setUp() { 52 48 bus = new EventBus(BUS_IDENTIFIER); 53 49 } 54 50 55 51 @Test 56 publicvoid testBasicCatcherDistribution() {52 void testBasicCatcherDistribution() { 57 53 StringCatcher catcher = new StringCatcher(); 58 54 bus.register(catcher); … … 60 56 61 57 List<String> events = catcher.getEvents(); 62 assertEquals( "Only one event should be delivered.", 1, events.size());63 assertEquals( "Correct string should be delivered.", EVENT, events.get(0));58 assertEquals(1, events.size(), "Only one event should be delivered."); 59 assertEquals(EVENT, events.get(0), "Correct string should be delivered."); 64 60 } 65 61 … … 71 67 */ 72 68 @Test 73 publicvoid testPolymorphicDistribution() {69 void testPolymorphicDistribution() { 74 70 // Three catchers for related types String, Object, and Comparable<?>. 75 71 // String isa Object … … 101 97 // Two additional event types: Object and Comparable<?> (played by Integer) 102 98 Object objEvent = new Object(); 103 Object compEvent = new Integer(6);99 Object compEvent = 6; 104 100 105 101 bus.post(EVENT); … … 109 105 // Check the StringCatcher... 110 106 List<String> stringEvents = stringCatcher.getEvents(); 111 assertEquals( "Only one String should be delivered.", 1, stringEvents.size());112 assertEquals( "Correct string should be delivered.", EVENT, stringEvents.get(0));107 assertEquals(1, stringEvents.size(), "Only one String should be delivered."); 108 assertEquals(EVENT, stringEvents.get(0), "Correct string should be delivered."); 113 109 114 110 // Check the Catcher<Object>... 115 assertEquals("Three Objects should be delivered.", 3, objectEvents.size()); 116 assertEquals("String fixture must be first object delivered.", EVENT, objectEvents.get(0)); 117 assertEquals("Object fixture must be second object delivered.", objEvent, objectEvents.get(1)); 118 assertEquals( 119 "Comparable fixture must be thirdobject delivered.", compEvent, objectEvents.get(2)); 111 assertEquals(3, objectEvents.size(), "Three Objects should be delivered."); 112 assertEquals(EVENT, objectEvents.get(0), "String fixture must be first object delivered."); 113 assertEquals(objEvent, objectEvents.get(1), "Object fixture must be second object delivered."); 114 assertEquals(compEvent, objectEvents.get(2), "Comparable fixture must be thirdobject delivered."); 120 115 121 116 // Check the Catcher<Comparable<?>>... 122 assertEquals("Two Comparable<?>s should be delivered.", 2, compEvents.size()); 123 assertEquals("String fixture must be first comparable delivered.", EVENT, compEvents.get(0)); 124 assertEquals( 125 "Comparable fixture must be second comparable delivered.", compEvent, compEvents.get(1)); 126 } 127 128 @Test 129 public void testSubscriberThrowsException() throws Exception { 117 assertEquals(2, compEvents.size(), "Two Comparable<?>s should be delivered."); 118 assertEquals(EVENT, compEvents.get(0), "String fixture must be first comparable delivered."); 119 assertEquals(compEvent, compEvents.get(1), "Comparable fixture must be second comparable delivered."); 120 } 121 122 @Test 123 void testSubscriberThrowsException() throws Exception { 130 124 final RecordingSubscriberExceptionHandler handler = new RecordingSubscriberExceptionHandler(); 131 125 final EventBus eventBus = new EventBus(handler); … … 142 136 eventBus.post(EVENT); 143 137 144 assertEquals("Cause should be available.", exception, handler.exception); 145 assertEquals("EventBus should be available.", eventBus, handler.context.getEventBus()); 146 assertEquals("Event should be available.", EVENT, handler.context.getEvent()); 147 assertEquals("Subscriber should be available.", subscriber, handler.context.getSubscriber()); 148 assertEquals( 149 "Method should be available.", 150 subscriber.getClass().getMethod("throwExceptionOn", String.class), 151 handler.context.getSubscriberMethod()); 152 } 153 154 @Test 155 public void testSubscriberThrowsExceptionHandlerThrowsException() throws Exception { 138 assertEquals(exception, handler.exception, "Cause should be available."); 139 assertEquals(eventBus, handler.context.getEventBus(), "EventBus should be available."); 140 assertEquals(EVENT, handler.context.getEvent(), "Event should be available."); 141 assertEquals(subscriber, handler.context.getSubscriber(), "Subscriber should be available."); 142 assertEquals(subscriber.getClass().getMethod("throwExceptionOn", String.class), handler.context.getSubscriberMethod(), "Method should be available."); 143 } 144 145 @Test 146 void testSubscriberThrowsExceptionHandlerThrowsException() throws Exception { 156 147 final EventBus eventBus = 157 148 new EventBus( 158 new SubscriberExceptionHandler() { 159 @Override 160 public void handleException(Throwable exception, SubscriberExceptionContext context) { 161 throw new RuntimeException("testSubscriberThrowsExceptionHandlerThrowsException_1. This is a normal exception"); 162 } 163 }); 149 (exception, context) -> { 150 throw new RuntimeException("testSubscriberThrowsExceptionHandlerThrowsException_1. This is a normal exception"); 151 }); 164 152 final Object subscriber = 165 153 new Object() { … … 170 158 }; 171 159 eventBus.register(subscriber); 172 try { 173 eventBus.post(EVENT); 174 } catch (RuntimeException e) { 175 fail("Exception should not be thrown."); 176 } 177 } 178 179 @Test 180 public void testDeadEventForwarding() { 160 assertDoesNotThrow(() -> eventBus.post(EVENT)); 161 } 162 163 @Test 164 void testDeadEventForwarding() { 181 165 GhostCatcher catcher = new GhostCatcher(); 182 166 bus.register(catcher); … … 186 170 187 171 List<DeadEvent> events = catcher.getEvents(); 188 assertEquals( "One dead event should be delivered.", 1, events.size());189 assertEquals( "The dead event should wrap the original event.", EVENT, events.get(0).getEvent());190 } 191 192 @Test 193 publicvoid testDeadEventPosting() {172 assertEquals(1, events.size(), "One dead event should be delivered."); 173 assertEquals(EVENT, events.get(0).getEvent(), "The dead event should wrap the original event."); 174 } 175 176 @Test 177 void testDeadEventPosting() { 194 178 GhostCatcher catcher = new GhostCatcher(); 195 179 bus.register(catcher); … … 198 182 199 183 List<DeadEvent> events = catcher.getEvents(); 200 assertEquals( "The explicit DeadEvent should be delivered.", 1, events.size());201 assertEquals( "The dead event must not be re-wrapped.", EVENT, events.get(0).getEvent());202 } 203 204 @Test 205 publicvoid testMissingSubscribe() {184 assertEquals(1, events.size(), "The explicit DeadEvent should be delivered."); 185 assertEquals(EVENT, events.get(0).getEvent(), "The dead event must not be re-wrapped."); 186 } 187 188 @Test 189 void testMissingSubscribe() { 206 190 bus.register(new Object()); 207 191 } 208 192 209 193 @Test 210 publicvoid testUnregister() {194 void testUnregister() { 211 195 StringCatcher catcher1 = new StringCatcher(); 212 196 StringCatcher catcher2 = new StringCatcher(); 213 try { 214 bus.unregister(catcher1); 215 fail("Attempting to unregister an unregistered object succeeded"); 216 } catch (IllegalArgumentException expected) { 217 // OK. 218 } 197 assertThrows(IllegalArgumentException.class, () -> bus.unregister(catcher1), "Attempting to unregister an unregistered object succeeded"); 219 198 220 199 bus.register(catcher1); … … 227 206 expectedEvents.add(EVENT); 228 207 229 assertEquals("Two correct events should be delivered.", expectedEvents, catcher1.getEvents()); 230 231 assertEquals( 232 "One correct event should be delivered.", Arrays.asList(EVENT), catcher2.getEvents()); 208 assertEquals(expectedEvents, catcher1.getEvents(), "Two correct events should be delivered."); 209 210 assertEquals(Collections.singletonList(EVENT), catcher2.getEvents(), "One correct event should be delivered."); 233 211 234 212 bus.unregister(catcher1); 235 213 bus.post(EVENT); 236 214 237 assertEquals( 238 "Shouldn't catch any more events when unregistered.", expectedEvents, catcher1.getEvents()); 239 assertEquals("Two correct events should be delivered.", expectedEvents, catcher2.getEvents()); 240 241 try { 242 bus.unregister(catcher1); 243 fail("Attempting to unregister an unregistered object succeeded"); 244 } catch (IllegalArgumentException expected) { 245 // OK. 246 } 215 assertEquals(expectedEvents, catcher1.getEvents(), "Shouldn't catch any more events when unregistered."); 216 assertEquals(expectedEvents, catcher2.getEvents(), "Two correct events should be delivered."); 217 218 assertThrows(IllegalArgumentException.class, () -> bus.unregister(catcher1), "Attempting to unregister an unregistered object succeeded"); 247 219 248 220 bus.unregister(catcher2); 249 221 bus.post(EVENT); 250 assertEquals( 251 "Shouldn't catch any more events when unregistered.", expectedEvents, catcher1.getEvents()); 252 assertEquals( 253 "Shouldn't catch any more events when unregistered.", expectedEvents, catcher2.getEvents()); 222 assertEquals(expectedEvents, catcher1.getEvents(), "Shouldn't catch any more events when unregistered."); 223 assertEquals(expectedEvents, catcher2.getEvents(), "Shouldn't catch any more events when unregistered."); 254 224 } 255 225 … … 258 228 259 229 @Test 260 publicvoid testRegisterThreadSafety() throws Exception {230 void testRegisterThreadSafety() throws Exception { 261 231 List<StringCatcher> catchers = new CopyOnWriteArrayList<>(); 262 232 List<Future<?>> futures = new ArrayList<>(); … … 269 239 futures.get(i).get(); 270 240 } 271 assertEquals( "Unexpected number of catchers in the list", numberOfCatchers, catchers.size());272 bus.post(EVENT); 273 List<String> expectedEvents = Arrays.asList(EVENT);241 assertEquals(numberOfCatchers, catchers.size(), "Unexpected number of catchers in the list"); 242 bus.post(EVENT); 243 List<String> expectedEvents = Collections.singletonList(EVENT); 274 244 for (StringCatcher catcher : catchers) { 275 assertEquals( 276 "One of the registered catchers did not receive an event.", 277 expectedEvents, 278 catcher.getEvents()); 279 } 280 } 281 282 @Test 283 public void testToString() throws Exception { 245 assertEquals(expectedEvents, catcher.getEvents(), "One of the registered catchers did not receive an event."); 246 } 247 } 248 249 @Test 250 void testToString() { 284 251 EventBus eventBus = new EventBus("a b ; - \" < > / \\ €"); 285 252 assertEquals("EventBus [a b ; - \" < > / \\ €]", eventBus.toString()); … … 293 260 */ 294 261 @Test 295 publicvoid testRegistrationWithBridgeMethod() {262 void testRegistrationWithBridgeMethod() { 296 263 final AtomicInteger calls = new AtomicInteger(); 297 264 bus.register( … … 347 314 */ 348 315 public static class GhostCatcher { 349 private List<DeadEvent> events = new ArrayList<>();316 private final List<DeadEvent> events = new ArrayList<>(); 350 317 351 318 @Subscribe -
applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/ReentrantEventsTest.java
r34000 r36064 17 17 package org.openstreetmap.josm.eventbus; 18 18 19 import static org.junit.Assert.assertEquals; 20 import static org.junit.Assert.assertTrue; 19 import static org.junit.jupiter.api.Assertions.assertEquals; 21 20 22 21 import java.util.ArrayList; … … 24 23 import java.util.List; 25 24 26 import org.junit.Test; 27 import org.openstreetmap.josm.eventbus.EventBus; 28 import org.openstreetmap.josm.eventbus.Subscribe; 25 import org.junit.jupiter.api.Assertions; 26 import org.junit.jupiter.api.Test; 29 27 30 28 /** … … 33 31 * @author Jesse Wilson 34 32 */ 35 publicclass ReentrantEventsTest {33 class ReentrantEventsTest { 36 34 37 35 static final String FIRST = "one"; … … 41 39 42 40 @Test 43 publicvoid testNoReentrantEvents() {41 void testNoReentrantEvents() { 44 42 ReentrantEventsHater hater = new ReentrantEventsHater(); 45 43 bus.register(hater); … … 47 45 bus.post(FIRST); 48 46 49 assertEquals( 50 "ReentrantEventHater expected 2 events", 51 Arrays.asList(FIRST, SECOND), 52 hater.eventsReceived); 47 assertEquals(Arrays.asList(FIRST, SECOND), hater.eventsReceived, "ReentrantEventHater expected 2 events"); 53 48 } 54 49 … … 70 65 @Subscribe 71 66 public void listenForDoubles(Double event) { 72 assertTrue("I received an event when I wasn't ready!", ready);67 Assertions.assertTrue(ready, "I received an event when I wasn't ready!"); 73 68 eventsReceived.add(event); 74 69 } … … 76 71 77 72 @Test 78 publicvoid testEventOrderingIsPredictable() {73 void testEventOrderingIsPredictable() { 79 74 EventProcessor processor = new EventProcessor(); 80 75 bus.register(processor); … … 85 80 bus.post(FIRST); 86 81 87 assertEquals( 88 "EventRecorder expected events in order", 89 Arrays.asList(FIRST, SECOND), 90 recorder.eventsReceived); 82 assertEquals(Arrays.asList(FIRST, SECOND), recorder.eventsReceived, "EventRecorder expected events in order"); 91 83 } 92 84 -
applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/StringCatcher.java
r34000 r36064 17 17 package org.openstreetmap.josm.eventbus; 18 18 19 import static org.junit. Assert.fail;19 import static org.junit.jupiter.api.Assertions.fail; 20 20 21 21 import java.util.ArrayList; 22 22 import java.util.List; 23 24 import org.openstreetmap.josm.eventbus.Subscribe;25 23 26 24 /** … … 33 31 */ 34 32 public class StringCatcher { 35 private List<String> events = new ArrayList<>();33 private final List<String> events = new ArrayList<>(); 36 34 37 35 @Subscribe -
applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/SubscriberRegistryTest.java
r34000 r36064 17 17 package org.openstreetmap.josm.eventbus; 18 18 19 import static org.junit. Assert.assertEquals;20 import static org.junit. Assert.assertFalse;21 import static org.junit. Assert.assertTrue;22 import static org.junit. Assert.fail;19 import static org.junit.jupiter.api.Assertions.assertEquals; 20 import static org.junit.jupiter.api.Assertions.assertFalse; 21 import static org.junit.jupiter.api.Assertions.assertThrows; 22 import static org.junit.jupiter.api.Assertions.assertTrue; 23 23 24 24 import java.util.Arrays; … … 26 26 import java.util.Iterator; 27 27 28 import org.junit.Ignore; 29 import org.junit.Test; 30 import org.openstreetmap.josm.eventbus.EventBus; 31 import org.openstreetmap.josm.eventbus.Subscribe; 32 import org.openstreetmap.josm.eventbus.Subscriber; 33 import org.openstreetmap.josm.eventbus.SubscriberRegistry; 28 import org.junit.jupiter.api.Assertions; 29 import org.junit.jupiter.api.Disabled; 30 import org.junit.jupiter.api.Test; 31 34 32 35 33 /** … … 43 41 44 42 @Test 45 publicvoid testRegister() {43 void testRegister() { 46 44 assertEquals(0, registry.getSubscribersForTesting(String.class).size()); 47 45 … … 58 56 59 57 @Test 60 publicvoid testUnregister() {58 void testUnregister() { 61 59 StringSubscriber s1 = new StringSubscriber(); 62 60 StringSubscriber s2 = new StringSubscriber(); … … 73 71 74 72 @Test 75 public void testUnregister_notRegistered() { 76 try { 77 registry.unregister(new StringSubscriber()); 78 fail(); 79 } catch (IllegalArgumentException expected) { 80 } 73 void testUnregisterNotRegistered() { 74 StringSubscriber temp = new StringSubscriber(); 75 assertThrows(IllegalArgumentException.class, () -> registry.unregister(temp)); 81 76 82 77 StringSubscriber s1 = new StringSubscriber(); 83 78 registry.register(s1); 84 try { 85 registry.unregister(new StringSubscriber()); 86 fail(); 87 } catch (IllegalArgumentException expected) { 88 // a StringSubscriber was registered, but not the same one we tried to unregister 89 } 79 // a StringSubscriber was registered, but not the same one we tried to unregister 80 assertThrows(IllegalArgumentException.class, () -> registry.unregister(temp)); 90 81 91 82 registry.unregister(s1); 92 93 try { 94 registry.unregister(s1); 95 fail(); 96 } catch (IllegalArgumentException expected) { 97 } 98 } 99 100 @Test 101 public void testGetSubscribers() { 83 assertThrows(IllegalArgumentException.class, () -> registry.unregister(s1)); 84 } 85 86 @Test 87 void testGetSubscribers() { 102 88 assertEquals(0, size(registry.getSubscribers(""))); 103 89 … … 120 106 121 107 @Test 122 @ Ignore("FIXME")123 public void testGetSubscribers_returnsImmutableSnapshot() {108 @Disabled("FIXME") 109 void testGetSubscribersReturnsImmutableSnapshot() { 124 110 StringSubscriber s1 = new StringSubscriber(); 125 111 StringSubscriber s2 = new StringSubscriber(); … … 186 172 187 173 @Test 188 public void testFlattenHierarchy() { 189 assertEquals( 190 new HashSet<>(Arrays.asList( 191 Object.class, 192 HierarchyFixtureInterface.class, 193 HierarchyFixtureSubinterface.class, 194 HierarchyFixtureParent.class, 195 HierarchyFixture.class)), 196 SubscriberRegistry.flattenHierarchy(HierarchyFixture.class)); 174 void testFlattenHierarchy() { 175 assertEquals(new HashSet<>(Arrays.asList( 176 Object.class, 177 HierarchyFixtureInterface.class, 178 HierarchyFixtureSubinterface.class, 179 HierarchyFixtureParent.class, 180 HierarchyFixture.class)), SubscriberRegistry.flattenHierarchy(HierarchyFixture.class)); 197 181 } 198 182 -
applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/SubscriberTest.java
r34000 r36064 18 18 19 19 //import com.google.common.testing.EqualsTester; 20 21 import static org.junit.jupiter.api.Assertions.assertSame; 22 import static org.junit.jupiter.api.Assertions.assertThrows; 23 import static org.junit.jupiter.api.Assertions.assertTrue; 24 20 25 import java.lang.reflect.InvocationTargetException; 21 26 import java.lang.reflect.Method; 22 27 23 import org.junit.Ignore; 24 import org.junit.Test; 25 import org.openstreetmap.josm.eventbus.AllowConcurrentEvents; 26 import org.openstreetmap.josm.eventbus.EventBus; 27 import org.openstreetmap.josm.eventbus.Subscribe; 28 import org.openstreetmap.josm.eventbus.Subscriber; 29 30 import junit.framework.TestCase; 28 import org.junit.jupiter.api.Assertions; 29 import org.junit.jupiter.api.BeforeEach; 30 import org.junit.jupiter.api.Disabled; 31 import org.junit.jupiter.api.Test; 31 32 32 33 /** … … 36 37 * @author Colin Decker 37 38 */ 38 public class SubscriberTest extends TestCase{39 class SubscriberTest { 39 40 40 41 private static final Object FIXTURE_ARGUMENT = new Object(); … … 44 45 private Object methodArgument; 45 46 46 @ Override47 protected void setUp() throws Exception{47 @BeforeEach 48 protected void setUp() { 48 49 bus = new EventBus(); 49 50 methodCalled = false; … … 52 53 53 54 @Test 54 publicvoid testCreate() {55 void testCreate() { 55 56 Subscriber s1 = Subscriber.create(bus, this, getTestSubscriberMethod("recordingMethod")); 56 57 assertTrue(s1 instanceof Subscriber.SynchronizedSubscriber); … … 58 59 // a thread-safe method should not create a synchronized subscriber 59 60 Subscriber s2 = Subscriber.create(bus, this, getTestSubscriberMethod("threadSafeMethod")); 60 assertFalse(s2 instanceof Subscriber.SynchronizedSubscriber);61 Assertions.assertFalse(s2 instanceof Subscriber.SynchronizedSubscriber); 61 62 } 62 63 63 64 @Test 64 public void testInvokeSubscriberMethod_basicMethodCall() throws Throwable {65 void testInvokeSubscriberMethodBasicMethodCall() throws Throwable { 65 66 Method method = getTestSubscriberMethod("recordingMethod"); 66 67 Subscriber subscriber = Subscriber.create(bus, this, method); … … 68 69 subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT); 69 70 70 assertTrue("Subscriber must call provided method", methodCalled); 71 assertTrue( 72 "Subscriber argument must be exactly the provided object.", 73 methodArgument == FIXTURE_ARGUMENT); 71 assertTrue(methodCalled, "Subscriber must call provided method"); 72 assertSame(methodArgument, FIXTURE_ARGUMENT, "Subscriber argument must be exactly the provided object."); 74 73 } 75 74 76 75 @Test 77 public void testInvokeSubscriberMethod_exceptionWrapping() throws Throwable{76 void testInvokeSubscriberMethodExceptionWrapping() { 78 77 Method method = getTestSubscriberMethod("exceptionThrowingMethod"); 79 78 Subscriber subscriber = Subscriber.create(bus, this, method); 80 79 81 try { 82 subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT); 83 fail("Subscribers whose methods throw must throw InvocationTargetException"); 84 } catch (InvocationTargetException expected) { 85 assertTrue(expected.getCause() instanceof IntentionalException); 86 } 80 InvocationTargetException ite = assertThrows(InvocationTargetException.class, () -> subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT), 81 "Subscribers whose methods throw must throw InvocationTargetException"); 82 assertTrue(ite.getCause() instanceof IntentionalException); 87 83 } 88 84 89 85 @Test 90 public void testInvokeSubscriberMethod_errorPassthrough() throws Throwable{86 void testInvokeSubscriberMethodErrorPassthrough() { 91 87 Method method = getTestSubscriberMethod("errorThrowingMethod"); 92 88 Subscriber subscriber = Subscriber.create(bus, this, method); 93 89 94 try { 95 subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT); 96 fail("Subscribers whose methods throw Errors must rethrow them"); 97 } catch (JudgmentError expected) { 98 } 90 assertThrows(JudgmentError.class, () -> subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT), 91 "Subscribers whose methods throw Errors must rethrow them"); 99 92 } 100 93 101 94 @Test 102 @ Ignore("FIXME")103 public void testEquals() throws Exception{95 @Disabled("FIXME") 96 void testEquals() { 104 97 /*Method charAt = String.class.getMethod("charAt", int.class); 105 98 Method concat = String.class.getMethod("concat", String.class); … … 128 121 @Subscribe 129 122 public void recordingMethod(Object arg) { 130 assertFalse(methodCalled);123 Assertions.assertFalse(methodCalled); 131 124 methodCalled = true; 132 125 methodArgument = arg; … … 139 132 140 133 /** Local exception subclass to check variety of exception thrown. */ 141 class IntentionalException extends Exception {134 static class IntentionalException extends Exception { 142 135 143 136 private static final long serialVersionUID = -2500191180248181379L; -
applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/outside/AnnotatedSubscriberFinderTests.java
r34000 r36064 17 17 package org.openstreetmap.josm.eventbus.outside; 18 18 19 import static org.junit.Assert.assertTrue; 19 20 import static org.junit.jupiter.api.Assertions.assertTrue; 20 21 21 22 import java.util.ArrayList; 22 23 import java.util.List; 23 24 24 import org.junit. After;25 import org.junit. Before;26 import org.junit. Test;25 import org.junit.jupiter.api.AfterEach; 26 import org.junit.jupiter.api.BeforeEach; 27 import org.junit.jupiter.api.Test; 27 28 import org.openstreetmap.josm.eventbus.EventBus; 28 29 import org.openstreetmap.josm.eventbus.Subscribe; … … 48 49 } 49 50 50 @Before 51 public void setUp() throws Exception{51 @BeforeEach 52 public void setUp() { 52 53 subscriber = createSubscriber(); 53 54 EventBus bus = new EventBus(); … … 56 57 } 57 58 58 @After 59 public void tearDown() throws Exception{59 @AfterEach 60 public void tearDown() { 60 61 subscriber = null; 61 62 } … … 65 66 * We break the tests up based on whether they are annotated or abstract in the superclass. 66 67 */ 67 publicstatic class BaseSubscriberFinderTest68 static class BaseSubscriberFinderTest 68 69 extends AbstractEventBusTestParent<BaseSubscriberFinderTest.Subscriber> { 69 70 static class Subscriber { … … 82 83 83 84 @Test 84 publicvoid testNonSubscriber() {85 void testNonSubscriber() { 85 86 assertTrue(getSubscriber().nonSubscriberEvents.isEmpty()); 86 87 } 87 88 88 89 @Test 89 publicvoid testSubscriber() {90 void testSubscriber() { 90 91 assertTrue(getSubscriber().subscriberEvents.contains(EVENT)); 91 92 } … … 97 98 } 98 99 99 publicstatic class AnnotatedAndAbstractInSuperclassTest100 static class AnnotatedAndAbstractInSuperclassTest 100 101 extends AbstractEventBusTestParent<AnnotatedAndAbstractInSuperclassTest.SubClass> { 101 102 abstract static class SuperClass { … … 124 125 125 126 @Test 126 publicvoid testOverriddenAndAnnotatedInSubclass() {127 void testOverriddenAndAnnotatedInSubclass() { 127 128 assertTrue(getSubscriber().overriddenAndAnnotatedInSubclassEvents.contains(EVENT)); 128 129 } 129 130 130 131 @Test 131 publicvoid testOverriddenNotAnnotatedInSubclass() {132 void testOverriddenNotAnnotatedInSubclass() { 132 133 assertTrue(getSubscriber().overriddenInSubclassEvents.contains(EVENT)); 133 134 } … … 139 140 } 140 141 141 publicstatic class AnnotatedNotAbstractInSuperclassTest142 static class AnnotatedNotAbstractInSuperclassTest 142 143 extends AbstractEventBusTestParent<AnnotatedNotAbstractInSuperclassTest.SubClass> { 143 144 static class SuperClass { … … 206 207 207 208 @Test 208 publicvoid testNotOverriddenInSubclass() {209 void testNotOverriddenInSubclass() { 209 210 assertTrue(getSubscriber().notOverriddenInSubclassEvents.contains(EVENT)); 210 211 } 211 212 212 213 @Test 213 publicvoid testOverriddenNotAnnotatedInSubclass() {214 void testOverriddenNotAnnotatedInSubclass() { 214 215 assertTrue(getSubscriber().overriddenNotAnnotatedInSubclassEvents.contains(EVENT)); 215 216 } 216 217 217 218 @Test 218 publicvoid testDifferentlyOverriddenNotAnnotatedInSubclass() {219 void testDifferentlyOverriddenNotAnnotatedInSubclass() { 219 220 assertTrue(getSubscriber().differentlyOverriddenNotAnnotatedInSubclassGoodEvents 220 221 .contains(EVENT)); … … 223 224 224 225 @Test 225 publicvoid testOverriddenAndAnnotatedInSubclass() {226 void testOverriddenAndAnnotatedInSubclass() { 226 227 assertTrue(getSubscriber().overriddenAndAnnotatedInSubclassEvents.contains(EVENT)); 227 228 } 228 229 229 230 @Test 230 publicvoid testDifferentlyOverriddenAndAnnotatedInSubclass() {231 void testDifferentlyOverriddenAndAnnotatedInSubclass() { 231 232 assertTrue(getSubscriber().differentlyOverriddenAnnotatedInSubclassGoodEvents 232 233 .contains(EVENT)); … … 240 241 } 241 242 242 publicstatic class AbstractNotAnnotatedInSuperclassTest243 static class AbstractNotAnnotatedInSuperclassTest 243 244 extends AbstractEventBusTestParent<AbstractNotAnnotatedInSuperclassTest.SubClass> { 244 245 abstract static class SuperClass { … … 265 266 266 267 @Test 267 publicvoid testOverriddenAndAnnotatedInSubclass() {268 void testOverriddenAndAnnotatedInSubclass() { 268 269 assertTrue(getSubscriber().overriddenAndAnnotatedInSubclassEvents.contains(EVENT)); 269 270 } 270 271 271 272 @Test 272 publicvoid testOverriddenInSubclassNowhereAnnotated() {273 void testOverriddenInSubclassNowhereAnnotated() { 273 274 assertTrue(getSubscriber().overriddenInSubclassNowhereAnnotatedEvents.isEmpty()); 274 275 } … … 280 281 } 281 282 282 publicstatic class NeitherAbstractNorAnnotatedInSuperclassTest283 static class NeitherAbstractNorAnnotatedInSuperclassTest 283 284 extends AbstractEventBusTestParent<NeitherAbstractNorAnnotatedInSuperclassTest.SubClass> { 284 285 static class SuperClass { … … 314 315 315 316 @Test 316 publicvoid testNeitherOverriddenNorAnnotated() {317 void testNeitherOverriddenNorAnnotated() { 317 318 assertTrue(getSubscriber().neitherOverriddenNorAnnotatedEvents.isEmpty()); 318 319 } 319 320 320 321 @Test 321 publicvoid testOverriddenInSubclassNowhereAnnotated() {322 void testOverriddenInSubclassNowhereAnnotated() { 322 323 assertTrue(getSubscriber().overriddenInSubclassNowhereAnnotatedEvents.isEmpty()); 323 324 } 324 325 325 326 @Test 326 publicvoid testOverriddenAndAnnotatedInSubclass() {327 void testOverriddenAndAnnotatedInSubclass() { 327 328 assertTrue(getSubscriber().overriddenAndAnnotatedInSubclassEvents.contains(EVENT)); 328 329 } … … 334 335 } 335 336 336 publicstatic class DeepInterfaceTest337 static class DeepInterfaceTest 337 338 extends AbstractEventBusTestParent<DeepInterfaceTest.SubscriberClass> { 338 339 interface Interface1 { … … 427 428 428 429 @Test 429 publicvoid testAnnotatedIn1() {430 void testAnnotatedIn1() { 430 431 assertTrue(getSubscriber().annotatedIn1Events.contains(EVENT)); 431 432 } 432 433 433 434 @Test 434 publicvoid testAnnotatedIn2() {435 void testAnnotatedIn2() { 435 436 assertTrue(getSubscriber().annotatedIn2Events.contains(EVENT)); 436 437 } 437 438 438 439 @Test 439 publicvoid testAnnotatedIn1And2() {440 void testAnnotatedIn1And2() { 440 441 assertTrue(getSubscriber().annotatedIn1And2Events.contains(EVENT)); 441 442 } 442 443 443 444 @Test 444 publicvoid testAnnotatedIn1And2AndClass() {445 void testAnnotatedIn1And2AndClass() { 445 446 assertTrue(getSubscriber().annotatedIn1And2AndClassEvents.contains(EVENT)); 446 447 } 447 448 448 449 @Test 449 publicvoid testDeclaredIn1AnnotatedIn2() {450 void testDeclaredIn1AnnotatedIn2() { 450 451 assertTrue(getSubscriber().declaredIn1AnnotatedIn2Events.contains(EVENT)); 451 452 } 452 453 453 454 @Test 454 publicvoid testDeclaredIn1AnnotatedInClass() {455 void testDeclaredIn1AnnotatedInClass() { 455 456 assertTrue(getSubscriber().declaredIn1AnnotatedInClassEvents.contains(EVENT)); 456 457 } 457 458 458 459 @Test 459 publicvoid testDeclaredIn2AnnotatedInClass() {460 void testDeclaredIn2AnnotatedInClass() { 460 461 assertTrue(getSubscriber().declaredIn2AnnotatedInClassEvents.contains(EVENT)); 461 462 } 462 463 463 464 @Test 464 publicvoid testNowhereAnnotated() {465 void testNowhereAnnotated() { 465 466 assertTrue(getSubscriber().nowhereAnnotatedEvents.isEmpty()); 466 467 } -
applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/outside/OutsideEventBusTest.java
r34000 r36064 17 17 package org.openstreetmap.josm.eventbus.outside; 18 18 19 import static org.junit. Assert.assertEquals;19 import static org.junit.jupiter.api.Assertions.assertEquals; 20 20 21 21 import java.util.concurrent.atomic.AtomicInteger; 22 22 import java.util.concurrent.atomic.AtomicReference; 23 23 24 import org.junit. Test;24 import org.junit.jupiter.api.Test; 25 25 import org.openstreetmap.josm.eventbus.EventBus; 26 26 import org.openstreetmap.josm.eventbus.Subscribe; … … 31 31 * @author Louis Wasserman 32 32 */ 33 publicclass OutsideEventBusTest {33 class OutsideEventBusTest { 34 34 35 35 /* … … 39 39 */ 40 40 @Test 41 publicvoid testAnonymous() {41 void testAnonymous() { 42 42 final AtomicReference<String> holder = new AtomicReference<>(); 43 43 final AtomicInteger deliveries = new AtomicInteger(); … … 55 55 bus.post(EVENT); 56 56 57 assertEquals( "Only one event should be delivered.", 1, deliveries.get());58 assertEquals( "Correct string should be delivered.", EVENT, holder.get());57 assertEquals(1, deliveries.get(), "Only one event should be delivered."); 58 assertEquals(EVENT, holder.get(), "Correct string should be delivered."); 59 59 } 60 60 } -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/FullGraphCreationTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core; 3 3 4 import static org.junit.Assert.assertSame; 4 5 import static org.junit.jupiter.api.Assertions.assertSame; 5 6 6 7 import java.util.Arrays; 7 8 import java.util.Collection; 9 import java.util.Collections; 8 10 import java.util.HashMap; 9 11 import java.util.Iterator; … … 12 14 import java.util.Map; 13 15 14 import org.junit. Test;16 import org.junit.jupiter.api.Test; 15 17 import org.openstreetmap.josm.plugins.graphview.core.TestDataSource.TestNode; 16 18 import org.openstreetmap.josm.plugins.graphview.core.TestDataSource.TestRelation; … … 33 35 import org.openstreetmap.josm.plugins.graphview.plugin.preferences.VehiclePropertyStringParser.PropertyValueSyntaxException; 34 36 35 publicclass FullGraphCreationTest {37 class FullGraphCreationTest { 36 38 37 39 private static final AccessParameters ACCESS_PARAMS; … … 44 46 ACCESS_PARAMS = new PreferenceAccessParameters( 45 47 "test_vehicle", 46 Arrays.asList(AccessType.UNDEFINED),48 Collections.singletonList(AccessType.UNDEFINED), 47 49 vehiclePropertyValues); 48 50 } catch (PropertyValueSyntaxException e) { … … 54 56 @Override 55 57 public java.util.List<String> getAccessHierarchyAncestors(String transportMode) { 56 return Arrays.asList(transportMode);58 return Collections.singletonList(transportMode); 57 59 } 58 60 59 61 @Override 60 62 public Collection<Tag> getBaseTags() { 61 return Arrays.asList(new Tag("highway", "test"));63 return Collections.singletonList(new Tag("highway", "test")); 62 64 } 63 65 … … 69 71 70 72 @Test 71 publicvoid testTJunction() {73 void testTJunction() { 72 74 73 75 TestDataSource ds = new TestDataSource(); … … 125 127 126 128 @Test 127 publicvoid testBarrier() {129 void testBarrier() { 128 130 129 131 TestDataSource ds = new TestDataSource(); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/access/AccessRulesetReaderTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.access; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertNotNull;7 import static org.junit. Assert.assertSame;8 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertSame; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 9 9 10 10 import java.io.FileInputStream; … … 15 15 import java.util.Map; 16 16 17 import org.junit. Test;17 import org.junit.jupiter.api.Test; 18 18 import org.openstreetmap.josm.TestUtils; 19 19 import org.openstreetmap.josm.plugins.graphview.core.data.MapBasedTagGroup; … … 21 21 import org.openstreetmap.josm.plugins.graphview.core.data.TagGroup; 22 22 23 publicclass AccessRulesetReaderTest {23 class AccessRulesetReaderTest { 24 24 25 25 @Test 26 public void testReadAccessRuleset_valid_classes() throws IOException {26 void testReadAccessRulesetValidClasses() throws IOException { 27 27 28 28 InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml"); … … 50 50 51 51 @Test 52 public void testReadAccessRuleset_valid_basetags() throws IOException {52 void testReadAccessRulesetValidBasetags() throws IOException { 53 53 54 54 InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml"); … … 66 66 67 67 @Test 68 public void testReadAccessRuleset_valid_implications() throws IOException {68 void testReadAccessRulesetValidImplications() throws IOException { 69 69 70 70 InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml"); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadInclineTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.property; 3 3 4 import org.junit. Test;4 import org.junit.jupiter.api.Test; 5 5 import org.openstreetmap.josm.plugins.graphview.core.data.Tag; 6 6 7 public class RoadInclineTest extends RoadPropertyTest {7 class RoadInclineTest implements RoadPropertyTest { 8 8 9 9 private static void testIncline(Float expectedInclineForward, Float expectedInclineBackward, 10 10 String inclineString) { 11 11 12 testEvaluateW(new RoadIncline(),12 RoadPropertyTest.testEvaluateW(new RoadIncline(), 13 13 expectedInclineForward, expectedInclineBackward, 14 14 new Tag("incline", inclineString)); … … 16 16 17 17 @Test 18 publicvoid testEvaluate() {18 void testEvaluate() { 19 19 testIncline(5f, -5f, "5 %"); 20 20 testIncline(9.5f, -9.5f, "9.5 %"); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadMaxspeedTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.property; 3 3 4 import org.junit. Test;4 import org.junit.jupiter.api.Test; 5 5 import org.openstreetmap.josm.plugins.graphview.core.data.Tag; 6 6 7 public class RoadMaxspeedTest extends RoadPropertyTest {7 class RoadMaxspeedTest implements RoadPropertyTest { 8 8 9 9 private static void testMaxspeed(float expectedMaxspeed, String maxspeedString) { 10 testEvaluateBoth(new RoadMaxspeed(), expectedMaxspeed, new Tag("maxspeed", maxspeedString));10 RoadPropertyTest.testEvaluateBoth(new RoadMaxspeed(), expectedMaxspeed, new Tag("maxspeed", maxspeedString)); 11 11 } 12 12 13 13 @Test 14 public void testEvaluate_numeric() {14 void testEvaluateNumeric() { 15 15 testMaxspeed(30, "30"); 16 16 testMaxspeed(48.3f, "48.3"); … … 18 18 19 19 @Test 20 public void testEvaluate_kmh() {20 void testEvaluateKmh() { 21 21 testMaxspeed(50, "50 km/h"); 22 22 testMaxspeed(120, "120km/h"); … … 25 25 26 26 @Test 27 public void testEvaluate_mph() {27 void testEvaluateMph() { 28 28 testMaxspeed(72.42048f, "45 mph"); 29 29 testMaxspeed(64.373764f, "40mph"); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadPropertyTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.property; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 import org.junit.Ignore;7 6 import org.openstreetmap.josm.plugins.graphview.core.TestDataSource; 8 7 import org.openstreetmap.josm.plugins.graphview.core.data.Tag; 9 8 10 @Ignore("no test") 11 public abstract class RoadPropertyTest { 9 public interface RoadPropertyTest { 12 10 13 protectedstatic <P> void testEvaluateW(RoadPropertyType<P> property, P expectedForward, P expectedBackward, Tag... wayTags) {11 static <P> void testEvaluateW(RoadPropertyType<P> property, P expectedForward, P expectedBackward, Tag... wayTags) { 14 12 15 13 TestDataSource ds = new TestDataSource(); … … 25 23 } 26 24 27 protectedstatic <P> void testEvaluateN(RoadPropertyType<P> property, P expected, Tag... nodeTags) {25 static <P> void testEvaluateN(RoadPropertyType<P> property, P expected, Tag... nodeTags) { 28 26 29 27 TestDataSource ds = new TestDataSource(); … … 40 38 } 41 39 42 protectedstatic <P> void testEvaluateBoth(RoadPropertyType<P> property, P expected, Tag... nodeTags) {40 static <P> void testEvaluateBoth(RoadPropertyType<P> property, P expected, Tag... nodeTags) { 43 41 testEvaluateW(property, expected, expected, nodeTags); 44 42 testEvaluateN(property, expected, nodeTags); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/util/TagConditionLogicTest.java
r32620 r36064 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.graphview.core.util; 3 import static org.junit.Assert.assertFalse; 4 import static org.junit.Assert.assertTrue; 3 4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 5 6 6 7 import java.util.Arrays; 8 import java.util.Collections; 7 9 import java.util.HashMap; 8 10 import java.util.Map; 9 11 10 import org.junit. Before;11 import org.junit. Test;12 import org.junit.jupiter.api.BeforeEach; 13 import org.junit.jupiter.api.Test; 12 14 import org.openstreetmap.josm.plugins.graphview.core.data.MapBasedTagGroup; 13 15 import org.openstreetmap.josm.plugins.graphview.core.data.Tag; 14 16 import org.openstreetmap.josm.plugins.graphview.core.data.TagGroup; 15 17 16 publicclass TagConditionLogicTest {18 class TagConditionLogicTest { 17 19 18 20 TagGroup groupA; 19 21 TagGroup groupB; 20 22 21 @Before 22 publicvoid setUp() {23 @BeforeEach 24 void setUp() { 23 25 Map<String, String> mapA = new HashMap<>(); 24 26 mapA.put("key1", "value1"); … … 34 36 35 37 @Test 36 publicvoid testTag() {38 void testTag() { 37 39 TagCondition condition = TagConditionLogic.tag(new Tag("key3", "value1")); 38 40 assertTrue(condition.matches(groupA)); … … 41 43 42 44 @Test 43 publicvoid testKey() {45 void testKey() { 44 46 TagCondition condition = TagConditionLogic.key("key3"); 45 47 assertTrue(condition.matches(groupA)); … … 48 50 49 51 @Test 50 publicvoid testAnd() {52 void testAnd() { 51 53 TagCondition condition1 = TagConditionLogic.tag(new Tag("key2", "value2")); 52 54 TagCondition conditionAnd1a = TagConditionLogic.and(condition1); 53 TagCondition conditionAnd1b = TagConditionLogic.and( Arrays.asList(condition1));55 TagCondition conditionAnd1b = TagConditionLogic.and(Collections.singletonList(condition1)); 54 56 55 57 assertTrue(conditionAnd1a.matches(groupA)); … … 78 80 79 81 @Test 80 publicvoid testOr() {82 void testOr() { 81 83 TagCondition condition1 = TagConditionLogic.tag(new Tag("key42", "value42")); 82 84 TagCondition conditionOr1a = TagConditionLogic.or(condition1); 83 TagCondition conditionOr1b = TagConditionLogic.or( Arrays.asList(condition1));85 TagCondition conditionOr1b = TagConditionLogic.or(Collections.singletonList(condition1)); 84 86 85 87 assertFalse(conditionOr1a.matches(groupA)); … … 108 110 109 111 @Test 110 publicvoid testNot() {112 void testNot() { 111 113 TagCondition condition = TagConditionLogic.not(TagConditionLogic.key("key3")); 112 114 assertFalse(condition.matches(groupA)); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/util/ValueStringParserTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.util; 3 3 4 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertNull; 5 5 import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseMeasure; 6 6 import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseSpeed; 7 7 import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseWeight; 8 8 9 import org.junit. Test;9 import org.junit.jupiter.api.Test; 10 10 11 public class ValueStringParserTest { 11 12 class ValueStringParserTest { 12 13 13 14 /* speed */ 14 15 15 16 @Test 16 publicvoid testParseSpeedDefault() {17 void testParseSpeedDefault() { 17 18 assertClose(50, parseSpeed("50")); 18 19 } 19 20 20 21 @Test 21 publicvoid testParseSpeedKmh() {22 void testParseSpeedKmh() { 22 23 assertClose(30, parseSpeed("30 km/h")); 23 24 assertClose(100, parseSpeed("100km/h")); … … 25 26 26 27 @Test 27 publicvoid testParseSpeedMph() {28 void testParseSpeedMph() { 28 29 assertClose(40.234f, parseSpeed("25mph")); 29 30 assertClose(40.234f, parseSpeed("25 mph")); … … 31 32 32 33 @Test 33 publicvoid testParseSpeedInvalid() {34 void testParseSpeedInvalid() { 34 35 assertNull(parseSpeed("lightspeed")); 35 36 } … … 38 39 39 40 @Test 40 publicvoid testParseMeasureDefault() {41 void testParseMeasureDefault() { 41 42 assertClose(3.5f, parseMeasure("3.5")); 42 43 } 43 44 44 45 @Test 45 publicvoid testParseMeasureM() {46 void testParseMeasureM() { 46 47 assertClose(2, parseMeasure("2m")); 47 48 assertClose(5.5f, parseMeasure("5.5 m")); … … 49 50 50 51 @Test 51 publicvoid testParseMeasureKm() {52 void testParseMeasureKm() { 52 53 assertClose(1000, parseMeasure("1 km")); 53 54 assertClose(7200, parseMeasure("7.2km")); … … 55 56 56 57 @Test 57 publicvoid testParseMeasureMi() {58 void testParseMeasureMi() { 58 59 assertClose(1609.344f, parseMeasure("1 mi")); 59 60 } 60 61 61 62 @Test 62 publicvoid testParseMeasureFeetInches() {63 void testParseMeasureFeetInches() { 63 64 assertClose(3.6576f, parseMeasure("12'0\"")); 64 65 assertClose(1.9812f, parseMeasure("6' 6\"")); … … 66 67 67 68 @Test 68 publicvoid testParseMeasureInvalid() {69 void testParseMeasureInvalid() { 69 70 assertNull(parseMeasure("very long")); 70 71 assertNull(parseMeasure("6' 16\"")); … … 74 75 75 76 @Test 76 publicvoid testParseWeightDefault() {77 void testParseWeightDefault() { 77 78 assertClose(3.6f, parseWeight("3.6")); 78 79 } 79 80 80 81 @Test 81 publicvoid testParseWeightT() {82 void testParseWeightT() { 82 83 assertClose(30, parseWeight("30t")); 83 84 assertClose(3.5f, parseWeight("3.5 t")); … … 85 86 86 87 @Test 87 publicvoid testParseWeightInvalid() {88 void testParseWeightInvalid() { 88 89 assertNull(parseWeight("heavy")); 89 90 } -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/visualisation/FloatPropertyColorSchemeTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.awt.Color; … … 8 8 import java.util.Map; 9 9 10 import org.junit. Before;11 import org.junit. Test;10 import org.junit.jupiter.api.BeforeEach; 11 import org.junit.jupiter.api.Test; 12 12 import org.openstreetmap.josm.plugins.graphview.core.property.RoadMaxweight; 13 13 14 publicclass FloatPropertyColorSchemeTest {14 class FloatPropertyColorSchemeTest { 15 15 16 16 private FloatPropertyColorScheme subject; 17 17 18 @Before 18 @BeforeEach 19 19 public void setUp() { 20 20 … … 28 28 29 29 @Test 30 public void testGetColorForValue_below() {30 void testGetColorForValueBelow() { 31 31 assertEquals(new Color(42, 42, 42), subject.getColorForValue(1f)); 32 32 assertEquals(new Color(42, 42, 42), subject.getColorForValue(5f)); … … 34 34 35 35 @Test 36 public void testGetColorForValue_above() {36 void testGetColorForValueAbove() { 37 37 assertEquals(new Color(200, 200, 200), subject.getColorForValue(25f)); 38 38 } 39 39 40 40 @Test 41 public void testGetColorForValue_value() {41 void testGetColorForValueValue() { 42 42 assertEquals(new Color(100, 100, 100), subject.getColorForValue(10f)); 43 43 } 44 44 45 45 @Test 46 public void testGetColorForValue_interpolate() {46 void testGetColorForValueInterpolate() { 47 47 assertEquals(new Color(150, 150, 150), subject.getColorForValue(15f)); 48 48 } -
applications/editors/josm/plugins/http2/test/unit/org/openstreetmap/josm/plugins/http2/Http2ClientTest.java
r35790 r36064 2 2 package org.openstreetmap.josm.plugins.http2; 3 3 4 import static org.junit.Assert.assertEquals; 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 import static org.junit.jupiter.api.Assertions.assertThrows; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; … … 63 64 64 65 @Test 65 void testCreateRequest _invalidURI() throws Exception{66 void testCreateRequestInvalidURI() { 66 67 // From https://josm.openstreetmap.de/ticket/21126 67 68 // URISyntaxException for URL not formatted strictly according to RFC2396 68 69 // See chapter "2.4.3. Excluded US-ASCII Characters" 69 assertTrue(assertThrows(IOException.class, () -> new Http2Client(70 new URL("https://commons.wikimedia.org/w/api.php?format=xml&action=query&list=geosearch&gsnamespace=6&gslimit=500&gsprop=type|name&gsbbox=52.2804692|38.1772755|52.269721|38.2045051"), "GET")70 final URL url = assertDoesNotThrow(() -> new URL("https://commons.wikimedia.org/w/api.php?format=xml&action=query&list=geosearch&gsnamespace=6&gslimit=500&gsprop=type|name&gsbbox=52.2804692|38.1772755|52.269721|38.2045051")); 71 assertTrue(assertThrows(IOException.class, () -> new Http2Client(url, "GET") 71 72 .createRequest()).getCause().getMessage().startsWith("Illegal character in query at index 116:")); 72 73 } -
applications/editors/josm/plugins/imagery-xml-bounds/test/unit/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/ComputeBoundsActionTest.java
r35100 r36064 1 1 package org.openstreetmap.josm.plugins.imageryxmlbounds.actions; 2 2 3 import static org.junit. Assert.assertEquals;3 import static org.junit.jupiter.api.Assertions.assertEquals; 4 4 5 5 import java.util.Arrays; 6 6 7 import org.junit.Rule; 8 import org.junit.Test; 7 import org.junit.jupiter.api.Test; 9 8 import org.openstreetmap.josm.data.coor.LatLon; 10 9 import org.openstreetmap.josm.data.osm.Node; 11 10 import org.openstreetmap.josm.data.osm.Way; 12 import org.openstreetmap.josm.testutils.JOSMTestRules; 13 14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 11 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 15 12 16 13 /** 17 14 * Unit tests of {@link ComputeBoundsAction} 18 15 */ 19 public class ComputeBoundsActionTest { 20 21 /** 22 * Setup rule 23 */ 24 @Rule 25 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 26 public JOSMTestRules test = new JOSMTestRules(); 27 16 @BasicPreferences 17 class ComputeBoundsActionTest { 28 18 /** 29 19 * Unit test of {@link ComputeBoundsAction#getBounds} 30 20 */ 31 21 @Test 32 publicvoid testGetBounds() {22 void testGetBounds() { 33 23 assertEquals(" <bounds min-lat='0' min-lon='0' max-lat='0' max-lon='0'>\n", 34 24 ComputeBoundsAction.getBounds(new Node(LatLon.ZERO), false)); -
applications/editors/josm/plugins/o5m/test/unit/org/openstreetmap/josm/plugins/o5m/io/O5mImporterTest.java
r34837 r36064 2 2 package org.openstreetmap.josm.plugins.o5m.io; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNotNull;6 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 7 8 8 import java.io.IOException; 9 9 10 import org.junit. Rule;11 import org.junit. Test;10 import org.junit.jupiter.api.Assertions; 11 import org.junit.jupiter.api.Test; 12 12 import org.openstreetmap.josm.TestUtils; 13 13 import org.openstreetmap.josm.data.osm.DataSet; … … 16 16 import org.openstreetmap.josm.data.osm.User; 17 17 import org.openstreetmap.josm.io.IllegalDataException; 18 import org.openstreetmap.josm.testutils. JOSMTestRules;18 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 19 19 20 20 /** 21 21 * Unit tests for {@link O5mImporter}. 22 22 */ 23 public class O5mImporterTest { 24 25 /** 26 * Setup test. 27 */ 28 @Rule 29 public JOSMTestRules rules = new JOSMTestRules().preferences(); 30 23 @BasicPreferences 24 class O5mImporterTest { 31 25 private static void checkUserNull(OsmPrimitive osm, boolean hasToBeNull) { 32 26 User usr = osm.getUser(); 33 27 if (hasToBeNull) { 34 assertNull( osm + " -> " + usr,usr);28 assertNull(usr, osm + " -> " + usr); 35 29 } else { 36 assertNotNull( osm + " -> " + usr,usr);30 assertNotNull(usr, osm + " -> " + usr); 37 31 } 38 32 } … … 56 50 */ 57 51 @Test 58 publicvoid testParseDataSet() throws Exception {52 void testParseDataSet() throws Exception { 59 53 doTestMonaco(TestUtils.getTestDataRoot() + "/monaco-latest.o5m", false); 60 54 } … … 66 60 */ 67 61 @Test 68 publicvoid testParseDataSetDropVersion() throws Exception {62 void testParseDataSetDropVersion() throws Exception { 69 63 doTestMonaco(TestUtils.getTestDataRoot() + "/monaco-drop-version.o5m", true); 70 64 } -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/test/unit/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseModuleTest.java
r35269 r36064 2 2 package org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse; 3 3 4 import static org.junit.Assert.assertEquals;5 import static org.junit.Assert.assertFalse;6 4 7 import org.junit.Rule; 8 import org.junit.Test; 9 import org.openstreetmap.josm.testutils.JOSMTestRules; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertFalse; 7 8 import org.junit.jupiter.api.Test; 9 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 10 10 11 11 /** 12 12 * Unit tests of {@link ToulouseModule} class. 13 13 */ 14 public class ToulouseModuleTest { 15 16 /** 17 * Setup test. 18 */ 19 @Rule 20 public JOSMTestRules rules = new JOSMTestRules().preferences(); 21 14 @BasicPreferences 15 class ToulouseModuleTest { 22 16 @Test 23 publicvoid testHandlersConstruction() {17 void testHandlersConstruction() { 24 18 ToulouseModule module = new ToulouseModule(null); 25 19 assertFalse(module.getHandlers().isEmpty()); -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/test/unit/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseModuleTestIT.java
r35272 r36064 2 2 package org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse; 3 3 4 import static org.junit.Assert.assertTrue; 4 5 import static org.junit.jupiter.api.Assertions.assertTrue; 5 6 6 7 import java.io.IOException; … … 8 9 import java.util.TreeMap; 9 10 10 import org.junit. Rule;11 import org.junit. Test;11 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api.Timeout; 12 13 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 13 import org.openstreetmap.josm.testutils. JOSMTestRules;14 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 14 15 import org.openstreetmap.josm.tools.HttpClient; 15 16 … … 17 18 * Integration tests of {@link ToulouseModule} class. 18 19 */ 19 public class ToulouseModuleTestIT { 20 21 /** 22 * Setup test. 23 */ 24 @Rule 25 public JOSMTestRules rules = new JOSMTestRules().preferences().timeout(30_000); 26 20 @BasicPreferences 21 @Timeout(30) 22 class ToulouseModuleTestIT { 27 23 @Test 28 publicvoid testUrlValidity() throws IOException {24 void testUrlValidity() throws IOException { 29 25 Map<String, Integer> errors = new TreeMap<>(); 30 26 for (AbstractDataSetHandler handler : new ToulouseModule(null).getNewlyInstanciatedHandlers()) { … … 34 30 } 35 31 } 36 assertTrue(errors. toString(), errors.isEmpty());32 assertTrue(errors.isEmpty(), errors.toString()); 37 33 } 38 34 } -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipReaderTest.java
r35899 r36064 3 3 4 4 import java.io.File; 5 import java.io.FileInputStream;6 5 import java.io.InputStream; 6 import java.nio.file.Files; 7 7 import java.nio.file.Path; 8 8 import java.util.Map.Entry; 9 import java.util.concurrent.TimeUnit; 9 10 10 11 import org.junit.jupiter.api.Test; 11 import org.junit.jupiter.api. extension.RegisterExtension;12 import org.junit.jupiter.api.Timeout; 12 13 import org.openstreetmap.josm.data.osm.DataSet; 13 14 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests; 14 import org.openstreetmap.josm.testutils.JOSMTestRules;15 15 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 16 import org.openstreetmap.josm.testutils.annotations.Projection; 16 17 import org.openstreetmap.josm.tools.Logging; 17 18 … … 20 21 */ 21 22 @BasicPreferences 23 @Projection 24 @Timeout(value = 10, unit = TimeUnit.MINUTES) 22 25 class ZipReaderTest { 23 24 /**25 * Setup test.26 */27 @RegisterExtension28 public JOSMTestRules rules = new JOSMTestRules().projection().noTimeout();29 30 26 /** 31 27 * Test for various zip files reading … … 37 33 File zipfile = p.toFile(); 38 34 Logging.info("Testing reading file "+zipfile.getPath()); 39 try (InputStream is = new FileInputStream(zipfile)) {35 try (InputStream is = Files.newInputStream(zipfile.toPath())) { 40 36 for (Entry<File, DataSet> entry : ZipReader.parseDataSets(is, null, null, false).entrySet()) { 41 37 String name = entry.getKey().getName(); -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/datasets/DataSetUpdaterTest.java
r35899 r36064 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.datasets; 3 3 4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 4 7 import java.io.File; 5 import java.io.FileInputStream;6 8 import java.io.InputStream; 9 import java.nio.file.Files; 10 import java.util.concurrent.TimeUnit; 7 11 import java.util.function.Predicate; 8 12 9 13 import org.junit.jupiter.api.Test; 14 import org.junit.jupiter.api.Timeout; 10 15 import org.junit.jupiter.api.extension.RegisterExtension; 11 16 import org.openstreetmap.josm.TestUtils; … … 17 22 import org.openstreetmap.josm.testutils.JOSMTestRules; 18 23 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 19 20 import static org.junit.jupiter.api.Assertions.assertFalse; 21 import static org.junit.jupiter.api.Assertions.assertTrue; 24 import org.openstreetmap.josm.testutils.annotations.Projection; 22 25 23 26 /** … … 25 28 */ 26 29 @BasicPreferences 30 @Projection 31 @Timeout(value = 1, unit = TimeUnit.MINUTES) 27 32 class DataSetUpdaterTest { 28 33 … … 31 36 */ 32 37 @RegisterExtension 33 JOSMTestRules rules = new JOSMTestRules(). projection().devAPI().timeout(60000);38 JOSMTestRules rules = new JOSMTestRules().devAPI(); 34 39 35 40 /** … … 40 45 void testTicket11166() throws Exception { 41 46 File file = new File(TestUtils.getRegressionDataFile(11166, "raba760dissJosm.zip")); 42 try (InputStream is = new FileInputStream(file)) {47 try (InputStream is = Files.newInputStream(file.toPath())) { 43 48 Predicate<? super Way> p = w -> w.getNodesCount() >= 0.9 * OsmApi.getOsmApi().getCapabilities().getMaxWayNodes(); 44 49 DataSet ds = ZipReader.parseDataSet(is, null, null, false); -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlReaderTest.java
r35899 r36064 6 6 7 7 import java.io.File; 8 import java.io.FileInputStream;9 8 import java.io.InputStream; 9 import java.nio.file.Files; 10 import java.util.concurrent.TimeUnit; 10 11 11 12 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api. extension.RegisterExtension;13 import org.junit.jupiter.api.Timeout; 13 14 import org.openstreetmap.josm.TestUtils; 14 15 import org.openstreetmap.josm.data.osm.Node; 15 import org.openstreetmap.josm.testutils.JOSMTestRules;16 16 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 17 import org.openstreetmap.josm.testutils.annotations.Projection; 17 18 18 19 /** … … 20 21 */ 21 22 @BasicPreferences 23 @Projection 24 @Timeout(value = 1, unit = TimeUnit.MINUTES) 22 25 class GmlReaderTest { 23 24 /**25 * Setup test.26 */27 @RegisterExtension28 JOSMTestRules rules = new JOSMTestRules().projection().timeout(60000);29 30 26 /** 31 27 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/11624">#11624</a> … … 35 31 void testTicket11624() throws Exception { 36 32 File file = new File(TestUtils.getRegressionDataFile(11624, "temp3.gml")); 37 try (InputStream is = new FileInputStream(file)) {33 try (InputStream is = Files.newInputStream(file.toPath())) { 38 34 for (Node n : GmlReader.parseDataSet(is, null, null).getNodes()) { 39 35 assertNotNull(n.getCoor(), n.toString()); -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlReaderTest.java
r35910 r36064 8 8 9 9 import org.junit.jupiter.api.Test; 10 import org.junit.jupiter.api.extension.RegisterExtension;11 10 import org.openstreetmap.josm.TestUtils; 12 11 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests; 13 import org.openstreetmap.josm.testutils.JOSMTestRules;14 12 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 13 import org.openstreetmap.josm.testutils.annotations.Projection; 15 14 16 15 /** … … 18 17 */ 19 18 @BasicPreferences 19 @Projection 20 20 class KmlReaderTest { 21 22 /**23 * Setup test.24 */25 @RegisterExtension26 JOSMTestRules rules = new JOSMTestRules().projection();27 28 21 /** 29 22 * Unit test of {@link KmlReader#COLOR_PATTERN} -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifReaderTest.java
r35899 r36064 8 8 9 9 import org.junit.jupiter.api.Test; 10 import org.junit.jupiter.api.extension.RegisterExtension;11 10 import org.openstreetmap.josm.TestUtils; 12 11 import org.openstreetmap.josm.data.osm.DataSet; … … 14 13 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 15 14 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests; 16 import org.openstreetmap.josm.testutils.JOSMTestRules;17 15 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 16 import org.openstreetmap.josm.testutils.annotations.Projection; 18 17 19 18 /** … … 21 20 */ 22 21 @BasicPreferences 22 @Projection 23 23 class MifReaderTest { 24 25 /**26 * Setup test.27 */28 @RegisterExtension29 JOSMTestRules rules = new JOSMTestRules().projection();30 31 24 private static AbstractDataSetHandler newHandler(final String epsgCode) { 32 25 AbstractDataSetHandler handler = new AbstractDataSetHandler() { -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReaderTest.java
r35899 r36064 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.geographic; 3 4 import java.io.File;5 import java.io.FileInputStream;6 import java.io.InputStream;7 import java.util.Collection;8 import java.util.Objects;9 10 import org.junit.jupiter.api.Disabled;11 import org.junit.jupiter.api.Test;12 import org.junit.jupiter.api.extension.RegisterExtension;13 import org.openstreetmap.josm.TestUtils;14 import org.openstreetmap.josm.data.coor.LatLon;15 import org.openstreetmap.josm.data.osm.Node;16 import org.openstreetmap.josm.data.osm.Way;17 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;18 import org.openstreetmap.josm.testutils.JOSMTestRules;19 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;20 3 21 4 import static org.junit.jupiter.api.Assertions.assertEquals; … … 25 8 import static org.junit.jupiter.api.Assertions.assertTrue; 26 9 10 import java.io.File; 11 import java.io.FileInputStream; 12 import java.io.InputStream; 13 import java.nio.file.Files; 14 import java.util.Collection; 15 import java.util.Objects; 16 import java.util.concurrent.TimeUnit; 17 18 import org.junit.jupiter.api.Disabled; 19 import org.junit.jupiter.api.Test; 20 import org.junit.jupiter.api.Timeout; 21 import org.openstreetmap.josm.TestUtils; 22 import org.openstreetmap.josm.data.coor.LatLon; 23 import org.openstreetmap.josm.data.osm.Node; 24 import org.openstreetmap.josm.data.osm.Way; 25 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests; 26 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 27 import org.openstreetmap.josm.testutils.annotations.Projection; 28 27 29 /** 28 30 * Unit tests of {@link ShpReader} class. 29 31 */ 30 32 @BasicPreferences 33 @Projection 34 @Timeout(value = 1, unit = TimeUnit.MINUTES) 31 35 class ShpReaderTest { 32 33 /**34 * Setup test.35 */36 @RegisterExtension37 JOSMTestRules rules = new JOSMTestRules().projection().timeout(60000);38 39 36 /** 40 37 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/12714">#12714</a> … … 44 41 void testTicket12714() throws Exception { 45 42 File file = new File(TestUtils.getRegressionDataFile(12714, "linhas.shp")); 46 try (InputStream is = new FileInputStream(file)) {43 try (InputStream is = Files.newInputStream(file.toPath())) { 47 44 for (Node n : ShpReader.parseDataSet(is, file, null, null).getNodes()) { 48 45 assertNotNull(n.getCoor(), n.toString()); -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/TabReaderTest.java
r35899 r36064 3 3 4 4 import java.io.File; 5 import java.io.FileInputStream;6 5 import java.io.InputStream; 6 import java.nio.file.Files; 7 import java.util.concurrent.TimeUnit; 7 8 8 9 import org.junit.jupiter.api.Test; 9 import org.junit.jupiter.api. extension.RegisterExtension;10 import org.junit.jupiter.api.Timeout; 10 11 import org.openstreetmap.josm.TestUtils; 11 12 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests; 12 import org.openstreetmap.josm.testutils.JOSMTestRules;13 13 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 14 import org.openstreetmap.josm.testutils.annotations.Projection; 14 15 15 16 /** … … 17 18 */ 18 19 @BasicPreferences 20 @Projection 21 @Timeout(value = 1, unit = TimeUnit.MINUTES) 19 22 class TabReaderTest { 20 21 /**22 * Setup test.23 */24 @RegisterExtension25 JOSMTestRules rules = new JOSMTestRules().projection().timeout(60000);26 27 23 /** 28 24 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/15159">#15159</a> … … 32 28 void testTicket15159() throws Exception { 33 29 File file = new File(TestUtils.getRegressionDataFile(15159, "Sanisette.tab")); 34 try (InputStream is = new FileInputStream(file)) {30 try (InputStream is = Files.newInputStream(file.toPath())) { 35 31 NonRegFunctionalTests.testGeneric("#15159", TabReader.parseDataSet(is, file, null, null)); 36 32 } -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvReaderTest.java
r35899 r36064 5 5 6 6 import org.junit.jupiter.api.Test; 7 import org.junit.jupiter.api.extension.RegisterExtension;8 7 import org.openstreetmap.josm.TestUtils; 9 8 import org.openstreetmap.josm.data.coor.EastNorth; … … 13 12 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 14 13 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests; 15 import org.openstreetmap.josm.testutils.JOSMTestRules;16 14 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 15 import org.openstreetmap.josm.testutils.annotations.Projection; 17 16 18 17 /** … … 20 19 */ 21 20 @BasicPreferences 21 @Projection 22 22 class CsvReaderTest { 23 24 /**25 * Setup test.26 */27 @RegisterExtension28 JOSMTestRules rules = new JOSMTestRules().projection();29 30 23 private static AbstractDataSetHandler newHandler(final String epsgCode) { 31 24 AbstractDataSetHandler handler = new AbstractDataSetHandler() { -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/tabular/OdsReaderTest.java
r35899 r36064 5 5 6 6 import org.junit.jupiter.api.Test; 7 import org.junit.jupiter.api.extension.RegisterExtension;8 7 import org.openstreetmap.josm.TestUtils; 9 8 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests; 10 import org.openstreetmap.josm.testutils.JOSMTestRules;11 9 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 10 import org.openstreetmap.josm.testutils.annotations.Projection; 12 11 13 12 /** … … 15 14 */ 16 15 @BasicPreferences 16 @Projection 17 17 class OdsReaderTest { 18 19 /**20 * Setup test.21 */22 @RegisterExtension23 JOSMTestRules rules = new JOSMTestRules().projection();24 18 25 19 /** -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/tabular/XlsReaderTest.java
r35899 r36064 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.tabular; 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 3 6 4 7 import java.io.InputStream; 5 8 6 9 import org.junit.jupiter.api.Test; 7 import org.junit.jupiter.api.extension.RegisterExtension;8 10 import org.openstreetmap.josm.TestUtils; 9 11 import org.openstreetmap.josm.data.coor.EastNorth; … … 14 16 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 15 17 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests; 16 import org.openstreetmap.josm.testutils.JOSMTestRules;17 18 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 18 19 import static org.junit.jupiter.api.Assertions.assertEquals; 20 import static org.junit.jupiter.api.Assertions.assertNotNull; 19 import org.openstreetmap.josm.testutils.annotations.Projection; 21 20 22 21 /** … … 24 23 */ 25 24 @BasicPreferences 25 @Projection 26 26 class XlsReaderTest { 27 28 /**29 * Setup test.30 */31 @RegisterExtension32 public JOSMTestRules rules = new JOSMTestRules().projection();33 34 27 private static AbstractDataSetHandler newHandler(final String epsgCode) { 35 28 AbstractDataSetHandler handler = new AbstractDataSetHandler() { -
applications/editors/josm/plugins/pbf/test/unit/org/openstreetmap/josm/plugins/pbf/io/PbfExporterTest.java
r32927 r36064 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.pbf.io; 3 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 3 5 4 6 import java.io.FileInputStream; … … 6 8 import java.nio.file.Files; 7 9 import java.nio.file.Path; 10 import java.nio.file.Paths; 8 11 9 import org.junit. Rule;10 import org.junit. Test;12 import org.junit.jupiter.api.Test; 13 import org.junit.jupiter.api.Timeout; 11 14 import org.openstreetmap.josm.TestUtils; 12 15 import org.openstreetmap.josm.data.osm.DataSet; … … 14 17 import org.openstreetmap.josm.io.Compression; 15 18 import org.openstreetmap.josm.io.OsmReader; 16 import org.openstreetmap.josm.testutils. JOSMTestRules;19 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 17 20 18 21 /** 19 22 * Unit tests for {@link PbfExporter}. 20 23 */ 21 public class PbfExporterTest { 22 23 /** 24 * Setup test. 25 */ 26 @Rule 27 public JOSMTestRules rules = new JOSMTestRules().preferences().timeout(20000); 28 24 @BasicPreferences 25 @Timeout(20) 26 class PbfExporterTest { 29 27 /** 30 28 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/11169">Ticket #11169</a>. … … 32 30 */ 33 31 @Test 34 publicvoid testTicket11169() throws Exception {32 void testTicket11169() throws Exception { 35 33 try (InputStream is = Compression.ZIP.getUncompressedInputStream( 36 new FileInputStream(TestUtils.getRegressionDataFile(11169, "Portsmouth_Area.osm.zip")))) {34 Files.newInputStream(Paths.get(TestUtils.getRegressionDataFile(11169, "Portsmouth_Area.osm.zip"))))) { 37 35 DataSet ds = OsmReader.parseDataSet(is, null); 38 36 Path out = Files.createTempFile("pbf-bug-11169", "pbf"); 39 new PbfExporter().doSave(out.toFile(), new OsmDataLayer(ds, null, null)); 37 PbfExporter exporter = new PbfExporter(); 38 assertDoesNotThrow(() -> exporter.doSave(out.toFile(), new OsmDataLayer(ds, null, null))); 40 39 Files.delete(out); 41 40 } -
applications/editors/josm/plugins/pbf/test/unit/org/openstreetmap/josm/plugins/pbf/io/PbfImporterTest.java
r34848 r36064 2 2 package org.openstreetmap.josm.plugins.pbf.io; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNotNull;6 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 7 8 8 import java.io.IOException; 9 9 10 import org.junit.Rule; 11 import org.junit.Test; 10 import org.junit.jupiter.api.Test; 12 11 import org.openstreetmap.josm.TestUtils; 13 12 import org.openstreetmap.josm.data.osm.DataSet; … … 16 15 import org.openstreetmap.josm.data.osm.User; 17 16 import org.openstreetmap.josm.io.IllegalDataException; 18 import org.openstreetmap.josm.testutils. JOSMTestRules;17 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 19 18 20 19 /** 21 20 * Unit tests for {@link PbfImporter}. 22 21 */ 23 public class PbfImporterTest { 24 25 /** 26 * Setup test. 27 */ 28 @Rule 29 public JOSMTestRules rules = new JOSMTestRules().preferences(); 30 22 @BasicPreferences 23 class PbfImporterTest { 31 24 private static void checkUserNull(OsmPrimitive osm, boolean hasToBeNull) { 32 25 User usr = osm.getUser(); 33 26 if (hasToBeNull) { 34 assertNull( osm + " -> " + usr,usr);27 assertNull(usr, osm + " -> " + usr); 35 28 } else { 36 assertNotNull( osm + " -> " + usr,usr);29 assertNotNull(usr, osm + " -> " + usr); 37 30 } 38 31 } … … 55 48 */ 56 49 @Test 57 publicvoid testParseDataSet() throws Exception {50 void testParseDataSet() throws Exception { 58 51 doTestMonaco(TestUtils.getTestDataRoot() + "/monaco-latest.osm.pbf", false); 59 52 } … … 64 57 */ 65 58 @Test 66 publicvoid testTicket10132() throws Exception {59 void testTicket10132() throws Exception { 67 60 doTestMonaco(TestUtils.getRegressionDataFile(10132, "Monaco-SP.osm.pbf"), true); 68 61 } … … 73 66 */ 74 67 @Test 75 publicvoid testTicket12567() throws Exception {68 void testTicket12567() throws Exception { 76 69 DataSet ds = new PbfImporter().parseDataSet(TestUtils.getRegressionDataFile(12567, "12390008.osm.pbf")); 77 70 assertNotNull(ds); … … 86 79 */ 87 80 @Test 88 publicvoid testTicket14545() throws Exception {81 void testTicket14545() throws Exception { 89 82 DataSet ds = new PbfImporter().parseDataSet(TestUtils.getRegressionDataFile(14545, "reg14545.osm.pbf")); 90 83 assertNotNull(ds); -
applications/editors/josm/plugins/pdfimport/test/unit/org/openstreetmap/josm/plugins/pdfimport/pdfbox/PDFParserTest.java
r34609 r36064 2 2 package org.openstreetmap.josm.plugins.pdfimport.pdfbox; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 6 7 import java.awt.Rectangle; 7 8 import java.io.File; 8 9 9 import org.junit. Test;10 import org.junit.jupiter.api.Test; 10 11 import org.openstreetmap.josm.TestUtils; 11 12 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 12 13 import org.openstreetmap.josm.plugins.pdfimport.PathOptimizer; 13 14 14 publicclass PDFParserTest {15 class PDFParserTest { 15 16 16 17 private PathOptimizer parse(String fileName) throws Exception { … … 22 23 23 24 @Test 24 publicvoid testParse9053() throws Exception {25 void testParse9053() throws Exception { 25 26 PathOptimizer data = parse(TestUtils.getRegressionDataFile(9053, "testpdf.pdf")); 26 27 assertEquals(0, data.bounds.getMinX(), 0); … … 33 34 34 35 @Test 35 publicvoid testParse12176() throws Exception {36 void testParse12176() throws Exception { 36 37 PathOptimizer data = parse(TestUtils.getRegressionDataFile(12176, "LYD_Etage_0.pdf")); 37 38 assertEquals(new Rectangle(595, 842), data.bounds); -
applications/editors/josm/plugins/poly/test/unit/poly/PolyExporterTest.java
r34966 r36064 2 2 package poly; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNotNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 6 7 7 import java.nio.file.Files; 8 8 import java.nio.file.Path; 9 9 10 import org.junit. Rule;11 import org.junit. Test;10 import org.junit.jupiter.api.Test; 11 import org.junit.jupiter.api.Timeout; 12 12 import org.openstreetmap.josm.TestUtils; 13 13 import org.openstreetmap.josm.data.osm.DataSet; 14 14 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 15 import org.openstreetmap.josm.testutils. JOSMTestRules;15 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 16 16 17 17 /** … … 19 19 * @author Gerd Petermann 20 20 */ 21 public class PolyExporterTest { 22 23 /** 24 * Setup test. 25 */ 26 @Rule 27 public JOSMTestRules rules = new JOSMTestRules().preferences().timeout(20000); 28 21 @BasicPreferences 22 @Timeout(20) 23 class PolyExporterTest { 29 24 /** 30 25 * Import file, export it, import the exported file and compare content … … 32 27 */ 33 28 @Test 34 publicvoid testSimpleExport() throws Exception {29 void testSimpleExport() throws Exception { 35 30 DataSet dsIn1 = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/simple.poly"); 36 31 assertNotNull(dsIn1); … … 55 50 */ 56 51 @Test 57 publicvoid testExport() throws Exception {52 void testExport() throws Exception { 58 53 DataSet dsIn1 = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/holes.poly"); 59 54 assertNotNull(dsIn1); -
applications/editors/josm/plugins/poly/test/unit/poly/PolyImporterTest.java
r34860 r36064 2 2 package poly; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNotNull;6 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 7 8 import org.junit.Rule; 9 import org.junit.Test; 8 import org.junit.jupiter.api.Test; 10 9 import org.openstreetmap.josm.TestUtils; 11 10 import org.openstreetmap.josm.data.osm.DataSet; 12 11 import org.openstreetmap.josm.io.IllegalDataException; 13 import org.openstreetmap.josm.testutils. JOSMTestRules;12 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 14 13 15 14 /** … … 17 16 * @author Gerd Petermann 18 17 */ 19 public class PolyImporterTest { 20 21 /** 22 * Setup test. 23 */ 24 @Rule 25 public JOSMTestRules rules = new JOSMTestRules().preferences(); 26 18 @BasicPreferences 19 class PolyImporterTest { 27 20 /** 28 21 * @throws Exception if an error occurs 29 22 */ 30 23 @Test 31 publicvoid testSimple() throws Exception {24 void testSimple() throws Exception { 32 25 DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/simple.poly"); 33 26 assertNotNull(ds); … … 42 35 */ 43 36 @Test 44 publicvoid testSimple2() throws Exception {37 void testSimple2() throws Exception { 45 38 DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/splitter.poly"); 46 39 assertNotNull(ds); … … 54 47 */ 55 48 @Test 56 publicvoid testHoles() throws Exception {49 void testHoles() throws Exception { 57 50 DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/holes.poly"); 58 51 assertNotNull(ds); … … 66 59 */ 67 60 @Test 68 publicvoid testTwoOuter() throws Exception {61 void testTwoOuter() throws Exception { 69 62 DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/australia_v.poly"); 70 63 assertNotNull(ds); … … 78 71 */ 79 72 @Test 80 publicvoid testDoubleEnd() throws Exception {73 void testDoubleEnd() throws Exception { 81 74 DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/bremen-double-end.poly"); 82 75 assertNotNull(ds); … … 90 83 */ 91 84 @Test 92 publicvoid testMultipleFile() throws Exception {85 void testMultipleFile() throws Exception { 93 86 DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/multi-concat.poly"); 94 87 assertNotNull(ds); … … 100 93 /** 101 94 * Should throw an IllegalDataException 102 * @throws Exception if an error occurs103 95 */ 104 @Test (expected = IllegalDataException.class)105 public void testNameMissing() throws Exception{106 DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/name-missing.poly");107 assert Null(ds);96 @Test 97 void testNameMissing() { 98 final PolyImporter importer = new PolyImporter(); 99 assertThrows(IllegalDataException.class, () -> importer.parseDataSet(TestUtils.getTestDataRoot() + "/name-missing.poly")); 108 100 } 109 101 -
applications/editors/josm/plugins/print/test/unit/org/openstreetmap/josm/plugins/print/PrintDialogTest.java
r33118 r36064 2 2 package org.openstreetmap.josm.plugins.print; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 6 7 import java.util.Arrays; … … 8 9 import javax.print.attribute.standard.OrientationRequested; 9 10 10 import org.junit.Ignore; 11 import org.junit.Rule; 12 import org.junit.Test; 13 import org.openstreetmap.josm.testutils.JOSMTestRules; 11 import org.junit.jupiter.api.Disabled; 12 import org.junit.jupiter.api.Test; 13 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 14 14 15 15 /** 16 16 * Unit test of {@link PrintDialog} class. 17 17 */ 18 public class PrintDialogTest { 19 20 /** 21 * Setup test. 22 */ 23 @Rule 24 public JOSMTestRules rules = new JOSMTestRules().preferences(); 25 18 @BasicPreferences 19 class PrintDialogTest { 26 20 /** 27 21 * Unit test of {@link PrintDialog#unmarshallPrintSetting} … … 29 23 */ 30 24 @Test 31 publicvoid testUnmarshallPrintSetting() throws ReflectiveOperationException {25 void testUnmarshallPrintSetting() throws ReflectiveOperationException { 32 26 assertEquals(OrientationRequested.PORTRAIT, PrintDialog.unmarshallPrintSetting(Arrays.asList( 33 27 "javax.print.attribute.standard.OrientationRequested", … … 42 36 */ 43 37 @Test 44 @ Ignore("not fixed yet")45 publicvoid testTicket13302() throws ReflectiveOperationException {38 @Disabled("not fixed yet") 39 void testTicket13302() throws ReflectiveOperationException { 46 40 assertEquals(OrientationRequested.PORTRAIT, PrintDialog.unmarshallPrintSetting(Arrays.asList( 47 41 "javax.print.attribute.standard.MediaSizeName", -
applications/editors/josm/plugins/surveyor/test/unit/org/openstreetmap/josm/plugins/surveyor/SurveyorShowActionTest.java
r35262 r36064 2 2 package org.openstreetmap.josm.plugins.surveyor; 3 3 4 import static org.junit.Assert.assertNotNull; 5 import static org.junit.Assert.assertTrue; 4 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 6 7 7 8 import java.util.List; 8 9 9 import org.junit.Rule; 10 import org.junit.Test; 11 import org.openstreetmap.josm.testutils.JOSMTestRules; 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 12 12 import org.openstreetmap.josm.tools.Logging; 13 14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;15 13 16 14 /** 17 15 * Unit tests of {@link #SurveyorShowAction} 18 16 */ 19 public class SurveyorShowActionTest { 20 21 /** 22 * Setup rule 23 */ 24 @Rule 25 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 26 public JOSMTestRules test = new JOSMTestRules().preferences(); 27 17 @BasicPreferences 18 class SurveyorShowActionTest { 28 19 @Test 29 publicvoid testCreateComponent() {20 void testCreateComponent() { 30 21 Logging.clearLastErrorAndWarnings(); 31 22 SurveyorComponent comp = SurveyorShowAction.createComponent(); 32 23 assertNotNull(comp); 33 24 List<String> errors = Logging.getLastErrorAndWarnings(); 34 assertTrue(errors. toString(), errors.isEmpty());25 assertTrue(errors.isEmpty(), errors.toString()); 35 26 } 36 27 } -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/AllUnitTests.java
r32519 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions; 3 3 4 import org.junit. runner.RunWith;5 import org.junit. runners.Suite;4 import org.junit.platform.suite.api.SelectClasses; 5 import org.junit.platform.suite.api.Suite; 6 6 import org.openstreetmap.josm.plugins.turnrestrictions.editor.AllEditorTests; 7 7 8 @ RunWith(Suite.class)9 @S uite.SuiteClasses({8 @Suite 9 @SelectClasses({ 10 10 AllEditorTests.class, 11 11 TurnRestrictionBuilderTest.class -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionBuilderTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertNotNull;7 import static org.junit. Assert.assertNull;8 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertNull; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 9 9 import static org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.intersectionAngle; 10 10 import static org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.selectToWayAfterSplit; … … 12 12 import java.util.ArrayList; 13 13 import java.util.Arrays; 14 import java.util.Collections; 14 15 import java.util.List; 15 16 import java.util.Optional; 16 17 17 import org.junit.Rule; 18 import org.junit.Test; 18 import org.junit.jupiter.api.Test; 19 19 import org.openstreetmap.josm.data.coor.LatLon; 20 20 import org.openstreetmap.josm.data.osm.Node; … … 25 25 import org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.RelativeWayJoinOrientation; 26 26 import org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionType; 27 import org.openstreetmap.josm.testutils.JOSMTestRules; 28 29 public class TurnRestrictionBuilderTest { 30 31 @Rule 32 public JOSMTestRules rules = new JOSMTestRules().preferences(); 33 27 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 28 29 @BasicPreferences 30 class TurnRestrictionBuilderTest { 34 31 TurnRestrictionBuilder builder = new TurnRestrictionBuilder(); 35 32 36 33 boolean hasExactlyOneMemberWithRole(Relation r, final String role) { 37 return r.getMembers().stream(). filter(rm -> role.equals(rm.getRole())).findFirst().isPresent();34 return r.getMembers().stream().anyMatch(rm -> role.equals(rm.getRole())); 38 35 } 39 36 40 37 OsmPrimitive memberWithRole(Relation r, final String role) { 41 38 Optional<RelationMember> opt = r.getMembers().stream().filter(rm -> role.equals(rm.getRole())).findFirst(); 42 if (!opt.isPresent()) 43 return null; 44 return opt.get().getMember(); 39 return opt.map(RelationMember::getMember).orElse(null); 45 40 } 46 41 … … 57 52 */ 58 53 @Test 59 public void noUTurn_1() {54 void testNoUTurn1() { 60 55 Way w = new Way(1); 61 56 Node n1 = new Node(1); … … 84 79 */ 85 80 @Test 86 public void noUTurn_2() {81 void testNoUTurn2() { 87 82 Way w = new Way(1); 88 83 Node n1 = new Node(1); … … 106 101 107 102 @Test 108 public void nullSelection() {103 void testNullSelection() { 109 104 assertEmptyTurnRestriction(builder.build(null)); 110 105 } 111 106 112 107 @Test 113 public void emptySelection() {108 void testEmptySelection() { 114 109 assertEmptyTurnRestriction(builder.build(new ArrayList<>())); 115 110 } … … 120 115 */ 121 116 @Test 122 public void oneSelectedWay() {117 void testOneSelectedWay() { 123 118 Way w = new Way(1); 124 Relation tr = builder.build( Arrays.asList(w));119 Relation tr = builder.build(Collections.singletonList(w)); 125 120 assertNotNull(tr); 126 121 assertEquals("restriction", tr.get("type")); … … 134 129 */ 135 130 @Test 136 public void twoUnconnectedWays() {131 void testTwoUnconnectedWays() { 137 132 Way w1 = new Way(1); 138 133 w1.setNodes(Arrays.asList(new Node(11), new Node(12))); … … 159 154 */ 160 155 @Test 161 public void twoConnectedWays_1() {156 void testTwoConnectedWays1() { 162 157 Node n1 = new Node(1); 163 158 n1.setCoor(new LatLon(1, 1)); … … 217 212 */ 218 213 @Test 219 public void twoConnectedWays_2() {214 void testTwoConnectedWays2() { 220 215 Node n1 = new Node(1); 221 216 n1.setCoor(new LatLon(5, 5)); … … 260 255 261 256 /** 262 * Two connected ways. end node of the first way connects to end node of 263 * the second way. left turn. 264 * 265 * 266 * (7,5) - 267 * ^ - w2 268 * | w1 ------> (6,7) 269 * | 270 * (5,5) 271 */ 272 @Test 273 public void twoConnectedWays_3() { 274 Node n1 = new Node(1); 275 n1.setCoor(new LatLon(5, 5)); 276 Node n2 = new Node(2); 277 n2.setCoor(new LatLon(7, 5)); 278 Node n3 = new Node(3); 279 n3.setCoor(new LatLon(6, 7)); 280 281 Way w1 = new Way(1); 282 w1.setNodes(Arrays.asList(n1, n2)); 283 Way w2 = new Way(2); 284 w2.setNodes(Arrays.asList(n2, n3)); 285 286 Relation tr = builder.build(Arrays.asList(w1, w2, n2)); 287 288 assertNotNull(tr); 289 assertEquals("restriction", tr.get("type")); 290 assertEquals(3, tr.getMembersCount()); 291 assertEquals(w1, memberWithRole(tr, "from")); 292 assertEquals(w2, memberWithRole(tr, "to")); 293 assertEquals(n2, memberWithRole(tr, "via")); 294 295 assertEquals("no_right_turn", tr.get("restriction")); 296 } 297 298 /** 299 * Two connected ways. end node of the first way connects to end node of 300 * the second way. left turn. 301 * 302 * 303 * (10,10) 304 * \ 305 * \ 306 * \ 307 * v 308 * (8,15) 309 * / 310 * / 311 * / 312 * v 313 * (5,11) 314 */ 315 @Test 316 public void twoConnectedWays_4() { 317 Node n1 = new Node(1); 318 n1.setCoor(new LatLon(10, 10)); 319 Node n2 = new Node(2); 320 n2.setCoor(new LatLon(8, 15)); 321 Node n3 = new Node(3); 322 n3.setCoor(new LatLon(5, 11)); 323 324 Way w1 = new Way(1); 325 w1.setNodes(Arrays.asList(n1, n2)); 326 Way w2 = new Way(2); 327 w2.setNodes(Arrays.asList(n2, n3)); 328 329 Relation tr = builder.build(Arrays.asList(w1, w2, n2)); 330 331 assertNotNull(tr); 332 assertEquals("restriction", tr.get("type")); 333 assertEquals(3, tr.getMembersCount()); 334 assertEquals(w1, memberWithRole(tr, "from")); 335 assertEquals(w2, memberWithRole(tr, "to")); 336 assertEquals(n2, memberWithRole(tr, "via")); 337 338 assertEquals("no_right_turn", tr.get("restriction")); 339 340 /* 341 * opposite order, from w2 to w1. In this case we have left turn. 342 */ 343 tr = builder.build(Arrays.asList(w2, w1, n2)); 344 345 assertNotNull(tr); 346 assertEquals("restriction", tr.get("type")); 347 assertEquals(3, tr.getMembersCount()); 348 assertEquals(w2, memberWithRole(tr, "from")); 349 assertEquals(w1, memberWithRole(tr, "to")); 350 assertEquals(n2, memberWithRole(tr, "via")); 351 352 assertEquals("no_left_turn", tr.get("restriction")); 257 * Two connected ways. end node of the first way connects to end node of 258 * the second way. left turn. 259 * 260 * (7,5) - 261 * ^ - w2 262 * | w1 ------> (6,7) 263 * | 264 * (5,5) 265 */ 266 @Test 267 void testTwoConnectedWays3() { 268 Node n1 = new Node(1); 269 n1.setCoor(new LatLon(5, 5)); 270 Node n2 = new Node(2); 271 n2.setCoor(new LatLon(7, 5)); 272 Node n3 = new Node(3); 273 n3.setCoor(new LatLon(6, 7)); 274 275 Way w1 = new Way(1); 276 w1.setNodes(Arrays.asList(n1, n2)); 277 Way w2 = new Way(2); 278 w2.setNodes(Arrays.asList(n2, n3)); 279 280 Relation tr = builder.build(Arrays.asList(w1, w2, n2)); 281 282 assertNotNull(tr); 283 assertEquals("restriction", tr.get("type")); 284 assertEquals(3, tr.getMembersCount()); 285 assertEquals(w1, memberWithRole(tr, "from")); 286 assertEquals(w2, memberWithRole(tr, "to")); 287 assertEquals(n2, memberWithRole(tr, "via")); 288 289 assertEquals("no_right_turn", tr.get("restriction")); 290 } 291 292 /** 293 * Two connected ways. end node of the first way connects to end node of 294 * the second way. left turn. 295 * 296 * (10,10) 297 * \ 298 * \ 299 * \ 300 * v 301 * (8,15) 302 * / 303 * / 304 * / 305 * v 306 * (5,11) 307 */ 308 @Test 309 void testTwoConnectedWays4() { 310 Node n1 = new Node(1); 311 n1.setCoor(new LatLon(10, 10)); 312 Node n2 = new Node(2); 313 n2.setCoor(new LatLon(8, 15)); 314 Node n3 = new Node(3); 315 n3.setCoor(new LatLon(5, 11)); 316 317 Way w1 = new Way(1); 318 w1.setNodes(Arrays.asList(n1, n2)); 319 Way w2 = new Way(2); 320 w2.setNodes(Arrays.asList(n2, n3)); 321 322 Relation tr = builder.build(Arrays.asList(w1, w2, n2)); 323 324 assertNotNull(tr); 325 assertEquals("restriction", tr.get("type")); 326 assertEquals(3, tr.getMembersCount()); 327 assertEquals(w1, memberWithRole(tr, "from")); 328 assertEquals(w2, memberWithRole(tr, "to")); 329 assertEquals(n2, memberWithRole(tr, "via")); 330 331 assertEquals("no_right_turn", tr.get("restriction")); 332 333 /* 334 * opposite order, from w2 to w1. In this case we have left turn. 335 */ 336 tr = builder.build(Arrays.asList(w2, w1, n2)); 337 338 assertNotNull(tr); 339 assertEquals("restriction", tr.get("type")); 340 assertEquals(3, tr.getMembersCount()); 341 assertEquals(w2, memberWithRole(tr, "from")); 342 assertEquals(w1, memberWithRole(tr, "to")); 343 assertEquals(n2, memberWithRole(tr, "via")); 344 345 assertEquals("no_left_turn", tr.get("restriction")); 353 346 } 354 347 … … 374 367 */ 375 368 @Test 376 public void intersectionAngle_1() {369 void testIntersectionAngle1() { 377 370 Node n1 = nn(1, 5, 5); 378 371 Node n2 = nn(2, 5, 10); … … 429 422 */ 430 423 @Test 431 public void intersectionAngle_2() {424 void testIntersectionAngle2() { 432 425 Node n1 = nn(1, 5, 5); 433 426 Node n2 = nn(2, 5, 10); … … 473 466 * / 474 467 * (-5, -10) n2 475 * ^ 476 * | 477 * | from 478 * | 479 * (-10,-10) n1 480 */ 481 @Test 482 public void intersectionAngle_3() { 483 Node n1 = nn(1, -10, -10); 484 Node n2 = nn(2, -5, -10); 485 Node n3 = nn(3, -1, -6); 486 Way from = nw(1, n1, n2); 487 Way to = nw(2, n2, n3); 488 489 double a = TurnRestrictionBuilder.intersectionAngle(from, to); 490 assertEquals(45, Math.toDegrees(a), 1e-7); 491 492 /* 493 * if reversed from, the intersection angle is still 45 494 */ 495 from = nw(1, n2, n1); 496 to = nw(2, n2, n3); 497 a = TurnRestrictionBuilder.intersectionAngle(from, to); 498 assertEquals(45, Math.toDegrees(a), 1e-7); 499 500 /* 501 * if reversed to, the intersection angle is still 45 502 */ 503 from = nw(1, n1, n2); 504 to = nw(2, n3, n2); 505 a = TurnRestrictionBuilder.intersectionAngle(from, to); 506 assertEquals(45, Math.toDegrees(a), 1e-7); 507 508 /* 509 * if reversed both, the intersection angle is still 45 510 */ 511 from = nw(1, n2, n1); 512 to = nw(2, n3, n2); 513 a = TurnRestrictionBuilder.intersectionAngle(from, to); 514 assertEquals(45, Math.toDegrees(a), 1e-7); 515 } 516 517 /** 518 * 519 * 520 * (-1,-14) (n3) 521 * ^ 522 * \ 523 * \ to 524 * \ 525 * (-5, -10) n2 526 * ^ 527 * | 528 * | from 529 * | 530 * (-10,-10) n1 531 */ 532 @Test 533 public void intersectionAngle_4() { 534 Node n1 = nn(1, -10, -10); 535 Node n2 = nn(2, -5, -10); 536 Node n3 = nn(3, -1, -14); 537 Way from = nw(1, n1, n2); 538 Way to = nw(2, n2, n3); 539 540 double a = TurnRestrictionBuilder.intersectionAngle(from, to); 541 assertEquals(-45, Math.toDegrees(a), 1e-7); 542 543 /* 544 * if reversed from, the intersection angle is still -45 545 */ 546 from = nw(1, n2, n1); 547 to = nw(2, n2, n3); 548 a = TurnRestrictionBuilder.intersectionAngle(from, to); 549 assertEquals(-45, Math.toDegrees(a), 1e-7); 550 551 /* 552 * if reversed to, the intersection angle is still -45 468 * ^ 469 * | 470 * | from 471 * | 472 * (-10,-10) n1 553 473 */ 554 from = nw(1, n1, n2); 555 to = nw(2, n3, n2); 556 a = TurnRestrictionBuilder.intersectionAngle(from, to); 557 assertEquals(-45, Math.toDegrees(a), 1e-7); 558 559 /* 560 * if reversed both, the intersection angle is still 45 474 @Test 475 void testIntersectionAngle3() { 476 Node n1 = nn(1, -10, -10); 477 Node n2 = nn(2, -5, -10); 478 Node n3 = nn(3, -1, -6); 479 Way from = nw(1, n1, n2); 480 Way to = nw(2, n2, n3); 481 482 double a = TurnRestrictionBuilder.intersectionAngle(from, to); 483 assertEquals(45, Math.toDegrees(a), 1e-7); 484 485 /* 486 * if reversed from, the intersection angle is still 45 487 */ 488 from = nw(1, n2, n1); 489 to = nw(2, n2, n3); 490 a = TurnRestrictionBuilder.intersectionAngle(from, to); 491 assertEquals(45, Math.toDegrees(a), 1e-7); 492 493 /* 494 * if reversed to, the intersection angle is still 45 495 */ 496 from = nw(1, n1, n2); 497 to = nw(2, n3, n2); 498 a = TurnRestrictionBuilder.intersectionAngle(from, to); 499 assertEquals(45, Math.toDegrees(a), 1e-7); 500 501 /* 502 * if reversed both, the intersection angle is still 45 503 */ 504 from = nw(1, n2, n1); 505 to = nw(2, n3, n2); 506 a = TurnRestrictionBuilder.intersectionAngle(from, to); 507 assertEquals(45, Math.toDegrees(a), 1e-7); 508 } 509 510 /** 511 * 512 * 513 * (-1,-14) (n3) 514 * ^ 515 * \ 516 * \ to 517 * \ 518 * (-5, -10) n2 519 * ^ 520 * | 521 * | from 522 * | 523 * (-10,-10) n1 561 524 */ 562 from = nw(1, n2, n1); 563 to = nw(2, n3, n2); 564 a = TurnRestrictionBuilder.intersectionAngle(from, to); 565 assertEquals(-45, Math.toDegrees(a), 1e-7); 566 } 567 568 569 /* 525 @Test 526 void testIntersectionAngle4() { 527 Node n1 = nn(1, -10, -10); 528 Node n2 = nn(2, -5, -10); 529 Node n3 = nn(3, -1, -14); 530 Way from = nw(1, n1, n2); 531 Way to = nw(2, n2, n3); 532 533 double a = TurnRestrictionBuilder.intersectionAngle(from, to); 534 assertEquals(-45, Math.toDegrees(a), 1e-7); 535 536 /* 537 * if reversed from, the intersection angle is still -45 538 */ 539 from = nw(1, n2, n1); 540 to = nw(2, n2, n3); 541 a = TurnRestrictionBuilder.intersectionAngle(from, to); 542 assertEquals(-45, Math.toDegrees(a), 1e-7); 543 544 /* 545 * if reversed to, the intersection angle is still -45 546 */ 547 from = nw(1, n1, n2); 548 to = nw(2, n3, n2); 549 a = TurnRestrictionBuilder.intersectionAngle(from, to); 550 assertEquals(-45, Math.toDegrees(a), 1e-7); 551 552 /* 553 * if reversed both, the intersection angle is still 45 554 */ 555 from = nw(1, n2, n1); 556 to = nw(2, n3, n2); 557 a = TurnRestrictionBuilder.intersectionAngle(from, to); 558 assertEquals(-45, Math.toDegrees(a), 1e-7); 559 } 560 561 /** 570 562 * 571 563 * n21 w21 n22 w22 n23 … … 579 571 */ 580 572 @Test 581 public void splitToWay() {573 void testSplitToWay() { 582 574 Node n11 = new Node(11); 583 575 n11.setCoor(new LatLon(5, 15)); -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/AllEditorTests.java
r32519 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import org.junit.runner.RunWith; 5 import org.junit.runners.Suite; 4 import org.junit.platform.suite.api.SelectClasses; 6 5 7 6 import junit.framework.TestCase; 7 import org.junit.platform.suite.api.Suite; 8 8 9 @ RunWith(Suite.class)10 @S uite.SuiteClasses({9 @Suite 10 @SelectClasses({ 11 11 JosmSelectionListModelTest.class, 12 12 TurnRestrictionEditorModelUnitTest.class, -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/BasicEditorPanelTest.java
r32519 r36064 7 7 import javax.swing.JFrame; 8 8 9 import org.junit. Ignore;9 import org.junit.jupiter.api.Disabled; 10 10 import org.openstreetmap.josm.data.osm.DataSet; 11 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 15 15 * 16 16 */ 17 @ Ignore("no test")17 @Disabled("no test") 18 18 public class BasicEditorPanelTest extends JFrame { 19 19 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/ExceptValueModelTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertTrue; 4 import static org.junit.jupiter.api.Assertions.assertAll; 5 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 6 import static org.junit.jupiter.api.Assertions.assertEquals; 7 import static org.junit.jupiter.api.Assertions.assertFalse; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 7 9 8 import org.junit.Test; 10 import org.junit.jupiter.api.Test; 11 import org.junit.jupiter.params.ParameterizedTest; 12 import org.junit.jupiter.params.provider.ValueSource; 9 13 10 publicclass ExceptValueModelTest {14 class ExceptValueModelTest { 11 15 12 @Test 13 public void testConstructors() { 14 new ExceptValueModel(); 15 new ExceptValueModel(null); 16 new ExceptValueModel(""); 17 new ExceptValueModel(" "); 18 new ExceptValueModel("hgv"); 19 new ExceptValueModel("hgv;psv"); 20 new ExceptValueModel("non_standard"); 16 @ParameterizedTest 17 @ValueSource(strings = {"", " ", "hgv", "hgv;psv", "non_standard"}) 18 void testStringConstructors(String value) { 19 assertDoesNotThrow(() -> new ExceptValueModel(value)); 21 20 } 22 21 23 22 @Test 24 public void testSetValue() { 23 void testAdditionalConstructors() { 24 assertAll(() -> assertDoesNotThrow(() -> new ExceptValueModel()), 25 () -> assertDoesNotThrow(() -> new ExceptValueModel(null))); 26 } 27 28 @Test 29 void testSetValue() { 25 30 ExceptValueModel evm; 26 31 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionListModelTest.java
r33847 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNotNull; 6 import static org.junit.Assert.assertTrue; 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertThrows; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 7 9 8 10 import java.util.ArrayList; … … 14 16 import javax.swing.ListSelectionModel; 15 17 16 import org.junit.Rule; 17 import org.junit.Test; 18 import org.junit.jupiter.api.Test; 18 19 import org.openstreetmap.josm.data.coor.LatLon; 19 20 import org.openstreetmap.josm.data.osm.DataSet; … … 24 25 import org.openstreetmap.josm.gui.MainApplication; 25 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 26 import org.openstreetmap.josm.testutils. JOSMTestRules;27 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 27 28 28 29 /** 29 30 * Unit test for {@see JosmSelctionListModel} 30 31 */ 31 public class JosmSelectionListModelTest { 32 33 @Rule 34 public JOSMTestRules rules = new JOSMTestRules().preferences(); 32 @BasicPreferences 33 class JosmSelectionListModelTest { 35 34 36 35 @Test 37 public void testConstructor() { 38 assertNotNull(new JosmSelectionListModel(new OsmDataLayer(new DataSet(), "test", null))); 39 } 40 41 @Test(expected = IllegalArgumentException.class) 42 public void testConstructorNull() { 43 new JosmSelectionListModel(null); 36 void testConstructor() { 37 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "test", null); 38 assertDoesNotThrow(() -> new JosmSelectionListModel(layer)); 44 39 } 45 40 46 41 @Test 47 public void test_setJOSMSelection() { 42 void testConstructorNull() { 43 assertThrows(IllegalArgumentException.class, () -> new JosmSelectionListModel(null)); 44 } 45 46 @Test 47 void testSetJOSMSelection() { 48 48 DataSet ds = new DataSet(); 49 49 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); … … 66 66 67 67 @Test 68 public void test_setJOSMSelection_withSelected() {68 void testSetJOSMSelectionWithSelected() { 69 69 DataSet ds = new DataSet(); 70 70 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); … … 84 84 85 85 @Test 86 public void test_getSelected() {86 void testGetSelected() { 87 87 DataSet ds = new DataSet(); 88 88 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); … … 105 105 106 106 @Test 107 public void test_setSelected() {107 void testSetSelected() { 108 108 // set selected with null is OK - nothing selected thereafter 109 109 JosmSelectionListModel model = new JosmSelectionListModel(new OsmDataLayer(new DataSet(), "test", null)); … … 118 118 List<OsmPrimitive> objects = (Arrays.asList(new Node(new LatLon(1, 1)), new Way(), new Relation())); 119 119 model.setJOSMSelection(objects); 120 model.setSelected( Arrays.asList(objects.get(0)));120 model.setSelected(Collections.singletonList(objects.get(0))); 121 121 assertEquals(Collections.singleton(objects.get(0)), model.getSelected()); 122 122 123 123 // select an object not-existing in the list of displayed objects 124 124 model.setJOSMSelection(objects); 125 model.setSelected( Arrays.asList(new Way()));125 model.setSelected(Collections.singletonList(new Way())); 126 126 assertTrue(model.getSelected().isEmpty()); 127 127 } 128 128 129 129 @Test 130 public void test_editLayerChanged() {130 void testEditLayerChanged() { 131 131 DataSet ds = new DataSet(); 132 132 133 133 List<OsmPrimitive> objects = (Arrays.asList(new Node(new LatLon(1, 1)), new Way(), new Relation())); 134 objects. stream().forEach(ds::addPrimitive);134 objects.forEach(ds::addPrimitive); 135 135 136 136 OsmDataLayer layer1 = new OsmDataLayer(ds, "layer1", null); -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionComboBoxTest.java
r32519 r36064 8 8 import javax.swing.JFrame; 9 9 10 import org.junit. Ignore;10 import org.junit.jupiter.api.Disabled; 11 11 import org.openstreetmap.josm.data.osm.DataSet; 12 12 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 17 17 * 18 18 */ 19 @ Ignore("no test")19 @Disabled("no test") 20 20 public class TurnRestrictionComboBoxTest extends JFrame { 21 21 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorModelUnitTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNotNull; 6 import static org.junit.Assert.assertTrue; 7 import static org.junit.Assert.fail; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 8 import static org.junit.jupiter.api.Assertions.fail; 8 9 import static org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionLegRole.FROM; 9 10 import static org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionLegRole.TO; … … 13 14 import java.util.Collections; 14 15 15 import org.junit.Before; 16 import org.junit.Rule; 17 import org.junit.Test; 16 import org.junit.jupiter.api.BeforeEach; 17 import org.junit.jupiter.api.Test; 18 18 import org.openstreetmap.josm.data.coor.LatLon; 19 19 import org.openstreetmap.josm.data.osm.DataSet; … … 21 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 22 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 23 import org.openstreetmap.josm.data.osm.PrimitiveId; 23 24 import org.openstreetmap.josm.data.osm.Relation; 24 25 import org.openstreetmap.josm.data.osm.RelationMember; … … 26 27 import org.openstreetmap.josm.data.osm.Way; 27 28 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 28 import org.openstreetmap.josm.testutils. JOSMTestRules;29 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 29 30 30 31 /** 31 32 * This is a unit test for {@link TurnRestrictionEditorModel} 32 33 */ 33 public class TurnRestrictionEditorModelUnitTest { 34 35 @Rule 36 public JOSMTestRules rules = new JOSMTestRules().preferences(); 34 @BasicPreferences 35 class TurnRestrictionEditorModelUnitTest { 37 36 38 37 private final NavigationControler navigationControlerMock = new NavigationControler() { … … 114 113 } 115 114 116 @Before 115 @BeforeEach 117 116 public void setUp() { 118 117 ds = new DataSet(); … … 124 123 * Test the constructor 125 124 */ 126 @Test (expected = IllegalArgumentException.class)127 publicvoid testConstructor1() {128 new TurnRestrictionEditorModel(null, navigationControlerMock);125 @Test 126 void testConstructor1() { 127 assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionEditorModel(null, navigationControlerMock)); 129 128 } 130 129 … … 132 131 * Test the constructor 133 132 */ 134 @Test (expected = IllegalArgumentException.class)135 publicvoid testConstructor2() {136 new TurnRestrictionEditorModel(layer, null);137 } 138 139 @Test 140 publicvoid testPopulateEmptyTurnRestriction() {133 @Test 134 void testConstructor2() { 135 assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionEditorModel(layer, null)); 136 } 137 138 @Test 139 void testPopulateEmptyTurnRestriction() { 141 140 // an "empty" turn restriction with a public id 142 141 Relation r = new Relation(1); … … 156 155 */ 157 156 @Test 158 public void test_populate_SimpleStandardTurnRestriction() {157 void testPopulateSimpleStandardTurnRestriction() { 159 158 buildDataSet1(); 160 159 model.populate(rel(1)); … … 162 161 assertEquals(Collections.singleton(way(2)), model.getTurnRestrictionLeg(FROM)); 163 162 assertEquals(Collections.singleton(way(3)), model.getTurnRestrictionLeg(TO)); 164 assertEquals( Arrays.asList(node(22)), model.getVias());163 assertEquals(Collections.singletonList(node(22)), model.getVias()); 165 164 assertEquals("no_left_turn", model.getRestrictionTagValue()); 166 165 assertEquals("", model.getExcept().getValue()); … … 168 167 169 168 @Test 170 public void setFrom() {169 void testSetFrom() { 171 170 buildDataSet1(); 172 171 model.populate(rel(1)); … … 178 177 // set another way as from 179 178 model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, way(4).getPrimitiveId()); 180 assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg( TurnRestrictionLegRole.FROM));179 assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(FROM)); 181 180 182 181 // delete the/all members with role 'from' 183 182 model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, null); 184 assertTrue(model.getTurnRestrictionLeg(TurnRestrictionLegRole.FROM).isEmpty()); 185 186 try { 187 // can't add a node as 'from' 188 model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, node(21).getPrimitiveId()); 189 fail(); 190 } catch (IllegalArgumentException e) { 191 // OK 192 System.out.println(e.getMessage()); 193 } 194 195 try { 196 // can't set a way as 'from' if it isn't part of the dataset 197 model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, new Way().getPrimitiveId()); 198 fail(); 199 } catch (IllegalStateException e) { 200 // OK 201 System.out.println(e.getMessage()); 202 } 203 } 204 205 @Test 206 public void setTo() { 183 assertTrue(model.getTurnRestrictionLeg(FROM).isEmpty()); 184 185 // can't add a node as 'from' 186 PrimitiveId node = node(21).getPrimitiveId(); 187 assertThrows(IllegalArgumentException.class, 188 () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, node)); 189 190 // can't set a way as 'from' if it isn't part of the dataset 191 PrimitiveId way = new Way().getPrimitiveId(); 192 assertThrows(IllegalStateException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, way)); 193 } 194 195 @Test 196 void setTo() { 207 197 buildDataSet1(); 208 198 model.populate(rel(1)); … … 214 204 // set another way as from 215 205 model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, way(4).getPrimitiveId()); 216 assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(T urnRestrictionLegRole.TO));206 assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(TO)); 217 207 218 208 // delete the/all members with role 'from' 219 209 model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, null); 220 assertTrue(model.getTurnRestrictionLeg(TurnRestrictionLegRole.TO).isEmpty()); 221 222 try { 223 // can't add a node as 'from' 224 model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, node(21).getPrimitiveId()); 225 fail(); 226 } catch (IllegalArgumentException e) { 227 // OK 228 System.out.println(e.getMessage()); 229 } 230 231 try { 232 // can't set a way as 'from' if it isn't part of the dataset 233 model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, new Way().getPrimitiveId()); 234 fail(); 235 } catch (IllegalStateException e) { 236 // OK 237 System.out.println(e.getMessage()); 238 } 210 assertTrue(model.getTurnRestrictionLeg(TO).isEmpty()); 211 212 PrimitiveId node = node(21).getPrimitiveId(); 213 assertThrows(IllegalArgumentException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, node)); 214 215 PrimitiveId way = new Way().getPrimitiveId(); 216 assertThrows(IllegalStateException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, way)); 239 217 } 240 218 … … 269 247 270 248 // one node as via - OK 271 model.setVias( Arrays.asList(node(22)));272 assertEquals( Arrays.asList(node(22)), model.getVias());249 model.setVias(Collections.singletonList(node(22))); 250 assertEquals(Collections.singletonList(node(22)), model.getVias()); 273 251 274 252 // pass in null as vias -> remove all vias … … 291 269 // null values in the list of vias are skipped 292 270 model.setVias(Arrays.asList(null, node(22))); 293 assertEquals( Arrays.asList(node(22)), model.getVias());271 assertEquals(Collections.singletonList(node(22)), model.getVias()); 294 272 295 273 try { 296 274 // an object which doesn't belong to the same dataset can't be a via 297 model.setVias( Arrays.asList(new Node(LatLon.ZERO)));275 model.setVias(Collections.singletonList(new Node(LatLon.ZERO))); 298 276 fail(); 299 277 } catch (IllegalArgumentException e) { -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorTest.java
r32519 r36064 4 4 import javax.swing.JFrame; 5 5 6 import org.junit. Ignore;6 import org.junit.jupiter.api.Disabled; 7 7 import org.openstreetmap.josm.data.osm.DataSet; 8 8 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 11 11 * 12 12 */ 13 @ Ignore("no test")13 @Disabled("no test") 14 14 public class TurnRestrictionEditorTest extends JFrame { 15 15 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditorTest.java
r34148 r36064 17 17 import javax.swing.JScrollPane; 18 18 19 import org.junit. Ignore;19 import org.junit.jupiter.api.Disabled; 20 20 import org.openstreetmap.josm.data.coor.LatLon; 21 21 import org.openstreetmap.josm.data.osm.DataSet; … … 34 34 * {@see TurnRestrictionLegEditor} 35 35 */ 36 @ Ignore("no test")36 @Disabled("no test") 37 37 public class TurnRestrictionLegEditorTest extends JFrame { 38 38 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditorUnitTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit.Assert.assertEquals;5 4 6 import org.junit.Before; 7 import org.junit.Rule; 8 import org.junit.Test; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 8 import org.junit.jupiter.api.BeforeEach; 9 import org.junit.jupiter.api.Test; 9 10 import org.openstreetmap.josm.data.osm.DataSet; 10 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 11 import org.openstreetmap.josm.testutils. JOSMTestRules;12 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 12 13 13 14 /** 14 15 * Unit test for the {@link TurnRestrictionLegEditor} 15 16 */ 16 public class TurnRestrictionLegEditorUnitTest { 17 18 @Rule 19 public JOSMTestRules rules = new JOSMTestRules().preferences(); 20 17 @BasicPreferences 18 class TurnRestrictionLegEditorUnitTest { 21 19 private DataSet ds; 22 20 private OsmDataLayer layer; 23 21 private TurnRestrictionEditorModel model; 24 22 25 @Before 23 @BeforeEach 26 24 public void setUp() { 27 25 ds = new DataSet(); … … 43 41 44 42 @Test 45 publicvoid testConstructor1() {43 void testConstructor1() { 46 44 TurnRestrictionLegEditor editor = new TurnRestrictionLegEditor(model, TurnRestrictionLegRole.FROM); 47 45 assertEquals(model, editor.getModel()); … … 49 47 } 50 48 51 @Test (expected = IllegalArgumentException.class)52 publicvoid testConstructor2() {53 new TurnRestrictionLegEditor(null, TurnRestrictionLegRole.FROM);49 @Test 50 void testConstructor2() { 51 assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionLegEditor(null, TurnRestrictionLegRole.FROM)); 54 52 } 55 53 56 @Test (expected = IllegalArgumentException.class)57 publicvoid testConstructor3() {58 new TurnRestrictionLegEditor(model, null);54 @Test 55 void testConstructor3() { 56 assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionLegEditor(model, null)); 59 57 } 60 58 } -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionTypeRendererTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNotNull;6 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 7 8 8 import javax.swing.JLabel; 9 9 10 import org.junit.Rule; 11 import org.junit.Test; 12 import org.openstreetmap.josm.testutils.JOSMTestRules; 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 13 12 14 public class TurnRestrictionTypeRendererTest { 15 16 @Rule 17 public JOSMTestRules rules = new JOSMTestRules().preferences(); 18 13 @BasicPreferences 14 class TurnRestrictionTypeRendererTest { 19 15 @Test 20 public void test_Constructor() {16 void testConstructor() { 21 17 TurnRestrictionTypeRenderer renderer = new TurnRestrictionTypeRenderer(); 22 18 … … 26 22 27 23 @Test 28 public void test_getListCellRendererComponent_1() {24 void testGetListCellRendererComponent1() { 29 25 TurnRestrictionTypeRenderer renderer = new TurnRestrictionTypeRenderer(); 30 26 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionTypeTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNull; 6 6 7 import org.junit. Test;7 import org.junit.jupiter.api.Test; 8 8 9 public class TurnRestrictionTypeTest { 9 10 class TurnRestrictionTypeTest { 10 11 11 12 @Test 12 public void test_fromTagValue() {13 void testFromTagValue() { 13 14 14 15 TurnRestrictionType type = TurnRestrictionType.fromTagValue("no_left_turn"); -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/VehicleExceptionEditorTest.java
r32519 r36064 7 7 import javax.swing.JFrame; 8 8 9 import org.junit. Ignore;9 import org.junit.jupiter.api.Disabled; 10 10 import org.openstreetmap.josm.data.osm.DataSet; 11 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 16 16 * 17 17 */ 18 @ Ignore("no test")18 @Disabled("no test") 19 19 public class VehicleExceptionEditorTest extends JFrame { 20 20 TurnRestrictionEditorModel model; -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/ViaListTest.java
r32519 r36064 11 11 import javax.swing.JList; 12 12 13 import org.junit. Ignore;13 import org.junit.jupiter.api.Disabled; 14 14 import org.openstreetmap.josm.data.coor.LatLon; 15 15 import org.openstreetmap.josm.data.osm.DataSet; … … 23 23 * 24 24 */ 25 @ Ignore("no test")25 @Disabled("no test") 26 26 public class ViaListTest extends JFrame { 27 27 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesViewTest.java
r32519 r36064 11 11 import javax.swing.JScrollPane; 12 12 13 import org.junit. Ignore;13 import org.junit.jupiter.api.Disabled; 14 14 import org.openstreetmap.josm.data.osm.DataSet; 15 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 20 20 * Simple test application for layout and functionality of the issues view. 21 21 */ 22 @ Ignore("no test")22 @Disabled("no test") 23 23 public class IssuesViewTest extends JFrame { 24 24 private IssuesModel model;
Note:
See TracChangeset
for help on using the changeset viewer.