Changeset 18690 in josm
- Timestamp:
- 2023-03-13T21:59:27+01:00 (20 months ago)
- Location:
- trunk
- Files:
-
- 106 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ivy.xml
r18629 r18690 61 61 <dependency conf="test->default" org="com.github.tomakehurst" name="wiremock-jre8" rev="2.35.0"/> 62 62 <dependency conf="test->default" org="io.github.classgraph" name="classgraph" rev="4.8.154"/> 63 <dependency conf="test->default" org="org.junit.platform" name="junit-platform-launcher" rev="1.9.1"/> 64 <dependency conf="test->default" org="org.junit.vintage" name="junit-vintage-engine" rev="5.9.1"/> 65 <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-params" rev="5.9.1"/> 66 <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-api" rev="5.9.1"/> 67 <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-engine" rev="5.9.1"/> 68 <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-migrationsupport" rev="5.9.1"/> 63 <dependency conf="test->default" org="org.junit.platform" name="junit-platform-launcher" rev="1.9.2"/> 64 <dependency conf="test->default" org="org.junit.platform" name="junit-platform-suite" rev="1.9.2"/> 65 <dependency conf="test->default" org="org.junit.vintage" name="junit-vintage-engine" rev="5.9.2"/> 66 <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-params" rev="5.9.2"/> 67 <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-api" rev="5.9.2"/> 68 <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-engine" rev="5.9.2"/> 69 <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-migrationsupport" rev="5.9.2"/> 69 70 <dependency conf="test->default" org="net.trajano.commons" name="commons-testing" rev="2.1.0"/> 70 71 <dependency conf="test->default" org="nl.jqno.equalsverifier" name="equalsverifier" rev="3.12.3"/> -
trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
r18203 r18690 16 16 import java.io.PrintWriter; 17 17 import java.nio.charset.StandardCharsets; 18 import java.nio.file.Files; 18 19 import java.security.SecureRandom; 19 20 import java.text.MessageFormat; … … 52 53 */ 53 54 @SuppressFBWarnings(value = "CRLF_INJECTION_LOGS") 54 @Timeout(value = 60, unit = TimeUnit.SECONDS)55 @Timeout(value = 1, unit = TimeUnit.MINUTES) 55 56 class MultiFetchServerObjectReaderTest { 56 57 private static final Logger logger = Logger.getLogger(MultiFetchServerObjectReader.class.getName()); … … 191 192 try ( 192 193 PrintWriter pw = new PrintWriter( 193 new OutputStreamWriter( new FileOutputStream(dataSetCacheOutputFile), StandardCharsets.UTF_8)194 new OutputStreamWriter(Files.newOutputStream(dataSetCacheOutputFile.toPath()), StandardCharsets.UTF_8) 194 195 )) { 195 196 logger.info(MessageFormat.format("caching test data set in ''{0}'' ...", dataSetCacheOutputFile.toString())); -
trunk/test/functional/org/openstreetmap/josm/tools/HttpClientTest.java
r18437 r18690 240 240 void testTooMuchRedirects() throws IOException { 241 241 mockRedirects(false, 3); 242 assertThrows(IOException.class, () -> HttpClient.create(url("/relative-redirect/3")).setMaxRedirects(2).connect(progress)); 242 final HttpClient client = HttpClient.create(url("/relative-redirect/3")).setMaxRedirects(2); 243 try { 244 assertThrows(IOException.class, () -> client.connect(progress)); 245 } finally { 246 client.disconnect(); 247 } 243 248 } 244 249 … … 370 375 void testTakesTooLong() throws IOException { 371 376 mockDelay(1); 372 assertThrows(IOException.class, () -> HttpClient.create(url("/delay/1")).setReadTimeout(500).connect(progress)); 377 final HttpClient client = HttpClient.create(url("/delay/1")).setReadTimeout(500); 378 try { 379 assertThrows(IOException.class, () -> client.connect(progress)); 380 } finally { 381 client.disconnect(); 382 } 373 383 } 374 384 … … 387 397 388 398 /** 389 * Test of {@link Response#uncompress } method with Gzip compression.399 * Test of {@link Response#uncompress(boolean)} method with Gzip compression. 390 400 * @throws IOException if any I/O error occurs 391 401 */ … … 407 417 408 418 /** 409 * Test of {@link Response#uncompress } method with Bzip compression.419 * Test of {@link Response#uncompress(boolean)} method with Bzip compression. 410 420 * @throws IOException if any I/O error occurs 411 421 */ … … 427 437 428 438 /** 429 * Test of {@link Response#uncompress } method with Bzip compression.439 * Test of {@link Response#uncompress(boolean)} method with Bzip compression. 430 440 * @throws IOException if any I/O error occurs 431 441 */ -
trunk/test/performance/org/openstreetmap/josm/data/osm/KeyValuePerformanceTest.java
r17275 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assert False;5 import static org.junit.jupiter.api.Assertions.assertNotEquals; 6 6 import static org.junit.jupiter.api.Assertions.assertNotSame; 7 7 import static org.junit.jupiter.api.Assertions.assertSame; … … 14 14 15 15 import org.apache.commons.lang3.RandomStringUtils; 16 import org.junit. Before;16 import org.junit.jupiter.api.BeforeEach; 17 17 import org.junit.jupiter.api.Test; 18 18 import org.junit.jupiter.api.Timeout; … … 29 29 * @author Michael Zangl 30 30 */ 31 @Timeout(value = 15 *60, unit = TimeUnit.SECONDS)31 @Timeout(value = 15, unit = TimeUnit.MINUTES) 32 32 class KeyValuePerformanceTest { 33 33 private static final int PUT_RUNS = 10000; … … 96 96 timer = PerformanceTestUtils.startTimer("str1.equals(str2) = fails (without intern)"); 97 97 for (int i = 0; i < STRING_INTERN_TESTS; i++) { 98 assert False(str1.equals(str2));98 assertNotEquals(str1, str2); 99 99 } 100 100 timer.done(); … … 116 116 * Generate an array of test strings. 117 117 */ 118 @Before 118 @BeforeEach 119 119 public void generateTestStrings() { 120 120 testStrings.clear(); -
trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRendererPerformanceTestParent.java
r17615 r18690 31 31 * Abstract superclass of {@code StyledMapRendererPerformanceTest} and {@code WireframeMapRendererPerformanceTest}. 32 32 */ 33 @Timeout(value = 15 *60, unit = TimeUnit.SECONDS)33 @Timeout(value = 15, unit = TimeUnit.MINUTES) 34 34 abstract class AbstractMapRendererPerformanceTestParent { 35 35 … … 79 79 try (InputStream fisR = Files.newInputStream(Paths.get("nodist/data/restriction.osm")); 80 80 InputStream fisM = Files.newInputStream(Paths.get("nodist/data/multipolygon.osm")); 81 InputStream fisO = Compression.getUncompressedFileInputStream(new File("nodist/data/overpass-download.osm.bz2")) ;) {81 InputStream fisO = Compression.getUncompressedFileInputStream(new File("nodist/data/overpass-download.osm.bz2"))) { 82 82 dsRestriction = OsmReader.parseDataSet(fisR, NullProgressMonitor.INSTANCE); 83 83 dsMultipolygon = OsmReader.parseDataSet(fisM, NullProgressMonitor.INSTANCE); … … 125 125 } 126 126 127 @Test128 127 /** 129 128 * Complex polygon (Lake Ontario) with small download area. 130 129 */ 130 @Test 131 131 void testOverpassDownload() throws Exception { 132 132 test(20, dsOverpass, new Bounds(43.4510496, -76.536684, 43.4643202, -76.4954853)); -
trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java
r17615 r18690 3 3 4 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.assertTrue; 5 7 6 8 import java.awt.Color; … … 21 23 import javax.imageio.ImageIO; 22 24 23 import org.junit.Assert;24 25 import org.junit.jupiter.api.AfterAll; 25 26 import org.junit.jupiter.api.BeforeAll; … … 125 126 List<StyleSource> sources = MapPaintStyles.getStyles().getStyleSources(); 126 127 filterStyleIdx = sources.indexOf(filterStyle); 127 Assert.assertEquals(2, filterStyleIdx);128 129 Assert.assertEquals(Feature.values().length, filterStyle.settings.size());128 assertEquals(2, filterStyleIdx); 129 130 assertEquals(Feature.values().length, filterStyle.settings.size()); 130 131 for (StyleSetting set : filterStyle.settings) { 131 132 BooleanStyleSetting bset = (BooleanStyleSetting) set; … … 139 140 } 140 141 } 141 Assert.assertTrue(prefKey, found);142 assertTrue(found, prefKey); 142 143 } 143 144 … … 151 152 } 152 153 } 153 Assert.assertNotNull(defaultStyle);154 assertNotNull(defaultStyle); 154 155 155 156 for (StyleSetting set : defaultStyle.settings) { … … 161 162 } 162 163 } 163 Assert.assertNotNull(hideIconsSetting);164 assertNotNull(hideIconsSetting); 164 165 hideIconsSetting.setValue(false); 165 166 MapPaintStyleLoader.reloadStyles(defaultStyleIdx); … … 209 210 if (checkScale) { 210 211 int lvl = Selector.GeneralSelector.scale2level(nc.getDist100Pixel()); 211 Assert.assertEquals(17, lvl);212 assertEquals(17, lvl); 212 213 } 213 214 … … 360 361 361 362 public void dumpTimes() { 362 System.out.print (String.format("gen. %4d, sort %4d, draw %4d%n", getGenerateTime(), getSortTime(), getDrawTime()));363 System.out.printf("gen. %4d, sort %4d, draw %4d%n", getGenerateTime(), getSortTime(), getDrawTime()); 363 364 } 364 365 -
trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSourceFilterTest.java
r17275 r18690 18 18 * @author Michael Zangl 19 19 */ 20 @Timeout(value = 15 *60, unit = TimeUnit.SECONDS)20 @Timeout(value = 15, unit = TimeUnit.MINUTES) 21 21 class MapCSSStyleSourceFilterTest { 22 22 … … 71 71 72 72 private void addRule(String selector) { 73 sb.append(selector +" {}\n");73 sb.append(selector).append(" {}\n"); 74 74 } 75 75 -
trunk/test/performance/org/openstreetmap/josm/io/OsmReaderPerformanceTest.java
r17615 r18690 10 10 import java.io.IOException; 11 11 import java.io.InputStream; 12 import java.nio.file.Files; 12 13 import java.util.concurrent.TimeUnit; 13 14 … … 27 28 * @author Michael Zangl 28 29 */ 29 @Timeout(value = 15 *60, unit = TimeUnit.SECONDS)30 @Timeout(value = 15, unit = TimeUnit.MINUTES) 30 31 class OsmReaderPerformanceTest { 31 32 private static final int TIMES = 4; … … 73 74 private InputStream loadFile(boolean decompressBeforeRead) throws IOException { 74 75 File file = new File(PerformanceTestUtils.DATA_FILE); 75 try (InputStream is = decompressBeforeRead ? Compression.getUncompressedFileInputStream(file) : new FileInputStream(file)) {76 try (InputStream is = decompressBeforeRead ? Compression.getUncompressedFileInputStream(file) : Files.newInputStream(file.toPath())) { 76 77 ByteArrayOutputStream temporary = new ByteArrayOutputStream(); 77 78 byte[] readBuffer = new byte[4096]; -
trunk/test/performance/org/openstreetmap/josm/io/OsmWriterPerformanceTest.java
r17848 r18690 20 20 * For this, we use the neubrandenburg-file, which is a good real world example of an OSM file. 21 21 */ 22 @Timeout(value = 15 *60, unit = TimeUnit.SECONDS)22 @Timeout(value = 15, unit = TimeUnit.MINUTES) 23 23 class OsmWriterPerformanceTest { 24 24 private static final int TIMES = 4; -
trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java
r18208 r18690 117 117 I18n.init(); 118 118 // initialize the platform hook, and 119 // call the really early hook before weanything else119 // call the really early hook before anything else 120 120 PlatformManager.getPlatform().preStartupHook(); 121 121 … … 150 150 151 151 if (createGui) { 152 GuiHelper.runInEDTAndWaitWithException( () -> setupGUI());152 GuiHelper.runInEDTAndWaitWithException(this::setupGUI); 153 153 } 154 154 } -
trunk/test/unit/org/openstreetmap/josm/actions/CopyActionTest.java
r18487 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; … … 111 112 Object copied = ClipboardUtils.getClipboard().getContents(null).getTransferData(PrimitiveTransferData.DATA_FLAVOR); 112 113 assertNotNull(copied); 113 assertTrue(copied instanceof PrimitiveTransferData); 114 PrimitiveTransferData ptd = (PrimitiveTransferData) copied; 114 PrimitiveTransferData ptd = assertInstanceOf(PrimitiveTransferData.class, copied); 115 115 Object[] direct = ptd.getDirectlyAdded().toArray(); 116 116 assertEquals(1, direct.length); -
trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java
r17275 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 5 6 import static org.junit.jupiter.api.Assertions.assertTrue; 6 7 … … 199 200 Collection<OsmPrimitive> primitives = tests.get(test); 200 201 for (OsmPrimitive osm : primitives) { 201 assert True(osm instanceof Way, test + "; expected way, but got: " + osm);202 assertInstanceOf(Way.class, osm, test + "; expected way, but got: " + osm); 202 203 } 203 204 new JoinAreasAction(false).join((Collection) primitives); -
trunk/test/unit/org/openstreetmap/josm/actions/RestorePropertyActionTest.java
r17996 r18690 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static org.junit.jupiter.api.Assertions.assert True;4 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 5 5 6 6 import javax.swing.DefaultListSelectionModel; … … 45 45 UndoRedoHandler.getInstance().clean(); 46 46 new RestorePropertyAction(k -> key, v -> val, () -> n, selModel).actionPerformed(null); 47 assert True(UndoRedoHandler.getInstance().getLastCommand() instanceof ChangePropertyCommand);47 assertInstanceOf(ChangePropertyCommand.class, UndoRedoHandler.getInstance().getLastCommand()); 48 48 } 49 49 } -
trunk/test/unit/org/openstreetmap/josm/actions/SessionSaveActionTest.java
r18466 r18690 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static org.junit.Assert.assertFalse;5 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 7 -
trunk/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java
r17275 r18690 7 7 import java.util.Arrays; 8 8 9 import org.junit.Assert;10 9 import org.junit.jupiter.api.Test; 11 10 import org.junit.jupiter.api.extension.RegisterExtension; … … 59 58 w1.setNodes(Arrays.asList(w1NodesArray)); 60 59 Way w2 = new Way(); 61 w2.setNodes(Arrays.asList(n ew Node[] {n1, n2, n3, n1, n4, n5, n1}));60 w2.setNodes(Arrays.asList(n1, n2, n3, n1, n4, n5, n1)); 62 61 dataSet.addPrimitive(w1); 63 62 dataSet.addPrimitive(w2); … … 109 108 for (RelationMember member : restriction.getMembers()) { 110 109 if ("from".equals(member.getRole())) { 111 Assert.assertTrue(member.getWay().containsNode(via));110 assertTrue(member.getWay().containsNode(via)); 112 111 } 113 112 } -
trunk/test/unit/org/openstreetmap/josm/actions/corrector/ReverseWayTagCorrectorTest.java
r17289 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.actions.corrector; 3 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.assertTrue; 3 7 4 8 import java.util.Collections; … … 7 11 import java.util.stream.Stream; 8 12 9 import org.junit.Assert;10 13 import org.junit.jupiter.api.Test; 11 14 import org.junit.jupiter.api.extension.RegisterExtension; … … 105 108 106 109 private void assertSwitch(Tag oldTag, Tag newTag) { 107 Assert.assertEquals(newTag, ReverseWayTagCorrector.TagSwitcher.apply(oldTag));110 assertEquals(newTag, ReverseWayTagCorrector.TagSwitcher.apply(oldTag)); 108 111 } 109 112 … … 128 131 void testSwitchingWayNodes() { 129 132 final Map<OsmPrimitive, List<TagCorrection>> tagCorrections = getTagCorrectionsForWay("direction=forward"); 130 Assert.assertEquals(1, tagCorrections.size());131 Assert.assertEquals(Collections.singletonList(new TagCorrection("direction", "forward", "direction", "backward")),133 assertEquals(1, tagCorrections.size()); 134 assertEquals(Collections.singletonList(new TagCorrection("direction", "forward", "direction", "backward")), 132 135 tagCorrections.values().iterator().next()); 133 136 } … … 138 141 @Test 139 142 void testNotSwitchingWayNodes() { 140 Assert.assertEquals(0, getTagCorrectionsForWay("direction=SSW").size());141 Assert.assertEquals(0, getTagCorrectionsForWay("direction=145").size());143 assertEquals(0, getTagCorrectionsForWay("direction=SSW").size()); 144 assertEquals(0, getTagCorrectionsForWay("direction=145").size()); 142 145 } 143 146 … … 148 151 void testIsReversible() { 149 152 Way w0 = buildWayWithMiddleNode("highway=stop"); 150 Assert.assertTrue(ReverseWayTagCorrector.isReversible(w0));153 assertTrue(ReverseWayTagCorrector.isReversible(w0)); 151 154 Way w1 = buildWayWithMiddleNode("direction=forward"); 152 Assert.assertFalse(ReverseWayTagCorrector.isReversible(w1));153 Assert.assertEquals(3, w1.getNodesCount());155 assertFalse(ReverseWayTagCorrector.isReversible(w1)); 156 assertEquals(3, w1.getNodesCount()); 154 157 w1.getNodes().forEach(n -> n.setKeys(null)); 155 Assert.assertTrue(ReverseWayTagCorrector.isReversible(w1));158 assertTrue(ReverseWayTagCorrector.isReversible(w1)); 156 159 w1.put("oneway", "yes"); 157 Assert.assertFalse(ReverseWayTagCorrector.isReversible(w1));160 assertFalse(ReverseWayTagCorrector.isReversible(w1)); 158 161 } 159 162 -
trunk/test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java
r17275 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNotEquals; 6 7 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; … … 99 100 assertTrue(w2.hasKey("ford")); 100 101 101 assert False("false".equals(w3.get("oneway")));102 assert True("no".equals(w3.get("oneway")));102 assertNotEquals("false", w3.get("oneway")); 103 assertEquals("no", w3.get("oneway")); 103 104 104 assert False("0".equals(w4.get("oneway")));105 assert True("no".equals(w4.get("oneway")));105 assertNotEquals("0", w4.get("oneway")); 106 assertEquals("no", w4.get("oneway")); 106 107 107 assert False("true".equals(w5.get("oneway")));108 assert True("yes".equals(w5.get("oneway")));108 assertNotEquals("true", w5.get("oneway")); 109 assertEquals("yes", w5.get("oneway")); 109 110 110 assert False("1".equals(w6.get("oneway")));111 assert True("yes".equals(w6.get("oneway")));111 assertNotEquals("1", w6.get("oneway")); 112 assertEquals("yes", w6.get("oneway")); 112 113 113 114 assertFalse(w7.hasKey("highway")); 114 115 assertTrue(w7.hasKey("barrier")); 115 116 116 assert False("multipolygon".equals(r1.get("type")));117 assert True("boundary".equals(r1.get("type")));117 assertNotEquals("multipolygon", r1.get("type")); 118 assertEquals("boundary", r1.get("type")); 118 119 119 assert True("space_end".equals(r2.get("foo")));120 assert True("space_begin".equals(r2.get("bar")));121 assert True("space_both".equals(r2.get("baz")));120 assertEquals("space_end", r2.get("foo")); 121 assertEquals("space_begin", r2.get("bar")); 122 assertEquals("space_both", r2.get("baz")); 122 123 assertFalse(r2.hasKey(" space_begin")); 123 124 assertFalse(r2.hasKey("space_end ")); -
trunk/test/unit/org/openstreetmap/josm/command/AddPrimitivesCommandTest.java
r18037 r18690 9 9 import java.util.ArrayList; 10 10 import java.util.Arrays; 11 import java.util.Collections; 11 12 import java.util.HashSet; 12 13 import java.util.List; … … 115 116 116 117 AddPrimitivesCommand command1 = new AddPrimitivesCommand(testData, ds); 117 AddPrimitivesCommand command2 = new AddPrimitivesCommand( Arrays.<PrimitiveData>asList(data2), ds);118 AddPrimitivesCommand command2 = new AddPrimitivesCommand(Collections.singletonList(data2), ds); 118 119 119 120 assertEquals("Added 3 objects", command1.getDescriptionText()); … … 342 343 way.put("test", "test"); 343 344 way.setNodeIds(Arrays.asList(node1.getId(), node2.getId())); 344 List<PrimitiveData> testData = Arrays.<PrimitiveData>asList(node1, node2, way); 345 return testData; 345 return Arrays.asList(node1, node2, way); 346 346 } 347 347 -
trunk/test/unit/org/openstreetmap/josm/command/ChangeCommandTest.java
r18037 r18690 69 69 70 70 assertEquals("new", testData.existingNode.get("new")); 71 assert Equals(null,testData.existingNode.get("existing"));71 assertNull(testData.existingNode.get("existing")); 72 72 assertEquals(LatLon.NORTH_POLE, testData.existingNode.getCoor()); 73 73 … … 89 89 newNode.setCoor(LatLon.NORTH_POLE); 90 90 91 assertThrows(DataIntegrityProblemException.class, () -> new ChangeCommand(testData.existingNode, newNode).executeCommand()); 91 final ChangeCommand changeCommand = new ChangeCommand(testData.existingNode, newNode); 92 assertThrows(DataIntegrityProblemException.class, changeCommand::executeCommand); 92 93 } 93 94 -
trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxImageCorrelationTest.java
r18061 r18690 116 116 void testMatchGpxTrack1() { 117 117 assertEquals(7, GpxImageCorrelation.matchGpxTrack(images, gpx, new GpxImageCorrelationSettings(0, false))); 118 assert Equals(null,ib.getPos());118 assertNull(ib.getPos()); 119 119 assertEquals(new CachedLatLon(47.19286847859621, 8.79732714034617), i0.getPos()); // start of track 120 120 assertEquals(new CachedLatLon(47.196979885920882, 8.79541271366179), i1.getPos()); // exact match … … 133 133 // First waypoint has no speed in matchGpxTrack(). Speed is calculated 134 134 // and not taken from GPX track. 135 assert Equals(null,ib.getSpeed());136 assert Equals(null,i0.getSpeed());137 assertEquals( Double.valueOf(11.675317966018756), i1.getSpeed(), 0.000001);138 assertEquals( Double.valueOf(24.992418392716967), i2.getSpeed(), 0.000001);139 assertEquals( Double.valueOf(27.307968754679223), i3.getSpeed(), 0.000001);140 assert Equals(null,ib.getElevation());141 assert Equals(null,i0.getElevation());142 assertEquals( Double.valueOf(489.29), i1.getElevation(), 0.000001);143 assertEquals( Double.valueOf((490.40 + 489.75) / 2), i2.getElevation(), 0.000001);144 assertEquals( Double.valueOf(486.368333333), i3.getElevation(), 0.000001);135 assertNull(ib.getSpeed()); 136 assertNull(i0.getSpeed()); 137 assertEquals(11.675317966018756, i1.getSpeed(), 0.000001); 138 assertEquals(24.992418392716967, i2.getSpeed(), 0.000001); 139 assertEquals(27.307968754679223, i3.getSpeed(), 0.000001); 140 assertNull(ib.getElevation()); 141 assertNull(i0.getElevation()); 142 assertEquals(489.29, i1.getElevation(), 0.000001); 143 assertEquals((490.40 + 489.75) / 2, i2.getElevation(), 0.000001); 144 assertEquals(486.368333333, i3.getElevation(), 0.000001); 145 145 // interpolated elevation between trackpoints with interpolated timestamps 146 assertEquals( Double.valueOf(475.393978719), i4.getElevation(), 0.000001);147 assert Equals(null,i5.getElevation());148 assert Equals(null,i6.getElevation());149 150 assert Equals(null,ib.getGpsInstant());146 assertEquals(475.393978719, i4.getElevation(), 0.000001); 147 assertNull(i5.getElevation()); 148 assertNull(i6.getElevation()); 149 150 assertNull(ib.getGpsInstant()); 151 151 assertEquals(DateUtils.parseInstant("2016:01:03 11:59:54"), i0.getGpsInstant()); // original time is kept 152 152 assertEquals(DateUtils.parseInstant("2016:01:03 12:04:01"), i1.getGpsInstant()); … … 168 168 169 169 assertEquals(4, GpxImageCorrelation.matchGpxTrack(images, gpx, new GpxImageCorrelationSettings(0, false))); 170 assert Equals(null,ib.getPos());171 assert Equals(null,i0.getPos());170 assertNull(ib.getPos()); 171 assertNull(i0.getPos()); 172 172 assertEquals(new CachedLatLon(47.196979885920882, 8.79541271366179), i1.getPos()); 173 173 assertEquals(new CachedLatLon((47.197131179273129 + 47.197186248376966) / 2, … … 175 175 assertEquals(new CachedLatLon(47.197319911792874, 8.792139580473304), i3.getPos()); 176 176 assertEquals(new CachedLatLon(47.197568312311816, 8.790292849679897), i4.getPos()); 177 assert Equals(null,i5.getPos());178 assert Equals(null,i6.getPos());177 assertNull(i5.getPos()); 178 assertNull(i6.getPos()); 179 179 } 180 180 … … 196 196 197 197 assertEquals(6, GpxImageCorrelation.matchGpxTrack(images, gpx, new GpxImageCorrelationSettings(0, false))); 198 assert Equals(null,ib.getPos());198 assertNull(ib.getPos()); 199 199 assertEquals(new CachedLatLon(47.19286847859621, 8.79732714034617), i0.getPos()); 200 200 assertEquals(new CachedLatLon(47.196979885920882, 8.79541271366179), i1.getPos()); … … 204 204 assertEquals(new CachedLatLon(47.197568312311816, 8.790292849679897), i4.getPos()); 205 205 assertEquals(new CachedLatLon(47.19819249585271, 8.78536943346262), i5.getPos()); 206 assert Equals(null,i6.getPos());206 assertNull(i6.getPos()); 207 207 assertEquals(new CachedLatLon(1, 2), i7.getPos()); 208 208 } … … 228 228 assertEquals(new CachedLatLon(47.19985828931693, 8.77969308585768), i6.getPos()); // different values than in tests #1 and #3! 229 229 230 assertEquals( Double.valueOf(447.894014085), i5.getElevation(), 0.000001);231 assertEquals( Double.valueOf(437.395070423), i6.getElevation(), 0.000001);230 assertEquals(447.894014085, i5.getElevation(), 0.000001); 231 assertEquals(437.395070423, i6.getElevation(), 0.000001); 232 232 233 233 assertEquals(new CachedLatLon(47.20126815140247, 8.77192972227931), i7.getPos()); … … 265 265 assertEquals(new CachedLatLon(47.19985828931693, 8.77969308585768), i6.getPos()); 266 266 267 assertEquals( Double.valueOf(447.894014085), i5.getElevation(), 0.000001);268 assertEquals( Double.valueOf(437.395070423), i6.getElevation(), 0.000001);267 assertEquals(447.894014085, i5.getElevation(), 0.000001); 268 assertEquals(437.395070423, i6.getElevation(), 0.000001); 269 269 270 270 assertEquals(new CachedLatLon(47.20126815140247, 8.77192972227931), i7.getPos()); -
trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java
r17717 r18690 6 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 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.data.osm.Changeset.MAX_CHANGESET_TAG_LENGTH; 9 10 … … 16 17 import java.util.stream.IntStream; 17 18 18 import org.junit.Assert;19 19 import org.junit.jupiter.api.extension.RegisterExtension; 20 20 import org.junit.jupiter.api.Test; … … 48 48 try { 49 49 cs.setKeys(null); 50 Assert.fail("Should have thrown an IllegalArgumentException as we gave a null argument.");50 fail("Should have thrown an IllegalArgumentException as we gave a null argument."); 51 51 } catch (IllegalArgumentException e) { 52 52 Logging.trace(e); … … 63 63 keys.put("test", "test"); 64 64 cs.setKeys(keys); 65 Assert.assertEquals("Both valid keys should have been put in the ChangeSet.", 2, cs.getKeys().size());65 assertEquals(2, cs.getKeys().size(), "Both valid keys should have been put in the ChangeSet."); 66 66 67 67 // Add a map with too long values => IllegalArgumentException … … 71 71 try { 72 72 cs.setKeys(keys); 73 Assert.fail("Should have thrown an IllegalArgumentException as we gave a too long value.");73 fail("Should have thrown an IllegalArgumentException as we gave a too long value."); 74 74 } catch (IllegalArgumentException e) { 75 75 Logging.trace(e); -
trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
r17749 r18690 1001 1001 //-- merge it 1002 1002 DataSetMerger visitor = new DataSetMerger(my, their); 1003 assertThrows(DataIntegrityProblemException.class, () -> visitor.merge());1003 assertThrows(DataIntegrityProblemException.class, visitor::merge); 1004 1004 } 1005 1005 -
trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetTest.java
r17283 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 8 9 import java.util.ArrayList; 9 10 import java.util.Arrays; 11 import java.util.Collections; 10 12 import java.util.HashSet; 11 13 import java.util.List; 12 14 13 import org.junit.Assert;14 15 import org.junit.jupiter.api.Test; 15 16 import org.junit.jupiter.api.extension.RegisterExtension; … … 43 44 final DataSet ds = new DataSet(); 44 45 // null bbox => empty list 45 Assert.assertTrue( 46 "Empty data set should produce an empty list.", 47 ds.searchRelations(null).isEmpty() 48 ); 46 assertTrue(ds.searchRelations(null).isEmpty(), "Empty data set should produce an empty list."); 49 47 50 48 // empty data set, any bbox => empty list 51 49 BBox bbox = new BBox(new LatLon(-180, -90), new LatLon(180, 90)); 52 Assert.assertTrue( 53 "Empty data set should produce an empty list.", 54 ds.searchRelations(bbox).isEmpty() 55 ); 50 assertTrue(ds.searchRelations(bbox).isEmpty(), "Empty data set should produce an empty list."); 56 51 57 52 // data set with elements in the given bbox => these elements … … 64 59 bbox = new BBox(new LatLon(-1.0, -1.0), new LatLon(1.0, 1.0)); 65 60 List<Relation> result = ds.searchRelations(bbox); 66 Assert.assertEquals("We should have found only one item.", 1, result.size());67 Assert.assertTrue("The item found is relation r.", result.contains(r));61 assertEquals(1, result.size(), "We should have found only one item."); 62 assertTrue(result.contains(r), "The item found is relation r."); 68 63 } 69 64 … … 75 70 final DataSet ds = new DataSet(); 76 71 // null bbox => empty list 77 Assert.assertTrue("Empty data set should produce an empty list.", ds.searchPrimitives(null).isEmpty());72 assertTrue(ds.searchPrimitives(null).isEmpty(), "Empty data set should produce an empty list."); 78 73 79 74 // empty data set, any bbox => empty list 80 75 BBox bbox = new BBox(new LatLon(-180, -90), new LatLon(180, 90)); 81 Assert.assertTrue("Empty data set should produce an empty list.", ds.searchPrimitives(bbox).isEmpty());76 assertTrue(ds.searchPrimitives(bbox).isEmpty(), "Empty data set should produce an empty list."); 82 77 // data set with elements in the given bbox => these elements 83 78 Node node = new Node(LatLon.ZERO); … … 92 87 bbox = new BBox(new LatLon(-1.0, -1.0), new LatLon(1.0, 1.0)); 93 88 List<OsmPrimitive> result = ds.searchPrimitives(bbox); 94 Assert.assertEquals("We should have found four items.", 4, result.size());89 assertEquals(4, result.size(), "We should have found four items."); 95 90 } 96 91 … … 199 194 ds.addPrimitive(n3); 200 195 201 assertEquals( Arrays.asList(), new ArrayList<>(ds.getSelected()));196 assertEquals(Collections.emptyList(), new ArrayList<>(ds.getSelected())); 202 197 203 198 ds.setSelected(n1.getPrimitiveId(), n2.getPrimitiveId()); … … 205 200 206 201 ds.clearSelection(); 207 assertEquals( Arrays.asList(), new ArrayList<>(ds.getSelected()));202 assertEquals(Collections.emptyList(), new ArrayList<>(ds.getSelected())); 208 203 209 204 ds.addSelected(n3.getPrimitiveId()); … … 311 306 @Test 312 307 void testAddDataSourceListener() { 313 DataSourceListener addListener = new DataSourceListener() { 314 @Override 315 public void dataSourceChange(DataSourceChangeEvent event) { 316 assertTrue(event instanceof DataSourceAddedEvent); 317 } 318 }; 308 DataSourceListener addListener = event -> assertInstanceOf(DataSourceAddedEvent.class, event); 319 309 320 310 DataSet ds = new DataSet(); … … 329 319 @Test 330 320 void testRemoveDataSourceListener() { 331 DataSourceListener removeListener = new DataSourceListener() { 332 @Override 333 public void dataSourceChange(DataSourceChangeEvent event) { 334 assertTrue(event instanceof DataSourceRemovedEvent); 335 } 336 }; 321 DataSourceListener removeListener = event -> assertInstanceOf(DataSourceRemovedEvent.class, event); 337 322 338 323 DataSet ds = new DataSet(); … … 356 341 ds.addPrimitive(w); 357 342 Relation r = new Relation(); 358 r.setMembers( Arrays.asList(new RelationMember(null, w)));343 r.setMembers(Collections.singletonList(new RelationMember(null, w))); 359 344 ds.addPrimitive(r); 360 345 ds.lock(); -
trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java
r17275 r18690 11 11 import java.util.Arrays; 12 12 import java.util.Collection; 13 import java.util.Collections; 13 14 import java.util.HashSet; 14 15 import java.util.LinkedList; … … 52 53 ds.addPrimitive(n2); 53 54 54 Collection<OsmPrimitive> all = new HashSet<>(); 55 all.addAll(Arrays.asList(new OsmPrimitive[] {n1, n2})); 56 57 List<Filter> filters = new LinkedList<>(); 55 Collection<OsmPrimitive> all = new HashSet<>(Arrays.asList(n1, n2)); 56 58 57 Filter f1 = new Filter(); 59 58 f1.text = "fixme"; 60 59 f1.hiding = true; 61 filters.addAll(Arrays.asList(new Filter[] {f1}));60 List<Filter> filters = new LinkedList<>(Collections.singletonList(f1)); 62 61 63 62 FilterMatcher filterMatcher = new FilterMatcher(); … … 101 100 Filter f2 = new Filter(); 102 101 f2.text = "highway"; 103 filters.addAll(Arrays.asList( new Filter[] {f1, f2}));102 filters.addAll(Arrays.asList(f1, f2)); 104 103 break; 105 104 } … … 120 119 f2.text = "water"; 121 120 f2.mode = SearchMode.remove; 122 filters.addAll(Arrays.asList( new Filter[] {f1, f2}));121 filters.addAll(Arrays.asList(f1, f2)); 123 122 break; 124 123 } … … 133 132 Filter f3 = new Filter(); 134 133 f3.text = "natural"; 135 filters.addAll(Arrays.asList( new Filter[] {f1, f2, f3}));134 filters.addAll(Arrays.asList(f1, f2, f3)); 136 135 break; 137 136 } … … 151 150 f4.text = "name"; 152 151 f4.mode = SearchMode.remove; 153 filters.addAll(Arrays.asList( new Filter[] {f1, f2, f3, f4}));152 filters.addAll(Arrays.asList(f1, f2, f3, f4)); 154 153 break; 155 154 } … … 163 162 f2.mode = SearchMode.remove; 164 163 f2.hiding = true; // Remove only hide flag so water should stay disabled 165 filters.addAll(Arrays.asList( new Filter[] {f1, f2}));164 filters.addAll(Arrays.asList(f1, f2)); 166 165 break; 167 166 } … … 183 182 if (!osm.get(key).equals(filterCode(osm))) { 184 183 failedPrimitives.append(String.format( 185 "Object %s. Expected [%s] but was [%s]%n", osm .toString(), osm.get(key), filterCode(osm)));184 "Object %s. Expected [%s] but was [%s]%n", osm, osm.get(key), filterCode(osm))); 186 185 } 187 186 } … … 189 188 assertTrue(foundAtLeastOne); 190 189 if (failedPrimitives.length() != 0) 191 throw new AssertionError(String.format("Run #%d%n%s", i, failedPrimitives .toString()));190 throw new AssertionError(String.format("Run #%d%n%s", i, failedPrimitives)); 192 191 } 193 192 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/NodeDataTest.java
r17275 r18690 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertNull; 5 6 import static org.junit.jupiter.api.Assertions.assertTrue; … … 11 12 import java.io.ObjectOutputStream; 12 13 13 import org.junit.Assert;14 14 import org.junit.jupiter.api.Test; 15 15 import org.openstreetmap.josm.data.coor.LatLon; … … 38 38 data.setChangesetId(314159); 39 39 final NodeData readData = serializeUnserialize(data); 40 Assert.assertEquals(data.toString(), readData.toString());40 assertEquals(data.toString(), readData.toString()); 41 41 } 42 42 -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandlingTest.java
r17587 r18690 67 67 n.put("key.1", "value.1"); 68 68 n.put("key.2", "value.2"); 69 assert True(n.get("key.1").equals("value.1"));70 assert True(n.get("key.2").equals("value.2"));69 assertEquals("value.1", n.get("key.1")); 70 assertEquals("value.2", n.get("key.2")); 71 71 testKeysSize(n, 2); 72 72 assertTrue(n.hasKeys()); -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java
r17275 r18690 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertThrows; 5 6 … … 7 8 import java.util.HashSet; 8 9 9 import org.junit.Assert;10 10 import org.junit.jupiter.api.BeforeAll; 11 11 import org.junit.jupiter.api.Test; … … 31 31 32 32 private void compareReferrers(OsmPrimitive actual, OsmPrimitive... expected) { 33 Assert.assertEquals(new HashSet<>(Arrays.asList(expected)), 34 new HashSet<>(actual.getReferrers())); 33 assertEquals(new HashSet<>(Arrays.asList(expected)), new HashSet<>(actual.getReferrers())); 35 34 } 36 35 … … 149 148 new Way(w1); 150 149 151 Assert.assertEquals(n.getReferrers().size(), 1);152 Assert.assertEquals(n.getReferrers().get(0), w1);150 assertEquals(n.getReferrers().size(), 1); 151 assertEquals(n.getReferrers().get(0), w1); 153 152 } 154 153 … … 156 155 void testCheckMustBeInDatasate() { 157 156 Node n = new Node(); 158 assertThrows(DataIntegrityProblemException.class, () -> n.getReferrers());157 assertThrows(DataIntegrityProblemException.class, n::getReferrers); 159 158 } 160 159 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTypeTest.java
r17275 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 5 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertSame; 6 8 import static org.junit.jupiter.api.Assertions.assertTrue; 7 9 import static org.junit.jupiter.api.Assertions.assertThrows; … … 51 53 @Test 52 54 void testGetOsmClass() { 53 assert Equals(Node.class, OsmPrimitiveType.NODE.getOsmClass());54 assert Equals(Way.class, OsmPrimitiveType.WAY.getOsmClass());55 assert Equals(Relation.class, OsmPrimitiveType.RELATION.getOsmClass());55 assertSame(Node.class, OsmPrimitiveType.NODE.getOsmClass()); 56 assertSame(Way.class, OsmPrimitiveType.WAY.getOsmClass()); 57 assertSame(Relation.class, OsmPrimitiveType.RELATION.getOsmClass()); 56 58 assertNull(OsmPrimitiveType.CLOSEDWAY.getOsmClass()); 57 59 assertNull(OsmPrimitiveType.MULTIPOLYGON.getOsmClass()); … … 63 65 @Test 64 66 void testGetDataClass() { 65 assert Equals(NodeData.class, OsmPrimitiveType.NODE.getDataClass());66 assert Equals(WayData.class, OsmPrimitiveType.WAY.getDataClass());67 assert Equals(RelationData.class, OsmPrimitiveType.RELATION.getDataClass());68 assert Equals(WayData.class, OsmPrimitiveType.CLOSEDWAY.getDataClass());69 assert Equals(RelationData.class, OsmPrimitiveType.MULTIPOLYGON.getDataClass());67 assertSame(NodeData.class, OsmPrimitiveType.NODE.getDataClass()); 68 assertSame(WayData.class, OsmPrimitiveType.WAY.getDataClass()); 69 assertSame(RelationData.class, OsmPrimitiveType.RELATION.getDataClass()); 70 assertSame(WayData.class, OsmPrimitiveType.CLOSEDWAY.getDataClass()); 71 assertSame(RelationData.class, OsmPrimitiveType.MULTIPOLYGON.getDataClass()); 70 72 } 71 73 … … 140 142 OsmPrimitive r = OsmPrimitiveType.RELATION.newInstance(3, false); 141 143 142 assert True(n instanceof Node);143 assert True(w instanceof Way);144 assert True(r instanceof Relation);144 assertInstanceOf(Node.class, n); 145 assertInstanceOf(Way.class, w); 146 assertInstanceOf(Relation.class, r); 145 147 146 148 assertEquals(1, n.getId()); … … 166 168 OsmPrimitive r = OsmPrimitiveType.RELATION.newVersionedInstance(3, 6); 167 169 168 assert True(n instanceof Node);169 assert True(w instanceof Way);170 assert True(r instanceof Relation);170 assertInstanceOf(Node.class, n); 171 assertInstanceOf(Way.class, w); 172 assertInstanceOf(Relation.class, r); 171 173 172 174 assertEquals(1, n.getId()); -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmUtilsTest.java
r17586 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertNull; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; … … 35 36 void testCreatePrimitive() { 36 37 final OsmPrimitive p = OsmUtils.createPrimitive("way name=Foo railway=rail"); 37 assert True(p instanceof Way);38 assertInstanceOf(Way.class, p); 38 39 assertEquals(2, p.getKeys().size()); 39 40 assertEquals("Foo", p.get("name")); -
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r17275 r18690 2 2 package org.openstreetmap.josm.data.osm; 3 3 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.assertTrue; 4 7 import static org.openstreetmap.josm.TestUtils.getPrivateField; 5 8 … … 11 14 import java.util.Arrays; 12 15 import java.util.Collection; 16 import java.util.Collections; 13 17 import java.util.Iterator; 14 18 import java.util.List; 15 19 import java.util.Random; 16 20 17 import org.junit.Assert;18 21 import org.junit.jupiter.api.extension.RegisterExtension; 19 22 import org.junit.jupiter.api.Test; … … 63 66 ds.removePrimitive(o); 64 67 } 65 Assert.assertTrue(nodes.isEmpty());66 Assert.assertTrue(ways.isEmpty());67 Assert.assertTrue(relations.isEmpty());68 assertTrue(nodes.isEmpty()); 69 assertTrue(ways.isEmpty()); 70 assertTrue(relations.isEmpty()); 68 71 } 69 72 70 73 private void checkIterator(Iterable<? extends OsmPrimitive> col, int expectedCount) { 71 74 int count = 0; 72 Iterator<? extends OsmPrimitive> it = col.iterator(); 73 while (it.hasNext()) { 75 for (OsmPrimitive ignored : col) { 74 76 count++; 75 it.next(); 76 } 77 Assert.assertEquals(expectedCount, count); 77 } 78 assertEquals(expectedCount, count); 78 79 } 79 80 … … 122 123 Node n2 = new Node(2); n2.setCoor(new LatLon(10, 20)); 123 124 Node n3 = new Node(3); n2.setCoor(new LatLon(20, 30)); 124 w2.setNodes( Arrays.asList(n1));125 w2.setNodes(Collections.singletonList(n1)); 125 126 w3.setNodes(Arrays.asList(n1, n2, n3)); 126 127 127 128 qbNodes.add(n1); 128 129 qbNodes.add(n2); 129 Assert.assertEquals(2, qbNodes.size());130 Assert.assertTrue(qbNodes.contains(n1));131 Assert.assertTrue(qbNodes.contains(n2));132 Assert.assertFalse(qbNodes.contains(n3));130 assertEquals(2, qbNodes.size()); 131 assertTrue(qbNodes.contains(n1)); 132 assertTrue(qbNodes.contains(n2)); 133 assertFalse(qbNodes.contains(n3)); 133 134 qbNodes.remove(n1); 134 Assert.assertEquals(1, qbNodes.size());135 Assert.assertFalse(qbNodes.contains(n1));136 Assert.assertTrue(qbNodes.contains(n2));135 assertEquals(1, qbNodes.size()); 136 assertFalse(qbNodes.contains(n1)); 137 assertTrue(qbNodes.contains(n2)); 137 138 qbNodes.remove(n2); 138 Assert.assertEquals(0, qbNodes.size());139 Assert.assertFalse(qbNodes.contains(n1));140 Assert.assertFalse(qbNodes.contains(n2));139 assertEquals(0, qbNodes.size()); 140 assertFalse(qbNodes.contains(n1)); 141 assertFalse(qbNodes.contains(n2)); 141 142 142 143 qbNodes.addAll(Arrays.asList(n1, n2, n3)); 143 144 qbNodes.removeAll(Arrays.asList(n1, n3)); 144 Assert.assertEquals(1, qbNodes.size());145 Assert.assertTrue(qbNodes.contains(n2));145 assertEquals(1, qbNodes.size()); 146 assertTrue(qbNodes.contains(n2)); 146 147 147 148 qbWays.add(w1); 148 149 qbWays.add(w2); 149 150 qbWays.add(w3); 150 Assert.assertEquals(3, qbWays.size());151 Assert.assertTrue(qbWays.contains(w1));152 Assert.assertTrue(qbWays.contains(w2));153 Assert.assertTrue(qbWays.contains(w3));151 assertEquals(3, qbWays.size()); 152 assertTrue(qbWays.contains(w1)); 153 assertTrue(qbWays.contains(w2)); 154 assertTrue(qbWays.contains(w3)); 154 155 qbWays.remove(w1); 155 Assert.assertEquals(2, qbWays.size());156 Assert.assertFalse(qbWays.contains(w1));157 Assert.assertTrue(qbWays.contains(w2));158 Assert.assertTrue(qbWays.contains(w3));156 assertEquals(2, qbWays.size()); 157 assertFalse(qbWays.contains(w1)); 158 assertTrue(qbWays.contains(w2)); 159 assertTrue(qbWays.contains(w3)); 159 160 qbWays.remove(w2); 160 Assert.assertEquals(1, qbWays.size());161 Assert.assertFalse(qbWays.contains(w1));162 Assert.assertFalse(qbWays.contains(w2));163 Assert.assertTrue(qbWays.contains(w3));161 assertEquals(1, qbWays.size()); 162 assertFalse(qbWays.contains(w1)); 163 assertFalse(qbWays.contains(w2)); 164 assertTrue(qbWays.contains(w3)); 164 165 qbWays.remove(w3); 165 Assert.assertEquals(0, qbWays.size());166 Assert.assertFalse(qbWays.contains(w1));167 Assert.assertFalse(qbWays.contains(w2));168 Assert.assertFalse(qbWays.contains(w3));166 assertEquals(0, qbWays.size()); 167 assertFalse(qbWays.contains(w1)); 168 assertFalse(qbWays.contains(w2)); 169 assertFalse(qbWays.contains(w3)); 169 170 170 171 qbWays.clear(); 171 Assert.assertEquals(0, qbWays.size());172 assertEquals(0, qbWays.size()); 172 173 List<Way> allWays = new ArrayList<>(Arrays.asList(w1, w2, w3)); 173 174 qbWays.addAll(allWays); 174 Assert.assertEquals(3, qbWays.size());175 assertEquals(3, qbWays.size()); 175 176 int count = 0; 176 177 for (Way w : qbWays) { 177 Assert.assertTrue(allWays.contains(w));178 assertTrue(allWays.contains(w)); 178 179 count++; 179 180 } 180 Assert.assertEquals(3, count);181 assertEquals(3, count); 181 182 // test remove with iterator 182 183 Iterator<Way> iter = qbWays.iterator(); … … 185 186 iter.remove(); 186 187 count--; 187 Assert.assertEquals(count, qbWays.size());188 } 189 Assert.assertEquals(0, qbWays.size());188 assertEquals(count, qbWays.size()); 189 } 190 assertEquals(0, qbWays.size()); 190 191 191 192 } … … 221 222 ds.addPrimitive(w); 222 223 } 223 Assert.assertEquals(NUM_COMPLETE_WAYS, ds.getWays().size());224 Assert.assertEquals(NUM_COMPLETE_WAYS * NUM_NODES_PER_WAY, ds.getNodes().size());224 assertEquals(NUM_COMPLETE_WAYS, ds.getWays().size()); 225 assertEquals(NUM_COMPLETE_WAYS * NUM_NODES_PER_WAY, ds.getNodes().size()); 225 226 226 227 // add some incomplete nodes … … 230 231 ds.addPrimitive(n); 231 232 } 232 Assert.assertEquals(NUM_COMPLETE_WAYS * NUM_NODES_PER_WAY + NUM_INCOMPLETE_NODES, ds.getNodes().size());233 assertEquals(NUM_COMPLETE_WAYS * NUM_NODES_PER_WAY + NUM_INCOMPLETE_NODES, ds.getNodes().size()); 233 234 // add some incomplete ways 234 235 List<Way> incompleteWays = new ArrayList<>(); … … 239 240 ds.addPrimitive(w); 240 241 } 241 Assert.assertEquals(NUM_COMPLETE_WAYS + NUM_INCOMPLETE_WAYS, ds.getWays().size());242 assertEquals(NUM_COMPLETE_WAYS + NUM_INCOMPLETE_WAYS, ds.getWays().size()); 242 243 243 244 BBox planet = new BBox(-180, -90, 180, 90); 244 245 // incomplete ways should not be found with search 245 Assert.assertEquals(NUM_COMPLETE_WAYS, ds.searchWays(planet).size());246 assertEquals(NUM_COMPLETE_WAYS, ds.searchWays(planet).size()); 246 247 // incomplete ways are only retrieved via iterator or object reference 247 248 for (Way w : incompleteWays) { 248 Assert.assertTrue(ds.getWays().contains(w));249 assertTrue(ds.getWays().contains(w)); 249 250 } 250 251 … … 252 253 qb.addAll(ds.getWays()); 253 254 int count = qb.size(); 254 Assert.assertEquals(count, ds.getWays().size());255 assertEquals(count, ds.getWays().size()); 255 256 Iterator<Way> iter = qb.iterator(); 256 257 while (iter.hasNext()) { … … 258 259 iter.remove(); 259 260 count--; 260 Assert.assertEquals(count, qb.size());261 } 262 Assert.assertEquals(0, qb.size());261 assertEquals(count, qb.size()); 262 } 263 assertEquals(0, qb.size()); 263 264 } 264 265 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java
r17275 r18690 7 7 import static org.junit.jupiter.api.Assertions.assertThrows; 8 8 9 import org.junit.Assert;10 9 import org.junit.jupiter.api.Test; 11 10 import org.junit.jupiter.api.extension.RegisterExtension; … … 62 61 BBox bbox = new BBox(w1); 63 62 bbox.add(n3.getBBox()); 64 Assert.assertEquals(bbox, r1.getBBox());65 Assert.assertEquals(bbox, r2.getBBox());63 assertEquals(bbox, r1.getBBox()); 64 assertEquals(bbox, r2.getBBox()); 66 65 67 66 n3.setCoor(new LatLon(40, 40)); 68 67 bbox.add(n3.getBBox()); 69 Assert.assertEquals(bbox, r1.getBBox());70 Assert.assertEquals(bbox, r2.getBBox());68 assertEquals(bbox, r1.getBBox()); 69 assertEquals(bbox, r2.getBBox()); 71 70 72 71 r1.removeMembersFor(r2); 73 Assert.assertEquals(w1.getBBox(), r1.getBBox());74 Assert.assertEquals(bbox, r2.getBBox());72 assertEquals(w1.getBBox(), r1.getBBox()); 73 assertEquals(bbox, r2.getBBox()); 75 74 76 75 w1.addNode(n3); 77 Assert.assertEquals(w1.getBBox(), r1.getBBox());78 Assert.assertEquals(w1.getBBox(), r2.getBBox());76 assertEquals(w1.getBBox(), r1.getBBox()); 77 assertEquals(w1.getBBox(), r2.getBBox()); 79 78 80 79 // create incomplete node and add it to the relation, this must not change the bbox … … 85 84 r2.addMember(new RelationMember("", n4)); 86 85 87 Assert.assertEquals(oldBBox, r2.getBBox());86 assertEquals(oldBBox, r2.getBBox()); 88 87 } 89 88 … … 99 98 r1.addMember(new RelationMember("", w1)); 100 99 101 Assert.assertEquals(new BBox(w1), r1.getBBox());100 assertEquals(new BBox(w1), r1.getBBox()); 102 101 103 102 DataSet ds = new DataSet(); … … 107 106 ds.addPrimitive(r1); 108 107 109 Assert.assertEquals(new BBox(w1), r1.getBBox());108 assertEquals(new BBox(w1), r1.getBBox()); 110 109 111 110 ds.removePrimitive(r1); 112 111 113 112 n1.setCoor(new LatLon(30, 40)); 114 Assert.assertEquals(new BBox(w1), r1.getBBox());113 assertEquals(new BBox(w1), r1.getBBox()); 115 114 116 115 ds.addPrimitive(r1); 117 Assert.assertEquals(new BBox(w1), r1.getBBox());116 assertEquals(new BBox(w1), r1.getBBox()); 118 117 } 119 118 120 119 /** 121 120 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/12467">Bug #12467</a>. 122 * @throws Exception if any error occurs123 121 */ 124 122 @Test 125 void testTicket12467() throws Exception{123 void testTicket12467() { 126 124 Relation r = new Relation(); 127 125 r.put("type", "boundary"); … … 146 144 @Test 147 145 void testCloneFromIAE() { 148 assertThrows(IllegalArgumentException.class, () -> new Relation().cloneFrom(new Node())); 146 final Relation relation = new Relation(); 147 final Node node = new Node(); 148 assertThrows(IllegalArgumentException.class, () -> relation.cloneFrom(node)); 149 149 } 150 150 … … 154 154 @Test 155 155 void testLoadIAE() { 156 assertThrows(IllegalArgumentException.class, () -> new Relation().load(new NodeData())); 156 final Relation relation = new Relation(); 157 final NodeData nodeData = new NodeData(); 158 assertThrows(IllegalArgumentException.class, () -> relation.load(nodeData)); 157 159 } 158 160 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/TagCollectionTest.java
r18037 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNull; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 … … 17 18 import java.util.stream.Stream; 18 19 20 import org.junit.jupiter.api.Test; 19 21 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 20 21 import org.junit.jupiter.api.Test;22 22 23 23 /** … … 84 84 @Test 85 85 void testUnionOfAllPrimitivesCollectionOfQextendsTagged() { 86 TagCollection c = TagCollection.unionOfAllPrimitives( Arrays.asList(tagA));86 TagCollection c = TagCollection.unionOfAllPrimitives(Collections.singletonList(tagA)); 87 87 assertEquals(1, c.getTagOccurrence(tagA)); 88 88 … … 93 93 assertTagCounts(e, 0, 0, 0, 0); 94 94 95 TagCollection f = TagCollection.unionOfAllPrimitives( Arrays.<Tagged>asList());95 TagCollection f = TagCollection.unionOfAllPrimitives(Collections.emptyList()); 96 96 assertTagCounts(f, 0, 0, 0, 0); 97 97 … … 193 193 TagCollection c = new TagCollection(); 194 194 assertTagCounts(c, 0, 0, 0, 0); 195 c.add( Arrays.asList(tagC));195 c.add(Collections.singletonList(tagC)); 196 196 assertTagCounts(c, 0, 0, 1, 0); 197 197 c.add(Arrays.asList(tagA, tagC)); … … 210 210 TagCollection c = new TagCollection(); 211 211 assertTagCounts(c, 0, 0, 0, 0); 212 c.add(new TagCollection( Arrays.asList(tagC)));212 c.add(new TagCollection(Collections.singletonList(tagC))); 213 213 assertTagCounts(c, 0, 0, 1, 0); 214 214 c.add(new TagCollection(Arrays.asList(tagA, tagC))); … … 308 308 assertTrue(c.containsAll(Arrays.asList(tagA, tagB))); 309 309 assertFalse(c.containsAll(Arrays.asList(tagA, tagC))); 310 assertTrue(c.containsAll( Arrays.asList()));310 assertTrue(c.containsAll(Collections.emptyList())); 311 311 assertFalse(c.containsAll(null)); 312 312 } … … 320 320 assertTrue(c.containsAllKeys(Arrays.asList("k", "k2"))); 321 321 assertFalse(c.containsAllKeys(Arrays.asList("k", "k3"))); 322 assertTrue(c.containsAllKeys( Arrays.asList()));322 assertTrue(c.containsAllKeys(Collections.emptyList())); 323 323 assertFalse(c.containsAllKeys(null)); 324 324 } … … 394 394 assertFalse(c.hasUniqueEmptyValue("k3")); 395 395 396 TagCollection d = new TagCollection( Arrays.asList());396 TagCollection d = new TagCollection(Collections.emptyList()); 397 397 assertFalse(d.hasUniqueEmptyValue("k")); 398 398 assertFalse(d.hasUniqueEmptyValue("k2")); … … 453 453 @Test 454 454 void testIterator() { 455 TagCollection d = new TagCollection( Arrays.asList(tagA));455 TagCollection d = new TagCollection(Collections.singletonList(tagA)); 456 456 Iterator<Tag> it = d.iterator(); 457 457 assertTrue(it.hasNext()); … … 556 556 assertEquals("b", tagged.get("k2")); 557 557 assertEquals("x", tagged.get("k3")); 558 TagCollection d = new TagCollection( Arrays.asList(tagEmpty));558 TagCollection d = new TagCollection(Collections.singletonList(tagEmpty)); 559 559 d.applyTo(tagged); 560 assert Equals(null,tagged.get("k"));560 assertNull(tagged.get("k")); 561 561 } 562 562 … … 591 591 assertEquals("v", tagged.get("k")); 592 592 assertEquals("b", tagged.get("k2")); 593 assert Equals(null,tagged.get("k3"));593 assertNull(tagged.get("k3")); 594 594 } 595 595 … … 609 609 assertEquals("v", tagged2.get("k")); 610 610 assertEquals("b", tagged2.get("k2")); 611 assert Equals(null,tagged2.get("k3"));611 assertNull(tagged2.get("k3")); 612 612 } 613 613 … … 671 671 @Test 672 672 void testGetJoinedValues() { 673 TagCollection c = new TagCollection( Arrays.asList(new Tag("k", "a")));673 TagCollection c = new TagCollection(Collections.singletonList(new Tag("k", "a"))); 674 674 assertEquals("a", c.getJoinedValues("k")); 675 675 TagCollection d = new TagCollection(Arrays.asList(new Tag("k", "a"), new Tag("k", "b"))); -
trunk/test/unit/org/openstreetmap/josm/data/osm/WayDataTest.java
r17275 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.osm; 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 3 5 4 6 import java.io.ByteArrayInputStream; … … 8 10 import java.util.Arrays; 9 11 10 import org.junit.Assert;11 12 import org.junit.jupiter.api.Test; 12 13 … … 31 32 } 32 33 } 33 Assert.assertEquals(data.toString(), readData.toString());34 assertEquals(data.toString(), readData.toString()); 34 35 } 35 36 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/WaySegmentTest.java
r17896 r18690 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertThrows; 6 4 7 import java.util.Arrays; 5 8 6 import org.junit.Assert;7 9 import org.junit.jupiter.api.extension.RegisterExtension; 8 10 import org.junit.jupiter.api.Test; … … 25 27 26 28 @Test 27 void testForNodePair() throws Exception{29 void testForNodePair() { 28 30 final DataSet ds = new DataSet(); 29 31 final Node n1 = new Node(LatLon.ZERO); … … 42 44 w.addNode(n4); 43 45 w.addNode(n1); 44 Assert.assertEquals(WaySegment.forNodePair(w, n1, n2).getLowerIndex(), 0); 45 Assert.assertEquals(WaySegment.forNodePair(w, n1, n3).getLowerIndex(), 2); 46 Assert.assertEquals(WaySegment.forNodePair(w, n1, n4).getLowerIndex(), 4); 47 Assert.assertEquals(WaySegment.forNodePair(w, n4, n1).getLowerIndex(), 5); 48 try { 49 Assert.assertEquals(WaySegment.forNodePair(w, n3, n4).getLowerIndex(), 5); 50 throw new IllegalStateException("Expecting IllegalArgumentException"); 51 } catch (IllegalArgumentException expected) { 52 System.out.println("Expected exception: " + expected.getMessage()); 53 } 46 assertEquals(WaySegment.forNodePair(w, n1, n2).getLowerIndex(), 0); 47 assertEquals(WaySegment.forNodePair(w, n1, n3).getLowerIndex(), 2); 48 assertEquals(WaySegment.forNodePair(w, n1, n4).getLowerIndex(), 4); 49 assertEquals(WaySegment.forNodePair(w, n4, n1).getLowerIndex(), 5); 50 IllegalArgumentException iae = assertThrows(IllegalArgumentException.class, () -> WaySegment.forNodePair(w, n3, n4)); 51 assertEquals("Node pair is not part of way!", iae.getMessage()); 54 52 } 55 53 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryWayTest.java
r17838 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertThrows; 5 6 import static org.junit.jupiter.api.Assertions.assertTrue; 6 import static org.junit.jupiter.api.Assertions.fail;7 7 8 8 import java.time.Instant; … … 11 11 import java.util.Map; 12 12 13 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 14 import org.junit.jupiter.api.Test; 13 15 import org.junit.jupiter.api.extension.RegisterExtension; 14 import org.junit.jupiter.api.Test;15 16 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 16 17 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 17 18 import org.openstreetmap.josm.data.osm.User; 18 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 19 import org.openstreetmap.josm.tools.Logging;20 21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;22 20 23 21 /** … … 78 76 assertEquals(1, way.getNumNodes()); 79 77 assertEquals(1, way.getNodeId(0)); 80 try { 81 way.getNodeId(1); 82 fail("expected expection of type " + IndexOutOfBoundsException.class.toString()); 83 } catch (IndexOutOfBoundsException e) { 84 // OK 85 Logging.trace(e); 86 } 78 assertThrows(IndexOutOfBoundsException.class, () -> way.getNodeId(1)); 87 79 88 80 way.addNode(5); -
trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java
r18496 r18690 19 19 import java.util.Set; 20 20 21 import org.junit.Assert;22 21 import org.junit.jupiter.api.Test; 23 22 import org.junit.jupiter.api.Timeout; … … 430 429 /** 431 430 * Compiles "foo type bar" and tests the parse error message 432 * @throws SearchParseError always 433 */ 434 @Test 435 void testFooTypeBar() throws SearchParseError { 431 */ 432 @Test 433 void testFooTypeBar() { 436 434 Exception e = assertThrows(SearchParseError.class, () -> SearchCompiler.compile("foo type bar")); 437 435 assertEquals("<html>Expecting <code>:</code> after <i>type</i></html>", e.getMessage()); … … 754 752 TestUtils.assumeWorkingEqualsVerifier(); 755 753 Set<Class<? extends Match>> matchers = TestUtils.getJosmSubtypes(Match.class); 756 Assert.assertTrue(matchers.size() >= 10); // if it finds less than 10 classes, something is broken754 assertTrue(matchers.size() >= 10); // if it finds less than 10 classes, something is broken 757 755 for (Class<?> c : matchers) { 758 756 Logging.debug(c.toString()); -
trunk/test/unit/org/openstreetmap/josm/data/preferences/StrokePropertyTest.java
r18037 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertArrayEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertNull; 6 7 7 8 import java.awt.BasicStroke; 8 9 10 import org.junit.jupiter.api.Test; 9 11 import org.openstreetmap.josm.spi.preferences.Config; 10 12 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 11 12 import org.junit.jupiter.api.Test;13 13 14 14 /** … … 30 30 assertWide(bs); 31 31 assertEquals(11, bs.getLineWidth(), 1e-10); 32 assert Equals(null,bs.getDashArray());32 assertNull(bs.getDashArray()); 33 33 34 34 Config.getPref().put("x", ".5"); … … 36 36 assertThin(bs); 37 37 assertEquals(.5, bs.getLineWidth(), 1e-10); 38 assert Equals(null,bs.getDashArray());38 assertNull(bs.getDashArray()); 39 39 40 40 Config.getPref().put("x", "2 1"); … … 54 54 assertThin(bs); 55 55 assertEquals(1, bs.getLineWidth(), 1e-10); 56 assert Equals(null,bs.getDashArray());56 assertNull(bs.getDashArray()); 57 57 58 58 // ignore dashes … … 61 61 assertWide(bs); 62 62 assertEquals(11, bs.getLineWidth(), 1e-10); 63 assert Equals(null,bs.getDashArray());63 assertNull(bs.getDashArray()); 64 64 } 65 65 … … 74 74 assertWide(bs); 75 75 assertEquals(12, bs.getLineWidth(), 1e-10); 76 assert Equals(null,bs.getDashArray());76 assertNull(bs.getDashArray()); 77 77 78 78 property.put(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, new float[] {0.1f, 1, 10}, 0)); -
trunk/test/unit/org/openstreetmap/josm/data/projection/EllipsoidTest.java
r18144 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.projection; 3 4 import static org.junit.jupiter.api.Assertions.fail; 3 5 4 6 import java.security.SecureRandom; 5 7 import java.util.Random; 6 8 7 import org.junit.Assert;8 9 import org.junit.jupiter.api.Test; 9 10 import org.openstreetmap.josm.data.coor.LatLon; … … 37 38 String error = String.format("point: %s iterations: %s current: %s errorLat: %s errorLon %s", 38 39 new LatLon(lat, lon), i, ll, Math.abs(lat - ll.lat()), Math.abs(lon - ll.lon())); 39 System.err.println(error); 40 Assert.fail(); 40 fail(error); 41 41 } 42 42 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java
r18027 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.projection; 3 4 import static org.junit.jupiter.api.Assertions.fail; 3 5 4 6 import java.io.BufferedReader; … … 34 36 import java.util.regex.Pattern; 35 37 36 import org.junit.Assert;37 38 import org.junit.jupiter.api.Test; 38 39 import org.junit.jupiter.api.extension.RegisterExtension; … … 133 134 Matcher m = projPattern.matcher(line); 134 135 if (!m.matches()) { 135 Assert.fail("unable to parse line: " + line);136 fail("unable to parse line: " + line); 136 137 } 137 138 String code = m.group(1); … … 383 384 refs.stream().map(ref -> ref.code).forEach(allCodes::remove); 384 385 if (!allCodes.isEmpty()) { 385 Assert.fail("no reference data for following projections: "+allCodes);386 fail("no reference data for following projections: "+allCodes); 386 387 } 387 388 … … 389 390 String def0 = Projections.getInit(ref.code); 390 391 if (def0 == null) { 391 Assert.fail("unknown code: "+ref.code);392 fail("unknown code: "+ref.code); 392 393 } 393 394 if (!ref.def.equals(def0)) { … … 411 412 " expected: eastnorth(%s,%s),%n" + 412 413 " but got: eastnorth(%s,%s)!%n", 413 proj .toString(), proj.toCode(), ll.lat(), ll.lon(), enRef.east(), enRef.north(), en.east(), en.north());414 proj, proj.toCode(), ll.lat(), ll.lon(), enRef.east(), enRef.north(), en.east(), en.north()); 414 415 failures.add(errorEN); 415 416 failingProjs.computeIfAbsent(proj.proj.getProj4Id(), x -> new TreeSet<>()).add(ref.code); … … 419 420 }); 420 421 if (!failures.isEmpty()) { 421 System.err.println(failures .toString());422 System.err.println(failures); 422 423 throw new AssertionError("Failing:\n" + 423 424 failingProjs.keySet().size() + " projections: " + failingProjs.keySet() + "\n" + -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r18100 r18690 161 161 for (String code : Projections.getAllProjectionCodes()) { 162 162 if (!dataCodes.contains(code)) { 163 fail.append("Did not find projection " +code+" in test data!\n");163 fail.append("Did not find projection ").append(code).append(" in test data!\n"); 164 164 } 165 165 } … … 169 169 Projection proj = Projections.getProjectionByCode(data.code); 170 170 if (proj == null) { 171 fail.append("Projection " +data.code+" from test data was not found!\n");171 fail.append("Projection ").append(data.code).append(" from test data was not found!\n"); 172 172 continue; 173 173 } … … 178 178 " expected: eastnorth(%s,%s),%n" + 179 179 " but got: eastnorth(%s,%s)!%n", 180 proj .toString(), data.code, data.ll.lat(), data.ll.lon(), data.en.east(), data.en.north(), en.east(), en.north());180 proj, data.code, data.ll.lat(), data.ll.lon(), data.en.east(), data.en.north(), en.east(), en.north()); 181 181 fail.append(error); 182 182 } … … 185 185 " expected: latlon(%s,%s),%n" + 186 186 " but got: latlon(%s,%s)!%n", 187 proj .toString(), data.code, data.en.east(), data.en.north(), data.ll2.lat(), data.ll2.lon(), ll2.lat(), ll2.lon());187 proj, data.code, data.en.east(), data.en.north(), data.ll2.lat(), data.ll2.lon(), ll2.lat(), ll2.lon()); 188 188 fail.append(error); 189 189 } … … 191 191 192 192 if (fail.length() > 0) { 193 System.err.println(fail .toString());193 System.err.println(fail); 194 194 throw new AssertionError(fail.toString()); 195 195 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java
r18494 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertTrue; 5 import static org.junit.jupiter.api.Assertions.fail; 5 6 6 7 import java.security.SecureRandom; … … 10 11 import java.util.Random; 11 12 12 import org.junit.Assert;13 13 import org.junit.jupiter.api.Test; 14 14 import org.openstreetmap.josm.data.Bounds; … … 40 40 41 41 for (int i = 0; i <= 3; ++i) { 42 testProjection(Projections.getProjectionByCode("EPSG:"+ Integer.toString(27561+i))); // Lambert 4 Zones France42 testProjection(Projections.getProjectionByCode("EPSG:"+ (27561 + i))); // Lambert 4 Zones France 43 43 } 44 44 45 45 for (int i = 0; i <= 4; ++i) { 46 testProjection(Projections.getProjectionByCode("EPSG:"+ Integer.toString(2176+i))); // PUWG Poland46 testProjection(Projections.getProjectionByCode("EPSG:"+ (2176 + i))); // PUWG Poland 47 47 } 48 48 … … 50 50 51 51 for (int i = 0; i <= 60; ++i) { 52 testProjection(Projections.getProjectionByCode("EPSG:"+ Integer.toString(32601+i))); // UTM North53 testProjection(Projections.getProjectionByCode("EPSG:"+ Integer.toString(32701+i))); // UTM South52 testProjection(Projections.getProjectionByCode("EPSG:"+ (32601 + i))); // UTM North 53 testProjection(Projections.getProjectionByCode("EPSG:"+ (32701 + i))); // UTM South 54 54 } 55 55 … … 59 59 60 60 for (int i = 0; i <= 8; ++i) { 61 testProjection(Projections.getProjectionByCode("EPSG:"+ Integer.toString(3942+i))); // Lambert CC9 Zones France61 testProjection(Projections.getProjectionByCode("EPSG:"+ (3942 + i))); // Lambert CC9 Zones France 62 62 } 63 63 64 64 for (int i = 0; i <= 17; ++i) { 65 testProjection(Projections.getProjectionByCode("EPSG:"+ Integer.toString(102421+i))); // WGS_1984_ARC_System Zones65 testProjection(Projections.getProjectionByCode("EPSG:"+ (102421 + i))); // WGS_1984_ARC_System Zones 66 66 } 67 67 … … 70 70 71 71 if (error) { 72 System.err.println(text); 73 Assert.fail(); 72 fail(text); 74 73 } 75 74 } … … 80 79 Bounds b = p.getWorldBoundsLatLon(); 81 80 82 text += String.format("*** %s %s%n", p .toString(), p.toCode());81 text += String.format("*** %s %s%n", p, p.toCode()); 83 82 for (int num = 0; num < 1000; ++num) { 84 83 … … 148 147 149 148 if (error2) { 150 System.err.println(text2); 151 Assert.fail(); 149 fail(text2); 152 150 } 153 151 assertTrue(projIds.isEmpty(), "missing test: "+projIds); -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionsTest.java
r18030 r18690 2 2 package org.openstreetmap.josm.data.projection; 3 3 4 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertNull; 5 5 6 6 import org.junit.jupiter.api.Test; -
trunk/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTest.java
r17275 r18690 17 17 package org.openstreetmap.josm.data.validation.routines; 18 18 19 import static org.junit.Assert.assertEquals; 20 import static org.junit.Assert.assertFalse; 21 import static org.junit.Assert.assertNotNull; 22 import static org.junit.Assert.assertNull; 23 import static org.junit.Assert.assertTrue; 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.assertNotNull; 22 import static org.junit.jupiter.api.Assertions.assertNull; 23 import static org.junit.jupiter.api.Assertions.assertSame; 24 import static org.junit.jupiter.api.Assertions.assertThrows; 25 import static org.junit.jupiter.api.Assertions.assertTrue; 24 26 import static org.junit.jupiter.api.Assertions.fail; 25 27 … … 30 32 import org.junit.jupiter.api.BeforeEach; 31 33 import org.junit.jupiter.api.Test; 34 import org.junit.jupiter.params.ParameterizedTest; 35 import org.junit.jupiter.params.provider.EnumSource; 36 import org.junit.jupiter.params.provider.ValueSource; 32 37 import org.openstreetmap.josm.data.validation.routines.DomainValidator.ArrayType; 33 38 import org.openstreetmap.josm.tools.Logging; … … 56 61 @Test 57 62 void testValidDomains() { 58 assertTrue( "apache.org should validate", validator.isValid("apache.org"));59 assertTrue( "www.google.com should validate", validator.isValid("www.google.com"));60 61 assertTrue( "test-domain.com should validate", validator.isValid("test-domain.com"));62 assertTrue( "test---domain.com should validate", validator.isValid("test---domain.com"));63 assertTrue( "test-d-o-m-ain.com should validate", validator.isValid("test-d-o-m-ain.com"));64 assertTrue( "two-letter domain label should validate", validator.isValid("as.uk"));65 66 assertTrue( "case-insensitive ApAchE.Org should validate", validator.isValid("ApAchE.Org"));67 68 assertTrue( "single-character domain label should validate", validator.isValid("z.com"));69 70 assertTrue( "i.have.an-example.domain.name should validate", validator.isValid("i.have.an-example.domain.name"));63 assertTrue(validator.isValid("apache.org"), "apache.org should validate"); 64 assertTrue(validator.isValid("www.google.com"), "www.google.com should validate"); 65 66 assertTrue(validator.isValid("test-domain.com"), "test-domain.com should validate"); 67 assertTrue(validator.isValid("test---domain.com"), "test---domain.com should validate"); 68 assertTrue(validator.isValid("test-d-o-m-ain.com"), "test-d-o-m-ain.com should validate"); 69 assertTrue(validator.isValid("as.uk"), "two-letter domain label should validate"); 70 71 assertTrue(validator.isValid("ApAchE.Org"), "case-insensitive ApAchE.Org should validate"); 72 73 assertTrue(validator.isValid("z.com"), "single-character domain label should validate"); 74 75 assertTrue(validator.isValid("i.have.an-example.domain.name"), "i.have.an-example.domain.name should validate"); 71 76 } 72 77 … … 76 81 @Test 77 82 void testInvalidDomains() { 78 assertFalse( "bare TLD .org shouldn't validate", validator.isValid(".org"));79 assertFalse( "domain name with spaces shouldn't validate", validator.isValid(" apache.org "));80 assertFalse( "domain name containing spaces shouldn't validate", validator.isValid("apa che.org"));81 assertFalse( "domain name starting with dash shouldn't validate", validator.isValid("-testdomain.name"));82 assertFalse( "domain name ending with dash shouldn't validate", validator.isValid("testdomain-.name"));83 assertFalse( "domain name starting with multiple dashes shouldn't validate", validator.isValid("---c.com"));84 assertFalse( "domain name ending with multiple dashes shouldn't validate", validator.isValid("c--.com"));85 assertFalse( "domain name with invalid TLD shouldn't validate", validator.isValid("apache.rog"));86 87 assertFalse( "URL shouldn't validate", validator.isValid("http://www.apache.org"));88 assertFalse( "Empty string shouldn't validate as domain name", validator.isValid(" "));89 assertFalse( "Null shouldn't validate as domain name", validator.isValid(null));83 assertFalse(validator.isValid(".org"), "bare TLD .org shouldn't validate"); 84 assertFalse(validator.isValid(" apache.org "), "domain name with spaces shouldn't validate"); 85 assertFalse(validator.isValid("apa che.org"), "domain name containing spaces shouldn't validate"); 86 assertFalse(validator.isValid("-testdomain.name"), "domain name starting with dash shouldn't validate"); 87 assertFalse(validator.isValid("testdomain-.name"), "domain name ending with dash shouldn't validate"); 88 assertFalse(validator.isValid("---c.com"), "domain name starting with multiple dashes shouldn't validate"); 89 assertFalse(validator.isValid("c--.com"), "domain name ending with multiple dashes shouldn't validate"); 90 assertFalse(validator.isValid("apache.rog"), "domain name with invalid TLD shouldn't validate"); 91 92 assertFalse(validator.isValid("http://www.apache.org"), "URL shouldn't validate"); 93 assertFalse(validator.isValid(" "), "Empty string shouldn't validate as domain name"); 94 assertFalse(validator.isValid(null), "Null shouldn't validate as domain name"); 90 95 } 91 96 … … 96 101 void testTopLevelDomains() { 97 102 // infrastructure TLDs 98 assertTrue( ".arpa should validate as iTLD", validator.isValidInfrastructureTld(".arpa"));99 assertFalse( ".com shouldn't validate as iTLD", validator.isValidInfrastructureTld(".com"));103 assertTrue(validator.isValidInfrastructureTld(".arpa"), ".arpa should validate as iTLD"); 104 assertFalse(validator.isValidInfrastructureTld(".com"), ".com shouldn't validate as iTLD"); 100 105 101 106 // generic TLDs 102 assertTrue( ".name should validate as gTLD", validator.isValidGenericTld(".name"));103 assertFalse( ".us shouldn't validate as gTLD", validator.isValidGenericTld(".us"));107 assertTrue(validator.isValidGenericTld(".name"), ".name should validate as gTLD"); 108 assertFalse(validator.isValidGenericTld(".us"), ".us shouldn't validate as gTLD"); 104 109 105 110 // country code TLDs 106 assertTrue( ".uk should validate as ccTLD", validator.isValidCountryCodeTld(".uk"));107 assertFalse( ".org shouldn't validate as ccTLD", validator.isValidCountryCodeTld(".org"));111 assertTrue(validator.isValidCountryCodeTld(".uk"), ".uk should validate as ccTLD"); 112 assertFalse(validator.isValidCountryCodeTld(".org"), ".org shouldn't validate as ccTLD"); 108 113 109 114 // case-insensitive 110 assertTrue( ".COM should validate as TLD", validator.isValidTld(".COM"));111 assertTrue( ".BiZ should validate as TLD", validator.isValidTld(".BiZ"));115 assertTrue(validator.isValidTld(".COM"), ".COM should validate as TLD"); 116 assertTrue(validator.isValidTld(".BiZ"), ".BiZ should validate as TLD"); 112 117 113 118 // corner cases 114 assertFalse( "invalid TLD shouldn't validate", validator.isValid(".nope")); // TODO this is not guaranteed invalid forever115 assertFalse( "empty string shouldn't validate as TLD", validator.isValid(""));116 assertFalse( "null shouldn't validate as TLD", validator.isValid(null));119 assertFalse(validator.isValid(".nope"), "invalid TLD shouldn't validate"); // TODO this is not guaranteed invalid forever 120 assertFalse(validator.isValid(""), "empty string shouldn't validate as TLD"); 121 assertFalse(validator.isValid(null), "null shouldn't validate as TLD"); 117 122 } 118 123 … … 125 130 DomainValidator allowLocal = DomainValidator.getInstance(true); 126 131 127 // Default is false, and should use singletons128 assert Equals(noLocal, validator);132 // Should use singletons 133 assertSame(noLocal, validator); 129 134 130 135 // Default won't allow local 131 assertFalse( "localhost.localdomain should validate", noLocal.isValid("localhost.localdomain"));132 assertFalse( "localhost should validate", noLocal.isValid("localhost"));136 assertFalse(noLocal.isValid("localhost.localdomain"), "localhost.localdomain should validate"); 137 assertFalse(noLocal.isValid("localhost"), "localhost should validate"); 133 138 134 139 // But it may be requested 135 assertTrue( "localhost.localdomain should validate", allowLocal.isValid("localhost.localdomain"));136 assertTrue( "localhost should validate", allowLocal.isValid("localhost"));137 assertTrue( "hostname should validate", allowLocal.isValid("hostname"));138 assertTrue( "machinename should validate", allowLocal.isValid("machinename"));140 assertTrue(allowLocal.isValid("localhost.localdomain"), "localhost.localdomain should validate"); 141 assertTrue(allowLocal.isValid("localhost"), "localhost should validate"); 142 assertTrue(allowLocal.isValid("hostname"), "hostname should validate"); 143 assertTrue(allowLocal.isValid("machinename"), "machinename should validate"); 139 144 140 145 // Check the localhost one with a few others 141 assertTrue( "apache.org should validate", allowLocal.isValid("apache.org"));142 assertFalse( "domain name with spaces shouldn't validate", allowLocal.isValid(" apache.org "));146 assertTrue(allowLocal.isValid("apache.org"), "apache.org should validate"); 147 assertFalse(allowLocal.isValid(" apache.org "), "domain name with spaces shouldn't validate"); 143 148 } 144 149 … … 148 153 @Test 149 154 void testIDN() { 150 assertTrue("b\u00fccher.ch in IDN should validate", validator.isValid("www.xn--bcher-kva.ch")); 151 } 152 153 /** 154 * Test IDN with Java >= 6. 155 */ 156 @Test 157 void testIDNJava6OrLater() { 158 String version = System.getProperty("java.version"); 159 if (version.compareTo("1.6") < 0) { 160 System.out.println("Cannot run Unicode IDN tests"); 161 return; // Cannot run the test 162 } // xn--d1abbgf6aiiy.xn--p1ai http://президент.рф 163 assertTrue("b\u00fccher.ch should validate", validator.isValid("www.b\u00fccher.ch")); 164 assertTrue("xn--d1abbgf6aiiy.xn--p1ai should validate", validator.isValid("xn--d1abbgf6aiiy.xn--p1ai")); 165 assertTrue("президент.рф should validate", validator.isValid("президент.рф")); 166 assertFalse("www.\uFFFD.ch FFFD should fail", validator.isValid("www.\uFFFD.ch")); 155 assertTrue(validator.isValid("www.xn--bcher-kva.ch"), "b\u00fccher.ch in IDN should validate"); 156 assertTrue(validator.isValid("www.b\u00fccher.ch"), "b\u00fccher.ch should validate"); 157 // xn--d1abbgf6aiiy.xn--p1ai http://президент.рф 158 assertTrue(validator.isValid("xn--d1abbgf6aiiy.xn--p1ai"), "xn--d1abbgf6aiiy.xn--p1ai should validate"); 159 assertTrue(validator.isValid("президент.рф"), "президент.рф should validate"); 160 assertFalse(validator.isValid("www.\uFFFD.ch"), "www.\uFFFD.ch FFFD should fail"); 167 161 } 168 162 … … 172 166 @Test 173 167 void testRFC2396domainlabel() { // use fixed valid TLD 174 assertTrue( "a.ch should validate", validator.isValid("a.ch"));175 assertTrue( "9.ch should validate", validator.isValid("9.ch"));176 assertTrue( "az.ch should validate", validator.isValid("az.ch"));177 assertTrue( "09.ch should validate", validator.isValid("09.ch"));178 assertTrue( "9-1.ch should validate", validator.isValid("9-1.ch"));179 assertFalse( "91-.ch should not validate", validator.isValid("91-.ch"));180 assertFalse( "-.ch should not validate", validator.isValid("-.ch"));168 assertTrue(validator.isValid("a.ch"), "a.ch should validate"); 169 assertTrue(validator.isValid("9.ch"), "9.ch should validate"); 170 assertTrue(validator.isValid("az.ch"), "az.ch should validate"); 171 assertTrue(validator.isValid("09.ch"), "09.ch should validate"); 172 assertTrue(validator.isValid("9-1.ch"), "9-1.ch should validate"); 173 assertFalse(validator.isValid("91-.ch"), "91-.ch should not validate"); 174 assertFalse(validator.isValid("-.ch"), "-.ch should not validate"); 181 175 } 182 176 … … 187 181 void testRFC2396toplabel() { 188 182 // These tests use non-existent TLDs so currently need to use a package protected method 189 assertTrue( "a.c (alpha) should validate", validator.isValidDomainSyntax("a.c"));190 assertTrue( "a.cc (alpha alpha) should validate", validator.isValidDomainSyntax("a.cc"));191 assertTrue( "a.c9 (alpha alphanum) should validate", validator.isValidDomainSyntax("a.c9"));192 assertTrue( "a.c-9 (alpha - alphanum) should validate", validator.isValidDomainSyntax("a.c-9"));193 assertTrue( "a.c-z (alpha - alpha) should validate", validator.isValidDomainSyntax("a.c-z"));194 195 assertFalse( "a.9c (alphanum alpha) should fail", validator.isValidDomainSyntax("a.9c"));196 assertFalse( "a.c- (alpha -) should fail", validator.isValidDomainSyntax("a.c-"));197 assertFalse( "a.- (-) should fail", validator.isValidDomainSyntax("a.-"));198 assertFalse( "a.-9 (- alphanum) should fail", validator.isValidDomainSyntax("a.-9"));183 assertTrue(validator.isValidDomainSyntax("a.c"), "a.c (alpha) should validate"); 184 assertTrue(validator.isValidDomainSyntax("a.cc"), "a.cc (alpha alpha) should validate"); 185 assertTrue(validator.isValidDomainSyntax("a.c9"), "a.c9 (alpha alphanum) should validate"); 186 assertTrue(validator.isValidDomainSyntax("a.c-9"), "a.c-9 (alpha - alphanum) should validate"); 187 assertTrue(validator.isValidDomainSyntax("a.c-z"), "a.c-z (alpha - alpha) should validate"); 188 189 assertFalse(validator.isValidDomainSyntax("a.9c"), "a.9c (alphanum alpha) should fail"); 190 assertFalse(validator.isValidDomainSyntax("a.c-"), "a.c- (alpha -) should fail"); 191 assertFalse(validator.isValidDomainSyntax("a.-"), "a.- (-) should fail"); 192 assertFalse(validator.isValidDomainSyntax("a.-9"), "a.-9 (- alphanum) should fail"); 199 193 } 200 194 … … 204 198 @Test 205 199 void testDomainNoDots() { 206 assertTrue( "a (alpha) should validate", validator.isValidDomainSyntax("a"));207 assertTrue( "9 (alphanum) should validate", validator.isValidDomainSyntax("9"));208 assertTrue( "c-z (alpha - alpha) should validate", validator.isValidDomainSyntax("c-z"));209 210 assertFalse( "c- (alpha -) should fail", validator.isValidDomainSyntax("c-"));211 assertFalse( "-c (- alpha) should fail", validator.isValidDomainSyntax("-c"));212 assertFalse( "- (-) should fail", validator.isValidDomainSyntax("-"));200 assertTrue(validator.isValidDomainSyntax("a"), "a (alpha) should validate"); 201 assertTrue(validator.isValidDomainSyntax("9"), "9 (alphanum) should validate"); 202 assertTrue(validator.isValidDomainSyntax("c-z"), "c-z (alpha - alpha) should validate"); 203 204 assertFalse(validator.isValidDomainSyntax("c-"), "c- (alpha -) should fail"); 205 assertFalse(validator.isValidDomainSyntax("-c"), "-c (- alpha) should fail"); 206 assertFalse(validator.isValidDomainSyntax("-"), "- (-) should fail"); 213 207 } 214 208 … … 218 212 @Test 219 213 void testValidator297() { 220 assertTrue( "xn--d1abbgf6aiiy.xn--p1ai should validate", validator.isValid("xn--d1abbgf6aiiy.xn--p1ai")); // This uses a valid TLD214 assertTrue(validator.isValid("xn--d1abbgf6aiiy.xn--p1ai"), "xn--d1abbgf6aiiy.xn--p1ai should validate"); // This uses a valid TLD 221 215 } 222 216 … … 230 224 assertEquals(63, longString.length()); // 26 * 2 + 11 231 225 232 assertTrue( "63 chars label should validate", validator.isValidDomainSyntax(longString+".com"));233 assertFalse( "64 chars label should fail", validator.isValidDomainSyntax(longString+"x.com"));234 235 assertTrue( "63 chars TLD should validate", validator.isValidDomainSyntax("test."+longString));236 assertFalse( "64 chars TLD should fail", validator.isValidDomainSyntax("test.x"+longString));226 assertTrue(validator.isValidDomainSyntax(longString+".com"), "63 chars label should validate"); 227 assertFalse(validator.isValidDomainSyntax(longString+"x.com"), "64 chars label should fail"); 228 229 assertTrue(validator.isValidDomainSyntax("test."+longString), "63 chars TLD should validate"); 230 assertFalse(validator.isValidDomainSyntax("test.x"+longString), "64 chars TLD should fail"); 237 231 238 232 final String longDomain = … … 242 236 + "." + longString.substring(0, 61); 243 237 assertEquals(253, longDomain.length()); 244 assertTrue( "253 chars domain should validate", validator.isValidDomainSyntax(longDomain));245 assertFalse( "254 chars domain should fail", validator.isValidDomainSyntax(longDomain+"x"));238 assertTrue(validator.isValidDomainSyntax(longDomain), "253 chars domain should validate"); 239 assertFalse(validator.isValidDomainSyntax(longDomain+"x"), "254 chars domain should fail"); 246 240 } 247 241 … … 288 282 * @throws Exception if an error occurs 289 283 */ 290 @Test 291 void test_INFRASTRUCTURE_TLDS_sortedAndLowerCase() throws Exception { 292 final boolean sorted = isSortedLowerCase("INFRASTRUCTURE_TLDS"); 293 assertTrue(sorted); 294 } 295 296 /** 297 * Check array is sorted and is lower-case 298 * @throws Exception if an error occurs 299 */ 300 @Test 301 void test_COUNTRY_CODE_TLDS_sortedAndLowerCase() throws Exception { 302 final boolean sorted = isSortedLowerCase("COUNTRY_CODE_TLDS"); 303 assertTrue(sorted); 304 } 305 306 /** 307 * Check array is sorted and is lower-case 308 * @throws Exception if an error occurs 309 */ 310 @Test 311 void test_GENERIC_TLDS_sortedAndLowerCase() throws Exception { 312 final boolean sorted = isSortedLowerCase("GENERIC_TLDS"); 313 assertTrue(sorted); 314 } 315 316 /** 317 * Check array is sorted and is lower-case 318 * @throws Exception if an error occurs 319 */ 320 @Test 321 void test_LOCAL_TLDS_sortedAndLowerCase() throws Exception { 322 final boolean sorted = isSortedLowerCase("LOCAL_TLDS"); 284 @ParameterizedTest 285 @ValueSource(strings = {"COUNTRY_CODE_TLDS", "GENERIC_TLDS", "INFRASTRUCTURE_TLDS", "LOCAL_TLDS"}) 286 void testArraySortedAndLowerCase(String arrayName) throws Exception { 287 final boolean sorted = isSortedLowerCase(arrayName); 323 288 assertTrue(sorted); 324 289 } … … 335 300 * Test update base arrays 336 301 */ 337 @Test 338 void testUpdateBaseArrays() { 339 try { 340 DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_RO, new String[]{"com"}); 341 fail("Expected IllegalArgumentException"); 342 } catch (IllegalArgumentException iae) { 343 // expected 344 Logging.debug(iae.getMessage()); 345 } 346 try { 347 DomainValidator.updateTLDOverride(ArrayType.GENERIC_RO, new String[]{"com"}); 348 fail("Expected IllegalArgumentException"); 349 } catch (IllegalArgumentException iae) { 350 // expected 351 Logging.debug(iae.getMessage()); 352 } 353 try { 354 DomainValidator.updateTLDOverride(ArrayType.INFRASTRUCTURE_RO, new String[]{"com"}); 355 fail("Expected IllegalArgumentException"); 356 } catch (IllegalArgumentException iae) { 357 // expected 358 Logging.debug(iae.getMessage()); 359 } 360 try { 361 DomainValidator.updateTLDOverride(ArrayType.LOCAL_RO, new String[]{"com"}); 362 fail("Expected IllegalArgumentException"); 363 } catch (IllegalArgumentException iae) { 364 // expected 365 Logging.debug(iae.getMessage()); 366 } 302 @ParameterizedTest 303 @EnumSource(value = ArrayType.class, mode = EnumSource.Mode.MATCH_ALL, names = "^.*RO$") 304 void testUpdateBaseArrays(ArrayType type) { 305 Logging.debug(assertThrows(IllegalArgumentException.class, () -> DomainValidator.updateTLDOverride(type, "com"))); 367 306 } 368 307 … … 370 309 * Test get array. 371 310 */ 372 @Test 373 void testGetArray() { 374 assertNotNull(DomainValidator.getTLDEntries(ArrayType.COUNTRY_CODE_MINUS)); 375 assertNotNull(DomainValidator.getTLDEntries(ArrayType.COUNTRY_CODE_PLUS)); 376 assertNotNull(DomainValidator.getTLDEntries(ArrayType.GENERIC_MINUS)); 377 assertNotNull(DomainValidator.getTLDEntries(ArrayType.GENERIC_PLUS)); 378 assertNotNull(DomainValidator.getTLDEntries(ArrayType.COUNTRY_CODE_RO)); 379 assertNotNull(DomainValidator.getTLDEntries(ArrayType.GENERIC_RO)); 380 assertNotNull(DomainValidator.getTLDEntries(ArrayType.INFRASTRUCTURE_RO)); 381 assertNotNull(DomainValidator.getTLDEntries(ArrayType.LOCAL_RO)); 311 @ParameterizedTest 312 @EnumSource(ArrayType.class) 313 void testGetArray(ArrayType type) { 314 assertNotNull(DomainValidator.getTLDEntries(type)); 382 315 } 383 316 … … 388 321 void testUpdateCountryCode() { 389 322 assertFalse(validator.isValidCountryCodeTld("com")); // cannot be valid 390 DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_PLUS, new String[]{"com"});323 DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_PLUS, "com"); 391 324 assertTrue(validator.isValidCountryCodeTld("com")); // it is now! 392 DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_MINUS, new String[]{"com"});325 DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_MINUS, "com"); 393 326 assertFalse(validator.isValidCountryCodeTld("com")); // show that minus overrides the rest 394 327 395 328 assertTrue(validator.isValidCountryCodeTld("ch")); 396 DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_MINUS, new String[]{"ch"});329 DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_MINUS, "ch"); 397 330 assertFalse(validator.isValidCountryCodeTld("ch")); 398 DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_MINUS, new String[]{"xx"});331 DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_MINUS, "xx"); 399 332 assertTrue(validator.isValidCountryCodeTld("ch")); 400 333 } … … 406 339 void testUpdateGeneric() { 407 340 assertFalse(validator.isValidGenericTld("ch")); // cannot be valid 408 DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, new String[]{"ch"});341 DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, "ch"); 409 342 assertTrue(validator.isValidGenericTld("ch")); // it is now! 410 DomainValidator.updateTLDOverride(ArrayType.GENERIC_MINUS, new String[]{"ch"});343 DomainValidator.updateTLDOverride(ArrayType.GENERIC_MINUS, "ch"); 411 344 assertFalse(validator.isValidGenericTld("ch")); // show that minus overrides the rest 412 345 413 346 assertTrue(validator.isValidGenericTld("com")); 414 DomainValidator.updateTLDOverride(ArrayType.GENERIC_MINUS, new String[]{"com"});347 DomainValidator.updateTLDOverride(ArrayType.GENERIC_MINUS, "com"); 415 348 assertFalse(validator.isValidGenericTld("com")); 416 DomainValidator.updateTLDOverride(ArrayType.GENERIC_MINUS, new String[]{"xx"}); // change the minus list349 DomainValidator.updateTLDOverride(ArrayType.GENERIC_MINUS, "xx"); // change the minus list 417 350 assertTrue(validator.isValidGenericTld("com")); 418 351 } … … 423 356 @Test 424 357 void testCannotUpdate() { 425 DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, new String[]{"ch"}); // OK358 DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, "ch"); // OK 426 359 DomainValidator dv = DomainValidator.getInstance(); 427 360 assertNotNull(dv); 428 361 try { 429 DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, new String[]{"ch"});362 DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, "ch"); 430 363 fail("Expected IllegalStateException"); 431 364 } catch (IllegalStateException ise) { -
trunk/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java
r17374 r18690 35 35 import java.net.URL; 36 36 import java.nio.charset.StandardCharsets; 37 import java.nio.file.Files; 37 38 import java.text.SimpleDateFormat; 38 39 import java.util.Date; 39 40 import java.util.HashMap; 40 41 import java.util.HashSet; 41 import java.util.Iterator;42 42 import java.util.Locale; 43 43 import java.util.Map; … … 102 102 download(htmlFile, "http://www.iana.org/domains/root/db", timestamp); 103 103 104 try (BufferedReader br = new BufferedReader(new InputStreamReader( new FileInputStream(txtFile), StandardCharsets.UTF_8))) {104 try (BufferedReader br = new BufferedReader(new InputStreamReader(Files.newInputStream(txtFile.toPath()), StandardCharsets.UTF_8))) { 105 105 String line; 106 106 final String header; … … 186 186 Logging.warn(" // Taken from " + header); 187 187 } 188 Iterator<Map.Entry<String, String>> it = map.entrySet().iterator(); 189 while (it.hasNext()) { 190 Map.Entry<String, String> me = it.next(); 188 for (Map.Entry<String, String> me : map.entrySet()) { 191 189 Logging.warn(" \"" + me.getKey() + "\", // " + me.getValue()); 192 190 } … … 202 200 final Pattern comment = Pattern.compile("\\s+<td>([^<]+)</td>"); 203 201 204 try (BufferedReader br = new BufferedReader(new InputStreamReader( new FileInputStream(f), StandardCharsets.UTF_8))) {202 try (BufferedReader br = new BufferedReader(new InputStreamReader(Files.newInputStream(f.toPath()), StandardCharsets.UTF_8))) { 205 203 String line; 206 204 while ((line = br.readLine()) != null) { … … 301 299 File rootCheck = new File(System.getProperty("java.io.tmpdir"), "tld_" + domain + ".html"); 302 300 download(rootCheck, tldurl, 0L); 303 in = new BufferedReader(new InputStreamReader( new FileInputStream(rootCheck), StandardCharsets.UTF_8));301 in = new BufferedReader(new InputStreamReader(Files.newInputStream(rootCheck.toPath()), StandardCharsets.UTF_8)); 304 302 String inputLine; 305 303 while ((inputLine = in.readLine()) != null) { -
trunk/test/unit/org/openstreetmap/josm/data/validation/routines/EmailValidatorTest.java
r17374 r18690 17 17 package org.openstreetmap.josm.data.validation.routines; 18 18 19 import static org.junit. Assert.assertEquals;20 import static org.junit. Assert.assertFalse;21 import static org.junit. Assert.assertTrue;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.assertTrue; 22 22 23 23 import org.junit.jupiter.api.BeforeEach; … … 172 172 return; // Cannot run the test 173 173 } 174 assertTrue( "xn--d1abbgf6aiiy.xn--p1ai should validate", validator.isValid("someone@xn--d1abbgf6aiiy.xn--p1ai"));175 assertTrue( "президент.рф should validate", validator.isValid("someone@президент.рф"));176 assertTrue( "www.b\u00fccher.ch should validate", validator.isValid("someone@www.b\u00fccher.ch"));177 assertFalse( "www.\uFFFD.ch FFFD should fail", validator.isValid("someone@www.\uFFFD.ch"));178 assertTrue( "www.b\u00fccher.ch should validate", validator.isValid("someone@www.b\u00fccher.ch"));179 assertFalse( "www.\uFFFD.ch FFFD should fail", validator.isValid("someone@www.\uFFFD.ch"));174 assertTrue(validator.isValid("someone@xn--d1abbgf6aiiy.xn--p1ai"), "xn--d1abbgf6aiiy.xn--p1ai should validate"); 175 assertTrue(validator.isValid("someone@президент.рф"), "президент.рф should validate"); 176 assertTrue(validator.isValid("someone@www.b\u00fccher.ch"), "www.b\u00fccher.ch should validate"); 177 assertFalse(validator.isValid("someone@www.\uFFFD.ch"), "www.\uFFFD.ch FFFD should fail"); 178 assertTrue(validator.isValid("someone@www.b\u00fccher.ch"), "www.b\u00fccher.ch should validate"); 179 assertFalse(validator.isValid("someone@www.\uFFFD.ch"), "www.\uFFFD.ch FFFD should fail"); 180 180 } 181 181 … … 217 217 void testEmailWithControlChars() { 218 218 for (char c = 0; c < 32; c++) { 219 assertFalse( "Test control char " + ((int) c), validator.isValid("foo" + c + "bar@domain.com"));219 assertFalse(validator.isValid("foo" + c + "bar@domain.com"), "Test control char " + ((int) c)); 220 220 } 221 assertFalse( "Test control char 127", validator.isValid("foo" + ((char) 127) + "bar@domain.com"));221 assertFalse(validator.isValid("foo" + ((char) 127) + "bar@domain.com"), "Test control char 127"); 222 222 } 223 223 … … 234 234 235 235 // Depends on the validator 236 assertTrue( 237 "@localhost.localdomain should be accepted but wasn't", 238 allowLocal.isValid("joe@localhost.localdomain") 239 ); 240 assertTrue( 241 "@localhost should be accepted but wasn't", 242 allowLocal.isValid("joe@localhost") 243 ); 244 245 assertFalse( 246 "@localhost.localdomain should be accepted but wasn't", 247 noLocal.isValid("joe@localhost.localdomain") 248 ); 249 assertFalse( 250 "@localhost should be accepted but wasn't", 251 noLocal.isValid("joe@localhost") 252 ); 236 assertTrue(allowLocal.isValid("joe@localhost.localdomain"), "@localhost.localdomain should be accepted but wasn't"); 237 assertTrue(allowLocal.isValid("joe@localhost"), "@localhost should be accepted but wasn't"); 238 239 assertFalse(noLocal.isValid("joe@localhost.localdomain"), "@localhost.localdomain should be accepted but wasn't"); 240 assertFalse(noLocal.isValid("joe@localhost"), "@localhost should be accepted but wasn't"); 253 241 } 254 242 … … 259 247 @Test 260 248 void testEmailWithSlashes() { 261 assertTrue( 262 "/ and ! valid in username", 263 validator.isValid("joe!/blow@apache.org") 264 ); 265 assertFalse( 266 "/ not valid in domain", 267 validator.isValid("joe@ap/ache.org") 268 ); 269 assertFalse( 270 "! not valid in domain", 271 validator.isValid("joe@apac!he.org") 272 ); 249 assertTrue(validator.isValid("joe!/blow@apache.org"), "/ and ! valid in username"); 250 assertFalse(validator.isValid("joe@ap/ache.org"), "/ not valid in domain"); 251 assertFalse(validator.isValid("joe@apac!he.org"), "! not valid in domain"); 273 252 } 274 253 … … 496 475 String item = resultPair.item; 497 476 if (resultPair.valid) { 498 assertTrue( "Should be OK: " + item, validator.isValid(item));477 assertTrue(validator.isValid(item), "Should be OK: " + item); 499 478 } else { 500 assertFalse( "Should fail: " + item, validator.isValid(item));479 assertFalse(validator.isValid(item), "Should fail: " + item); 501 480 } 502 481 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/routines/InetAddressValidatorTest.java
r17275 r18690 17 17 package org.openstreetmap.josm.data.validation.routines; 18 18 19 import static org.junit. Assert.assertFalse;20 import static org.junit. Assert.assertNull;21 import static org.junit. Assert.assertTrue;19 import static org.junit.jupiter.api.Assertions.assertFalse; 20 import static org.junit.jupiter.api.Assertions.assertNull; 21 import static org.junit.jupiter.api.Assertions.assertTrue; 22 22 23 23 import org.junit.jupiter.api.BeforeEach; … … 47 47 void testInetAddressesFromTheWild() { 48 48 // CHECKSTYLE.OFF: SingleSpaceSeparator 49 assertTrue( "www.apache.org IP should be valid", validator.isValid("140.211.11.130"));50 assertTrue( "www.l.google.com IP should be valid", validator.isValid("72.14.253.103"));51 assertTrue( "fsf.org IP should be valid", validator.isValid("199.232.41.5"));52 assertTrue( "appscs.ign.com IP should be valid", validator.isValid("216.35.123.87"));49 assertTrue(validator.isValid("140.211.11.130"), "www.apache.org IP should be valid"); 50 assertTrue(validator.isValid("72.14.253.103"), "www.l.google.com IP should be valid"); 51 assertTrue(validator.isValid("199.232.41.5"), "fsf.org IP should be valid"); 52 assertTrue(validator.isValid("216.35.123.87"), "appscs.ign.com IP should be valid"); 53 53 // CHECKSTYLE.ON: SingleSpaceSeparator 54 54 } … … 59 59 @Test 60 60 void testVALIDATOR_335() { 61 assertTrue("2001:0438:FFFE:0000:0000:0000:0000:0A35 should be valid", 62 validator.isValid("2001:0438:FFFE:0000:0000:0000:0000:0A35")); 61 assertTrue(validator.isValid("2001:0438:FFFE:0000:0000:0000:0000:0A35"), "2001:0438:FFFE:0000:0000:0000:0000:0A35 should be valid"); 63 62 } 64 63 … … 69 68 void testInetAddressesByClass() { 70 69 // CHECKSTYLE.OFF: SingleSpaceSeparator 71 assertTrue( "class A IP should be valid", validator.isValid("24.25.231.12"));72 assertFalse( "illegal class A IP should be invalid", validator.isValid("2.41.32.324"));73 74 assertTrue( "class B IP should be valid", validator.isValid("135.14.44.12"));75 assertFalse( "illegal class B IP should be invalid", validator.isValid("154.123.441.123"));76 77 assertTrue( "class C IP should be valid", validator.isValid("213.25.224.32"));78 assertFalse( "illegal class C IP should be invalid", validator.isValid("201.543.23.11"));79 80 assertTrue( "class D IP should be valid", validator.isValid("229.35.159.6"));81 assertFalse( "illegal class D IP should be invalid", validator.isValid("231.54.11.987"));82 83 assertTrue( "class E IP should be valid", validator.isValid("248.85.24.92"));84 assertFalse( "illegal class E IP should be invalid", validator.isValid("250.21.323.48"));70 assertTrue(validator.isValid("24.25.231.12"), "class A IP should be valid"); 71 assertFalse(validator.isValid("2.41.32.324"), "illegal class A IP should be invalid"); 72 73 assertTrue(validator.isValid("135.14.44.12"), "class B IP should be valid"); 74 assertFalse(validator.isValid("154.123.441.123"), "illegal class B IP should be invalid"); 75 76 assertTrue(validator.isValid("213.25.224.32"), "class C IP should be valid"); 77 assertFalse(validator.isValid("201.543.23.11"), "illegal class C IP should be invalid"); 78 79 assertTrue(validator.isValid("229.35.159.6"), "class D IP should be valid"); 80 assertFalse(validator.isValid("231.54.11.987"), "illegal class D IP should be invalid"); 81 82 assertTrue(validator.isValid("248.85.24.92"), "class E IP should be valid"); 83 assertFalse(validator.isValid("250.21.323.48"), "illegal class E IP should be invalid"); 85 84 // CHECKSTYLE.ON: SingleSpaceSeparator 86 85 } … … 91 90 @Test 92 91 void testReservedInetAddresses() { 93 assertTrue( "localhost IP should be valid", validator.isValid("127.0.0.1"));94 assertTrue( "broadcast IP should be valid", validator.isValid("255.255.255.255"));92 assertTrue(validator.isValid("127.0.0.1"), "localhost IP should be valid"); 93 assertTrue(validator.isValid("255.255.255.255"), "broadcast IP should be valid"); 95 94 } 96 95 … … 101 100 void testBrokenInetAddresses() { 102 101 // CHECKSTYLE.OFF: SingleSpaceSeparator 103 assertFalse( "IP with characters should be invalid", validator.isValid("124.14.32.abc"));104 assertFalse( "IP with leading zeroes should be invalid", validator.isValid("124.14.32.01"));105 assertFalse( "IP with three groups should be invalid", validator.isValid("23.64.12"));106 assertFalse( "IP with five groups should be invalid", validator.isValid("26.34.23.77.234"));102 assertFalse(validator.isValid("124.14.32.abc"), "IP with characters should be invalid"); 103 assertFalse(validator.isValid("124.14.32.01"), "IP with leading zeroes should be invalid"); 104 assertFalse(validator.isValid("23.64.12"), "IP with three groups should be invalid"); 105 assertFalse(validator.isValid("26.34.23.77.234"), "IP with five groups should be invalid"); 107 106 // CHECKSTYLE.ON: SingleSpaceSeparator 108 107 } … … 121 120 // The original Perl script contained a lot of duplicate tests. 122 121 // I removed the duplicates I noticed, but there may be more. 123 assertFalse( "IPV6 empty string should be invalid", validator.isValidInet6Address("")); // empty string124 assertTrue( "IPV6 ::1 should be valid", validator.isValidInet6Address("::1")); // loopback, compressed, non-routable125 assertTrue( "IPV6 :: should be valid", validator.isValidInet6Address("::")); // unspecified, compressed, non-routable126 assertTrue( "IPV6 0:0:0:0:0:0:0:1 should be valid", validator.isValidInet6Address("0:0:0:0:0:0:0:1")); // loopback, full127 assertTrue( "IPV6 0:0:0:0:0:0:0:0 should be valid", validator.isValidInet6Address("0:0:0:0:0:0:0:0")); // unspecified, full128 assertTrue( "IPV6 2001:DB8:0:0:8:800:200C:417A should be valid", validator.isValidInet6Address("2001:DB8:0:0:8:800:200C:417A")); // unicast, full129 assertTrue( "IPV6 FF01:0:0:0:0:0:0:101 should be valid", validator.isValidInet6Address("FF01:0:0:0:0:0:0:101")); // multicast, full130 assertTrue( "IPV6 2001:DB8::8:800:200C:417A should be valid", validator.isValidInet6Address("2001:DB8::8:800:200C:417A")); // unicast, compressed131 assertTrue( "IPV6 FF01::101 should be valid", validator.isValidInet6Address("FF01::101")); // multicast, compressed132 assertFalse( "IPV6 2001:DB8:0:0:8:800:200C:417A:221 should be invalid", validator.isValidInet6Address("2001:DB8:0:0:8:800:200C:417A:221")); // unicast, full133 assertFalse( "IPV6 FF01::101::2 should be invalid", validator.isValidInet6Address("FF01::101::2")); // multicast, compressed134 assertTrue( "IPV6 fe80::217:f2ff:fe07:ed62 should be valid", validator.isValidInet6Address("fe80::217:f2ff:fe07:ed62"));135 assertTrue( "IPV6 2001:0000:1234:0000:0000:C1C0:ABCD:0876 should be valid", validator.isValidInet6Address("2001:0000:1234:0000:0000:C1C0:ABCD:0876"));136 assertTrue( "IPV6 3ffe:0b00:0000:0000:0001:0000:0000:000a should be valid", validator.isValidInet6Address("3ffe:0b00:0000:0000:0001:0000:0000:000a"));137 assertTrue( "IPV6 FF02:0000:0000:0000:0000:0000:0000:0001 should be valid", validator.isValidInet6Address("FF02:0000:0000:0000:0000:0000:0000:0001"));138 assertTrue( "IPV6 0000:0000:0000:0000:0000:0000:0000:0001 should be valid", validator.isValidInet6Address("0000:0000:0000:0000:0000:0000:0000:0001"));139 assertTrue( "IPV6 0000:0000:0000:0000:0000:0000:0000:0000 should be valid", validator.isValidInet6Address("0000:0000:0000:0000:0000:0000:0000:0000"));140 assertFalse( "IPV6 02001:0000:1234:0000:0000:C1C0:ABCD:0876 should be invalid", validator.isValidInet6Address("02001:0000:1234:0000:0000:C1C0:ABCD:0876")); // extra 0 not allowed!141 assertFalse( "IPV6 2001:0000:1234:0000:00001:C1C0:ABCD:0876 should be invalid", validator.isValidInet6Address("2001:0000:1234:0000:00001:C1C0:ABCD:0876")); // extra 0 not allowed!142 assertFalse( "IPV6 2001:0000:1234:0000:0000:C1C0:ABCD:0876 0 should be invalid", validator.isValidInet6Address("2001:0000:1234:0000:0000:C1C0:ABCD:0876 0")); // junk after valid address143 assertFalse( "IPV6 2001:0000:1234: 0000:0000:C1C0:ABCD:0876 should be invalid", validator.isValidInet6Address("2001:0000:1234: 0000:0000:C1C0:ABCD:0876")); // internal space144 assertFalse( "IPV6 3ffe:0b00:0000:0001:0000:0000:000a should be invalid", validator.isValidInet6Address("3ffe:0b00:0000:0001:0000:0000:000a")); // seven segments145 assertFalse( "IPV6 FF02:0000:0000:0000:0000:0000:0000:0000:0001 should be invalid", validator.isValidInet6Address("FF02:0000:0000:0000:0000:0000:0000:0000:0001")); // nine segments146 assertFalse( "IPV6 3ffe:b00::1::a should be invalid", validator.isValidInet6Address("3ffe:b00::1::a")); // double "::"147 assertFalse( "IPV6 ::1111:2222:3333:4444:5555:6666:: should be invalid", validator.isValidInet6Address("::1111:2222:3333:4444:5555:6666::")); // double "::"148 assertTrue( "IPV6 2::10 should be valid", validator.isValidInet6Address("2::10"));149 assertTrue( "IPV6 ff02::1 should be valid", validator.isValidInet6Address("ff02::1"));150 assertTrue( "IPV6 fe80:: should be valid", validator.isValidInet6Address("fe80::"));151 assertTrue( "IPV6 2002:: should be valid", validator.isValidInet6Address("2002::"));152 assertTrue( "IPV6 2001:db8:: should be valid", validator.isValidInet6Address("2001:db8::"));153 assertTrue( "IPV6 2001:0db8:1234:: should be valid", validator.isValidInet6Address("2001:0db8:1234::"));154 assertTrue( "IPV6 ::ffff:0:0 should be valid", validator.isValidInet6Address("::ffff:0:0"));155 assertTrue( "IPV6 1:2:3:4:5:6:7:8 should be valid", validator.isValidInet6Address("1:2:3:4:5:6:7:8"));156 assertTrue( "IPV6 1:2:3:4:5:6::8 should be valid", validator.isValidInet6Address("1:2:3:4:5:6::8"));157 assertTrue( "IPV6 1:2:3:4:5::8 should be valid", validator.isValidInet6Address("1:2:3:4:5::8"));158 assertTrue( "IPV6 1:2:3:4::8 should be valid", validator.isValidInet6Address("1:2:3:4::8"));159 assertTrue( "IPV6 1:2:3::8 should be valid", validator.isValidInet6Address("1:2:3::8"));160 assertTrue( "IPV6 1:2::8 should be valid", validator.isValidInet6Address("1:2::8"));161 assertTrue( "IPV6 1::8 should be valid", validator.isValidInet6Address("1::8"));162 assertTrue( "IPV6 1::2:3:4:5:6:7 should be valid", validator.isValidInet6Address("1::2:3:4:5:6:7"));163 assertTrue( "IPV6 1::2:3:4:5:6 should be valid", validator.isValidInet6Address("1::2:3:4:5:6"));164 assertTrue( "IPV6 1::2:3:4:5 should be valid", validator.isValidInet6Address("1::2:3:4:5"));165 assertTrue( "IPV6 1::2:3:4 should be valid", validator.isValidInet6Address("1::2:3:4"));166 assertTrue( "IPV6 1::2:3 should be valid", validator.isValidInet6Address("1::2:3"));167 assertTrue( "IPV6 ::2:3:4:5:6:7:8 should be valid", validator.isValidInet6Address("::2:3:4:5:6:7:8"));168 assertTrue( "IPV6 ::2:3:4:5:6:7 should be valid", validator.isValidInet6Address("::2:3:4:5:6:7"));169 assertTrue( "IPV6 ::2:3:4:5:6 should be valid", validator.isValidInet6Address("::2:3:4:5:6"));170 assertTrue( "IPV6 ::2:3:4:5 should be valid", validator.isValidInet6Address("::2:3:4:5"));171 assertTrue( "IPV6 ::2:3:4 should be valid", validator.isValidInet6Address("::2:3:4"));172 assertTrue( "IPV6 ::2:3 should be valid", validator.isValidInet6Address("::2:3"));173 assertTrue( "IPV6 ::8 should be valid", validator.isValidInet6Address("::8"));174 assertTrue( "IPV6 1:2:3:4:5:6:: should be valid", validator.isValidInet6Address("1:2:3:4:5:6::"));175 assertTrue( "IPV6 1:2:3:4:5:: should be valid", validator.isValidInet6Address("1:2:3:4:5::"));176 assertTrue( "IPV6 1:2:3:4:: should be valid", validator.isValidInet6Address("1:2:3:4::"));177 assertTrue( "IPV6 1:2:3:: should be valid", validator.isValidInet6Address("1:2:3::"));178 assertTrue( "IPV6 1:2:: should be valid", validator.isValidInet6Address("1:2::"));179 assertTrue( "IPV6 1:: should be valid", validator.isValidInet6Address("1::"));180 assertTrue( "IPV6 1:2:3:4:5::7:8 should be valid", validator.isValidInet6Address("1:2:3:4:5::7:8"));181 assertFalse( "IPV6 1:2:3::4:5::7:8 should be invalid", validator.isValidInet6Address("1:2:3::4:5::7:8")); // Double "::"182 assertFalse( "IPV6 12345::6:7:8 should be invalid", validator.isValidInet6Address("12345::6:7:8"));183 assertTrue( "IPV6 1:2:3:4::7:8 should be valid", validator.isValidInet6Address("1:2:3:4::7:8"));184 assertTrue( "IPV6 1:2:3::7:8 should be valid", validator.isValidInet6Address("1:2:3::7:8"));185 assertTrue( "IPV6 1:2::7:8 should be valid", validator.isValidInet6Address("1:2::7:8"));186 assertTrue( "IPV6 1::7:8 should be valid", validator.isValidInet6Address("1::7:8"));122 assertFalse(validator.isValidInet6Address(""), "IPV6 empty string should be invalid"); // empty string 123 assertTrue(validator.isValidInet6Address("::1"), "IPV6 ::1 should be valid"); // loopback, compressed, non-routable 124 assertTrue(validator.isValidInet6Address("::"), "IPV6 :: should be valid"); // unspecified, compressed, non-routable 125 assertTrue(validator.isValidInet6Address("0:0:0:0:0:0:0:1"), "IPV6 0:0:0:0:0:0:0:1 should be valid"); // loopback, full 126 assertTrue(validator.isValidInet6Address("0:0:0:0:0:0:0:0"), "IPV6 0:0:0:0:0:0:0:0 should be valid"); // unspecified, full 127 assertTrue(validator.isValidInet6Address("2001:DB8:0:0:8:800:200C:417A"), "IPV6 2001:DB8:0:0:8:800:200C:417A should be valid"); // unicast, full 128 assertTrue(validator.isValidInet6Address("FF01:0:0:0:0:0:0:101"), "IPV6 FF01:0:0:0:0:0:0:101 should be valid"); // multicast, full 129 assertTrue(validator.isValidInet6Address("2001:DB8::8:800:200C:417A"), "IPV6 2001:DB8::8:800:200C:417A should be valid"); // unicast, compressed 130 assertTrue(validator.isValidInet6Address("FF01::101"), "IPV6 FF01::101 should be valid"); // multicast, compressed 131 assertFalse(validator.isValidInet6Address("2001:DB8:0:0:8:800:200C:417A:221"), "IPV6 2001:DB8:0:0:8:800:200C:417A:221 should be invalid"); // unicast, full 132 assertFalse(validator.isValidInet6Address("FF01::101::2"), "IPV6 FF01::101::2 should be invalid"); // multicast, compressed 133 assertTrue(validator.isValidInet6Address("fe80::217:f2ff:fe07:ed62"), "IPV6 fe80::217:f2ff:fe07:ed62 should be valid"); 134 assertTrue(validator.isValidInet6Address("2001:0000:1234:0000:0000:C1C0:ABCD:0876"), "IPV6 2001:0000:1234:0000:0000:C1C0:ABCD:0876 should be valid"); 135 assertTrue(validator.isValidInet6Address("3ffe:0b00:0000:0000:0001:0000:0000:000a"), "IPV6 3ffe:0b00:0000:0000:0001:0000:0000:000a should be valid"); 136 assertTrue(validator.isValidInet6Address("FF02:0000:0000:0000:0000:0000:0000:0001"), "IPV6 FF02:0000:0000:0000:0000:0000:0000:0001 should be valid"); 137 assertTrue(validator.isValidInet6Address("0000:0000:0000:0000:0000:0000:0000:0001"), "IPV6 0000:0000:0000:0000:0000:0000:0000:0001 should be valid"); 138 assertTrue(validator.isValidInet6Address("0000:0000:0000:0000:0000:0000:0000:0000"), "IPV6 0000:0000:0000:0000:0000:0000:0000:0000 should be valid"); 139 assertFalse(validator.isValidInet6Address("02001:0000:1234:0000:0000:C1C0:ABCD:0876"), "IPV6 02001:0000:1234:0000:0000:C1C0:ABCD:0876 should be invalid"); // extra 0 not allowed! 140 assertFalse(validator.isValidInet6Address("2001:0000:1234:0000:00001:C1C0:ABCD:0876"), "IPV6 2001:0000:1234:0000:00001:C1C0:ABCD:0876 should be invalid"); // extra 0 not allowed! 141 assertFalse(validator.isValidInet6Address("2001:0000:1234:0000:0000:C1C0:ABCD:0876 0"), "IPV6 2001:0000:1234:0000:0000:C1C0:ABCD:0876 0 should be invalid"); // junk after valid address 142 assertFalse(validator.isValidInet6Address("2001:0000:1234: 0000:0000:C1C0:ABCD:0876"), "IPV6 2001:0000:1234: 0000:0000:C1C0:ABCD:0876 should be invalid"); // internal space 143 assertFalse(validator.isValidInet6Address("3ffe:0b00:0000:0001:0000:0000:000a"), "IPV6 3ffe:0b00:0000:0001:0000:0000:000a should be invalid"); // seven segments 144 assertFalse(validator.isValidInet6Address("FF02:0000:0000:0000:0000:0000:0000:0000:0001"), "IPV6 FF02:0000:0000:0000:0000:0000:0000:0000:0001 should be invalid"); // nine segments 145 assertFalse(validator.isValidInet6Address("3ffe:b00::1::a"), "IPV6 3ffe:b00::1::a should be invalid"); // double "::" 146 assertFalse(validator.isValidInet6Address("::1111:2222:3333:4444:5555:6666::"), "IPV6 ::1111:2222:3333:4444:5555:6666:: should be invalid"); // double "::" 147 assertTrue(validator.isValidInet6Address("2::10"), "IPV6 2::10 should be valid"); 148 assertTrue(validator.isValidInet6Address("ff02::1"), "IPV6 ff02::1 should be valid"); 149 assertTrue(validator.isValidInet6Address("fe80::"), "IPV6 fe80:: should be valid"); 150 assertTrue(validator.isValidInet6Address("2002::"), "IPV6 2002:: should be valid"); 151 assertTrue(validator.isValidInet6Address("2001:db8::"), "IPV6 2001:db8:: should be valid"); 152 assertTrue(validator.isValidInet6Address("2001:0db8:1234::"), "IPV6 2001:0db8:1234:: should be valid"); 153 assertTrue(validator.isValidInet6Address("::ffff:0:0"), "IPV6 ::ffff:0:0 should be valid"); 154 assertTrue(validator.isValidInet6Address("1:2:3:4:5:6:7:8"), "IPV6 1:2:3:4:5:6:7:8 should be valid"); 155 assertTrue(validator.isValidInet6Address("1:2:3:4:5:6::8"), "IPV6 1:2:3:4:5:6::8 should be valid"); 156 assertTrue(validator.isValidInet6Address("1:2:3:4:5::8"), "IPV6 1:2:3:4:5::8 should be valid"); 157 assertTrue(validator.isValidInet6Address("1:2:3:4::8"), "IPV6 1:2:3:4::8 should be valid"); 158 assertTrue(validator.isValidInet6Address("1:2:3::8"), "IPV6 1:2:3::8 should be valid"); 159 assertTrue(validator.isValidInet6Address("1:2::8"), "IPV6 1:2::8 should be valid"); 160 assertTrue(validator.isValidInet6Address("1::8"), "IPV6 1::8 should be valid"); 161 assertTrue(validator.isValidInet6Address("1::2:3:4:5:6:7"), "IPV6 1::2:3:4:5:6:7 should be valid"); 162 assertTrue(validator.isValidInet6Address("1::2:3:4:5:6"), "IPV6 1::2:3:4:5:6 should be valid"); 163 assertTrue(validator.isValidInet6Address("1::2:3:4:5"), "IPV6 1::2:3:4:5 should be valid"); 164 assertTrue(validator.isValidInet6Address("1::2:3:4"), "IPV6 1::2:3:4 should be valid"); 165 assertTrue(validator.isValidInet6Address("1::2:3"), "IPV6 1::2:3 should be valid"); 166 assertTrue(validator.isValidInet6Address("::2:3:4:5:6:7:8"), "IPV6 ::2:3:4:5:6:7:8 should be valid"); 167 assertTrue(validator.isValidInet6Address("::2:3:4:5:6:7"), "IPV6 ::2:3:4:5:6:7 should be valid"); 168 assertTrue(validator.isValidInet6Address("::2:3:4:5:6"), "IPV6 ::2:3:4:5:6 should be valid"); 169 assertTrue(validator.isValidInet6Address("::2:3:4:5"), "IPV6 ::2:3:4:5 should be valid"); 170 assertTrue(validator.isValidInet6Address("::2:3:4"), "IPV6 ::2:3:4 should be valid"); 171 assertTrue(validator.isValidInet6Address("::2:3"), "IPV6 ::2:3 should be valid"); 172 assertTrue(validator.isValidInet6Address("::8"), "IPV6 ::8 should be valid"); 173 assertTrue(validator.isValidInet6Address("1:2:3:4:5:6::"), "IPV6 1:2:3:4:5:6:: should be valid"); 174 assertTrue(validator.isValidInet6Address("1:2:3:4:5::"), "IPV6 1:2:3:4:5:: should be valid"); 175 assertTrue(validator.isValidInet6Address("1:2:3:4::"), "IPV6 1:2:3:4:: should be valid"); 176 assertTrue(validator.isValidInet6Address("1:2:3::"), "IPV6 1:2:3:: should be valid"); 177 assertTrue(validator.isValidInet6Address("1:2::"), "IPV6 1:2:: should be valid"); 178 assertTrue(validator.isValidInet6Address("1::"), "IPV6 1:: should be valid"); 179 assertTrue(validator.isValidInet6Address("1:2:3:4:5::7:8"), "IPV6 1:2:3:4:5::7:8 should be valid"); 180 assertFalse(validator.isValidInet6Address("1:2:3::4:5::7:8"), "IPV6 1:2:3::4:5::7:8 should be invalid"); // Double "::" 181 assertFalse(validator.isValidInet6Address("12345::6:7:8"), "IPV6 12345::6:7:8 should be invalid"); 182 assertTrue(validator.isValidInet6Address("1:2:3:4::7:8"), "IPV6 1:2:3:4::7:8 should be valid"); 183 assertTrue(validator.isValidInet6Address("1:2:3::7:8"), "IPV6 1:2:3::7:8 should be valid"); 184 assertTrue(validator.isValidInet6Address("1:2::7:8"), "IPV6 1:2::7:8 should be valid"); 185 assertTrue(validator.isValidInet6Address("1::7:8"), "IPV6 1::7:8 should be valid"); 187 186 // IPv4 addresses as dotted-quads 188 assertTrue( "IPV6 1:2:3:4:5:6:1.2.3.4 should be valid", validator.isValidInet6Address("1:2:3:4:5:6:1.2.3.4"));189 assertTrue( "IPV6 1:2:3:4:5::1.2.3.4 should be valid", validator.isValidInet6Address("1:2:3:4:5::1.2.3.4"));190 assertTrue( "IPV6 1:2:3:4::1.2.3.4 should be valid", validator.isValidInet6Address("1:2:3:4::1.2.3.4"));191 assertTrue( "IPV6 1:2:3::1.2.3.4 should be valid", validator.isValidInet6Address("1:2:3::1.2.3.4"));192 assertTrue( "IPV6 1:2::1.2.3.4 should be valid", validator.isValidInet6Address("1:2::1.2.3.4"));193 assertTrue( "IPV6 1::1.2.3.4 should be valid", validator.isValidInet6Address("1::1.2.3.4"));194 assertTrue( "IPV6 1:2:3:4::5:1.2.3.4 should be valid", validator.isValidInet6Address("1:2:3:4::5:1.2.3.4"));195 assertTrue( "IPV6 1:2:3::5:1.2.3.4 should be valid", validator.isValidInet6Address("1:2:3::5:1.2.3.4"));196 assertTrue( "IPV6 1:2::5:1.2.3.4 should be valid", validator.isValidInet6Address("1:2::5:1.2.3.4"));197 assertTrue( "IPV6 1::5:1.2.3.4 should be valid", validator.isValidInet6Address("1::5:1.2.3.4"));198 assertTrue( "IPV6 1::5:11.22.33.44 should be valid", validator.isValidInet6Address("1::5:11.22.33.44"));199 assertFalse( "IPV6 1::5:400.2.3.4 should be invalid", validator.isValidInet6Address("1::5:400.2.3.4"));200 assertFalse( "IPV6 1::5:260.2.3.4 should be invalid", validator.isValidInet6Address("1::5:260.2.3.4"));201 assertFalse( "IPV6 1::5:256.2.3.4 should be invalid", validator.isValidInet6Address("1::5:256.2.3.4"));202 assertFalse( "IPV6 1::5:1.256.3.4 should be invalid", validator.isValidInet6Address("1::5:1.256.3.4"));203 assertFalse( "IPV6 1::5:1.2.256.4 should be invalid", validator.isValidInet6Address("1::5:1.2.256.4"));204 assertFalse( "IPV6 1::5:1.2.3.256 should be invalid", validator.isValidInet6Address("1::5:1.2.3.256"));205 assertFalse( "IPV6 1::5:300.2.3.4 should be invalid", validator.isValidInet6Address("1::5:300.2.3.4"));206 assertFalse( "IPV6 1::5:1.300.3.4 should be invalid", validator.isValidInet6Address("1::5:1.300.3.4"));207 assertFalse( "IPV6 1::5:1.2.300.4 should be invalid", validator.isValidInet6Address("1::5:1.2.300.4"));208 assertFalse( "IPV6 1::5:1.2.3.300 should be invalid", validator.isValidInet6Address("1::5:1.2.3.300"));209 assertFalse( "IPV6 1::5:900.2.3.4 should be invalid", validator.isValidInet6Address("1::5:900.2.3.4"));210 assertFalse( "IPV6 1::5:1.900.3.4 should be invalid", validator.isValidInet6Address("1::5:1.900.3.4"));211 assertFalse( "IPV6 1::5:1.2.900.4 should be invalid", validator.isValidInet6Address("1::5:1.2.900.4"));212 assertFalse( "IPV6 1::5:1.2.3.900 should be invalid", validator.isValidInet6Address("1::5:1.2.3.900"));213 assertFalse( "IPV6 1::5:300.300.300.300 should be invalid", validator.isValidInet6Address("1::5:300.300.300.300"));214 assertFalse( "IPV6 1::5:3000.30.30.30 should be invalid", validator.isValidInet6Address("1::5:3000.30.30.30"));215 assertFalse( "IPV6 1::400.2.3.4 should be invalid", validator.isValidInet6Address("1::400.2.3.4"));216 assertFalse( "IPV6 1::260.2.3.4 should be invalid", validator.isValidInet6Address("1::260.2.3.4"));217 assertFalse( "IPV6 1::256.2.3.4 should be invalid", validator.isValidInet6Address("1::256.2.3.4"));218 assertFalse( "IPV6 1::1.256.3.4 should be invalid", validator.isValidInet6Address("1::1.256.3.4"));219 assertFalse( "IPV6 1::1.2.256.4 should be invalid", validator.isValidInet6Address("1::1.2.256.4"));220 assertFalse( "IPV6 1::1.2.3.256 should be invalid", validator.isValidInet6Address("1::1.2.3.256"));221 assertFalse( "IPV6 1::300.2.3.4 should be invalid", validator.isValidInet6Address("1::300.2.3.4"));222 assertFalse( "IPV6 1::1.300.3.4 should be invalid", validator.isValidInet6Address("1::1.300.3.4"));223 assertFalse( "IPV6 1::1.2.300.4 should be invalid", validator.isValidInet6Address("1::1.2.300.4"));224 assertFalse( "IPV6 1::1.2.3.300 should be invalid", validator.isValidInet6Address("1::1.2.3.300"));225 assertFalse( "IPV6 1::900.2.3.4 should be invalid", validator.isValidInet6Address("1::900.2.3.4"));226 assertFalse( "IPV6 1::1.900.3.4 should be invalid", validator.isValidInet6Address("1::1.900.3.4"));227 assertFalse( "IPV6 1::1.2.900.4 should be invalid", validator.isValidInet6Address("1::1.2.900.4"));228 assertFalse( "IPV6 1::1.2.3.900 should be invalid", validator.isValidInet6Address("1::1.2.3.900"));229 assertFalse( "IPV6 1::300.300.300.300 should be invalid", validator.isValidInet6Address("1::300.300.300.300"));230 assertFalse( "IPV6 1::3000.30.30.30 should be invalid", validator.isValidInet6Address("1::3000.30.30.30"));231 assertFalse( "IPV6 ::400.2.3.4 should be invalid", validator.isValidInet6Address("::400.2.3.4"));232 assertFalse( "IPV6 ::260.2.3.4 should be invalid", validator.isValidInet6Address("::260.2.3.4"));233 assertFalse( "IPV6 ::256.2.3.4 should be invalid", validator.isValidInet6Address("::256.2.3.4"));234 assertFalse( "IPV6 ::1.256.3.4 should be invalid", validator.isValidInet6Address("::1.256.3.4"));235 assertFalse( "IPV6 ::1.2.256.4 should be invalid", validator.isValidInet6Address("::1.2.256.4"));236 assertFalse( "IPV6 ::1.2.3.256 should be invalid", validator.isValidInet6Address("::1.2.3.256"));237 assertFalse( "IPV6 ::300.2.3.4 should be invalid", validator.isValidInet6Address("::300.2.3.4"));238 assertFalse( "IPV6 ::1.300.3.4 should be invalid", validator.isValidInet6Address("::1.300.3.4"));239 assertFalse( "IPV6 ::1.2.300.4 should be invalid", validator.isValidInet6Address("::1.2.300.4"));240 assertFalse( "IPV6 ::1.2.3.300 should be invalid", validator.isValidInet6Address("::1.2.3.300"));241 assertFalse( "IPV6 ::900.2.3.4 should be invalid", validator.isValidInet6Address("::900.2.3.4"));242 assertFalse( "IPV6 ::1.900.3.4 should be invalid", validator.isValidInet6Address("::1.900.3.4"));243 assertFalse( "IPV6 ::1.2.900.4 should be invalid", validator.isValidInet6Address("::1.2.900.4"));244 assertFalse( "IPV6 ::1.2.3.900 should be invalid", validator.isValidInet6Address("::1.2.3.900"));245 assertFalse( "IPV6 ::300.300.300.300 should be invalid", validator.isValidInet6Address("::300.300.300.300"));246 assertFalse( "IPV6 ::3000.30.30.30 should be invalid", validator.isValidInet6Address("::3000.30.30.30"));247 assertTrue( "IPV6 fe80::217:f2ff:254.7.237.98 should be valid", validator.isValidInet6Address("fe80::217:f2ff:254.7.237.98"));248 assertTrue( "IPV6 ::ffff:192.168.1.26 should be valid", validator.isValidInet6Address("::ffff:192.168.1.26"));249 assertFalse( "IPV6 2001:1:1:1:1:1:255Z255X255Y255 should be invalid", validator.isValidInet6Address("2001:1:1:1:1:1:255Z255X255Y255")); // garbage instead of "." in IPv4250 assertFalse( "IPV6 ::ffff:192x168.1.26 should be invalid", validator.isValidInet6Address("::ffff:192x168.1.26")); // ditto251 assertTrue( "IPV6 ::ffff:192.168.1.1 should be valid", validator.isValidInet6Address("::ffff:192.168.1.1"));252 assertTrue( "IPV6 0:0:0:0:0:0:13.1.68.3 should be valid", validator.isValidInet6Address("0:0:0:0:0:0:13.1.68.3")); // IPv4-compatible IPv6 address, full, deprecated253 assertTrue( "IPV6 0:0:0:0:0:FFFF:129.144.52.38 should be valid", validator.isValidInet6Address("0:0:0:0:0:FFFF:129.144.52.38")); // IPv4-mapped IPv6 address, full254 assertTrue( "IPV6 ::13.1.68.3 should be valid", validator.isValidInet6Address("::13.1.68.3")); // IPv4-compatible IPv6 address, compressed, deprecated255 assertTrue( "IPV6 ::FFFF:129.144.52.38 should be valid", validator.isValidInet6Address("::FFFF:129.144.52.38")); // IPv4-mapped IPv6 address, compressed256 assertTrue( "IPV6 fe80:0:0:0:204:61ff:254.157.241.86 should be valid", validator.isValidInet6Address("fe80:0:0:0:204:61ff:254.157.241.86"));257 assertTrue( "IPV6 fe80::204:61ff:254.157.241.86 should be valid", validator.isValidInet6Address("fe80::204:61ff:254.157.241.86"));258 assertTrue( "IPV6 ::ffff:12.34.56.78 should be valid", validator.isValidInet6Address("::ffff:12.34.56.78"));259 assertFalse( "IPV6 ::ffff:2.3.4 should be invalid", validator.isValidInet6Address("::ffff:2.3.4"));260 assertFalse( "IPV6 ::ffff:257.1.2.3 should be invalid", validator.isValidInet6Address("::ffff:257.1.2.3"));261 assertFalse( "IPV6 1.2.3.4 should be invalid", validator.isValidInet6Address("1.2.3.4"));262 assertFalse( "IPV6 1.2.3.4:1111:2222:3333:4444::5555 should be invalid", validator.isValidInet6Address("1.2.3.4:1111:2222:3333:4444::5555"));263 assertFalse( "IPV6 1.2.3.4:1111:2222:3333::5555 should be invalid", validator.isValidInet6Address("1.2.3.4:1111:2222:3333::5555"));264 assertFalse( "IPV6 1.2.3.4:1111:2222::5555 should be invalid", validator.isValidInet6Address("1.2.3.4:1111:2222::5555"));265 assertFalse( "IPV6 1.2.3.4:1111::5555 should be invalid", validator.isValidInet6Address("1.2.3.4:1111::5555"));266 assertFalse( "IPV6 1.2.3.4::5555 should be invalid", validator.isValidInet6Address("1.2.3.4::5555"));267 assertFalse( "IPV6 1.2.3.4:: should be invalid", validator.isValidInet6Address("1.2.3.4::"));187 assertTrue(validator.isValidInet6Address("1:2:3:4:5:6:1.2.3.4"), "IPV6 1:2:3:4:5:6:1.2.3.4 should be valid"); 188 assertTrue(validator.isValidInet6Address("1:2:3:4:5::1.2.3.4"), "IPV6 1:2:3:4:5::1.2.3.4 should be valid"); 189 assertTrue(validator.isValidInet6Address("1:2:3:4::1.2.3.4"), "IPV6 1:2:3:4::1.2.3.4 should be valid"); 190 assertTrue(validator.isValidInet6Address("1:2:3::1.2.3.4"), "IPV6 1:2:3::1.2.3.4 should be valid"); 191 assertTrue(validator.isValidInet6Address("1:2::1.2.3.4"), "IPV6 1:2::1.2.3.4 should be valid"); 192 assertTrue(validator.isValidInet6Address("1::1.2.3.4"), "IPV6 1::1.2.3.4 should be valid"); 193 assertTrue(validator.isValidInet6Address("1:2:3:4::5:1.2.3.4"), "IPV6 1:2:3:4::5:1.2.3.4 should be valid"); 194 assertTrue(validator.isValidInet6Address("1:2:3::5:1.2.3.4"), "IPV6 1:2:3::5:1.2.3.4 should be valid"); 195 assertTrue(validator.isValidInet6Address("1:2::5:1.2.3.4"), "IPV6 1:2::5:1.2.3.4 should be valid"); 196 assertTrue(validator.isValidInet6Address("1::5:1.2.3.4"), "IPV6 1::5:1.2.3.4 should be valid"); 197 assertTrue(validator.isValidInet6Address("1::5:11.22.33.44"), "IPV6 1::5:11.22.33.44 should be valid"); 198 assertFalse(validator.isValidInet6Address("1::5:400.2.3.4"), "IPV6 1::5:400.2.3.4 should be invalid"); 199 assertFalse(validator.isValidInet6Address("1::5:260.2.3.4"), "IPV6 1::5:260.2.3.4 should be invalid"); 200 assertFalse(validator.isValidInet6Address("1::5:256.2.3.4"), "IPV6 1::5:256.2.3.4 should be invalid"); 201 assertFalse(validator.isValidInet6Address("1::5:1.256.3.4"), "IPV6 1::5:1.256.3.4 should be invalid"); 202 assertFalse(validator.isValidInet6Address("1::5:1.2.256.4"), "IPV6 1::5:1.2.256.4 should be invalid"); 203 assertFalse(validator.isValidInet6Address("1::5:1.2.3.256"), "IPV6 1::5:1.2.3.256 should be invalid"); 204 assertFalse(validator.isValidInet6Address("1::5:300.2.3.4"), "IPV6 1::5:300.2.3.4 should be invalid"); 205 assertFalse(validator.isValidInet6Address("1::5:1.300.3.4"), "IPV6 1::5:1.300.3.4 should be invalid"); 206 assertFalse(validator.isValidInet6Address("1::5:1.2.300.4"), "IPV6 1::5:1.2.300.4 should be invalid"); 207 assertFalse(validator.isValidInet6Address("1::5:1.2.3.300"), "IPV6 1::5:1.2.3.300 should be invalid"); 208 assertFalse(validator.isValidInet6Address("1::5:900.2.3.4"), "IPV6 1::5:900.2.3.4 should be invalid"); 209 assertFalse(validator.isValidInet6Address("1::5:1.900.3.4"), "IPV6 1::5:1.900.3.4 should be invalid"); 210 assertFalse(validator.isValidInet6Address("1::5:1.2.900.4"), "IPV6 1::5:1.2.900.4 should be invalid"); 211 assertFalse(validator.isValidInet6Address("1::5:1.2.3.900"), "IPV6 1::5:1.2.3.900 should be invalid"); 212 assertFalse(validator.isValidInet6Address("1::5:300.300.300.300"), "IPV6 1::5:300.300.300.300 should be invalid"); 213 assertFalse(validator.isValidInet6Address("1::5:3000.30.30.30"), "IPV6 1::5:3000.30.30.30 should be invalid"); 214 assertFalse(validator.isValidInet6Address("1::400.2.3.4"), "IPV6 1::400.2.3.4 should be invalid"); 215 assertFalse(validator.isValidInet6Address("1::260.2.3.4"), "IPV6 1::260.2.3.4 should be invalid"); 216 assertFalse(validator.isValidInet6Address("1::256.2.3.4"), "IPV6 1::256.2.3.4 should be invalid"); 217 assertFalse(validator.isValidInet6Address("1::1.256.3.4"), "IPV6 1::1.256.3.4 should be invalid"); 218 assertFalse(validator.isValidInet6Address("1::1.2.256.4"), "IPV6 1::1.2.256.4 should be invalid"); 219 assertFalse(validator.isValidInet6Address("1::1.2.3.256"), "IPV6 1::1.2.3.256 should be invalid"); 220 assertFalse(validator.isValidInet6Address("1::300.2.3.4"), "IPV6 1::300.2.3.4 should be invalid"); 221 assertFalse(validator.isValidInet6Address("1::1.300.3.4"), "IPV6 1::1.300.3.4 should be invalid"); 222 assertFalse(validator.isValidInet6Address("1::1.2.300.4"), "IPV6 1::1.2.300.4 should be invalid"); 223 assertFalse(validator.isValidInet6Address("1::1.2.3.300"), "IPV6 1::1.2.3.300 should be invalid"); 224 assertFalse(validator.isValidInet6Address("1::900.2.3.4"), "IPV6 1::900.2.3.4 should be invalid"); 225 assertFalse(validator.isValidInet6Address("1::1.900.3.4"), "IPV6 1::1.900.3.4 should be invalid"); 226 assertFalse(validator.isValidInet6Address("1::1.2.900.4"), "IPV6 1::1.2.900.4 should be invalid"); 227 assertFalse(validator.isValidInet6Address("1::1.2.3.900"), "IPV6 1::1.2.3.900 should be invalid"); 228 assertFalse(validator.isValidInet6Address("1::300.300.300.300"), "IPV6 1::300.300.300.300 should be invalid"); 229 assertFalse(validator.isValidInet6Address("1::3000.30.30.30"), "IPV6 1::3000.30.30.30 should be invalid"); 230 assertFalse(validator.isValidInet6Address("::400.2.3.4"), "IPV6 ::400.2.3.4 should be invalid"); 231 assertFalse(validator.isValidInet6Address("::260.2.3.4"), "IPV6 ::260.2.3.4 should be invalid"); 232 assertFalse(validator.isValidInet6Address("::256.2.3.4"), "IPV6 ::256.2.3.4 should be invalid"); 233 assertFalse(validator.isValidInet6Address("::1.256.3.4"), "IPV6 ::1.256.3.4 should be invalid"); 234 assertFalse(validator.isValidInet6Address("::1.2.256.4"), "IPV6 ::1.2.256.4 should be invalid"); 235 assertFalse(validator.isValidInet6Address("::1.2.3.256"), "IPV6 ::1.2.3.256 should be invalid"); 236 assertFalse(validator.isValidInet6Address("::300.2.3.4"), "IPV6 ::300.2.3.4 should be invalid"); 237 assertFalse(validator.isValidInet6Address("::1.300.3.4"), "IPV6 ::1.300.3.4 should be invalid"); 238 assertFalse(validator.isValidInet6Address("::1.2.300.4"), "IPV6 ::1.2.300.4 should be invalid"); 239 assertFalse(validator.isValidInet6Address("::1.2.3.300"), "IPV6 ::1.2.3.300 should be invalid"); 240 assertFalse(validator.isValidInet6Address("::900.2.3.4"), "IPV6 ::900.2.3.4 should be invalid"); 241 assertFalse(validator.isValidInet6Address("::1.900.3.4"), "IPV6 ::1.900.3.4 should be invalid"); 242 assertFalse(validator.isValidInet6Address("::1.2.900.4"), "IPV6 ::1.2.900.4 should be invalid"); 243 assertFalse(validator.isValidInet6Address("::1.2.3.900"), "IPV6 ::1.2.3.900 should be invalid"); 244 assertFalse(validator.isValidInet6Address("::300.300.300.300"), "IPV6 ::300.300.300.300 should be invalid"); 245 assertFalse(validator.isValidInet6Address("::3000.30.30.30"), "IPV6 ::3000.30.30.30 should be invalid"); 246 assertTrue(validator.isValidInet6Address("fe80::217:f2ff:254.7.237.98"), "IPV6 fe80::217:f2ff:254.7.237.98 should be valid"); 247 assertTrue(validator.isValidInet6Address("::ffff:192.168.1.26"), "IPV6 ::ffff:192.168.1.26 should be valid"); 248 assertFalse(validator.isValidInet6Address("2001:1:1:1:1:1:255Z255X255Y255"), "IPV6 2001:1:1:1:1:1:255Z255X255Y255 should be invalid"); // garbage instead of "." in IPv4 249 assertFalse(validator.isValidInet6Address("::ffff:192x168.1.26"), "IPV6 ::ffff:192x168.1.26 should be invalid"); // ditto 250 assertTrue(validator.isValidInet6Address("::ffff:192.168.1.1"), "IPV6 ::ffff:192.168.1.1 should be valid"); 251 assertTrue(validator.isValidInet6Address("0:0:0:0:0:0:13.1.68.3"), "IPV6 0:0:0:0:0:0:13.1.68.3 should be valid"); // IPv4-compatible IPv6 address, full, deprecated 252 assertTrue(validator.isValidInet6Address("0:0:0:0:0:FFFF:129.144.52.38"), "IPV6 0:0:0:0:0:FFFF:129.144.52.38 should be valid"); // IPv4-mapped IPv6 address, full 253 assertTrue(validator.isValidInet6Address("::13.1.68.3"), "IPV6 ::13.1.68.3 should be valid"); // IPv4-compatible IPv6 address, compressed, deprecated 254 assertTrue(validator.isValidInet6Address("::FFFF:129.144.52.38"), "IPV6 ::FFFF:129.144.52.38 should be valid"); // IPv4-mapped IPv6 address, compressed 255 assertTrue(validator.isValidInet6Address("fe80:0:0:0:204:61ff:254.157.241.86"), "IPV6 fe80:0:0:0:204:61ff:254.157.241.86 should be valid"); 256 assertTrue(validator.isValidInet6Address("fe80::204:61ff:254.157.241.86"), "IPV6 fe80::204:61ff:254.157.241.86 should be valid"); 257 assertTrue(validator.isValidInet6Address("::ffff:12.34.56.78"), "IPV6 ::ffff:12.34.56.78 should be valid"); 258 assertFalse(validator.isValidInet6Address("::ffff:2.3.4"), "IPV6 ::ffff:2.3.4 should be invalid"); 259 assertFalse(validator.isValidInet6Address("::ffff:257.1.2.3"), "IPV6 ::ffff:257.1.2.3 should be invalid"); 260 assertFalse(validator.isValidInet6Address("1.2.3.4"), "IPV6 1.2.3.4 should be invalid"); 261 assertFalse(validator.isValidInet6Address("1.2.3.4:1111:2222:3333:4444::5555"), "IPV6 1.2.3.4:1111:2222:3333:4444::5555 should be invalid"); 262 assertFalse(validator.isValidInet6Address("1.2.3.4:1111:2222:3333::5555"), "IPV6 1.2.3.4:1111:2222:3333::5555 should be invalid"); 263 assertFalse(validator.isValidInet6Address("1.2.3.4:1111:2222::5555"), "IPV6 1.2.3.4:1111:2222::5555 should be invalid"); 264 assertFalse(validator.isValidInet6Address("1.2.3.4:1111::5555"), "IPV6 1.2.3.4:1111::5555 should be invalid"); 265 assertFalse(validator.isValidInet6Address("1.2.3.4::5555"), "IPV6 1.2.3.4::5555 should be invalid"); 266 assertFalse(validator.isValidInet6Address("1.2.3.4::"), "IPV6 1.2.3.4:: should be invalid"); 268 267 // Testing IPv4 addresses represented as dotted-quads 269 268 // Leading zeroes in IPv4 addresses not allowed: some systems treat the leading "0" in ".086" as the start of an octal number 270 269 // Update: The BNF in RFC-3986 explicitly defines the dec-octet (for IPv4 addresses) not to have a leading zero 271 assertFalse( "IPV6 fe80:0000:0000:0000:0204:61ff:254.157.241.086 should be invalid", validator.isValidInet6Address("fe80:0000:0000:0000:0204:61ff:254.157.241.086"));272 assertTrue( "IPV6 ::ffff:192.0.2.128 should be valid", validator.isValidInet6Address("::ffff:192.0.2.128")); // but this is OK, since there's a single digit273 assertFalse( "IPV6 XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:1.2.3.4 should be invalid", validator.isValidInet6Address("XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:1.2.3.4"));274 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:00.00.00.00 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:00.00.00.00"));275 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:000.000.000.000 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:000.000.000.000"));276 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:256.256.256.256 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:256.256.256.256"));277 assertTrue( "IPV6 fe80:0000:0000:0000:0204:61ff:fe9d:f156 should be valid", validator.isValidInet6Address("fe80:0000:0000:0000:0204:61ff:fe9d:f156"));278 assertTrue( "IPV6 fe80:0:0:0:204:61ff:fe9d:f156 should be valid", validator.isValidInet6Address("fe80:0:0:0:204:61ff:fe9d:f156"));279 assertTrue( "IPV6 fe80::204:61ff:fe9d:f156 should be valid", validator.isValidInet6Address("fe80::204:61ff:fe9d:f156"));280 assertFalse( "IPV6 : should be invalid", validator.isValidInet6Address(":"));281 assertTrue( "IPV6 ::ffff:c000:280 should be valid", validator.isValidInet6Address("::ffff:c000:280"));282 assertFalse( "IPV6 1111:2222:3333:4444::5555: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444::5555:"));283 assertFalse( "IPV6 1111:2222:3333::5555: should be invalid", validator.isValidInet6Address("1111:2222:3333::5555:"));284 assertFalse( "IPV6 1111:2222::5555: should be invalid", validator.isValidInet6Address("1111:2222::5555:"));285 assertFalse( "IPV6 1111::5555: should be invalid", validator.isValidInet6Address("1111::5555:"));286 assertFalse( "IPV6 ::5555: should be invalid", validator.isValidInet6Address("::5555:"));287 assertFalse( "IPV6 ::: should be invalid", validator.isValidInet6Address(":::"));288 assertFalse( "IPV6 1111: should be invalid", validator.isValidInet6Address("1111:"));289 assertFalse( "IPV6 :1111:2222:3333:4444::5555 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444::5555"));290 assertFalse( "IPV6 :1111:2222:3333::5555 should be invalid", validator.isValidInet6Address(":1111:2222:3333::5555"));291 assertFalse( "IPV6 :1111:2222::5555 should be invalid", validator.isValidInet6Address(":1111:2222::5555"));292 assertFalse( "IPV6 :1111::5555 should be invalid", validator.isValidInet6Address(":1111::5555"));293 assertFalse( "IPV6 :::5555 should be invalid", validator.isValidInet6Address(":::5555"));294 assertTrue( "IPV6 2001:0db8:85a3:0000:0000:8a2e:0370:7334 should be valid", validator.isValidInet6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7334"));295 assertTrue( "IPV6 2001:db8:85a3:0:0:8a2e:370:7334 should be valid", validator.isValidInet6Address("2001:db8:85a3:0:0:8a2e:370:7334"));296 assertTrue( "IPV6 2001:db8:85a3::8a2e:370:7334 should be valid", validator.isValidInet6Address("2001:db8:85a3::8a2e:370:7334"));297 assertTrue( "IPV6 2001:0db8:0000:0000:0000:0000:1428:57ab should be valid", validator.isValidInet6Address("2001:0db8:0000:0000:0000:0000:1428:57ab"));298 assertTrue( "IPV6 2001:0db8:0000:0000:0000::1428:57ab should be valid", validator.isValidInet6Address("2001:0db8:0000:0000:0000::1428:57ab"));299 assertTrue( "IPV6 2001:0db8:0:0:0:0:1428:57ab should be valid", validator.isValidInet6Address("2001:0db8:0:0:0:0:1428:57ab"));300 assertTrue( "IPV6 2001:0db8:0:0::1428:57ab should be valid", validator.isValidInet6Address("2001:0db8:0:0::1428:57ab"));301 assertTrue( "IPV6 2001:0db8::1428:57ab should be valid", validator.isValidInet6Address("2001:0db8::1428:57ab"));302 assertTrue( "IPV6 2001:db8::1428:57ab should be valid", validator.isValidInet6Address("2001:db8::1428:57ab"));303 assertTrue( "IPV6 ::ffff:0c22:384e should be valid", validator.isValidInet6Address("::ffff:0c22:384e"));304 assertTrue( "IPV6 2001:0db8:1234:0000:0000:0000:0000:0000 should be valid", validator.isValidInet6Address("2001:0db8:1234:0000:0000:0000:0000:0000"));305 assertTrue( "IPV6 2001:0db8:1234:ffff:ffff:ffff:ffff:ffff should be valid", validator.isValidInet6Address("2001:0db8:1234:ffff:ffff:ffff:ffff:ffff"));306 assertTrue( "IPV6 2001:db8:a::123 should be valid", validator.isValidInet6Address("2001:db8:a::123"));307 assertFalse( "IPV6 123 should be invalid", validator.isValidInet6Address("123"));308 assertFalse( "IPV6 ldkfj should be invalid", validator.isValidInet6Address("ldkfj"));309 assertFalse( "IPV6 2001::FFD3::57ab should be invalid", validator.isValidInet6Address("2001::FFD3::57ab"));310 assertFalse( "IPV6 2001:db8:85a3::8a2e:37023:7334 should be invalid", validator.isValidInet6Address("2001:db8:85a3::8a2e:37023:7334"));311 assertFalse( "IPV6 2001:db8:85a3::8a2e:370k:7334 should be invalid", validator.isValidInet6Address("2001:db8:85a3::8a2e:370k:7334"));312 assertFalse( "IPV6 1:2:3:4:5:6:7:8:9 should be invalid", validator.isValidInet6Address("1:2:3:4:5:6:7:8:9"));313 assertFalse( "IPV6 1::2::3 should be invalid", validator.isValidInet6Address("1::2::3"));314 assertFalse( "IPV6 1:::3:4:5 should be invalid", validator.isValidInet6Address("1:::3:4:5"));315 assertFalse( "IPV6 1:2:3::4:5:6:7:8:9 should be invalid", validator.isValidInet6Address("1:2:3::4:5:6:7:8:9"));316 assertTrue( "IPV6 1111:2222:3333:4444:5555:6666:7777:8888 should be valid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:8888"));317 assertTrue( "IPV6 1111:2222:3333:4444:5555:6666:7777:: should be valid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777::"));318 assertTrue( "IPV6 1111:2222:3333:4444:5555:6666:: should be valid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666::"));319 assertTrue( "IPV6 1111:2222:3333:4444:5555:: should be valid", validator.isValidInet6Address("1111:2222:3333:4444:5555::"));320 assertTrue( "IPV6 1111:2222:3333:4444:: should be valid", validator.isValidInet6Address("1111:2222:3333:4444::"));321 assertTrue( "IPV6 1111:2222:3333:: should be valid", validator.isValidInet6Address("1111:2222:3333::"));322 assertTrue( "IPV6 1111:2222:: should be valid", validator.isValidInet6Address("1111:2222::"));323 assertTrue( "IPV6 1111:: should be valid", validator.isValidInet6Address("1111::"));324 assertTrue( "IPV6 1111:2222:3333:4444:5555:6666::8888 should be valid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666::8888"));325 assertTrue( "IPV6 1111:2222:3333:4444:5555::8888 should be valid", validator.isValidInet6Address("1111:2222:3333:4444:5555::8888"));326 assertTrue( "IPV6 1111:2222:3333:4444::8888 should be valid", validator.isValidInet6Address("1111:2222:3333:4444::8888"));327 assertTrue( "IPV6 1111:2222:3333::8888 should be valid", validator.isValidInet6Address("1111:2222:3333::8888"));328 assertTrue( "IPV6 1111:2222::8888 should be valid", validator.isValidInet6Address("1111:2222::8888"));329 assertTrue( "IPV6 1111::8888 should be valid", validator.isValidInet6Address("1111::8888"));330 assertTrue( "IPV6 ::8888 should be valid", validator.isValidInet6Address("::8888"));331 assertTrue( "IPV6 1111:2222:3333:4444:5555::7777:8888 should be valid", validator.isValidInet6Address("1111:2222:3333:4444:5555::7777:8888"));332 assertTrue( "IPV6 1111:2222:3333:4444::7777:8888 should be valid", validator.isValidInet6Address("1111:2222:3333:4444::7777:8888"));333 assertTrue( "IPV6 1111:2222:3333::7777:8888 should be valid", validator.isValidInet6Address("1111:2222:3333::7777:8888"));334 assertTrue( "IPV6 1111:2222::7777:8888 should be valid", validator.isValidInet6Address("1111:2222::7777:8888"));335 assertTrue( "IPV6 1111::7777:8888 should be valid", validator.isValidInet6Address("1111::7777:8888"));336 assertTrue( "IPV6 ::7777:8888 should be valid", validator.isValidInet6Address("::7777:8888"));337 assertTrue( "IPV6 1111:2222:3333:4444::6666:7777:8888 should be valid", validator.isValidInet6Address("1111:2222:3333:4444::6666:7777:8888"));338 assertTrue( "IPV6 1111:2222:3333::6666:7777:8888 should be valid", validator.isValidInet6Address("1111:2222:3333::6666:7777:8888"));339 assertTrue( "IPV6 1111:2222::6666:7777:8888 should be valid", validator.isValidInet6Address("1111:2222::6666:7777:8888"));340 assertTrue( "IPV6 1111::6666:7777:8888 should be valid", validator.isValidInet6Address("1111::6666:7777:8888"));341 assertTrue( "IPV6 ::6666:7777:8888 should be valid", validator.isValidInet6Address("::6666:7777:8888"));342 assertTrue( "IPV6 1111:2222:3333::5555:6666:7777:8888 should be valid", validator.isValidInet6Address("1111:2222:3333::5555:6666:7777:8888"));343 assertTrue( "IPV6 1111:2222::5555:6666:7777:8888 should be valid", validator.isValidInet6Address("1111:2222::5555:6666:7777:8888"));344 assertTrue( "IPV6 1111::5555:6666:7777:8888 should be valid", validator.isValidInet6Address("1111::5555:6666:7777:8888"));345 assertTrue( "IPV6 ::5555:6666:7777:8888 should be valid", validator.isValidInet6Address("::5555:6666:7777:8888"));346 assertTrue( "IPV6 1111:2222::4444:5555:6666:7777:8888 should be valid", validator.isValidInet6Address("1111:2222::4444:5555:6666:7777:8888"));347 assertTrue( "IPV6 1111::4444:5555:6666:7777:8888 should be valid", validator.isValidInet6Address("1111::4444:5555:6666:7777:8888"));348 assertTrue( "IPV6 ::4444:5555:6666:7777:8888 should be valid", validator.isValidInet6Address("::4444:5555:6666:7777:8888"));349 assertTrue( "IPV6 1111::3333:4444:5555:6666:7777:8888 should be valid", validator.isValidInet6Address("1111::3333:4444:5555:6666:7777:8888"));350 assertTrue( "IPV6 ::3333:4444:5555:6666:7777:8888 should be valid", validator.isValidInet6Address("::3333:4444:5555:6666:7777:8888"));351 assertTrue( "IPV6 ::2222:3333:4444:5555:6666:7777:8888 should be valid", validator.isValidInet6Address("::2222:3333:4444:5555:6666:7777:8888"));352 assertTrue( "IPV6 1111:2222:3333:4444:5555:6666:123.123.123.123 should be valid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:123.123.123.123"));353 assertTrue( "IPV6 1111:2222:3333:4444:5555::123.123.123.123 should be valid", validator.isValidInet6Address("1111:2222:3333:4444:5555::123.123.123.123"));354 assertTrue( "IPV6 1111:2222:3333:4444::123.123.123.123 should be valid", validator.isValidInet6Address("1111:2222:3333:4444::123.123.123.123"));355 assertTrue( "IPV6 1111:2222:3333::123.123.123.123 should be valid", validator.isValidInet6Address("1111:2222:3333::123.123.123.123"));356 assertTrue( "IPV6 1111:2222::123.123.123.123 should be valid", validator.isValidInet6Address("1111:2222::123.123.123.123"));357 assertTrue( "IPV6 1111::123.123.123.123 should be valid", validator.isValidInet6Address("1111::123.123.123.123"));358 assertTrue( "IPV6 ::123.123.123.123 should be valid", validator.isValidInet6Address("::123.123.123.123"));359 assertTrue( "IPV6 1111:2222:3333:4444::6666:123.123.123.123 should be valid", validator.isValidInet6Address("1111:2222:3333:4444::6666:123.123.123.123"));360 assertTrue( "IPV6 1111:2222:3333::6666:123.123.123.123 should be valid", validator.isValidInet6Address("1111:2222:3333::6666:123.123.123.123"));361 assertTrue( "IPV6 1111:2222::6666:123.123.123.123 should be valid", validator.isValidInet6Address("1111:2222::6666:123.123.123.123"));362 assertTrue( "IPV6 1111::6666:123.123.123.123 should be valid", validator.isValidInet6Address("1111::6666:123.123.123.123"));363 assertTrue( "IPV6 ::6666:123.123.123.123 should be valid", validator.isValidInet6Address("::6666:123.123.123.123"));364 assertTrue( "IPV6 1111:2222:3333::5555:6666:123.123.123.123 should be valid", validator.isValidInet6Address("1111:2222:3333::5555:6666:123.123.123.123"));365 assertTrue( "IPV6 1111:2222::5555:6666:123.123.123.123 should be valid", validator.isValidInet6Address("1111:2222::5555:6666:123.123.123.123"));366 assertTrue( "IPV6 1111::5555:6666:123.123.123.123 should be valid", validator.isValidInet6Address("1111::5555:6666:123.123.123.123"));367 assertTrue( "IPV6 ::5555:6666:123.123.123.123 should be valid", validator.isValidInet6Address("::5555:6666:123.123.123.123"));368 assertTrue( "IPV6 1111:2222::4444:5555:6666:123.123.123.123 should be valid", validator.isValidInet6Address("1111:2222::4444:5555:6666:123.123.123.123"));369 assertTrue( "IPV6 1111::4444:5555:6666:123.123.123.123 should be valid", validator.isValidInet6Address("1111::4444:5555:6666:123.123.123.123"));370 assertTrue( "IPV6 ::4444:5555:6666:123.123.123.123 should be valid", validator.isValidInet6Address("::4444:5555:6666:123.123.123.123"));371 assertTrue( "IPV6 1111::3333:4444:5555:6666:123.123.123.123 should be valid", validator.isValidInet6Address("1111::3333:4444:5555:6666:123.123.123.123"));372 assertTrue( "IPV6 ::2222:3333:4444:5555:6666:123.123.123.123 should be valid", validator.isValidInet6Address("::2222:3333:4444:5555:6666:123.123.123.123"));270 assertFalse(validator.isValidInet6Address("fe80:0000:0000:0000:0204:61ff:254.157.241.086"), "IPV6 fe80:0000:0000:0000:0204:61ff:254.157.241.086 should be invalid"); 271 assertTrue(validator.isValidInet6Address("::ffff:192.0.2.128"), "IPV6 ::ffff:192.0.2.128 should be valid"); // but this is OK, since there's a single digit 272 assertFalse(validator.isValidInet6Address("XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:1.2.3.4"), "IPV6 XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:1.2.3.4 should be invalid"); 273 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:00.00.00.00"), "IPV6 1111:2222:3333:4444:5555:6666:00.00.00.00 should be invalid"); 274 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:000.000.000.000"), "IPV6 1111:2222:3333:4444:5555:6666:000.000.000.000 should be invalid"); 275 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:256.256.256.256"), "IPV6 1111:2222:3333:4444:5555:6666:256.256.256.256 should be invalid"); 276 assertTrue(validator.isValidInet6Address("fe80:0000:0000:0000:0204:61ff:fe9d:f156"), "IPV6 fe80:0000:0000:0000:0204:61ff:fe9d:f156 should be valid"); 277 assertTrue(validator.isValidInet6Address("fe80:0:0:0:204:61ff:fe9d:f156"), "IPV6 fe80:0:0:0:204:61ff:fe9d:f156 should be valid"); 278 assertTrue(validator.isValidInet6Address("fe80::204:61ff:fe9d:f156"), "IPV6 fe80::204:61ff:fe9d:f156 should be valid"); 279 assertFalse(validator.isValidInet6Address(":"), "IPV6 : should be invalid"); 280 assertTrue(validator.isValidInet6Address("::ffff:c000:280"), "IPV6 ::ffff:c000:280 should be valid"); 281 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444::5555:"), "IPV6 1111:2222:3333:4444::5555: should be invalid"); 282 assertFalse(validator.isValidInet6Address("1111:2222:3333::5555:"), "IPV6 1111:2222:3333::5555: should be invalid"); 283 assertFalse(validator.isValidInet6Address("1111:2222::5555:"), "IPV6 1111:2222::5555: should be invalid"); 284 assertFalse(validator.isValidInet6Address("1111::5555:"), "IPV6 1111::5555: should be invalid"); 285 assertFalse(validator.isValidInet6Address("::5555:"), "IPV6 ::5555: should be invalid"); 286 assertFalse(validator.isValidInet6Address(":::"), "IPV6 ::: should be invalid"); 287 assertFalse(validator.isValidInet6Address("1111:"), "IPV6 1111: should be invalid"); 288 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444::5555"), "IPV6 :1111:2222:3333:4444::5555 should be invalid"); 289 assertFalse(validator.isValidInet6Address(":1111:2222:3333::5555"), "IPV6 :1111:2222:3333::5555 should be invalid"); 290 assertFalse(validator.isValidInet6Address(":1111:2222::5555"), "IPV6 :1111:2222::5555 should be invalid"); 291 assertFalse(validator.isValidInet6Address(":1111::5555"), "IPV6 :1111::5555 should be invalid"); 292 assertFalse(validator.isValidInet6Address(":::5555"), "IPV6 :::5555 should be invalid"); 293 assertTrue(validator.isValidInet6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7334"), "IPV6 2001:0db8:85a3:0000:0000:8a2e:0370:7334 should be valid"); 294 assertTrue(validator.isValidInet6Address("2001:db8:85a3:0:0:8a2e:370:7334"), "IPV6 2001:db8:85a3:0:0:8a2e:370:7334 should be valid"); 295 assertTrue(validator.isValidInet6Address("2001:db8:85a3::8a2e:370:7334"), "IPV6 2001:db8:85a3::8a2e:370:7334 should be valid"); 296 assertTrue(validator.isValidInet6Address("2001:0db8:0000:0000:0000:0000:1428:57ab"), "IPV6 2001:0db8:0000:0000:0000:0000:1428:57ab should be valid"); 297 assertTrue(validator.isValidInet6Address("2001:0db8:0000:0000:0000::1428:57ab"), "IPV6 2001:0db8:0000:0000:0000::1428:57ab should be valid"); 298 assertTrue(validator.isValidInet6Address("2001:0db8:0:0:0:0:1428:57ab"), "IPV6 2001:0db8:0:0:0:0:1428:57ab should be valid"); 299 assertTrue(validator.isValidInet6Address("2001:0db8:0:0::1428:57ab"), "IPV6 2001:0db8:0:0::1428:57ab should be valid"); 300 assertTrue(validator.isValidInet6Address("2001:0db8::1428:57ab"), "IPV6 2001:0db8::1428:57ab should be valid"); 301 assertTrue(validator.isValidInet6Address("2001:db8::1428:57ab"), "IPV6 2001:db8::1428:57ab should be valid"); 302 assertTrue(validator.isValidInet6Address("::ffff:0c22:384e"), "IPV6 ::ffff:0c22:384e should be valid"); 303 assertTrue(validator.isValidInet6Address("2001:0db8:1234:0000:0000:0000:0000:0000"), "IPV6 2001:0db8:1234:0000:0000:0000:0000:0000 should be valid"); 304 assertTrue(validator.isValidInet6Address("2001:0db8:1234:ffff:ffff:ffff:ffff:ffff"), "IPV6 2001:0db8:1234:ffff:ffff:ffff:ffff:ffff should be valid"); 305 assertTrue(validator.isValidInet6Address("2001:db8:a::123"), "IPV6 2001:db8:a::123 should be valid"); 306 assertFalse(validator.isValidInet6Address("123"), "IPV6 123 should be invalid"); 307 assertFalse(validator.isValidInet6Address("ldkfj"), "IPV6 ldkfj should be invalid"); 308 assertFalse(validator.isValidInet6Address("2001::FFD3::57ab"), "IPV6 2001::FFD3::57ab should be invalid"); 309 assertFalse(validator.isValidInet6Address("2001:db8:85a3::8a2e:37023:7334"), "IPV6 2001:db8:85a3::8a2e:37023:7334 should be invalid"); 310 assertFalse(validator.isValidInet6Address("2001:db8:85a3::8a2e:370k:7334"), "IPV6 2001:db8:85a3::8a2e:370k:7334 should be invalid"); 311 assertFalse(validator.isValidInet6Address("1:2:3:4:5:6:7:8:9"), "IPV6 1:2:3:4:5:6:7:8:9 should be invalid"); 312 assertFalse(validator.isValidInet6Address("1::2::3"), "IPV6 1::2::3 should be invalid"); 313 assertFalse(validator.isValidInet6Address("1:::3:4:5"), "IPV6 1:::3:4:5 should be invalid"); 314 assertFalse(validator.isValidInet6Address("1:2:3::4:5:6:7:8:9"), "IPV6 1:2:3::4:5:6:7:8:9 should be invalid"); 315 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:8888"), "IPV6 1111:2222:3333:4444:5555:6666:7777:8888 should be valid"); 316 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777::"), "IPV6 1111:2222:3333:4444:5555:6666:7777:: should be valid"); 317 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666::"), "IPV6 1111:2222:3333:4444:5555:6666:: should be valid"); 318 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444:5555::"), "IPV6 1111:2222:3333:4444:5555:: should be valid"); 319 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444::"), "IPV6 1111:2222:3333:4444:: should be valid"); 320 assertTrue(validator.isValidInet6Address("1111:2222:3333::"), "IPV6 1111:2222:3333:: should be valid"); 321 assertTrue(validator.isValidInet6Address("1111:2222::"), "IPV6 1111:2222:: should be valid"); 322 assertTrue(validator.isValidInet6Address("1111::"), "IPV6 1111:: should be valid"); 323 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666::8888"), "IPV6 1111:2222:3333:4444:5555:6666::8888 should be valid"); 324 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444:5555::8888"), "IPV6 1111:2222:3333:4444:5555::8888 should be valid"); 325 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444::8888"), "IPV6 1111:2222:3333:4444::8888 should be valid"); 326 assertTrue(validator.isValidInet6Address("1111:2222:3333::8888"), "IPV6 1111:2222:3333::8888 should be valid"); 327 assertTrue(validator.isValidInet6Address("1111:2222::8888"), "IPV6 1111:2222::8888 should be valid"); 328 assertTrue(validator.isValidInet6Address("1111::8888"), "IPV6 1111::8888 should be valid"); 329 assertTrue(validator.isValidInet6Address("::8888"), "IPV6 ::8888 should be valid"); 330 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444:5555::7777:8888"), "IPV6 1111:2222:3333:4444:5555::7777:8888 should be valid"); 331 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444::7777:8888"), "IPV6 1111:2222:3333:4444::7777:8888 should be valid"); 332 assertTrue(validator.isValidInet6Address("1111:2222:3333::7777:8888"), "IPV6 1111:2222:3333::7777:8888 should be valid"); 333 assertTrue(validator.isValidInet6Address("1111:2222::7777:8888"), "IPV6 1111:2222::7777:8888 should be valid"); 334 assertTrue(validator.isValidInet6Address("1111::7777:8888"), "IPV6 1111::7777:8888 should be valid"); 335 assertTrue(validator.isValidInet6Address("::7777:8888"), "IPV6 ::7777:8888 should be valid"); 336 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444::6666:7777:8888"), "IPV6 1111:2222:3333:4444::6666:7777:8888 should be valid"); 337 assertTrue(validator.isValidInet6Address("1111:2222:3333::6666:7777:8888"), "IPV6 1111:2222:3333::6666:7777:8888 should be valid"); 338 assertTrue(validator.isValidInet6Address("1111:2222::6666:7777:8888"), "IPV6 1111:2222::6666:7777:8888 should be valid"); 339 assertTrue(validator.isValidInet6Address("1111::6666:7777:8888"), "IPV6 1111::6666:7777:8888 should be valid"); 340 assertTrue(validator.isValidInet6Address("::6666:7777:8888"), "IPV6 ::6666:7777:8888 should be valid"); 341 assertTrue(validator.isValidInet6Address("1111:2222:3333::5555:6666:7777:8888"), "IPV6 1111:2222:3333::5555:6666:7777:8888 should be valid"); 342 assertTrue(validator.isValidInet6Address("1111:2222::5555:6666:7777:8888"), "IPV6 1111:2222::5555:6666:7777:8888 should be valid"); 343 assertTrue(validator.isValidInet6Address("1111::5555:6666:7777:8888"), "IPV6 1111::5555:6666:7777:8888 should be valid"); 344 assertTrue(validator.isValidInet6Address("::5555:6666:7777:8888"), "IPV6 ::5555:6666:7777:8888 should be valid"); 345 assertTrue(validator.isValidInet6Address("1111:2222::4444:5555:6666:7777:8888"), "IPV6 1111:2222::4444:5555:6666:7777:8888 should be valid"); 346 assertTrue(validator.isValidInet6Address("1111::4444:5555:6666:7777:8888"), "IPV6 1111::4444:5555:6666:7777:8888 should be valid"); 347 assertTrue(validator.isValidInet6Address("::4444:5555:6666:7777:8888"), "IPV6 ::4444:5555:6666:7777:8888 should be valid"); 348 assertTrue(validator.isValidInet6Address("1111::3333:4444:5555:6666:7777:8888"), "IPV6 1111::3333:4444:5555:6666:7777:8888 should be valid"); 349 assertTrue(validator.isValidInet6Address("::3333:4444:5555:6666:7777:8888"), "IPV6 ::3333:4444:5555:6666:7777:8888 should be valid"); 350 assertTrue(validator.isValidInet6Address("::2222:3333:4444:5555:6666:7777:8888"), "IPV6 ::2222:3333:4444:5555:6666:7777:8888 should be valid"); 351 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:123.123.123.123"), "IPV6 1111:2222:3333:4444:5555:6666:123.123.123.123 should be valid"); 352 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444:5555::123.123.123.123"), "IPV6 1111:2222:3333:4444:5555::123.123.123.123 should be valid"); 353 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444::123.123.123.123"), "IPV6 1111:2222:3333:4444::123.123.123.123 should be valid"); 354 assertTrue(validator.isValidInet6Address("1111:2222:3333::123.123.123.123"), "IPV6 1111:2222:3333::123.123.123.123 should be valid"); 355 assertTrue(validator.isValidInet6Address("1111:2222::123.123.123.123"), "IPV6 1111:2222::123.123.123.123 should be valid"); 356 assertTrue(validator.isValidInet6Address("1111::123.123.123.123"), "IPV6 1111::123.123.123.123 should be valid"); 357 assertTrue(validator.isValidInet6Address("::123.123.123.123"), "IPV6 ::123.123.123.123 should be valid"); 358 assertTrue(validator.isValidInet6Address("1111:2222:3333:4444::6666:123.123.123.123"), "IPV6 1111:2222:3333:4444::6666:123.123.123.123 should be valid"); 359 assertTrue(validator.isValidInet6Address("1111:2222:3333::6666:123.123.123.123"), "IPV6 1111:2222:3333::6666:123.123.123.123 should be valid"); 360 assertTrue(validator.isValidInet6Address("1111:2222::6666:123.123.123.123"), "IPV6 1111:2222::6666:123.123.123.123 should be valid"); 361 assertTrue(validator.isValidInet6Address("1111::6666:123.123.123.123"), "IPV6 1111::6666:123.123.123.123 should be valid"); 362 assertTrue(validator.isValidInet6Address("::6666:123.123.123.123"), "IPV6 ::6666:123.123.123.123 should be valid"); 363 assertTrue(validator.isValidInet6Address("1111:2222:3333::5555:6666:123.123.123.123"), "IPV6 1111:2222:3333::5555:6666:123.123.123.123 should be valid"); 364 assertTrue(validator.isValidInet6Address("1111:2222::5555:6666:123.123.123.123"), "IPV6 1111:2222::5555:6666:123.123.123.123 should be valid"); 365 assertTrue(validator.isValidInet6Address("1111::5555:6666:123.123.123.123"), "IPV6 1111::5555:6666:123.123.123.123 should be valid"); 366 assertTrue(validator.isValidInet6Address("::5555:6666:123.123.123.123"), "IPV6 ::5555:6666:123.123.123.123 should be valid"); 367 assertTrue(validator.isValidInet6Address("1111:2222::4444:5555:6666:123.123.123.123"), "IPV6 1111:2222::4444:5555:6666:123.123.123.123 should be valid"); 368 assertTrue(validator.isValidInet6Address("1111::4444:5555:6666:123.123.123.123"), "IPV6 1111::4444:5555:6666:123.123.123.123 should be valid"); 369 assertTrue(validator.isValidInet6Address("::4444:5555:6666:123.123.123.123"), "IPV6 ::4444:5555:6666:123.123.123.123 should be valid"); 370 assertTrue(validator.isValidInet6Address("1111::3333:4444:5555:6666:123.123.123.123"), "IPV6 1111::3333:4444:5555:6666:123.123.123.123 should be valid"); 371 assertTrue(validator.isValidInet6Address("::2222:3333:4444:5555:6666:123.123.123.123"), "IPV6 ::2222:3333:4444:5555:6666:123.123.123.123 should be valid"); 373 372 // Trying combinations of "0" and "::" 374 373 // These are all syntactically correct, but are bad form 375 374 // because "0" adjacent to "::" should be combined into "::" 376 assertTrue( "IPV6 ::0:0:0:0:0:0:0 should be valid", validator.isValidInet6Address("::0:0:0:0:0:0:0"));377 assertTrue( "IPV6 ::0:0:0:0:0:0 should be valid", validator.isValidInet6Address("::0:0:0:0:0:0"));378 assertTrue( "IPV6 ::0:0:0:0:0 should be valid", validator.isValidInet6Address("::0:0:0:0:0"));379 assertTrue( "IPV6 ::0:0:0:0 should be valid", validator.isValidInet6Address("::0:0:0:0"));380 assertTrue( "IPV6 ::0:0:0 should be valid", validator.isValidInet6Address("::0:0:0"));381 assertTrue( "IPV6 ::0:0 should be valid", validator.isValidInet6Address("::0:0"));382 assertTrue( "IPV6 ::0 should be valid", validator.isValidInet6Address("::0"));383 assertTrue( "IPV6 0:0:0:0:0:0:0:: should be valid", validator.isValidInet6Address("0:0:0:0:0:0:0::"));384 assertTrue( "IPV6 0:0:0:0:0:0:: should be valid", validator.isValidInet6Address("0:0:0:0:0:0::"));385 assertTrue( "IPV6 0:0:0:0:0:: should be valid", validator.isValidInet6Address("0:0:0:0:0::"));386 assertTrue( "IPV6 0:0:0:0:: should be valid", validator.isValidInet6Address("0:0:0:0::"));387 assertTrue( "IPV6 0:0:0:: should be valid", validator.isValidInet6Address("0:0:0::"));388 assertTrue( "IPV6 0:0:: should be valid", validator.isValidInet6Address("0:0::"));389 assertTrue( "IPV6 0:: should be valid", validator.isValidInet6Address("0::"));375 assertTrue(validator.isValidInet6Address("::0:0:0:0:0:0:0"), "IPV6 ::0:0:0:0:0:0:0 should be valid"); 376 assertTrue(validator.isValidInet6Address("::0:0:0:0:0:0"), "IPV6 ::0:0:0:0:0:0 should be valid"); 377 assertTrue(validator.isValidInet6Address("::0:0:0:0:0"), "IPV6 ::0:0:0:0:0 should be valid"); 378 assertTrue(validator.isValidInet6Address("::0:0:0:0"), "IPV6 ::0:0:0:0 should be valid"); 379 assertTrue(validator.isValidInet6Address("::0:0:0"), "IPV6 ::0:0:0 should be valid"); 380 assertTrue(validator.isValidInet6Address("::0:0"), "IPV6 ::0:0 should be valid"); 381 assertTrue(validator.isValidInet6Address("::0"), "IPV6 ::0 should be valid"); 382 assertTrue(validator.isValidInet6Address("0:0:0:0:0:0:0::"), "IPV6 0:0:0:0:0:0:0:: should be valid"); 383 assertTrue(validator.isValidInet6Address("0:0:0:0:0:0::"), "IPV6 0:0:0:0:0:0:: should be valid"); 384 assertTrue(validator.isValidInet6Address("0:0:0:0:0::"), "IPV6 0:0:0:0:0:: should be valid"); 385 assertTrue(validator.isValidInet6Address("0:0:0:0::"), "IPV6 0:0:0:0:: should be valid"); 386 assertTrue(validator.isValidInet6Address("0:0:0::"), "IPV6 0:0:0:: should be valid"); 387 assertTrue(validator.isValidInet6Address("0:0::"), "IPV6 0:0:: should be valid"); 388 assertTrue(validator.isValidInet6Address("0::"), "IPV6 0:: should be valid"); 390 389 // Invalid data 391 assertFalse( "IPV6 XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX should be invalid", validator.isValidInet6Address("XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX"));390 assertFalse(validator.isValidInet6Address("XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX"), "IPV6 XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX should be invalid"); 392 391 // Too many components 393 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:7777:8888:9999 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:8888:9999"));394 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:7777:8888:: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:8888::"));395 assertFalse( "IPV6 ::2222:3333:4444:5555:6666:7777:8888:9999 should be invalid", validator.isValidInet6Address("::2222:3333:4444:5555:6666:7777:8888:9999"));392 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:8888:9999"), "IPV6 1111:2222:3333:4444:5555:6666:7777:8888:9999 should be invalid"); 393 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:8888::"), "IPV6 1111:2222:3333:4444:5555:6666:7777:8888:: should be invalid"); 394 assertFalse(validator.isValidInet6Address("::2222:3333:4444:5555:6666:7777:8888:9999"), "IPV6 ::2222:3333:4444:5555:6666:7777:8888:9999 should be invalid"); 396 395 // Too few components 397 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:7777 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777"));398 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666"));399 assertFalse( "IPV6 1111:2222:3333:4444:5555 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555"));400 assertFalse( "IPV6 1111:2222:3333:4444 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444"));401 assertFalse( "IPV6 1111:2222:3333 should be invalid", validator.isValidInet6Address("1111:2222:3333"));402 assertFalse( "IPV6 1111:2222 should be invalid", validator.isValidInet6Address("1111:2222"));403 assertFalse( "IPV6 1111 should be invalid", validator.isValidInet6Address("1111"));396 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777"), "IPV6 1111:2222:3333:4444:5555:6666:7777 should be invalid"); 397 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666"), "IPV6 1111:2222:3333:4444:5555:6666 should be invalid"); 398 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555"), "IPV6 1111:2222:3333:4444:5555 should be invalid"); 399 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444"), "IPV6 1111:2222:3333:4444 should be invalid"); 400 assertFalse(validator.isValidInet6Address("1111:2222:3333"), "IPV6 1111:2222:3333 should be invalid"); 401 assertFalse(validator.isValidInet6Address("1111:2222"), "IPV6 1111:2222 should be invalid"); 402 assertFalse(validator.isValidInet6Address("1111"), "IPV6 1111 should be invalid"); 404 403 // Missing : 405 assertFalse( "IPV6 11112222:3333:4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address("11112222:3333:4444:5555:6666:7777:8888"));406 assertFalse( "IPV6 1111:22223333:4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address("1111:22223333:4444:5555:6666:7777:8888"));407 assertFalse( "IPV6 1111:2222:33334444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address("1111:2222:33334444:5555:6666:7777:8888"));408 assertFalse( "IPV6 1111:2222:3333:44445555:6666:7777:8888 should be invalid", validator.isValidInet6Address("1111:2222:3333:44445555:6666:7777:8888"));409 assertFalse( "IPV6 1111:2222:3333:4444:55556666:7777:8888 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:55556666:7777:8888"));410 assertFalse( "IPV6 1111:2222:3333:4444:5555:66667777:8888 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:66667777:8888"));411 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:77778888 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:77778888"));404 assertFalse(validator.isValidInet6Address("11112222:3333:4444:5555:6666:7777:8888"), "IPV6 11112222:3333:4444:5555:6666:7777:8888 should be invalid"); 405 assertFalse(validator.isValidInet6Address("1111:22223333:4444:5555:6666:7777:8888"), "IPV6 1111:22223333:4444:5555:6666:7777:8888 should be invalid"); 406 assertFalse(validator.isValidInet6Address("1111:2222:33334444:5555:6666:7777:8888"), "IPV6 1111:2222:33334444:5555:6666:7777:8888 should be invalid"); 407 assertFalse(validator.isValidInet6Address("1111:2222:3333:44445555:6666:7777:8888"), "IPV6 1111:2222:3333:44445555:6666:7777:8888 should be invalid"); 408 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:55556666:7777:8888"), "IPV6 1111:2222:3333:4444:55556666:7777:8888 should be invalid"); 409 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:66667777:8888"), "IPV6 1111:2222:3333:4444:5555:66667777:8888 should be invalid"); 410 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:77778888"), "IPV6 1111:2222:3333:4444:5555:6666:77778888 should be invalid"); 412 411 // Missing : intended for :: 413 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:7777:8888: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:8888:"));414 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:7777: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:"));415 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:"));416 assertFalse( "IPV6 1111:2222:3333:4444:5555: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:"));417 assertFalse( "IPV6 1111:2222:3333:4444: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:"));418 assertFalse( "IPV6 1111:2222:3333: should be invalid", validator.isValidInet6Address("1111:2222:3333:"));419 assertFalse( "IPV6 1111:2222: should be invalid", validator.isValidInet6Address("1111:2222:"));420 assertFalse( "IPV6 :8888 should be invalid", validator.isValidInet6Address(":8888"));421 assertFalse( "IPV6 :7777:8888 should be invalid", validator.isValidInet6Address(":7777:8888"));422 assertFalse( "IPV6 :6666:7777:8888 should be invalid", validator.isValidInet6Address(":6666:7777:8888"));423 assertFalse( "IPV6 :5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":5555:6666:7777:8888"));424 assertFalse( "IPV6 :4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":4444:5555:6666:7777:8888"));425 assertFalse( "IPV6 :3333:4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":3333:4444:5555:6666:7777:8888"));426 assertFalse( "IPV6 :2222:3333:4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":2222:3333:4444:5555:6666:7777:8888"));427 assertFalse( "IPV6 :1111:2222:3333:4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666:7777:8888"));412 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:8888:"), "IPV6 1111:2222:3333:4444:5555:6666:7777:8888: should be invalid"); 413 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:"), "IPV6 1111:2222:3333:4444:5555:6666:7777: should be invalid"); 414 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:"), "IPV6 1111:2222:3333:4444:5555:6666: should be invalid"); 415 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:"), "IPV6 1111:2222:3333:4444:5555: should be invalid"); 416 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:"), "IPV6 1111:2222:3333:4444: should be invalid"); 417 assertFalse(validator.isValidInet6Address("1111:2222:3333:"), "IPV6 1111:2222:3333: should be invalid"); 418 assertFalse(validator.isValidInet6Address("1111:2222:"), "IPV6 1111:2222: should be invalid"); 419 assertFalse(validator.isValidInet6Address(":8888"), "IPV6 :8888 should be invalid"); 420 assertFalse(validator.isValidInet6Address(":7777:8888"), "IPV6 :7777:8888 should be invalid"); 421 assertFalse(validator.isValidInet6Address(":6666:7777:8888"), "IPV6 :6666:7777:8888 should be invalid"); 422 assertFalse(validator.isValidInet6Address(":5555:6666:7777:8888"), "IPV6 :5555:6666:7777:8888 should be invalid"); 423 assertFalse(validator.isValidInet6Address(":4444:5555:6666:7777:8888"), "IPV6 :4444:5555:6666:7777:8888 should be invalid"); 424 assertFalse(validator.isValidInet6Address(":3333:4444:5555:6666:7777:8888"), "IPV6 :3333:4444:5555:6666:7777:8888 should be invalid"); 425 assertFalse(validator.isValidInet6Address(":2222:3333:4444:5555:6666:7777:8888"), "IPV6 :2222:3333:4444:5555:6666:7777:8888 should be invalid"); 426 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666:7777:8888"), "IPV6 :1111:2222:3333:4444:5555:6666:7777:8888 should be invalid"); 428 427 // ::: 429 assertFalse( "IPV6 :::2222:3333:4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":::2222:3333:4444:5555:6666:7777:8888"));430 assertFalse( "IPV6 1111:::3333:4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address("1111:::3333:4444:5555:6666:7777:8888"));431 assertFalse( "IPV6 1111:2222:::4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address("1111:2222:::4444:5555:6666:7777:8888"));432 assertFalse( "IPV6 1111:2222:3333:::5555:6666:7777:8888 should be invalid", validator.isValidInet6Address("1111:2222:3333:::5555:6666:7777:8888"));433 assertFalse( "IPV6 1111:2222:3333:4444:::6666:7777:8888 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:::6666:7777:8888"));434 assertFalse( "IPV6 1111:2222:3333:4444:5555:::7777:8888 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:::7777:8888"));435 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:::8888 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:::8888"));436 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:7777::: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:::"));428 assertFalse(validator.isValidInet6Address(":::2222:3333:4444:5555:6666:7777:8888"), "IPV6 :::2222:3333:4444:5555:6666:7777:8888 should be invalid"); 429 assertFalse(validator.isValidInet6Address("1111:::3333:4444:5555:6666:7777:8888"), "IPV6 1111:::3333:4444:5555:6666:7777:8888 should be invalid"); 430 assertFalse(validator.isValidInet6Address("1111:2222:::4444:5555:6666:7777:8888"), "IPV6 1111:2222:::4444:5555:6666:7777:8888 should be invalid"); 431 assertFalse(validator.isValidInet6Address("1111:2222:3333:::5555:6666:7777:8888"), "IPV6 1111:2222:3333:::5555:6666:7777:8888 should be invalid"); 432 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:::6666:7777:8888"), "IPV6 1111:2222:3333:4444:::6666:7777:8888 should be invalid"); 433 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:::7777:8888"), "IPV6 1111:2222:3333:4444:5555:::7777:8888 should be invalid"); 434 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:::8888"), "IPV6 1111:2222:3333:4444:5555:6666:::8888 should be invalid"); 435 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:::"), "IPV6 1111:2222:3333:4444:5555:6666:7777::: should be invalid"); 437 436 // Double :: 438 assertFalse( "IPV6 ::2222::4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address("::2222::4444:5555:6666:7777:8888"));439 assertFalse( "IPV6 ::2222:3333::5555:6666:7777:8888 should be invalid", validator.isValidInet6Address("::2222:3333::5555:6666:7777:8888"));440 assertFalse( "IPV6 ::2222:3333:4444::6666:7777:8888 should be invalid", validator.isValidInet6Address("::2222:3333:4444::6666:7777:8888"));441 assertFalse( "IPV6 ::2222:3333:4444:5555::7777:8888 should be invalid", validator.isValidInet6Address("::2222:3333:4444:5555::7777:8888"));442 assertFalse( "IPV6 ::2222:3333:4444:5555:7777::8888 should be invalid", validator.isValidInet6Address("::2222:3333:4444:5555:7777::8888"));443 assertFalse( "IPV6 ::2222:3333:4444:5555:7777:8888:: should be invalid", validator.isValidInet6Address("::2222:3333:4444:5555:7777:8888::"));444 assertFalse( "IPV6 1111::3333::5555:6666:7777:8888 should be invalid", validator.isValidInet6Address("1111::3333::5555:6666:7777:8888"));445 assertFalse( "IPV6 1111::3333:4444::6666:7777:8888 should be invalid", validator.isValidInet6Address("1111::3333:4444::6666:7777:8888"));446 assertFalse( "IPV6 1111::3333:4444:5555::7777:8888 should be invalid", validator.isValidInet6Address("1111::3333:4444:5555::7777:8888"));447 assertFalse( "IPV6 1111::3333:4444:5555:6666::8888 should be invalid", validator.isValidInet6Address("1111::3333:4444:5555:6666::8888"));448 assertFalse( "IPV6 1111::3333:4444:5555:6666:7777:: should be invalid", validator.isValidInet6Address("1111::3333:4444:5555:6666:7777::"));449 assertFalse( "IPV6 1111:2222::4444::6666:7777:8888 should be invalid", validator.isValidInet6Address("1111:2222::4444::6666:7777:8888"));450 assertFalse( "IPV6 1111:2222::4444:5555::7777:8888 should be invalid", validator.isValidInet6Address("1111:2222::4444:5555::7777:8888"));451 assertFalse( "IPV6 1111:2222::4444:5555:6666::8888 should be invalid", validator.isValidInet6Address("1111:2222::4444:5555:6666::8888"));452 assertFalse( "IPV6 1111:2222::4444:5555:6666:7777:: should be invalid", validator.isValidInet6Address("1111:2222::4444:5555:6666:7777::"));453 assertFalse( "IPV6 1111:2222:3333::5555::7777:8888 should be invalid", validator.isValidInet6Address("1111:2222:3333::5555::7777:8888"));454 assertFalse( "IPV6 1111:2222:3333::5555:6666::8888 should be invalid", validator.isValidInet6Address("1111:2222:3333::5555:6666::8888"));455 assertFalse( "IPV6 1111:2222:3333::5555:6666:7777:: should be invalid", validator.isValidInet6Address("1111:2222:3333::5555:6666:7777::"));456 assertFalse( "IPV6 1111:2222:3333:4444::6666::8888 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444::6666::8888"));457 assertFalse( "IPV6 1111:2222:3333:4444::6666:7777:: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444::6666:7777::"));458 assertFalse( "IPV6 1111:2222:3333:4444:5555::7777:: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555::7777::"));437 assertFalse(validator.isValidInet6Address("::2222::4444:5555:6666:7777:8888"), "IPV6 ::2222::4444:5555:6666:7777:8888 should be invalid"); 438 assertFalse(validator.isValidInet6Address("::2222:3333::5555:6666:7777:8888"), "IPV6 ::2222:3333::5555:6666:7777:8888 should be invalid"); 439 assertFalse(validator.isValidInet6Address("::2222:3333:4444::6666:7777:8888"), "IPV6 ::2222:3333:4444::6666:7777:8888 should be invalid"); 440 assertFalse(validator.isValidInet6Address("::2222:3333:4444:5555::7777:8888"), "IPV6 ::2222:3333:4444:5555::7777:8888 should be invalid"); 441 assertFalse(validator.isValidInet6Address("::2222:3333:4444:5555:7777::8888"), "IPV6 ::2222:3333:4444:5555:7777::8888 should be invalid"); 442 assertFalse(validator.isValidInet6Address("::2222:3333:4444:5555:7777:8888::"), "IPV6 ::2222:3333:4444:5555:7777:8888:: should be invalid"); 443 assertFalse(validator.isValidInet6Address("1111::3333::5555:6666:7777:8888"), "IPV6 1111::3333::5555:6666:7777:8888 should be invalid"); 444 assertFalse(validator.isValidInet6Address("1111::3333:4444::6666:7777:8888"), "IPV6 1111::3333:4444::6666:7777:8888 should be invalid"); 445 assertFalse(validator.isValidInet6Address("1111::3333:4444:5555::7777:8888"), "IPV6 1111::3333:4444:5555::7777:8888 should be invalid"); 446 assertFalse(validator.isValidInet6Address("1111::3333:4444:5555:6666::8888"), "IPV6 1111::3333:4444:5555:6666::8888 should be invalid"); 447 assertFalse(validator.isValidInet6Address("1111::3333:4444:5555:6666:7777::"), "IPV6 1111::3333:4444:5555:6666:7777:: should be invalid"); 448 assertFalse(validator.isValidInet6Address("1111:2222::4444::6666:7777:8888"), "IPV6 1111:2222::4444::6666:7777:8888 should be invalid"); 449 assertFalse(validator.isValidInet6Address("1111:2222::4444:5555::7777:8888"), "IPV6 1111:2222::4444:5555::7777:8888 should be invalid"); 450 assertFalse(validator.isValidInet6Address("1111:2222::4444:5555:6666::8888"), "IPV6 1111:2222::4444:5555:6666::8888 should be invalid"); 451 assertFalse(validator.isValidInet6Address("1111:2222::4444:5555:6666:7777::"), "IPV6 1111:2222::4444:5555:6666:7777:: should be invalid"); 452 assertFalse(validator.isValidInet6Address("1111:2222:3333::5555::7777:8888"), "IPV6 1111:2222:3333::5555::7777:8888 should be invalid"); 453 assertFalse(validator.isValidInet6Address("1111:2222:3333::5555:6666::8888"), "IPV6 1111:2222:3333::5555:6666::8888 should be invalid"); 454 assertFalse(validator.isValidInet6Address("1111:2222:3333::5555:6666:7777::"), "IPV6 1111:2222:3333::5555:6666:7777:: should be invalid"); 455 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444::6666::8888"), "IPV6 1111:2222:3333:4444::6666::8888 should be invalid"); 456 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444::6666:7777::"), "IPV6 1111:2222:3333:4444::6666:7777:: should be invalid"); 457 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555::7777::"), "IPV6 1111:2222:3333:4444:5555::7777:: should be invalid"); 459 458 // Too many components" 460 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:7777:8888:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:8888:1.2.3.4"));461 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:7777:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:1.2.3.4"));462 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666::1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666::1.2.3.4"));463 assertFalse( "IPV6 ::2222:3333:4444:5555:6666:7777:1.2.3.4 should be invalid", validator.isValidInet6Address("::2222:3333:4444:5555:6666:7777:1.2.3.4"));464 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:1.2.3.4.5 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:1.2.3.4.5"));459 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:8888:1.2.3.4"), "IPV6 1111:2222:3333:4444:5555:6666:7777:8888:1.2.3.4 should be invalid"); 460 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:1.2.3.4"), "IPV6 1111:2222:3333:4444:5555:6666:7777:1.2.3.4 should be invalid"); 461 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666::1.2.3.4"), "IPV6 1111:2222:3333:4444:5555:6666::1.2.3.4 should be invalid"); 462 assertFalse(validator.isValidInet6Address("::2222:3333:4444:5555:6666:7777:1.2.3.4"), "IPV6 ::2222:3333:4444:5555:6666:7777:1.2.3.4 should be invalid"); 463 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:1.2.3.4.5"), "IPV6 1111:2222:3333:4444:5555:6666:1.2.3.4.5 should be invalid"); 465 464 // Too few components 466 assertFalse( "IPV6 1111:2222:3333:4444:5555:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:1.2.3.4"));467 assertFalse( "IPV6 1111:2222:3333:4444:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:1.2.3.4"));468 assertFalse( "IPV6 1111:2222:3333:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:1.2.3.4"));469 assertFalse( "IPV6 1111:2222:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:1.2.3.4"));470 assertFalse( "IPV6 1111:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:1.2.3.4"));471 assertFalse( "IPV6 1.2.3.4 should be invalid", validator.isValidInet6Address("1.2.3.4"));465 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:1.2.3.4"), "IPV6 1111:2222:3333:4444:5555:1.2.3.4 should be invalid"); 466 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:1.2.3.4"), "IPV6 1111:2222:3333:4444:1.2.3.4 should be invalid"); 467 assertFalse(validator.isValidInet6Address("1111:2222:3333:1.2.3.4"), "IPV6 1111:2222:3333:1.2.3.4 should be invalid"); 468 assertFalse(validator.isValidInet6Address("1111:2222:1.2.3.4"), "IPV6 1111:2222:1.2.3.4 should be invalid"); 469 assertFalse(validator.isValidInet6Address("1111:1.2.3.4"), "IPV6 1111:1.2.3.4 should be invalid"); 470 assertFalse(validator.isValidInet6Address("1.2.3.4"), "IPV6 1.2.3.4 should be invalid"); 472 471 // Missing : 473 assertFalse( "IPV6 11112222:3333:4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address("11112222:3333:4444:5555:6666:1.2.3.4"));474 assertFalse( "IPV6 1111:22223333:4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:22223333:4444:5555:6666:1.2.3.4"));475 assertFalse( "IPV6 1111:2222:33334444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:33334444:5555:6666:1.2.3.4"));476 assertFalse( "IPV6 1111:2222:3333:44445555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:44445555:6666:1.2.3.4"));477 assertFalse( "IPV6 1111:2222:3333:4444:55556666:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:55556666:1.2.3.4"));478 assertFalse( "IPV6 1111:2222:3333:4444:5555:66661.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:66661.2.3.4"));472 assertFalse(validator.isValidInet6Address("11112222:3333:4444:5555:6666:1.2.3.4"), "IPV6 11112222:3333:4444:5555:6666:1.2.3.4 should be invalid"); 473 assertFalse(validator.isValidInet6Address("1111:22223333:4444:5555:6666:1.2.3.4"), "IPV6 1111:22223333:4444:5555:6666:1.2.3.4 should be invalid"); 474 assertFalse(validator.isValidInet6Address("1111:2222:33334444:5555:6666:1.2.3.4"), "IPV6 1111:2222:33334444:5555:6666:1.2.3.4 should be invalid"); 475 assertFalse(validator.isValidInet6Address("1111:2222:3333:44445555:6666:1.2.3.4"), "IPV6 1111:2222:3333:44445555:6666:1.2.3.4 should be invalid"); 476 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:55556666:1.2.3.4"), "IPV6 1111:2222:3333:4444:55556666:1.2.3.4 should be invalid"); 477 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:66661.2.3.4"), "IPV6 1111:2222:3333:4444:5555:66661.2.3.4 should be invalid"); 479 478 // Missing . 480 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:255255.255.255 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:255255.255.255"));481 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:255.255255.255 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:255.255255.255"));482 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:255.255.255255 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:255.255.255255"));479 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:255255.255.255"), "IPV6 1111:2222:3333:4444:5555:6666:255255.255.255 should be invalid"); 480 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:255.255255.255"), "IPV6 1111:2222:3333:4444:5555:6666:255.255255.255 should be invalid"); 481 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:255.255.255255"), "IPV6 1111:2222:3333:4444:5555:6666:255.255.255255 should be invalid"); 483 482 // Missing : intended for :: 484 assertFalse( "IPV6 :1.2.3.4 should be invalid", validator.isValidInet6Address(":1.2.3.4"));485 assertFalse( "IPV6 :6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":6666:1.2.3.4"));486 assertFalse( "IPV6 :5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":5555:6666:1.2.3.4"));487 assertFalse( "IPV6 :4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":4444:5555:6666:1.2.3.4"));488 assertFalse( "IPV6 :3333:4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":3333:4444:5555:6666:1.2.3.4"));489 assertFalse( "IPV6 :2222:3333:4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":2222:3333:4444:5555:6666:1.2.3.4"));490 assertFalse( "IPV6 :1111:2222:3333:4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666:1.2.3.4"));483 assertFalse(validator.isValidInet6Address(":1.2.3.4"), "IPV6 :1.2.3.4 should be invalid"); 484 assertFalse(validator.isValidInet6Address(":6666:1.2.3.4"), "IPV6 :6666:1.2.3.4 should be invalid"); 485 assertFalse(validator.isValidInet6Address(":5555:6666:1.2.3.4"), "IPV6 :5555:6666:1.2.3.4 should be invalid"); 486 assertFalse(validator.isValidInet6Address(":4444:5555:6666:1.2.3.4"), "IPV6 :4444:5555:6666:1.2.3.4 should be invalid"); 487 assertFalse(validator.isValidInet6Address(":3333:4444:5555:6666:1.2.3.4"), "IPV6 :3333:4444:5555:6666:1.2.3.4 should be invalid"); 488 assertFalse(validator.isValidInet6Address(":2222:3333:4444:5555:6666:1.2.3.4"), "IPV6 :2222:3333:4444:5555:6666:1.2.3.4 should be invalid"); 489 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666:1.2.3.4"), "IPV6 :1111:2222:3333:4444:5555:6666:1.2.3.4 should be invalid"); 491 490 // ::: 492 assertFalse( "IPV6 :::2222:3333:4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":::2222:3333:4444:5555:6666:1.2.3.4"));493 assertFalse( "IPV6 1111:::3333:4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:::3333:4444:5555:6666:1.2.3.4"));494 assertFalse( "IPV6 1111:2222:::4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:::4444:5555:6666:1.2.3.4"));495 assertFalse( "IPV6 1111:2222:3333:::5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:::5555:6666:1.2.3.4"));496 assertFalse( "IPV6 1111:2222:3333:4444:::6666:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:::6666:1.2.3.4"));497 assertFalse( "IPV6 1111:2222:3333:4444:5555:::1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:::1.2.3.4"));491 assertFalse(validator.isValidInet6Address(":::2222:3333:4444:5555:6666:1.2.3.4"), "IPV6 :::2222:3333:4444:5555:6666:1.2.3.4 should be invalid"); 492 assertFalse(validator.isValidInet6Address("1111:::3333:4444:5555:6666:1.2.3.4"), "IPV6 1111:::3333:4444:5555:6666:1.2.3.4 should be invalid"); 493 assertFalse(validator.isValidInet6Address("1111:2222:::4444:5555:6666:1.2.3.4"), "IPV6 1111:2222:::4444:5555:6666:1.2.3.4 should be invalid"); 494 assertFalse(validator.isValidInet6Address("1111:2222:3333:::5555:6666:1.2.3.4"), "IPV6 1111:2222:3333:::5555:6666:1.2.3.4 should be invalid"); 495 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:::6666:1.2.3.4"), "IPV6 1111:2222:3333:4444:::6666:1.2.3.4 should be invalid"); 496 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:::1.2.3.4"), "IPV6 1111:2222:3333:4444:5555:::1.2.3.4 should be invalid"); 498 497 // Double :: 499 assertFalse( "IPV6 ::2222::4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address("::2222::4444:5555:6666:1.2.3.4"));500 assertFalse( "IPV6 ::2222:3333::5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address("::2222:3333::5555:6666:1.2.3.4"));501 assertFalse( "IPV6 ::2222:3333:4444::6666:1.2.3.4 should be invalid", validator.isValidInet6Address("::2222:3333:4444::6666:1.2.3.4"));502 assertFalse( "IPV6 ::2222:3333:4444:5555::1.2.3.4 should be invalid", validator.isValidInet6Address("::2222:3333:4444:5555::1.2.3.4"));503 assertFalse( "IPV6 1111::3333::5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address("1111::3333::5555:6666:1.2.3.4"));504 assertFalse( "IPV6 1111::3333:4444::6666:1.2.3.4 should be invalid", validator.isValidInet6Address("1111::3333:4444::6666:1.2.3.4"));505 assertFalse( "IPV6 1111::3333:4444:5555::1.2.3.4 should be invalid", validator.isValidInet6Address("1111::3333:4444:5555::1.2.3.4"));506 assertFalse( "IPV6 1111:2222::4444::6666:1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222::4444::6666:1.2.3.4"));507 assertFalse( "IPV6 1111:2222::4444:5555::1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222::4444:5555::1.2.3.4"));508 assertFalse( "IPV6 1111:2222:3333::5555::1.2.3.4 should be invalid", validator.isValidInet6Address("1111:2222:3333::5555::1.2.3.4"));498 assertFalse(validator.isValidInet6Address("::2222::4444:5555:6666:1.2.3.4"), "IPV6 ::2222::4444:5555:6666:1.2.3.4 should be invalid"); 499 assertFalse(validator.isValidInet6Address("::2222:3333::5555:6666:1.2.3.4"), "IPV6 ::2222:3333::5555:6666:1.2.3.4 should be invalid"); 500 assertFalse(validator.isValidInet6Address("::2222:3333:4444::6666:1.2.3.4"), "IPV6 ::2222:3333:4444::6666:1.2.3.4 should be invalid"); 501 assertFalse(validator.isValidInet6Address("::2222:3333:4444:5555::1.2.3.4"), "IPV6 ::2222:3333:4444:5555::1.2.3.4 should be invalid"); 502 assertFalse(validator.isValidInet6Address("1111::3333::5555:6666:1.2.3.4"), "IPV6 1111::3333::5555:6666:1.2.3.4 should be invalid"); 503 assertFalse(validator.isValidInet6Address("1111::3333:4444::6666:1.2.3.4"), "IPV6 1111::3333:4444::6666:1.2.3.4 should be invalid"); 504 assertFalse(validator.isValidInet6Address("1111::3333:4444:5555::1.2.3.4"), "IPV6 1111::3333:4444:5555::1.2.3.4 should be invalid"); 505 assertFalse(validator.isValidInet6Address("1111:2222::4444::6666:1.2.3.4"), "IPV6 1111:2222::4444::6666:1.2.3.4 should be invalid"); 506 assertFalse(validator.isValidInet6Address("1111:2222::4444:5555::1.2.3.4"), "IPV6 1111:2222::4444:5555::1.2.3.4 should be invalid"); 507 assertFalse(validator.isValidInet6Address("1111:2222:3333::5555::1.2.3.4"), "IPV6 1111:2222:3333::5555::1.2.3.4 should be invalid"); 509 508 // Missing parts 510 assertFalse( "IPV6 ::. should be invalid", validator.isValidInet6Address("::."));511 assertFalse( "IPV6 ::.. should be invalid", validator.isValidInet6Address("::.."));512 assertFalse( "IPV6 ::... should be invalid", validator.isValidInet6Address("::..."));513 assertFalse( "IPV6 ::1... should be invalid", validator.isValidInet6Address("::1..."));514 assertFalse( "IPV6 ::1.2.. should be invalid", validator.isValidInet6Address("::1.2.."));515 assertFalse( "IPV6 ::1.2.3. should be invalid", validator.isValidInet6Address("::1.2.3."));516 assertFalse( "IPV6 ::.2.. should be invalid", validator.isValidInet6Address("::.2.."));517 assertFalse( "IPV6 ::.2.3. should be invalid", validator.isValidInet6Address("::.2.3."));518 assertFalse( "IPV6 ::.2.3.4 should be invalid", validator.isValidInet6Address("::.2.3.4"));519 assertFalse( "IPV6 ::..3. should be invalid", validator.isValidInet6Address("::..3."));520 assertFalse( "IPV6 ::..3.4 should be invalid", validator.isValidInet6Address("::..3.4"));521 assertFalse( "IPV6 ::...4 should be invalid", validator.isValidInet6Address("::...4"));509 assertFalse(validator.isValidInet6Address("::."), "IPV6 ::. should be invalid"); 510 assertFalse(validator.isValidInet6Address("::.."), "IPV6 ::.. should be invalid"); 511 assertFalse(validator.isValidInet6Address("::..."), "IPV6 ::... should be invalid"); 512 assertFalse(validator.isValidInet6Address("::1..."), "IPV6 ::1... should be invalid"); 513 assertFalse(validator.isValidInet6Address("::1.2.."), "IPV6 ::1.2.. should be invalid"); 514 assertFalse(validator.isValidInet6Address("::1.2.3."), "IPV6 ::1.2.3. should be invalid"); 515 assertFalse(validator.isValidInet6Address("::.2.."), "IPV6 ::.2.. should be invalid"); 516 assertFalse(validator.isValidInet6Address("::.2.3."), "IPV6 ::.2.3. should be invalid"); 517 assertFalse(validator.isValidInet6Address("::.2.3.4"), "IPV6 ::.2.3.4 should be invalid"); 518 assertFalse(validator.isValidInet6Address("::..3."), "IPV6 ::..3. should be invalid"); 519 assertFalse(validator.isValidInet6Address("::..3.4"), "IPV6 ::..3.4 should be invalid"); 520 assertFalse(validator.isValidInet6Address("::...4"), "IPV6 ::...4 should be invalid"); 522 521 // Extra : in front 523 assertFalse( "IPV6 :1111:2222:3333:4444:5555:6666:7777:: should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666:7777::"));524 assertFalse( "IPV6 :1111:2222:3333:4444:5555:6666:: should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666::"));525 assertFalse( "IPV6 :1111:2222:3333:4444:5555:: should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444:5555::"));526 assertFalse( "IPV6 :1111:2222:3333:4444:: should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444::"));527 assertFalse( "IPV6 :1111:2222:3333:: should be invalid", validator.isValidInet6Address(":1111:2222:3333::"));528 assertFalse( "IPV6 :1111:2222:: should be invalid", validator.isValidInet6Address(":1111:2222::"));529 assertFalse( "IPV6 :1111:: should be invalid", validator.isValidInet6Address(":1111::"));530 assertFalse( "IPV6 :1111:2222:3333:4444:5555:6666::8888 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666::8888"));531 assertFalse( "IPV6 :1111:2222:3333:4444:5555::8888 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444:5555::8888"));532 assertFalse( "IPV6 :1111:2222:3333:4444::8888 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444::8888"));533 assertFalse( "IPV6 :1111:2222:3333::8888 should be invalid", validator.isValidInet6Address(":1111:2222:3333::8888"));534 assertFalse( "IPV6 :1111:2222::8888 should be invalid", validator.isValidInet6Address(":1111:2222::8888"));535 assertFalse( "IPV6 :1111::8888 should be invalid", validator.isValidInet6Address(":1111::8888"));536 assertFalse( "IPV6 :::8888 should be invalid", validator.isValidInet6Address(":::8888"));537 assertFalse( "IPV6 :1111:2222:3333:4444:5555::7777:8888 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444:5555::7777:8888"));538 assertFalse( "IPV6 :1111:2222:3333:4444::7777:8888 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444::7777:8888"));539 assertFalse( "IPV6 :1111:2222:3333::7777:8888 should be invalid", validator.isValidInet6Address(":1111:2222:3333::7777:8888"));540 assertFalse( "IPV6 :1111:2222::7777:8888 should be invalid", validator.isValidInet6Address(":1111:2222::7777:8888"));541 assertFalse( "IPV6 :1111::7777:8888 should be invalid", validator.isValidInet6Address(":1111::7777:8888"));542 assertFalse( "IPV6 :::7777:8888 should be invalid", validator.isValidInet6Address(":::7777:8888"));543 assertFalse( "IPV6 :1111:2222:3333:4444::6666:7777:8888 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444::6666:7777:8888"));544 assertFalse( "IPV6 :1111:2222:3333::6666:7777:8888 should be invalid", validator.isValidInet6Address(":1111:2222:3333::6666:7777:8888"));545 assertFalse( "IPV6 :1111:2222::6666:7777:8888 should be invalid", validator.isValidInet6Address(":1111:2222::6666:7777:8888"));546 assertFalse( "IPV6 :1111::6666:7777:8888 should be invalid", validator.isValidInet6Address(":1111::6666:7777:8888"));547 assertFalse( "IPV6 :::6666:7777:8888 should be invalid", validator.isValidInet6Address(":::6666:7777:8888"));548 assertFalse( "IPV6 :1111:2222:3333::5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":1111:2222:3333::5555:6666:7777:8888"));549 assertFalse( "IPV6 :1111:2222::5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":1111:2222::5555:6666:7777:8888"));550 assertFalse( "IPV6 :1111::5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":1111::5555:6666:7777:8888"));551 assertFalse( "IPV6 :::5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":::5555:6666:7777:8888"));552 assertFalse( "IPV6 :1111:2222::4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":1111:2222::4444:5555:6666:7777:8888"));553 assertFalse( "IPV6 :1111::4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":1111::4444:5555:6666:7777:8888"));554 assertFalse( "IPV6 :::4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":::4444:5555:6666:7777:8888"));555 assertFalse( "IPV6 :1111::3333:4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":1111::3333:4444:5555:6666:7777:8888"));556 assertFalse( "IPV6 :::3333:4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":::3333:4444:5555:6666:7777:8888"));557 assertFalse( "IPV6 :::2222:3333:4444:5555:6666:7777:8888 should be invalid", validator.isValidInet6Address(":::2222:3333:4444:5555:6666:7777:8888"));558 assertFalse( "IPV6 :1111:2222:3333:4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666:1.2.3.4"));559 assertFalse( "IPV6 :1111:2222:3333:4444:5555::1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444:5555::1.2.3.4"));560 assertFalse( "IPV6 :1111:2222:3333:4444::1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444::1.2.3.4"));561 assertFalse( "IPV6 :1111:2222:3333::1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222:3333::1.2.3.4"));562 assertFalse( "IPV6 :1111:2222::1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222::1.2.3.4"));563 assertFalse( "IPV6 :1111::1.2.3.4 should be invalid", validator.isValidInet6Address(":1111::1.2.3.4"));564 assertFalse( "IPV6 :::1.2.3.4 should be invalid", validator.isValidInet6Address(":::1.2.3.4"));565 assertFalse( "IPV6 :1111:2222:3333:4444::6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222:3333:4444::6666:1.2.3.4"));566 assertFalse( "IPV6 :1111:2222:3333::6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222:3333::6666:1.2.3.4"));567 assertFalse( "IPV6 :1111:2222::6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222::6666:1.2.3.4"));568 assertFalse( "IPV6 :1111::6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111::6666:1.2.3.4"));569 assertFalse( "IPV6 :::6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":::6666:1.2.3.4"));570 assertFalse( "IPV6 :1111:2222:3333::5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222:3333::5555:6666:1.2.3.4"));571 assertFalse( "IPV6 :1111:2222::5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222::5555:6666:1.2.3.4"));572 assertFalse( "IPV6 :1111::5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111::5555:6666:1.2.3.4"));573 assertFalse( "IPV6 :::5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":::5555:6666:1.2.3.4"));574 assertFalse( "IPV6 :1111:2222::4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111:2222::4444:5555:6666:1.2.3.4"));575 assertFalse( "IPV6 :1111::4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111::4444:5555:6666:1.2.3.4"));576 assertFalse( "IPV6 :::4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":::4444:5555:6666:1.2.3.4"));577 assertFalse( "IPV6 :1111::3333:4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":1111::3333:4444:5555:6666:1.2.3.4"));578 assertFalse( "IPV6 :::2222:3333:4444:5555:6666:1.2.3.4 should be invalid", validator.isValidInet6Address(":::2222:3333:4444:5555:6666:1.2.3.4"));522 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666:7777::"), "IPV6 :1111:2222:3333:4444:5555:6666:7777:: should be invalid"); 523 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666::"), "IPV6 :1111:2222:3333:4444:5555:6666:: should be invalid"); 524 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444:5555::"), "IPV6 :1111:2222:3333:4444:5555:: should be invalid"); 525 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444::"), "IPV6 :1111:2222:3333:4444:: should be invalid"); 526 assertFalse(validator.isValidInet6Address(":1111:2222:3333::"), "IPV6 :1111:2222:3333:: should be invalid"); 527 assertFalse(validator.isValidInet6Address(":1111:2222::"), "IPV6 :1111:2222:: should be invalid"); 528 assertFalse(validator.isValidInet6Address(":1111::"), "IPV6 :1111:: should be invalid"); 529 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666::8888"), "IPV6 :1111:2222:3333:4444:5555:6666::8888 should be invalid"); 530 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444:5555::8888"), "IPV6 :1111:2222:3333:4444:5555::8888 should be invalid"); 531 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444::8888"), "IPV6 :1111:2222:3333:4444::8888 should be invalid"); 532 assertFalse(validator.isValidInet6Address(":1111:2222:3333::8888"), "IPV6 :1111:2222:3333::8888 should be invalid"); 533 assertFalse(validator.isValidInet6Address(":1111:2222::8888"), "IPV6 :1111:2222::8888 should be invalid"); 534 assertFalse(validator.isValidInet6Address(":1111::8888"), "IPV6 :1111::8888 should be invalid"); 535 assertFalse(validator.isValidInet6Address(":::8888"), "IPV6 :::8888 should be invalid"); 536 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444:5555::7777:8888"), "IPV6 :1111:2222:3333:4444:5555::7777:8888 should be invalid"); 537 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444::7777:8888"), "IPV6 :1111:2222:3333:4444::7777:8888 should be invalid"); 538 assertFalse(validator.isValidInet6Address(":1111:2222:3333::7777:8888"), "IPV6 :1111:2222:3333::7777:8888 should be invalid"); 539 assertFalse(validator.isValidInet6Address(":1111:2222::7777:8888"), "IPV6 :1111:2222::7777:8888 should be invalid"); 540 assertFalse(validator.isValidInet6Address(":1111::7777:8888"), "IPV6 :1111::7777:8888 should be invalid"); 541 assertFalse(validator.isValidInet6Address(":::7777:8888"), "IPV6 :::7777:8888 should be invalid"); 542 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444::6666:7777:8888"), "IPV6 :1111:2222:3333:4444::6666:7777:8888 should be invalid"); 543 assertFalse(validator.isValidInet6Address(":1111:2222:3333::6666:7777:8888"), "IPV6 :1111:2222:3333::6666:7777:8888 should be invalid"); 544 assertFalse(validator.isValidInet6Address(":1111:2222::6666:7777:8888"), "IPV6 :1111:2222::6666:7777:8888 should be invalid"); 545 assertFalse(validator.isValidInet6Address(":1111::6666:7777:8888"), "IPV6 :1111::6666:7777:8888 should be invalid"); 546 assertFalse(validator.isValidInet6Address(":::6666:7777:8888"), "IPV6 :::6666:7777:8888 should be invalid"); 547 assertFalse(validator.isValidInet6Address(":1111:2222:3333::5555:6666:7777:8888"), "IPV6 :1111:2222:3333::5555:6666:7777:8888 should be invalid"); 548 assertFalse(validator.isValidInet6Address(":1111:2222::5555:6666:7777:8888"), "IPV6 :1111:2222::5555:6666:7777:8888 should be invalid"); 549 assertFalse(validator.isValidInet6Address(":1111::5555:6666:7777:8888"), "IPV6 :1111::5555:6666:7777:8888 should be invalid"); 550 assertFalse(validator.isValidInet6Address(":::5555:6666:7777:8888"), "IPV6 :::5555:6666:7777:8888 should be invalid"); 551 assertFalse(validator.isValidInet6Address(":1111:2222::4444:5555:6666:7777:8888"), "IPV6 :1111:2222::4444:5555:6666:7777:8888 should be invalid"); 552 assertFalse(validator.isValidInet6Address(":1111::4444:5555:6666:7777:8888"), "IPV6 :1111::4444:5555:6666:7777:8888 should be invalid"); 553 assertFalse(validator.isValidInet6Address(":::4444:5555:6666:7777:8888"), "IPV6 :::4444:5555:6666:7777:8888 should be invalid"); 554 assertFalse(validator.isValidInet6Address(":1111::3333:4444:5555:6666:7777:8888"), "IPV6 :1111::3333:4444:5555:6666:7777:8888 should be invalid"); 555 assertFalse(validator.isValidInet6Address(":::3333:4444:5555:6666:7777:8888"), "IPV6 :::3333:4444:5555:6666:7777:8888 should be invalid"); 556 assertFalse(validator.isValidInet6Address(":::2222:3333:4444:5555:6666:7777:8888"), "IPV6 :::2222:3333:4444:5555:6666:7777:8888 should be invalid"); 557 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444:5555:6666:1.2.3.4"), "IPV6 :1111:2222:3333:4444:5555:6666:1.2.3.4 should be invalid"); 558 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444:5555::1.2.3.4"), "IPV6 :1111:2222:3333:4444:5555::1.2.3.4 should be invalid"); 559 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444::1.2.3.4"), "IPV6 :1111:2222:3333:4444::1.2.3.4 should be invalid"); 560 assertFalse(validator.isValidInet6Address(":1111:2222:3333::1.2.3.4"), "IPV6 :1111:2222:3333::1.2.3.4 should be invalid"); 561 assertFalse(validator.isValidInet6Address(":1111:2222::1.2.3.4"), "IPV6 :1111:2222::1.2.3.4 should be invalid"); 562 assertFalse(validator.isValidInet6Address(":1111::1.2.3.4"), "IPV6 :1111::1.2.3.4 should be invalid"); 563 assertFalse(validator.isValidInet6Address(":::1.2.3.4"), "IPV6 :::1.2.3.4 should be invalid"); 564 assertFalse(validator.isValidInet6Address(":1111:2222:3333:4444::6666:1.2.3.4"), "IPV6 :1111:2222:3333:4444::6666:1.2.3.4 should be invalid"); 565 assertFalse(validator.isValidInet6Address(":1111:2222:3333::6666:1.2.3.4"), "IPV6 :1111:2222:3333::6666:1.2.3.4 should be invalid"); 566 assertFalse(validator.isValidInet6Address(":1111:2222::6666:1.2.3.4"), "IPV6 :1111:2222::6666:1.2.3.4 should be invalid"); 567 assertFalse(validator.isValidInet6Address(":1111::6666:1.2.3.4"), "IPV6 :1111::6666:1.2.3.4 should be invalid"); 568 assertFalse(validator.isValidInet6Address(":::6666:1.2.3.4"), "IPV6 :::6666:1.2.3.4 should be invalid"); 569 assertFalse(validator.isValidInet6Address(":1111:2222:3333::5555:6666:1.2.3.4"), "IPV6 :1111:2222:3333::5555:6666:1.2.3.4 should be invalid"); 570 assertFalse(validator.isValidInet6Address(":1111:2222::5555:6666:1.2.3.4"), "IPV6 :1111:2222::5555:6666:1.2.3.4 should be invalid"); 571 assertFalse(validator.isValidInet6Address(":1111::5555:6666:1.2.3.4"), "IPV6 :1111::5555:6666:1.2.3.4 should be invalid"); 572 assertFalse(validator.isValidInet6Address(":::5555:6666:1.2.3.4"), "IPV6 :::5555:6666:1.2.3.4 should be invalid"); 573 assertFalse(validator.isValidInet6Address(":1111:2222::4444:5555:6666:1.2.3.4"), "IPV6 :1111:2222::4444:5555:6666:1.2.3.4 should be invalid"); 574 assertFalse(validator.isValidInet6Address(":1111::4444:5555:6666:1.2.3.4"), "IPV6 :1111::4444:5555:6666:1.2.3.4 should be invalid"); 575 assertFalse(validator.isValidInet6Address(":::4444:5555:6666:1.2.3.4"), "IPV6 :::4444:5555:6666:1.2.3.4 should be invalid"); 576 assertFalse(validator.isValidInet6Address(":1111::3333:4444:5555:6666:1.2.3.4"), "IPV6 :1111::3333:4444:5555:6666:1.2.3.4 should be invalid"); 577 assertFalse(validator.isValidInet6Address(":::2222:3333:4444:5555:6666:1.2.3.4"), "IPV6 :::2222:3333:4444:5555:6666:1.2.3.4 should be invalid"); 579 578 // Extra : at end 580 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666:7777::: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:::"));581 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666::: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:::"));582 assertFalse( "IPV6 1111:2222:3333:4444:5555::: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:::"));583 assertFalse( "IPV6 1111:2222:3333:4444::: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:::"));584 assertFalse( "IPV6 1111:2222:3333::: should be invalid", validator.isValidInet6Address("1111:2222:3333:::"));585 assertFalse( "IPV6 1111:2222::: should be invalid", validator.isValidInet6Address("1111:2222:::"));586 assertFalse( "IPV6 1111::: should be invalid", validator.isValidInet6Address("1111:::"));587 assertFalse( "IPV6 1111:2222:3333:4444:5555:6666::8888: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555:6666::8888:"));588 assertFalse( "IPV6 1111:2222:3333:4444:5555::8888: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555::8888:"));589 assertFalse( "IPV6 1111:2222:3333:4444::8888: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444::8888:"));590 assertFalse( "IPV6 1111:2222:3333::8888: should be invalid", validator.isValidInet6Address("1111:2222:3333::8888:"));591 assertFalse( "IPV6 1111:2222::8888: should be invalid", validator.isValidInet6Address("1111:2222::8888:"));592 assertFalse( "IPV6 1111::8888: should be invalid", validator.isValidInet6Address("1111::8888:"));593 assertFalse( "IPV6 ::8888: should be invalid", validator.isValidInet6Address("::8888:"));594 assertFalse( "IPV6 1111:2222:3333:4444:5555::7777:8888: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444:5555::7777:8888:"));595 assertFalse( "IPV6 1111:2222:3333:4444::7777:8888: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444::7777:8888:"));596 assertFalse( "IPV6 1111:2222:3333::7777:8888: should be invalid", validator.isValidInet6Address("1111:2222:3333::7777:8888:"));597 assertFalse( "IPV6 1111:2222::7777:8888: should be invalid", validator.isValidInet6Address("1111:2222::7777:8888:"));598 assertFalse( "IPV6 1111::7777:8888: should be invalid", validator.isValidInet6Address("1111::7777:8888:"));599 assertFalse( "IPV6 ::7777:8888: should be invalid", validator.isValidInet6Address("::7777:8888:"));600 assertFalse( "IPV6 1111:2222:3333:4444::6666:7777:8888: should be invalid", validator.isValidInet6Address("1111:2222:3333:4444::6666:7777:8888:"));601 assertFalse( "IPV6 1111:2222:3333::6666:7777:8888: should be invalid", validator.isValidInet6Address("1111:2222:3333::6666:7777:8888:"));602 assertFalse( "IPV6 1111:2222::6666:7777:8888: should be invalid", validator.isValidInet6Address("1111:2222::6666:7777:8888:"));603 assertFalse( "IPV6 1111::6666:7777:8888: should be invalid", validator.isValidInet6Address("1111::6666:7777:8888:"));604 assertFalse( "IPV6 ::6666:7777:8888: should be invalid", validator.isValidInet6Address("::6666:7777:8888:"));605 assertFalse( "IPV6 1111:2222:3333::5555:6666:7777:8888: should be invalid", validator.isValidInet6Address("1111:2222:3333::5555:6666:7777:8888:"));606 assertFalse( "IPV6 1111:2222::5555:6666:7777:8888: should be invalid", validator.isValidInet6Address("1111:2222::5555:6666:7777:8888:"));607 assertFalse( "IPV6 1111::5555:6666:7777:8888: should be invalid", validator.isValidInet6Address("1111::5555:6666:7777:8888:"));608 assertFalse( "IPV6 ::5555:6666:7777:8888: should be invalid", validator.isValidInet6Address("::5555:6666:7777:8888:"));609 assertFalse( "IPV6 1111:2222::4444:5555:6666:7777:8888: should be invalid", validator.isValidInet6Address("1111:2222::4444:5555:6666:7777:8888:"));610 assertFalse( "IPV6 1111::4444:5555:6666:7777:8888: should be invalid", validator.isValidInet6Address("1111::4444:5555:6666:7777:8888:"));611 assertFalse( "IPV6 ::4444:5555:6666:7777:8888: should be invalid", validator.isValidInet6Address("::4444:5555:6666:7777:8888:"));612 assertFalse( "IPV6 1111::3333:4444:5555:6666:7777:8888: should be invalid", validator.isValidInet6Address("1111::3333:4444:5555:6666:7777:8888:"));613 assertFalse( "IPV6 ::3333:4444:5555:6666:7777:8888: should be invalid", validator.isValidInet6Address("::3333:4444:5555:6666:7777:8888:"));614 assertFalse( "IPV6 ::2222:3333:4444:5555:6666:7777:8888: should be invalid", validator.isValidInet6Address("::2222:3333:4444:5555:6666:7777:8888:"));615 assertTrue( "IPV6 0:a:b:c:d:e:f:: should be valid", validator.isValidInet6Address("0:a:b:c:d:e:f::"));616 assertTrue( "IPV6 ::0:a:b:c:d:e:f should be valid", validator.isValidInet6Address("::0:a:b:c:d:e:f")); // syntactically correct, but bad form (::0:... could be combined)617 assertTrue( "IPV6 a:b:c:d:e:f:0:: should be valid", validator.isValidInet6Address("a:b:c:d:e:f:0::"));618 assertFalse( "IPV6 ':10.0.0.1 should be invalid", validator.isValidInet6Address("':10.0.0.1"));579 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:7777:::"), "IPV6 1111:2222:3333:4444:5555:6666:7777::: should be invalid"); 580 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666:::"), "IPV6 1111:2222:3333:4444:5555:6666::: should be invalid"); 581 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:::"), "IPV6 1111:2222:3333:4444:5555::: should be invalid"); 582 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:::"), "IPV6 1111:2222:3333:4444::: should be invalid"); 583 assertFalse(validator.isValidInet6Address("1111:2222:3333:::"), "IPV6 1111:2222:3333::: should be invalid"); 584 assertFalse(validator.isValidInet6Address("1111:2222:::"), "IPV6 1111:2222::: should be invalid"); 585 assertFalse(validator.isValidInet6Address("1111:::"), "IPV6 1111::: should be invalid"); 586 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555:6666::8888:"), "IPV6 1111:2222:3333:4444:5555:6666::8888: should be invalid"); 587 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555::8888:"), "IPV6 1111:2222:3333:4444:5555::8888: should be invalid"); 588 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444::8888:"), "IPV6 1111:2222:3333:4444::8888: should be invalid"); 589 assertFalse(validator.isValidInet6Address("1111:2222:3333::8888:"), "IPV6 1111:2222:3333::8888: should be invalid"); 590 assertFalse(validator.isValidInet6Address("1111:2222::8888:"), "IPV6 1111:2222::8888: should be invalid"); 591 assertFalse(validator.isValidInet6Address("1111::8888:"), "IPV6 1111::8888: should be invalid"); 592 assertFalse(validator.isValidInet6Address("::8888:"), "IPV6 ::8888: should be invalid"); 593 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444:5555::7777:8888:"), "IPV6 1111:2222:3333:4444:5555::7777:8888: should be invalid"); 594 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444::7777:8888:"), "IPV6 1111:2222:3333:4444::7777:8888: should be invalid"); 595 assertFalse(validator.isValidInet6Address("1111:2222:3333::7777:8888:"), "IPV6 1111:2222:3333::7777:8888: should be invalid"); 596 assertFalse(validator.isValidInet6Address("1111:2222::7777:8888:"), "IPV6 1111:2222::7777:8888: should be invalid"); 597 assertFalse(validator.isValidInet6Address("1111::7777:8888:"), "IPV6 1111::7777:8888: should be invalid"); 598 assertFalse(validator.isValidInet6Address("::7777:8888:"), "IPV6 ::7777:8888: should be invalid"); 599 assertFalse(validator.isValidInet6Address("1111:2222:3333:4444::6666:7777:8888:"), "IPV6 1111:2222:3333:4444::6666:7777:8888: should be invalid"); 600 assertFalse(validator.isValidInet6Address("1111:2222:3333::6666:7777:8888:"), "IPV6 1111:2222:3333::6666:7777:8888: should be invalid"); 601 assertFalse(validator.isValidInet6Address("1111:2222::6666:7777:8888:"), "IPV6 1111:2222::6666:7777:8888: should be invalid"); 602 assertFalse(validator.isValidInet6Address("1111::6666:7777:8888:"), "IPV6 1111::6666:7777:8888: should be invalid"); 603 assertFalse(validator.isValidInet6Address("::6666:7777:8888:"), "IPV6 ::6666:7777:8888: should be invalid"); 604 assertFalse(validator.isValidInet6Address("1111:2222:3333::5555:6666:7777:8888:"), "IPV6 1111:2222:3333::5555:6666:7777:8888: should be invalid"); 605 assertFalse(validator.isValidInet6Address("1111:2222::5555:6666:7777:8888:"), "IPV6 1111:2222::5555:6666:7777:8888: should be invalid"); 606 assertFalse(validator.isValidInet6Address("1111::5555:6666:7777:8888:"), "IPV6 1111::5555:6666:7777:8888: should be invalid"); 607 assertFalse(validator.isValidInet6Address("::5555:6666:7777:8888:"), "IPV6 ::5555:6666:7777:8888: should be invalid"); 608 assertFalse(validator.isValidInet6Address("1111:2222::4444:5555:6666:7777:8888:"), "IPV6 1111:2222::4444:5555:6666:7777:8888: should be invalid"); 609 assertFalse(validator.isValidInet6Address("1111::4444:5555:6666:7777:8888:"), "IPV6 1111::4444:5555:6666:7777:8888: should be invalid"); 610 assertFalse(validator.isValidInet6Address("::4444:5555:6666:7777:8888:"), "IPV6 ::4444:5555:6666:7777:8888: should be invalid"); 611 assertFalse(validator.isValidInet6Address("1111::3333:4444:5555:6666:7777:8888:"), "IPV6 1111::3333:4444:5555:6666:7777:8888: should be invalid"); 612 assertFalse(validator.isValidInet6Address("::3333:4444:5555:6666:7777:8888:"), "IPV6 ::3333:4444:5555:6666:7777:8888: should be invalid"); 613 assertFalse(validator.isValidInet6Address("::2222:3333:4444:5555:6666:7777:8888:"), "IPV6 ::2222:3333:4444:5555:6666:7777:8888: should be invalid"); 614 assertTrue(validator.isValidInet6Address("0:a:b:c:d:e:f::"), "IPV6 0:a:b:c:d:e:f:: should be valid"); 615 assertTrue(validator.isValidInet6Address("::0:a:b:c:d:e:f"), "IPV6 ::0:a:b:c:d:e:f should be valid"); // syntactically correct, but bad form (::0:... could be combined) 616 assertTrue(validator.isValidInet6Address("a:b:c:d:e:f:0::"), "IPV6 a:b:c:d:e:f:0:: should be valid"); 617 assertFalse(validator.isValidInet6Address("':10.0.0.1"), "IPV6 ':10.0.0.1 should be invalid"); 619 618 } 620 619 // CHECKSTYLE.ON: ExecutableStatementCount -
trunk/test/unit/org/openstreetmap/josm/data/validation/routines/RegexValidatorTest.java
r17275 r18690 17 17 package org.openstreetmap.josm.data.validation.routines; 18 18 19 import static org.junit. Assert.assertEquals;20 import static org.junit. Assert.assertFalse;21 import static org.junit. Assert.assertNull;22 import static org.junit. Assert.assertTrue;23 import static org.junit.jupiter.api.Assertions. fail;24 25 import java.util.Arrays; 19 import static org.junit.jupiter.api.Assertions.assertArrayEquals; 20 import static org.junit.jupiter.api.Assertions.assertEquals; 21 import static org.junit.jupiter.api.Assertions.assertFalse; 22 import static org.junit.jupiter.api.Assertions.assertNull; 23 import static org.junit.jupiter.api.Assertions.assertThrows; 24 import static org.junit.jupiter.api.Assertions.assertTrue; 25 26 26 import java.util.regex.PatternSyntaxException; 27 27 … … 60 60 61 61 // isValid() 62 assertTrue( "Sensitive isValid() valid", sensitive.isValid("ac-DE-1"));63 assertFalse( "Sensitive isValid() invalid", sensitive.isValid("AB-de-1"));64 assertTrue( "Insensitive isValid() valid", insensitive.isValid("AB-de-1"));65 assertFalse( "Insensitive isValid() invalid", insensitive.isValid("ABd-de-1"));62 assertTrue(sensitive.isValid("ac-DE-1"), "Sensitive isValid() valid"); 63 assertFalse(sensitive.isValid("AB-de-1"), "Sensitive isValid() invalid"); 64 assertTrue(insensitive.isValid("AB-de-1"), "Insensitive isValid() valid"); 65 assertFalse(insensitive.isValid("ABd-de-1"), "Insensitive isValid() invalid"); 66 66 67 67 // validate() 68 assertEquals(" Sensitive validate() valid", "acDE1", sensitive.validate("ac-DE-1"));69 assertNull( "Sensitive validate() invalid", sensitive.validate("AB-de-1"));70 assertEquals(" Insensitive validate() valid", "ABde1", insensitive.validate("AB-de-1"));71 assertNull( "Insensitive validate() invalid", insensitive.validate("ABd-de-1"));68 assertEquals("acDE1", sensitive.validate("ac-DE-1"), "Sensitive validate() valid"); 69 assertNull(sensitive.validate("AB-de-1"), "Sensitive validate() invalid"); 70 assertEquals("ABde1", insensitive.validate("AB-de-1"), "Insensitive validate() valid"); 71 assertNull(insensitive.validate("ABd-de-1"), "Insensitive validate() invalid"); 72 72 73 73 // match() 74 checkArray("Sensitive match() valid", new String[] {"ac", "DE", "1"}, sensitive.match("ac-DE-1")); 75 checkArray("Sensitive match() invalid", null, sensitive.match("AB-de-1")); 76 checkArray("Insensitive match() valid", new String[] {"AB", "de", "1"}, insensitive.match("AB-de-1")); 77 checkArray("Insensitive match() invalid", null, insensitive.match("ABd-de-1")); 78 assertEquals("validate one", "ABC", (new RegexValidator("^([A-Z]*)$")).validate("ABC")); 79 checkArray("match one", new String[] {"ABC"}, (new RegexValidator("^([A-Z]*)$")).match("ABC")); 74 String[] result2 = sensitive.match("ac-DE-1"); 75 assertArrayEquals(new String[] {"ac", "DE", "1"}, result2, "Sensitive match() valid"); 76 assertNull(sensitive.match("AB-de-1"), "Sensitive match() invalid"); 77 String[] result1 = insensitive.match("AB-de-1"); 78 assertArrayEquals(new String[] {"AB", "de", "1"}, result1, "Insensitive match() valid"); 79 assertNull(insensitive.match("ABd-de-1"), "Insensitive match() invalid"); 80 assertEquals("ABC", (new RegexValidator("^([A-Z]*)$")).validate("ABC"), "validate one"); 81 String[] result = (new RegexValidator("^([A-Z]*)$")).match("ABC"); 82 assertArrayEquals(new String[] {"ABC"}, result, "match one"); 80 83 } 81 84 … … 98 101 99 102 // isValid() 100 assertTrue( "Sensitive isValid() Multiple", multiple.isValid(value));101 assertFalse( "Sensitive isValid() 1st", single1.isValid(value));102 assertTrue( "Sensitive isValid() 2nd", single2.isValid(value));103 assertFalse( "Sensitive isValid() 3rd", single3.isValid(value));103 assertTrue(multiple.isValid(value), "Sensitive isValid() Multiple"); 104 assertFalse(single1.isValid(value), "Sensitive isValid() 1st"); 105 assertTrue(single2.isValid(value), "Sensitive isValid() 2nd"); 106 assertFalse(single3.isValid(value), "Sensitive isValid() 3rd"); 104 107 105 108 // validate() 106 assertEquals( "Sensitive validate() Multiple", expect, multiple.validate(value));107 assertNull( "Sensitive validate() 1st", single1.validate(value));108 assertEquals( "Sensitive validate() 2nd", expect, single2.validate(value));109 assertNull( "Sensitive validate() 3rd", single3.validate(value));109 assertEquals(expect, multiple.validate(value), "Sensitive validate() Multiple"); 110 assertNull(single1.validate(value), "Sensitive validate() 1st"); 111 assertEquals(expect, single2.validate(value), "Sensitive validate() 2nd"); 112 assertNull(single3.validate(value), "Sensitive validate() 3rd"); 110 113 111 114 // match() 112 checkArray("Sensitive match() Multiple", array, multiple.match(value));113 checkArray("Sensitive match() 1st", null, single1.match(value));114 checkArray("Sensitive match() 2nd", array, single2.match(value));115 checkArray("Sensitive match() 3rd", null, single3.match(value));115 assertArrayEquals(array, multiple.match(value), "Sensitive match() Multiple"); 116 assertNull(single1.match(value), "Sensitive match() 1st"); 117 assertArrayEquals(array, single2.match(value), "Sensitive match() 2nd"); 118 assertNull(single3.match(value), "Sensitive match() 3rd"); 116 119 117 120 // All invalid 118 121 value = "AAC*FDE*321"; 119 assertFalse( "isValid() Invalid", multiple.isValid(value));120 assertNull( "validate() Invalid", multiple.validate(value));121 assertNull( "match() Multiple", multiple.match(value));122 assertFalse(multiple.isValid(value), "isValid() Invalid"); 123 assertNull(multiple.validate(value), "validate() Invalid"); 124 assertNull(multiple.match(value), "match() Multiple"); 122 125 } 123 126 … … 140 143 141 144 // isValid() 142 assertTrue( "isValid() Multiple", multiple.isValid(value));143 assertFalse( "isValid() 1st", single1.isValid(value));144 assertTrue( "isValid() 2nd", single2.isValid(value));145 assertFalse( "isValid() 3rd", single3.isValid(value));145 assertTrue(multiple.isValid(value), "isValid() Multiple"); 146 assertFalse(single1.isValid(value), "isValid() 1st"); 147 assertTrue(single2.isValid(value), "isValid() 2nd"); 148 assertFalse(single3.isValid(value), "isValid() 3rd"); 146 149 147 150 // validate() 148 assertEquals( "validate() Multiple", expect, multiple.validate(value));149 assertNull( "validate() 1st", single1.validate(value));150 assertEquals( "validate() 2nd", expect, single2.validate(value));151 assertNull( "validate() 3rd", single3.validate(value));151 assertEquals(expect, multiple.validate(value), "validate() Multiple"); 152 assertNull(single1.validate(value), "validate() 1st"); 153 assertEquals(expect, single2.validate(value), "validate() 2nd"); 154 assertNull(single3.validate(value), "validate() 3rd"); 152 155 153 156 // match() 154 checkArray("match() Multiple", array, multiple.match(value));155 checkArray("match() 1st", null, single1.match(value));156 checkArray("match() 2nd", array, single2.match(value));157 checkArray("match() 3rd", null, single3.match(value));157 assertArrayEquals(array, multiple.match(value), "match() Multiple"); 158 assertNull(single1.match(value), "match() 1st"); 159 assertArrayEquals(array, single2.match(value), "match() 2nd"); 160 assertNull(single3.match(value), "match() 3rd"); 158 161 159 162 // All invalid 160 163 value = "AAC*FDE*321"; 161 assertFalse( "isValid() Invalid", multiple.isValid(value));162 assertNull( "validate() Invalid", multiple.validate(value));163 assertNull( "match() Multiple", multiple.match(value));164 assertFalse(multiple.isValid(value), "isValid() Invalid"); 165 assertNull(multiple.validate(value), "validate() Invalid"); 166 assertNull(multiple.match(value), "match() Multiple"); 164 167 } 165 168 … … 170 173 void testNullValue() { 171 174 RegexValidator validator = new RegexValidator(REGEX); 172 assertFalse( "Instance isValid()", validator.isValid(null));173 assertNull( "Instance validate()", validator.validate(null));174 assertNull( "Instance match()", validator.match(null));175 assertFalse(validator.isValid(null), "Instance isValid()"); 176 assertNull(validator.validate(null), "Instance validate()"); 177 assertNull(validator.match(null), "Instance match()"); 175 178 } 176 179 … … 182 185 @Test 183 186 void testMissingRegex() { 184 185 187 // Single Regular Expression - null 186 try { 187 new RegexValidator((String) null); 188 fail("Single Null - expected IllegalArgumentException"); 189 } catch (IllegalArgumentException e) { 190 assertEquals("Single Null", "Regular expression[0] is missing", e.getMessage()); 191 } 188 IllegalArgumentException iae = assertThrows(IllegalArgumentException.class, () -> new RegexValidator((String) null), 189 "Single Null - expected IllegalArgumentException"); 190 assertEquals("Regular expression[0] is missing", iae.getMessage(), "Single Null"); 192 191 193 192 // Single Regular Expression - Zero Length 194 try { 195 new RegexValidator(""); 196 fail("Single Zero Length - expected IllegalArgumentException"); 197 } catch (IllegalArgumentException e) { 198 assertEquals("Single Zero Length", "Regular expression[0] is missing", e.getMessage()); 199 } 193 iae = assertThrows(IllegalArgumentException.class, () -> new RegexValidator(""), 194 "Single Zero Length - expected IllegalArgumentException"); 195 assertEquals("Regular expression[0] is missing", iae.getMessage(), "Single Zero Length"); 200 196 201 197 // Multiple Regular Expression - Null array 202 try { 203 new RegexValidator((String[]) null); 204 fail("Null Array - expected IllegalArgumentException"); 205 } catch (IllegalArgumentException e) { 206 assertEquals("Null Array", "Regular expressions are missing", e.getMessage()); 207 } 198 iae = assertThrows(IllegalArgumentException.class, () -> new RegexValidator((String[]) null), 199 "Null Array - expected IllegalArgumentException"); 200 assertEquals("Regular expressions are missing", iae.getMessage(), "Null Array"); 208 201 209 202 // Multiple Regular Expression - Zero Length array 210 try { 211 new RegexValidator(new String[0]); 212 fail("Zero Length Array - expected IllegalArgumentException"); 213 } catch (IllegalArgumentException e) { 214 assertEquals("Zero Length Array", "Regular expressions are missing", e.getMessage()); 215 } 203 iae = assertThrows(IllegalArgumentException.class, RegexValidator::new, 204 "Zero Length Array - expected IllegalArgumentException"); 205 assertEquals("Regular expressions are missing", iae.getMessage(), "Zero Length Array"); 216 206 217 207 // Multiple Regular Expression - Array has Null 218 String[] expressions = new String[] {"ABC", null}; 219 try { 220 new RegexValidator(expressions); 221 fail("Array has Null - expected IllegalArgumentException"); 222 } catch (IllegalArgumentException e) { 223 assertEquals("Array has Null", "Regular expression[1] is missing", e.getMessage()); 224 } 208 iae = assertThrows(IllegalArgumentException.class, () -> new RegexValidator("ABC", null), 209 "Array has Null - expected IllegalArgumentException"); 210 assertEquals("Regular expression[1] is missing", iae.getMessage(), "Array has Null"); 225 211 226 212 // Multiple Regular Expression - Array has Zero Length 227 expressions = new String[] {"", "ABC"}; 228 try { 229 new RegexValidator(expressions); 230 fail("Array has Zero Length - expected IllegalArgumentException"); 231 } catch (IllegalArgumentException e) { 232 assertEquals("Array has Zero Length", "Regular expression[0] is missing", e.getMessage()); 233 } 213 iae = assertThrows(IllegalArgumentException.class, () -> new RegexValidator("", "ABC"), 214 "Array has Zero Length - expected IllegalArgumentException"); 215 assertEquals("Regular expression[0] is missing", iae.getMessage(), "Array has Zero Length"); 234 216 } 235 217 … … 254 236 void testToString() { 255 237 RegexValidator single = new RegexValidator(REGEX); 256 assertEquals(" Single", "RegexValidator{" + REGEX + "}", single.toString());257 258 RegexValidator multiple = new RegexValidator( new String[] {REGEX, REGEX});259 assertEquals(" Multiple", "RegexValidator{" + REGEX + "," + REGEX + "}", multiple.toString());238 assertEquals("RegexValidator{" + REGEX + "}", single.toString(), "Single"); 239 240 RegexValidator multiple = new RegexValidator(REGEX, REGEX); 241 assertEquals("RegexValidator{" + REGEX + "," + REGEX + "}", multiple.toString(), "Multiple"); 260 242 } 261 243 … … 268 250 } 269 251 270 /**271 * Compare two arrays272 * @param label Label for the test273 * @param expect Expected array274 * @param result Actual array275 */276 private void checkArray(String label, String[] expect, String[] result) {277 278 // Handle nulls279 if (expect == null || result == null) {280 if (expect == null && result == null) {281 return; // valid, both null282 } else {283 fail(label + " Null expect=" + Arrays.toString(expect) + " result=" + Arrays.toString(result));284 }285 return; // not strictly necessary, but prevents possible NPE below286 }287 288 // Check Length289 if (expect.length != result.length) {290 fail(label + " Length expect=" + expect.length + " result=" + result.length);291 }292 293 // Check Values294 for (int i = 0; i < expect.length; i++) {295 assertEquals(label +" value[" + i + "]", expect[i], result[i]);296 }297 }298 252 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/routines/UrlValidatorTest.java
r17381 r18690 17 17 package org.openstreetmap.josm.data.validation.routines; 18 18 19 import static org.junit. Assert.assertEquals;20 import static org.junit. Assert.assertFalse;21 import static org.junit. Assert.assertTrue;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.assertTrue; 22 22 23 23 import org.junit.jupiter.api.BeforeEach; … … 48 48 */ 49 49 @Test 50 publicvoid testIsValid() {50 void testIsValid() { 51 51 testIsValid(testUrlParts, UrlValidator.ALLOW_ALL_SCHEMES); 52 52 setUp(); … … 63 63 */ 64 64 @Test 65 publicvoid testIsValidScheme() {65 void testIsValidScheme() { 66 66 if (printStatus) { 67 67 System.out.print("\n testIsValidScheme() "); … … 71 71 for (ResultPair testPair : testScheme) { 72 72 boolean result = urlVal.isValidScheme(testPair.item); 73 assertEquals(testPair. item, testPair.valid, result);73 assertEquals(testPair.valid, result, testPair.item); 74 74 if (printStatus) { 75 75 if (result == testPair.valid) { … … 112 112 String url = testBuffer.toString(); 113 113 boolean result = urlVal.isValid(url); 114 assertEquals( url, expected, result);114 assertEquals(expected, result, url); 115 115 if (printStatus) { 116 116 if (printIndex) { … … 164 164 void testValidator218() { 165 165 UrlValidator validator = new UrlValidator(UrlValidator.ALLOW_2_SLASHES); 166 assertTrue("parentheses should be valid in URLs", 167 validator.isValid("http://somewhere.com/pathxyz/file(1).html")); 166 assertTrue(validator.isValid("http://somewhere.com/pathxyz/file(1).html"), "parentheses should be valid in URLs"); 168 167 } 169 168 … … 179 178 } 180 179 UrlValidator validator = new UrlValidator(); 181 assertTrue( "xn--d1abbgf6aiiy.xn--p1ai should validate", validator.isValid("http://xn--d1abbgf6aiiy.xn--p1ai"));182 assertTrue( "президент.рф should validate", validator.isValid("http://президент.рф"));183 assertTrue( "www.b\u00fccher.ch should validate", validator.isValid("http://www.b\u00fccher.ch"));184 assertFalse( "www.\uFFFD.ch FFFD should fail", validator.isValid("http://www.\uFFFD.ch"));185 assertTrue( "www.b\u00fccher.ch should validate", validator.isValid("ftp://www.b\u00fccher.ch"));186 assertFalse( "www.\uFFFD.ch FFFD should fail", validator.isValid("ftp://www.\uFFFD.ch"));180 assertTrue(validator.isValid("http://xn--d1abbgf6aiiy.xn--p1ai"), "xn--d1abbgf6aiiy.xn--p1ai should validate"); 181 assertTrue(validator.isValid("http://президент.рф"), "президент.рф should validate"); 182 assertTrue(validator.isValid("http://www.b\u00fccher.ch"), "www.b\u00fccher.ch should validate"); 183 assertFalse(validator.isValid("http://www.\uFFFD.ch"), "www.\uFFFD.ch FFFD should fail"); 184 assertTrue(validator.isValid("ftp://www.b\u00fccher.ch"), "www.b\u00fccher.ch should validate"); 185 assertFalse(validator.isValid("ftp://www.\uFFFD.ch"), "www.\uFFFD.ch FFFD should fail"); 187 186 } 188 187 … … 195 194 UrlValidator validator = new UrlValidator(regex, 0); 196 195 197 assertTrue("localhost URL should validate", 198 validator.isValid("http://localhost/test/index.html")); 199 assertTrue("first.my-testing should validate", 200 validator.isValid("http://first.my-testing/test/index.html")); 201 assertTrue("sup3r.my-testing should validate", 202 validator.isValid("http://sup3r.my-testing/test/index.html")); 203 204 assertFalse("broke.my-test should not validate", 205 validator.isValid("http://broke.my-test/test/index.html")); 206 207 assertTrue("www.apache.org should still validate", 208 validator.isValid("http://www.apache.org/test/index.html")); 196 assertTrue(validator.isValid("http://localhost/test/index.html"), "localhost URL should validate"); 197 assertTrue(validator.isValid("http://first.my-testing/test/index.html"), "first.my-testing should validate"); 198 assertTrue(validator.isValid("http://sup3r.my-testing/test/index.html"), "sup3r.my-testing should validate"); 199 200 assertFalse(validator.isValid("http://broke.my-test/test/index.html"), "broke.my-test should not validate"); 201 202 assertTrue(validator.isValid("http://www.apache.org/test/index.html"), "www.apache.org should still validate"); 209 203 210 204 // Now check using options 211 205 validator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS); 212 206 213 assertTrue("localhost URL should validate", 214 validator.isValid("http://localhost/test/index.html")); 215 216 assertTrue("machinename URL should validate", 217 validator.isValid("http://machinename/test/index.html")); 218 219 assertTrue("www.apache.org should still validate", 220 validator.isValid("http://www.apache.org/test/index.html")); 207 assertTrue(validator.isValid("http://localhost/test/index.html"), "localhost URL should validate"); 208 209 assertTrue(validator.isValid("http://machinename/test/index.html"), "machinename URL should validate"); 210 211 assertTrue(validator.isValid("http://www.apache.org/test/index.html"), "www.apache.org should still validate"); 221 212 } 222 213 … … 228 219 UrlValidator validator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS); 229 220 230 assertTrue("hostname should validate", 231 validator.isValid("http://hostname")); 232 233 assertTrue("hostname with path should validate", 234 validator.isValid("http://hostname/test/index.html")); 235 236 assertTrue("localhost URL should validate", 237 validator.isValid("http://localhost/test/index.html")); 238 239 assertFalse("first.my-testing should not validate", 240 validator.isValid("http://first.my-testing/test/index.html")); 241 242 assertFalse("broke.hostname should not validate", 243 validator.isValid("http://broke.hostname/test/index.html")); 244 245 assertTrue("www.apache.org should still validate", 246 validator.isValid("http://www.apache.org/test/index.html")); 221 assertTrue(validator.isValid("http://hostname"), "hostname should validate"); 222 223 assertTrue(validator.isValid("http://hostname/test/index.html"), "hostname with path should validate"); 224 225 assertTrue(validator.isValid("http://localhost/test/index.html"), "localhost URL should validate"); 226 227 assertFalse(validator.isValid("http://first.my-testing/test/index.html"), "first.my-testing should not validate"); 228 229 assertFalse(validator.isValid("http://broke.hostname/test/index.html"), "broke.hostname should not validate"); 230 231 assertTrue(validator.isValid("http://www.apache.org/test/index.html"), "www.apache.org should still validate"); 247 232 248 233 // Turn it off, and check 249 234 validator = new UrlValidator(0); 250 235 251 assertFalse("hostname should no longer validate", 252 validator.isValid("http://hostname")); 253 254 assertFalse("localhost URL should no longer validate", 255 validator.isValid("http://localhost/test/index.html")); 256 257 assertTrue("www.apache.org should still validate", 258 validator.isValid("http://www.apache.org/test/index.html")); 236 assertFalse(validator.isValid("http://hostname"), "hostname should no longer validate"); 237 238 assertFalse(validator.isValid("http://localhost/test/index.html"), "localhost URL should no longer validate"); 239 240 assertTrue(validator.isValid("http://www.apache.org/test/index.html"), "www.apache.org should still validate"); 259 241 } 260 242 … … 267 249 UrlValidator validator = new UrlValidator(); 268 250 269 assertTrue("http://apache.org/ should be allowed by default", 270 validator.isValid("http://www.apache.org/test/index.html")); 271 272 assertFalse("file:///c:/ shouldn't be allowed by default", 273 validator.isValid("file:///C:/some.file")); 274 275 assertFalse("file:///c:\\ shouldn't be allowed by default", 276 validator.isValid("file:///C:\\some.file")); 277 278 assertFalse("file:///etc/ shouldn't be allowed by default", 279 validator.isValid("file:///etc/hosts")); 280 281 assertFalse("file://localhost/etc/ shouldn't be allowed by default", 282 validator.isValid("file://localhost/etc/hosts")); 283 284 assertFalse("file://localhost/c:/ shouldn't be allowed by default", 285 validator.isValid("file://localhost/c:/some.file")); 251 assertTrue(validator.isValid("http://www.apache.org/test/index.html"), "http://apache.org/ should be allowed by default"); 252 253 assertFalse(validator.isValid("file:///C:/some.file"), "file:///c:/ shouldn't be allowed by default"); 254 255 assertFalse(validator.isValid("file:///C:\\some.file"), "file:///c:\\ shouldn't be allowed by default"); 256 257 assertFalse(validator.isValid("file:///etc/hosts"), "file:///etc/ shouldn't be allowed by default"); 258 259 assertFalse(validator.isValid("file://localhost/etc/hosts"), "file://localhost/etc/ shouldn't be allowed by default"); 260 261 assertFalse(validator.isValid("file://localhost/c:/some.file"), "file://localhost/c:/ shouldn't be allowed by default"); 286 262 287 263 // Turn it on, and check … … 289 265 validator = new UrlValidator(new String[]{"http", "file"}, UrlValidator.ALLOW_LOCAL_URLS); 290 266 291 assertTrue("http://apache.org/ should be allowed by default", 292 validator.isValid("http://www.apache.org/test/index.html")); 293 294 assertTrue("file:///c:/ should now be allowed", 295 validator.isValid("file:///C:/some.file")); 267 assertTrue(validator.isValid("http://www.apache.org/test/index.html"), "http://apache.org/ should be allowed by default"); 268 269 assertTrue(validator.isValid("file:///C:/some.file"), "file:///c:/ should now be allowed"); 296 270 297 271 // Currently, we don't support the c:\ form 298 assertFalse("file:///c:\\ shouldn't be allowed", 299 validator.isValid("file:///C:\\some.file")); 300 301 assertTrue("file:///etc/ should now be allowed", 302 validator.isValid("file:///etc/hosts")); 303 304 assertTrue("file://localhost/etc/ should now be allowed", 305 validator.isValid("file://localhost/etc/hosts")); 306 307 assertTrue("file://localhost/c:/ should now be allowed", 308 validator.isValid("file://localhost/c:/some.file")); 272 assertFalse(validator.isValid("file:///C:\\some.file"), "file:///c:\\ shouldn't be allowed"); 273 274 assertTrue(validator.isValid("file:///etc/hosts"), "file:///etc/ should now be allowed"); 275 276 assertTrue(validator.isValid("file://localhost/etc/hosts"), "file://localhost/etc/ should now be allowed"); 277 278 assertTrue(validator.isValid("file://localhost/c:/some.file"), "file://localhost/c:/ should now be allowed"); 309 279 310 280 // These are never valid 311 assertFalse("file://c:/ shouldn't ever be allowed, needs file:///c:/", 312 validator.isValid("file://C:/some.file")); 313 314 assertFalse("file://c:\\ shouldn't ever be allowed, needs file:///c:/", 315 validator.isValid("file://C:\\some.file")); 281 assertFalse(validator.isValid("file://C:/some.file"), "file://c:/ shouldn't ever be allowed, needs file:///c:/"); 282 283 assertFalse(validator.isValid("file://C:\\some.file"), "file://c:\\ shouldn't ever be allowed, needs file:///c:/"); 316 284 } 317 285 … … 406 374 */ 407 375 @Test 408 publicvoid testValidator290() {376 void testValidator290() { 409 377 UrlValidator validator = new UrlValidator(); 410 378 assertTrue(validator.isValid("http://xn--h1acbxfam.idn.icann.org/")); … … 447 415 */ 448 416 @Test 449 publicvoid testValidator361() {417 void testValidator361() { 450 418 UrlValidator validator = new UrlValidator(); 451 419 assertTrue(validator.isValid("http://hello.tokyo/")); … … 456 424 */ 457 425 @Test 458 publicvoid testValidator363() {426 void testValidator363() { 459 427 UrlValidator urlValidator = new UrlValidator(); 460 428 assertTrue(urlValidator.isValid("http://www.example.org/a/b/hello..world")); … … 480 448 */ 481 449 @Test 482 publicvoid testValidator375() {450 void testValidator375() { 483 451 UrlValidator validator = new UrlValidator(); 484 452 String url = "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html"; 485 assertTrue( "IPv6 address URL should validate: " + url, validator.isValid(url));453 assertTrue(validator.isValid(url), "IPv6 address URL should validate: " + url); 486 454 url = "http://[::1]:80/index.html"; 487 assertTrue( "IPv6 address URL should validate: " + url, validator.isValid(url));455 assertTrue(validator.isValid(url), "IPv6 address URL should validate: " + url); 488 456 url = "http://FEDC:BA98:7654:3210:FEDC:BA98:7654:3210:80/index.html"; 489 assertFalse( "IPv6 address without [] should not validate: " + url, validator.isValid(url));457 assertFalse(validator.isValid(url), "IPv6 address without [] should not validate: " + url); 490 458 } 491 459 … … 494 462 */ 495 463 @Test 496 publicvoid testValidator353() { // userinfo464 void testValidator353() { // userinfo 497 465 UrlValidator validator = new UrlValidator(); 498 466 assertTrue(validator.isValid("http://www.apache.org:80/path")); … … 510 478 */ 511 479 @Test 512 publicvoid testValidator382() {480 void testValidator382() { 513 481 UrlValidator validator = new UrlValidator(); 514 482 assertTrue(validator.isValid("ftp://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose")); … … 519 487 */ 520 488 @Test 521 publicvoid testValidator380() {489 void testValidator380() { 522 490 UrlValidator validator = new UrlValidator(); 523 491 assertTrue(validator.isValid("http://www.apache.org:80/path")); … … 530 498 */ 531 499 @Test 532 publicvoid testValidatorName() {500 void testValidatorName() { 533 501 assertEquals("URL validator", UrlValidator.getInstance().getValidatorName()); 534 502 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/ConnectivityRelationsTest.java
r17384 r18690 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import org.junit.Assert; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 import org.junit.jupiter.api.BeforeEach; 6 7 import org.junit.jupiter.api.Test; … … 32 33 33 34 @BeforeEach 34 public void setUpCheck() throws Exception{35 public void setUpCheck() { 35 36 check = new ConnectivityRelations(); 36 37 } … … 52 53 check.visit(relation); 53 54 54 Assert.assertEquals(0, check.getErrors().size());55 assertEquals(0, check.getErrors().size()); 55 56 56 57 relation.remove(CONNECTIVITY); 57 58 check.visit(relation); 58 Assert.assertEquals(1, check.getErrors().size());59 assertEquals(1, check.getErrors().size()); 59 60 } 60 61 … … 68 69 int expectedFailures = 0; 69 70 70 Assert.assertEquals(expectedFailures, check.getErrors().size());71 assertEquals(expectedFailures, check.getErrors().size()); 71 72 72 73 relation.put(CONNECTIVITY, "45000:1"); 73 74 check.visit(relation); 74 Assert.assertEquals(++expectedFailures, check.getErrors().size());75 assertEquals(++expectedFailures, check.getErrors().size()); 75 76 76 77 relation.put(CONNECTIVITY, "1:45000"); 77 78 check.visit(relation); 78 Assert.assertEquals(++expectedFailures, check.getErrors().size());79 assertEquals(++expectedFailures, check.getErrors().size()); 79 80 80 81 relation.put(CONNECTIVITY, "1:1,2"); 81 82 check.visit(relation); 82 Assert.assertEquals(expectedFailures, check.getErrors().size());83 assertEquals(expectedFailures, check.getErrors().size()); 83 84 84 85 relation.put(CONNECTIVITY, "1:1,(2)"); 85 86 check.visit(relation); 86 Assert.assertEquals(expectedFailures, check.getErrors().size());87 assertEquals(expectedFailures, check.getErrors().size()); 87 88 88 89 relation.put(CONNECTIVITY, "1:1,(20000)"); 89 90 check.visit(relation); 90 Assert.assertEquals(++expectedFailures, check.getErrors().size());91 assertEquals(++expectedFailures, check.getErrors().size()); 91 92 } 92 93 93 94 /** 94 95 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/201821">Bug #20182</a>. 95 * @throws Exception if an error occurs96 96 */ 97 97 @Test 98 void testTicket20182() throws Exception{98 void testTicket20182() { 99 99 Relation relation = createDefaultTestRelation(); 100 100 check.visit(relation); 101 101 int expectedFailures = 0; 102 102 103 Assert.assertEquals(expectedFailures, check.getErrors().size());103 assertEquals(expectedFailures, check.getErrors().size()); 104 104 105 105 relation.put(CONNECTIVITY, "left_turn"); 106 106 check.visit(relation); 107 Assert.assertEquals(++expectedFailures, check.getErrors().size());107 assertEquals(++expectedFailures, check.getErrors().size()); 108 108 109 109 relation.put(CONNECTIVITY, "1"); 110 110 check.visit(relation); 111 Assert.assertEquals(++expectedFailures, check.getErrors().size());111 assertEquals(++expectedFailures, check.getErrors().size()); 112 112 } 113 113 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/DirectionNodesTest.java
r17413 r18690 4 4 import org.junit.jupiter.api.Test; 5 5 import org.junit.jupiter.api.extension.RegisterExtension; 6 import org.openstreetmap.josm.data.osm.DataSet; 6 7 import org.openstreetmap.josm.testutils.JOSMTestRules; 7 8 … … 28 29 void testDirectionsNodesTestFile() throws Exception { 29 30 final DirectionNodes test = new DirectionNodes(); 30 ValidatorTestUtils.testSampleFile("nodist/data/direction-nodes.osm", ds -> ds.getNodes(), null, test);31 ValidatorTestUtils.testSampleFile("nodist/data/direction-nodes.osm", DataSet::getNodes, null, test); 31 32 } 32 33 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r17916 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; … … 129 130 "}")).parseChecks.get(0); 130 131 final Command command = check.fixPrimitive(p); 131 assert True(command instanceof SequenceCommand);132 assertInstanceOf(SequenceCommand.class, command); 132 133 final Iterator<PseudoCommand> it = command.getChildren().iterator(); 133 assert True(it.next() instanceof ChangePropertyKeyCommand);134 assert True(it.next() instanceof ChangePropertyCommand);134 assertInstanceOf(ChangePropertyKeyCommand.class, it.next()); 135 assertInstanceOf(ChangePropertyCommand.class, it.next()); 135 136 } 136 137 -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java
r18037 r18690 7 7 import static org.hamcrest.MatcherAssert.assertThat; 8 8 import static org.junit.jupiter.api.Assertions.assertEquals; 9 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 9 10 import static org.junit.jupiter.api.Assertions.assertNotNull; 10 11 import static org.junit.jupiter.api.Assertions.assertTrue; … … 258 259 private static void assertFixEquals(String value, TestError error) { 259 260 assertNotNull(error.getFix(), "fix is not null"); 260 assertTrue(error.getFix() instanceof ChangePropertyCommand, "fix is ChangePropertyCommand"); 261 final ChangePropertyCommand command = (ChangePropertyCommand) error.getFix(); 261 final ChangePropertyCommand command = assertInstanceOf(ChangePropertyCommand.class, error.getFix(), "fix is ChangePropertyCommand"); 262 262 assertEquals(1, command.getTags().size()); 263 263 assertEquals(value, command.getTags().values().iterator().next()); -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/SelfIntersectingWayTest.java
r17275 r18690 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 4 7 import java.util.ArrayList; 8 import java.util.Arrays; 5 9 import java.util.List; 6 10 import java.util.stream.Collectors; 7 11 import java.util.stream.IntStream; 8 12 9 import org.junit.Assert;10 13 import org.junit.jupiter.api.BeforeAll; 11 14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.params.ParameterizedTest; 16 import org.junit.jupiter.params.provider.Arguments; 17 import org.junit.jupiter.params.provider.MethodSource; 12 18 import org.openstreetmap.josm.JOSMFixture; 13 19 import org.openstreetmap.josm.data.coor.LatLon; … … 59 65 SelfIntersectingWay test = new SelfIntersectingWay(); 60 66 test.visit(w); 61 Assert.assertEquals(1, test.getErrors().size()); 62 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(1))); 63 } 64 65 /** 66 * First node is identical to an inner node ("P"-Shape). 67 assertEquals(1, test.getErrors().size()); 68 assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(1))); 69 } 70 71 static List<Arguments> testOkInnerNode() { 72 // The first two are duplicates 73 return Arrays.asList( 74 Arguments.of("testUnclosedWayFirst - First node is identical to an inner node (\"P\"-Shape)", 75 new int[] {0, 1, 2, 0 /* problem */, 3, 4}), 76 Arguments.of("testUnclosedWayFirstRepeated - First node is identical to an inner node (\"P\"-Shape)", 77 new int[] {0, 1, 2, 0 /* problem */, 3, 4}), 78 Arguments.of("testUnclosedWayLast - Last node is identical to an inner node (\"b\"-Shape)", 79 new int[] {0, 1 /* problem */, 2, 3, 4, 1}) 80 ); 81 } 82 83 /** 84 * The starting or ending nodes are also an inner node. 67 85 * This is considered okay. 68 86 */ 69 @Test 70 void testUnclosedWayFirst() { 87 @ParameterizedTest(name = "{0}") 88 @MethodSource("testOkInnerNode") 89 void testUnclosedWayFirst(String description, int[] nodeIndex) { 90 List<Node> nodes = createNodes(); 91 92 Way w = (Way) OsmUtils.createPrimitive("way "); 93 List<Node> wayNodes = new ArrayList<>(nodeIndex.length); 94 for (int i : nodeIndex) { 95 wayNodes.add(nodes.get(i)); 96 } 97 w.setNodes(wayNodes); 98 SelfIntersectingWay test = new SelfIntersectingWay(); 99 test.visit(w); 100 assertEquals(0, test.getErrors().size()); 101 } 102 103 /** 104 * Both endpoints join at one inner node ("8"-shape). 105 * This is considered to be an error. 106 */ 107 @Test 108 void testClosedWay() { 71 109 List<Node> nodes = createNodes(); 72 110 … … 79 117 wayNodes.add(nodes.get(3)); 80 118 wayNodes.add(nodes.get(4)); 81 w.setNodes(wayNodes); 82 SelfIntersectingWay test = new SelfIntersectingWay(); 83 test.visit(w); 84 Assert.assertEquals(0, test.getErrors().size()); 85 } 86 87 /** 88 * First node is identical to an inner node ("P"-Shape). 89 * This is considered okay. 90 */ 91 @Test 92 void testUnclosedWayFirstRepeated() { 93 List<Node> nodes = createNodes(); 94 95 Way w = (Way) OsmUtils.createPrimitive("way "); 96 List<Node> wayNodes = new ArrayList<>(); 97 wayNodes.add(nodes.get(0)); 98 wayNodes.add(nodes.get(1)); 99 wayNodes.add(nodes.get(2)); 100 wayNodes.add(nodes.get(0)); 101 wayNodes.add(nodes.get(3)); 102 wayNodes.add(nodes.get(4)); 103 w.setNodes(wayNodes); 104 SelfIntersectingWay test = new SelfIntersectingWay(); 105 test.visit(w); 106 Assert.assertEquals(0, test.getErrors().size()); 107 } 108 109 /** 110 * Last node is identical to an inner node ("b"-Shape). 111 * This is considered okay. 112 */ 113 @Test 114 void testUnclosedWayLast() { 115 List<Node> nodes = createNodes(); 116 117 Way w = (Way) OsmUtils.createPrimitive("way "); 118 List<Node> wayNodes = new ArrayList<>(); 119 wayNodes.add(nodes.get(0)); 120 wayNodes.add(nodes.get(1)); // problem node 121 wayNodes.add(nodes.get(2)); 122 wayNodes.add(nodes.get(3)); 123 wayNodes.add(nodes.get(4)); 124 wayNodes.add(nodes.get(1)); 125 w.setNodes(wayNodes); 126 SelfIntersectingWay test = new SelfIntersectingWay(); 127 test.visit(w); 128 Assert.assertEquals(0, test.getErrors().size()); 129 } 130 131 /** 132 * Both endpoints join at one inner node ("8"-shape). 133 * This is considered to be an error. 134 */ 135 @Test 136 void testClosedWay() { 137 List<Node> nodes = createNodes(); 138 139 Way w = (Way) OsmUtils.createPrimitive("way "); 140 List<Node> wayNodes = new ArrayList<>(); 141 wayNodes.add(nodes.get(0)); 142 wayNodes.add(nodes.get(1)); 143 wayNodes.add(nodes.get(2)); 119 wayNodes.add(nodes.get(0)); 120 w.setNodes(wayNodes); 121 SelfIntersectingWay test = new SelfIntersectingWay(); 122 test.visit(w); 123 assertEquals(1, test.getErrors().size()); 124 assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(0))); 125 } 126 127 /** 128 * Closed way contains a spike. 129 * This is considered to be an error. 130 */ 131 @Test 132 void testSpikeWithStartInClosedWay() { 133 List<Node> nodes = createNodes(); 134 135 Way w = (Way) OsmUtils.createPrimitive("way "); 136 List<Node> wayNodes = new ArrayList<>(); 137 wayNodes.add(nodes.get(0)); 138 wayNodes.add(nodes.get(1)); 144 139 wayNodes.add(nodes.get(0)); // problem 145 140 wayNodes.add(nodes.get(3)); … … 149 144 SelfIntersectingWay test = new SelfIntersectingWay(); 150 145 test.visit(w); 151 Assert.assertEquals(1, test.getErrors().size());152 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(0)));146 assertEquals(1, test.getErrors().size()); 147 assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(0))); 153 148 } 154 149 … … 158 153 */ 159 154 @Test 160 void testSpikeWithStartInClosedWay() { 161 List<Node> nodes = createNodes(); 162 163 Way w = (Way) OsmUtils.createPrimitive("way "); 164 List<Node> wayNodes = new ArrayList<>(); 165 wayNodes.add(nodes.get(0)); 166 wayNodes.add(nodes.get(1)); 155 void testSpikeWithEndInClosedWay() { 156 List<Node> nodes = createNodes(); 157 158 Way w = (Way) OsmUtils.createPrimitive("way "); 159 List<Node> wayNodes = new ArrayList<>(); 160 wayNodes.add(nodes.get(0)); 161 wayNodes.add(nodes.get(1)); 162 wayNodes.add(nodes.get(2)); 167 163 wayNodes.add(nodes.get(0)); // problem 168 164 wayNodes.add(nodes.get(3)); 169 wayNodes.add(nodes.get(4)); 170 wayNodes.add(nodes.get(0)); 171 w.setNodes(wayNodes); 172 SelfIntersectingWay test = new SelfIntersectingWay(); 173 test.visit(w); 174 Assert.assertEquals(1, test.getErrors().size()); 175 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(0))); 165 wayNodes.add(nodes.get(0)); 166 w.setNodes(wayNodes); 167 SelfIntersectingWay test = new SelfIntersectingWay(); 168 test.visit(w); 169 assertEquals(1, test.getErrors().size()); 170 assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(0))); 176 171 } 177 172 … … 181 176 */ 182 177 @Test 183 void testSpikeWithEndInClosedWay() {184 List<Node> nodes = createNodes();185 186 Way w = (Way) OsmUtils.createPrimitive("way ");187 List<Node> wayNodes = new ArrayList<>();188 wayNodes.add(nodes.get(0));189 wayNodes.add(nodes.get(1));190 wayNodes.add(nodes.get(2));191 wayNodes.add(nodes.get(0)); // problem192 wayNodes.add(nodes.get(3));193 wayNodes.add(nodes.get(0));194 w.setNodes(wayNodes);195 SelfIntersectingWay test = new SelfIntersectingWay();196 test.visit(w);197 Assert.assertEquals(1, test.getErrors().size());198 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(0)));199 }200 201 /**202 * Closed way contains a spike.203 * This is considered to be an error.204 */205 @Test206 178 void testSpikeInClosedWay() { 207 179 List<Node> nodes = createNodes(); … … 218 190 SelfIntersectingWay test = new SelfIntersectingWay(); 219 191 test.visit(w); 220 Assert.assertEquals(1, test.getErrors().size());221 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(2)));192 assertEquals(1, test.getErrors().size()); 193 assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(2))); 222 194 } 223 195 … … 243 215 SelfIntersectingWay test = new SelfIntersectingWay(); 244 216 test.visit(w); 245 Assert.assertEquals(1, test.getErrors().size());246 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(3)));217 assertEquals(1, test.getErrors().size()); 218 assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(3))); 247 219 } 248 220 -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
r18282 r18690 11 11 import java.util.stream.Collectors; 12 12 13 import org.junit. Assert;13 import org.junit.jupiter.api.Assertions; 14 14 import org.junit.jupiter.api.Disabled; 15 15 import org.junit.jupiter.api.Test; … … 266 266 267 267 private static void doTestUnwantedNonprintingControlCharacters(String s) { 268 doTestUnwantedNonprintingControlCharacters(s, Assert ::assertTrue, "");268 doTestUnwantedNonprintingControlCharacters(s, Assertions::assertTrue, ""); 269 269 } 270 270 … … 276 276 void testContainsRemoveUnwantedNonprintingControlCharacters() { 277 277 // Check empty string is handled 278 doTestUnwantedNonprintingControlCharacters("", Assert ::assertFalse, "");278 doTestUnwantedNonprintingControlCharacters("", Assertions::assertFalse, ""); 279 279 // Check 65 ASCII control characters are removed, except new lines 280 280 for (char c = 0x0; c < 0x20; c++) { … … 282 282 doTestUnwantedNonprintingControlCharacters(Character.toString(c)); 283 283 } else { 284 doTestUnwantedNonprintingControlCharacters(Character.toString(c), Assert ::assertFalse, Character.toString(c));284 doTestUnwantedNonprintingControlCharacters(Character.toString(c), Assertions::assertFalse, Character.toString(c)); 285 285 } 286 286 } … … 298 298 doTestUnwantedNonprintingControlCharacters(s); 299 299 doTestUnwantedNonprintingControlCharacters(s + s); 300 doTestUnwantedNonprintingControlCharacters(s + 'a' + s, Assert ::assertTrue, "a");300 doTestUnwantedNonprintingControlCharacters(s + 'a' + s, Assertions::assertTrue, "a"); 301 301 final String ok = 'a' + s + 'b'; 302 doTestUnwantedNonprintingControlCharacters(ok, Assert ::assertFalse, ok);303 doTestUnwantedNonprintingControlCharacters(s + ok, Assert ::assertTrue, ok);304 doTestUnwantedNonprintingControlCharacters(ok + s, Assert ::assertTrue, ok);305 doTestUnwantedNonprintingControlCharacters(s + ok + s, Assert ::assertTrue, ok);302 doTestUnwantedNonprintingControlCharacters(ok, Assertions::assertFalse, ok); 303 doTestUnwantedNonprintingControlCharacters(s + ok, Assertions::assertTrue, ok); 304 doTestUnwantedNonprintingControlCharacters(ok + s, Assertions::assertTrue, ok); 305 doTestUnwantedNonprintingControlCharacters(s + ok + s, Assertions::assertTrue, ok); 306 306 } 307 307 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TurnRestrictionTestTest.java
r17275 r18690 4 4 import org.junit.jupiter.api.extension.RegisterExtension; 5 5 import org.junit.jupiter.api.Test; 6 import org.openstreetmap.josm.data.osm.DataSet; 6 7 import org.openstreetmap.josm.testutils.JOSMTestRules; 7 8 … … 30 31 void testTurnrestrictionFile() throws Exception { 31 32 ValidatorTestUtils.testSampleFile("nodist/data/restriction.osm", 32 ds -> ds.getRelations(),33 DataSet::getRelations, 33 34 name -> name.startsWith("E"), TURNRESTRICTION_TEST, RELATION_TEST); 34 35 } -
trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java
r18602 r18690 5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 6 import static org.junit.jupiter.api.Assertions.assertFalse; 7 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 7 8 import static org.junit.jupiter.api.Assertions.assertNotNull; 8 9 import static org.junit.jupiter.api.Assertions.assertNull; … … 125 126 try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { 126 127 System.setOut(new PrintStream(baos)); 127 Thread t = new Thread() { 128 @Override 129 public void run() { 130 MainApplication.main(new String[] {arg}); 131 } 132 }; 128 Thread t = new Thread(() -> MainApplication.main(new String[] {arg})); 133 129 t.start(); 134 130 t.join(); … … 229 225 .until(() -> !BugReportQueue.getInstance().exceptionHandlingInProgress()); 230 226 assertNotNull(exceptionAtomicReference.get()); 231 assert True(exceptionAtomicReference.get() instanceof UnsupportedOperationException);227 assertInstanceOf(UnsupportedOperationException.class, exceptionAtomicReference.get()); 232 228 // The LAF only resets on restart, so don't bother checking that it switched back in UIManager 233 229 assertEquals(LafPreference.LAF.getDefaultValue(), LafPreference.LAF.get()); … … 253 249 void testPostConstructorProcessCmdLineEmpty() { 254 250 // Check the method accepts no arguments 255 MainApplication.postConstructorProcessCmdLine(new ProgramArguments( new String[0]));251 MainApplication.postConstructorProcessCmdLine(new ProgramArguments()); 256 252 } 257 253 258 254 private static void doTestPostConstructorProcessCmdLine(String download, String downloadGps, boolean gpx) { 259 255 assertNull(MainApplication.getLayerManager().getEditDataSet()); 260 for (Future<?> f : MainApplication.postConstructorProcessCmdLine(new ProgramArguments(new String[]{ 261 "--download=" + download, 256 for (Future<?> f : MainApplication.postConstructorProcessCmdLine(new ProgramArguments("--download=" + download, 262 257 "--downloadgps=" + downloadGps, 263 "--selection=type: node" }))) {258 "--selection=type: node"))) { 264 259 try { 265 260 f.get(); … … 314 309 /** 315 310 * Unit test of {@link MainApplication#postConstructorProcessCmdLine} - nominal case with file names. 316 * @throws MalformedURLException if an error occurs 317 */ 318 @Test 319 void testPostConstructorProcessCmdLineFilename() throws MalformedURLException { 311 */ 312 @Test 313 void testPostConstructorProcessCmdLineFilename() { 320 314 doTestPostConstructorProcessCmdLine( 321 315 Paths.get(TestUtils.getTestDataRoot() + "multipolygon.osm").toFile().getAbsolutePath(), -
trunk/test/unit/org/openstreetmap/josm/gui/MapViewStateTest.java
r17275 r18690 65 65 @Test 66 66 void testGetCenter() { 67 doTestGetCenter( s -> s.getCenter(), t -> t / 2d);67 doTestGetCenter(MapViewState::getCenter, t -> t / 2d); 68 68 } 69 69 -
trunk/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java
r18574 r18690 101 101 assertThat(component.getPoint2D((EastNorth) null), CustomMatchers.is(new Point2D.Double())); 102 102 Point2D shouldBeCenter = component.getPoint2D(component.getCenter()); 103 assertThat(shouldBeCenter, CustomMatchers.is(new Point2D.Double(WIDTH / 2 , HEIGHT / 2)));103 assertThat(shouldBeCenter, CustomMatchers.is(new Point2D.Double(WIDTH / 2.0, HEIGHT / 2.0))); 104 104 105 105 EastNorth testPoint = component.getCenter().add(300 * component.getScale(), 200 * component.getScale()); 106 106 Point2D testPointConverted = component.getPoint2D(testPoint); 107 assertThat(testPointConverted, CustomMatchers.is(new Point2D.Double(WIDTH / 2 + 300, HEIGHT / 2- 200)));107 assertThat(testPointConverted, CustomMatchers.is(new Point2D.Double(WIDTH / 2.0 + 300, HEIGHT / 2.0 - 200))); 108 108 } 109 109 -
trunk/test/unit/org/openstreetmap/josm/gui/TableCellRendererTest.java
r17275 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertNotNull; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 5 6 6 7 import java.lang.reflect.Constructor; … … 14 15 import javax.swing.table.TableCellRenderer; 15 16 16 import org.junit.Assert;17 17 import org.junit.jupiter.api.extension.RegisterExtension; 18 18 import org.junit.jupiter.api.Test; … … 64 64 void testTableCellRenderer() throws ReflectiveOperationException { 65 65 Set<Class<? extends TableCellRenderer>> renderers = TestUtils.getJosmSubtypes(TableCellRenderer.class); 66 Assert.assertTrue(renderers.size() >= 10); // if it finds less than 10 classes, something is broken66 assertTrue(renderers.size() >= 10); // if it finds less than 10 classes, something is broken 67 67 JTable tbl = new JTable(2, 2); 68 68 for (Class<? extends TableCellRenderer> klass : renderers) { -
trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/ClipboardUtilsTest.java
r18037 r18690 58 58 59 59 @Override 60 public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException , IOException{60 public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { 61 61 throw new UnsupportedFlavorException(flavor); 62 62 } … … 84 84 85 85 ClipboardUtils.copy(new SupportNothingTransferable()); 86 assert Equals(null,ClipboardUtils.getClipboardStringContent());86 assertNull(ClipboardUtils.getClipboardStringContent()); 87 87 } 88 88 -
trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/LayerTransferableTest.java
r17275 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertSame; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; … … 47 48 @Test 48 49 void testLayerData() { 49 Data data = new Data(manager, Arrays. <Layer>asList(layer1, layer2));50 Data data = new Data(manager, Arrays.asList(layer1, layer2)); 50 51 51 52 // need to be identity … … 61 62 @Test 62 63 void testSupportedDataFlavor() { 63 LayerTransferable transferable = new LayerTransferable(manager, Arrays. <Layer>asList(layer1, layer2));64 LayerTransferable transferable = new LayerTransferable(manager, Arrays.asList(layer1, layer2)); 64 65 65 66 assertFalse(transferable.isDataFlavorSupported(DataFlavor.imageFlavor)); … … 77 78 @Test 78 79 void testTransferData() throws Exception { 79 LayerTransferable transferable = new LayerTransferable(manager, Arrays. <Layer>asList(layer1, layer2));80 LayerTransferable transferable = new LayerTransferable(manager, Arrays.asList(layer1, layer2)); 80 81 81 82 Object object = transferable.getTransferData(LayerTransferable.LAYER_DATA); 82 assertTrue(object instanceof Data); 83 Data data = (Data) object; 83 Data data = assertInstanceOf(Data.class, object); 84 84 assertSame(manager, data.getManager()); 85 85 assertSame(layer1, data.getLayers().get(0)); … … 92 92 @Test 93 93 void testTransferDataUnsupported() { 94 LayerTransferable transferable = new LayerTransferable(manager, Arrays. <Layer>asList(layer1, layer2));94 LayerTransferable transferable = new LayerTransferable(manager, Arrays.asList(layer1, layer2)); 95 95 96 96 assertThrows(UnsupportedFlavorException.class, () -> transferable.getTransferData(DataFlavor.imageFlavor)); -
trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferableTest.java
r18037 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertThrows; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; … … 67 68 Collection<PrimitiveData> td = ((PrimitiveTransferData) pt.getTransferData(PrimitiveTransferData.DATA_FLAVOR)).getAll(); 68 69 assertEquals(1, td.size()); 69 assert True(td.iterator().next() instanceof NodeData);70 assertInstanceOf(NodeData.class, td.iterator().next()); 70 71 71 72 -
trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/data/PrimitiveTagTransferDataTest.java
r18037 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNull; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 … … 9 10 import java.util.Map; 10 11 12 import org.junit.jupiter.api.Test; 11 13 import org.openstreetmap.josm.data.osm.Node; 12 14 import org.openstreetmap.josm.data.osm.NodeData; … … 17 19 import org.openstreetmap.josm.data.osm.WayData; 18 20 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 19 20 import org.junit.jupiter.api.Test;21 21 22 22 /** … … 109 109 assertEquals(2, (int) stats.get(OsmPrimitiveType.NODE)); 110 110 assertEquals(1, (int) stats.get(OsmPrimitiveType.WAY)); 111 assert Equals(null,stats.get(OsmPrimitiveType.RELATION));111 assertNull(stats.get(OsmPrimitiveType.RELATION)); 112 112 } 113 113 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
r17279 r18690 3 3 4 4 import static java.util.concurrent.TimeUnit.MILLISECONDS; 5 import static org.junit.Assert.assertArrayEquals; 6 import static org.junit.Assert.assertEquals; 7 import static org.junit.Assert.assertFalse; 8 import static org.junit.Assert.assertTrue; 9 import static org.junit.Assert.fail; 5 import static org.junit.jupiter.api.Assertions.assertArrayEquals; 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.assertInstanceOf; 9 import static org.junit.jupiter.api.Assertions.assertTrue; 10 import static org.junit.jupiter.api.Assertions.fail; 10 11 import static org.openstreetmap.josm.tools.I18n.tr; 11 12 … … 27 28 import javax.swing.JPopupMenu; 28 29 30 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 29 31 import org.awaitility.Awaitility; 30 32 import org.junit.Rule; … … 50 52 import org.openstreetmap.josm.testutils.JOSMTestRules; 51 53 52 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;53 54 54 /** 55 55 * Unit tests of {@link MinimapDialog} class. … … 95 95 boolean found = false; 96 96 for (Component c: menu.getComponents()) { 97 if ( JPopupMenu.Separator.class.isInstance(c)) {97 if (c instanceof JPopupMenu.Separator) { 98 98 break; 99 99 } else { … … 102 102 assertEquals(equalText, isSelected); 103 103 if (equalText) { 104 assertFalse( "Second selected source found", found);104 assertFalse(found, "Second selected source found"); 105 105 found = true; 106 106 } 107 107 } 108 108 } 109 assertTrue( "Selected source not found in menu", found);109 assertTrue(found, "Selected source not found in menu"); 110 110 } 111 111 … … 115 115 JPopupMenu menu = this.sourceButton.getPopupMenu(); 116 116 for (Component c: menu.getComponents()) { 117 if ( JPopupMenu.Separator.class.isInstance(c)) {117 if (c instanceof JPopupMenu.Separator) { 118 118 // sources should all come before any separators 119 119 break; … … 124 124 // else continue... 125 125 } 126 fail( );126 fail("Expected JMenuItem with text " + label + " not found"); 127 127 }); 128 128 } catch (Throwable e) { … … 196 196 /** 197 197 * Tests to switch imagery source. 198 * @throws Exception if any error occurs199 198 */ 200 199 @Test 201 public void testSourceSwitching() throws Exception{200 public void testSourceSwitching() { 202 201 // relevant prefs starting out empty, should choose the first source and have shown download area enabled 203 202 // (not that there's a data layer for it to use) … … 243 242 /** 244 243 * Tests that the apparently-selected TileSource survives the tile sources being refreshed. 245 * @throws Exception if any error occurs246 244 */ 247 245 @Test 248 public void testRefreshSourcesRetainsSelection() throws Exception{246 public void testRefreshSourcesRetainsSelection() { 249 247 // relevant prefs starting out empty, should choose the first source and have shown download area enabled 250 248 // (not that there's a data layer for it to use) … … 281 279 * Tests that the currently selected source being removed from ImageryLayerInfo will remain present and 282 280 * selected in the source menu even after the tile sources have been refreshed. 283 * @throws Exception if any error occurs284 281 */ 285 282 @Test 286 public void testRemovedSourceStillSelected() throws Exception{283 public void testRemovedSourceStillSelected() { 287 284 // relevant prefs starting out empty, should choose the first source and have shown download area enabled 288 285 // (not that there's a data layer for it to use) … … 314 311 /** 315 312 * Tests the tile source list includes sources only present in the LayerManager 316 * @throws Exception if any error occurs317 313 */ 318 314 @Test 319 public void testTileSourcesFromCurrentLayers() throws Exception{315 public void testTileSourcesFromCurrentLayers() { 320 316 // relevant prefs starting out empty, should choose the first (ImageryLayerInfo) source and have shown download area enabled 321 317 // (not that there's a data layer for it to use) … … 448 444 /** 449 445 * Tests minimap obeys a saved "mapstyle" preference on startup. 450 * @throws Exception if any error occurs451 446 */ 452 447 @Test 453 public void testSourcePrefObeyed() throws Exception{448 public void testSourcePrefObeyed() { 454 449 Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); 455 450 … … 475 470 /** 476 471 * Tests minimap handles an unrecognized "mapstyle" preference on startup 477 * @throws Exception if any error occurs478 472 */ 479 473 @Test 480 public void testSourcePrefInvalid() throws Exception{474 public void testSourcePrefInvalid() { 481 475 Config.getPref().put("slippy_map_chooser.mapstyle", "Hooloovoo Tiles"); 482 476 … … 497 491 /** 498 492 * test viewport marker rectangle matches the mapView's aspect ratio 499 * @throws Exception if any error occurs500 493 */ 501 494 @Test 502 public void testViewportAspectRatio() throws Exception{495 public void testViewportAspectRatio() { 503 496 // Add a test layer to the layer manager to get the MapFrame & MapView 504 497 MainApplication.getLayerManager().addLayer(new TestLayer()); … … 546 539 // should equal the number on the right 547 540 assertTrue( 548 "Viewport marker not horizontally centered",549 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4550 );541 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4, 542 "Viewport marker not horizontally centered" 543 ); 551 544 552 545 Matcher colMatcher = ImagePatternMatching.columnMatch( … … 561 554 // should equal the number on the bottom 562 555 assertTrue( 563 "Viewport marker not vertically centered",564 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4565 );556 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4, 557 "Viewport marker not vertically centered" 558 ); 566 559 567 560 // (within a tolerance for numerical error) the viewport marker should be square 568 561 assertTrue( 569 "Viewport marker not square",570 Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4571 );562 Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4, 563 "Viewport marker not square" 564 ); 572 565 573 566 // now change the mapView size … … 591 584 ); 592 585 assertTrue( 593 "Viewport marker not horizontally centered",594 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4595 );586 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4, 587 "Viewport marker not horizontally centered" 588 ); 596 589 597 590 colMatcher = ImagePatternMatching.columnMatch( … … 603 596 ); 604 597 assertTrue( 605 "Viewport marker not vertically centered",606 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4607 );598 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4, 599 "Viewport marker not vertically centered" 600 ); 608 601 609 602 try { … … 614 607 615 608 assertTrue( 616 "Viewport marker not 2:1 aspect ratio",617 Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5618 );609 Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5, 610 "Viewport marker not 2:1 aspect ratio" 611 ); 619 612 } 620 613 … … 623 616 boolean afterSeparator = false; 624 617 for (Component c: menu.getComponents()) { 625 if ( JPopupMenu.Separator.class.isInstance(c)) {626 assertFalse( "More than one separator before target item", afterSeparator);618 if (c instanceof JPopupMenu.Separator) { 619 assertFalse(afterSeparator, "More than one separator before target item"); 627 620 afterSeparator = true; 628 621 } else if (((JMenuItem) c).getText().equals(tr("Show downloaded area"))) { 629 assertTrue("Separator not found before target item", afterSeparator); 630 assertTrue("Target item doesn't appear to be a JCheckBoxMenuItem", JCheckBoxMenuItem.class.isInstance(c)); 631 return (JCheckBoxMenuItem) c; 622 assertTrue(afterSeparator, "Separator not found before target item"); 623 return assertInstanceOf(JCheckBoxMenuItem.class, c, "Target item doesn't appear to be a JCheckBoxMenuItem"); 632 624 } 633 625 } … … 638 630 /** 639 631 * test downloaded area is shown shaded 640 * @throws Exception if any error occurs641 632 */ 642 633 @Test 643 public void testShowDownloadedArea() throws Exception{634 public void testShowDownloadedArea() { 644 635 Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); 645 636 Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", false); … … 797 788 /** 798 789 * test display of downloaded area follows active layer switching 799 * @throws Exception if any error occurs800 790 */ 801 791 @Test 802 public void testShowDownloadedAreaLayerSwitching() throws Exception{792 public void testShowDownloadedAreaLayerSwitching() { 803 793 Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); 804 794 Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", true); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/layer/CycleLayerActionTest.java
r17279 r18690 2 2 package org.openstreetmap.josm.gui.dialogs.layer; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/layer/DuplicateActionTest.java
r18037 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assert False;5 import static org.junit.jupiter.api.Assertions.assertNotEquals; 6 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 7 import static org.junit.jupiter.api.Assertions.assertNull; … … 37 37 editLayer = MainApplication.getLayerManager().getEditLayer(); 38 38 assertNotNull(editLayer); 39 assert False(layer.equals(editLayer));39 assertNotEquals(layer, editLayer); 40 40 assertEquals(layer.data.getNodes().size(), editLayer.data.getNodes().size()); 41 41 assertEquals(layer.data.getWays().size(), editLayer.data.getWays().size()); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java
r17275 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.dialogs.relation.sort; 3 4 import static org.junit.jupiter.api.Assertions.assertArrayEquals; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 3 6 4 7 import java.io.IOException; … … 8 11 import java.util.List; 9 12 10 import org.junit.Assert;11 13 import org.junit.jupiter.api.BeforeEach; 12 14 import org.junit.jupiter.api.Test; … … 68 70 final String[] expected = {"t1w4", "t1w3", "t1w2", "t1w1", "t1w7", "t1w6", "t1w5", "t1n1", "t1n2"}; 69 71 // expect nodes to be sorted correctly 70 Assert.assertEquals(expected[7], actual[7]);71 Assert.assertEquals(expected[8], actual[8]);72 assertEquals(expected[7], actual[7]); 73 assertEquals(expected[8], actual[8]); 72 74 } 73 75 … … 75 77 void testAssociatedStreet() { 76 78 String[] actual = getNames(sorter.sortMembers(getRelation("associatedStreet").getMembers())); 77 Assert.assertArrayEquals(new String[] {"t2w1", "t2w2", "t2n1", "t2n2", "t2n3", "t2n4"}, actual);79 assertArrayEquals(new String[] {"t2w1", "t2w2", "t2n1", "t2n2", "t2n3", "t2n4"}, actual); 78 80 } 79 81 … … 81 83 void testStreet() { 82 84 String[] actual = getNames(sorter.sortMembers(getRelation("street").getMembers())); 83 Assert.assertArrayEquals(new String[]{"t2w1", "t2w2", "t2n1", "t2n2", "t2n3", "t2n4", "playground", "tree"}, actual);85 assertArrayEquals(new String[]{"t2w1", "t2w2", "t2n1", "t2n2", "t2n3", "t2n4", "playground", "tree"}, actual); 84 86 } 85 87 … … 94 96 // Check the first way before sorting, otherwise the sorter 95 97 // might pick a different loop starting point than expected below 96 Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));98 assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name")); 97 99 98 100 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 99 Assert.assertArrayEquals(new String[]{101 assertArrayEquals(new String[]{ 100 102 "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b", "t5w4b", 101 103 "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b", … … 110 112 // Check the first way before sorting, otherwise the sorter 111 113 // might sort in reverse compared to what is expected below 112 Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));114 assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name")); 113 115 114 116 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 115 Assert.assertArrayEquals(new String[]{117 assertArrayEquals(new String[]{ 116 118 "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b", "t5w4b", 117 119 "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b", … … 125 127 Relation relation = getRelation("three-loops-ends-node"); 126 128 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 127 Assert.assertArrayEquals(new String[]{129 assertArrayEquals(new String[]{ 128 130 "t5w4a", "t5w3a", "t5w2a", "t5w2b", "t5w3b", "t5w4b", 129 131 "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b", … … 136 138 Relation relation = getRelation("one-loop-ends-split"); 137 139 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 138 Assert.assertArrayEquals(new String[]{140 assertArrayEquals(new String[]{ 139 141 "t5w3a", "t5w4a", "t5w3b", "t5w4b", 140 142 "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b", … … 150 152 // for now. 151 153 String[] actual = getNames(relation.getMembers()); 152 Assert.assertArrayEquals(new String[]{154 assertArrayEquals(new String[]{ 153 155 "t5w7a", "t5w8a", "t5w7b", "t5w8b", 154 156 "t5w9a", "t5w10a", "t5w9b", "t5w10b", … … 161 163 // TODO: This is not yet sorted perfectly (might not be possible) 162 164 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 163 Assert.assertArrayEquals(new String[]{165 assertArrayEquals(new String[]{ 164 166 "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b", 165 167 "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w9a", "t5w10a", "t5w11a", "t5w6b", "t5w7b", … … 173 175 // TODO: This is not always sorted properly, only when the right 174 176 // way is already at the top, so check that 175 Assert.assertEquals("t6w1a", relation.getMembers().get(0).getMember().get("name"));177 assertEquals("t6w1a", relation.getMembers().get(0).getMember().get("name")); 176 178 177 179 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 178 Assert.assertArrayEquals(new String[]{180 assertArrayEquals(new String[]{ 179 181 "t6w1a", "t6w2a", "t6w3a", 180 182 "t6w1b", "t6w2b", "t6w3b", -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java
r17275 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.dialogs.relation.sort; 3 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.assertTrue; 3 7 4 8 import java.io.IOException; … … 12 16 import java.util.List; 13 17 14 import org.junit.Assert;15 18 import org.junit.jupiter.api.BeforeEach; 16 19 import org.junit.jupiter.api.Test; … … 102 105 void testEmpty() { 103 106 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(new ArrayList<>())); 104 Assert.assertEquals("[]", actual);107 assertEquals("[]", actual); 105 108 } 106 109 … … 113 116 Relation relation = getRelation("generic"); 114 117 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(relation.getMembers())); 115 Assert.assertEquals("[NONE, NONE, FORWARD, FORWARD, NONE, NONE, NONE, I, I]", actual);118 assertEquals("[NONE, NONE, FORWARD, FORWARD, NONE, NONE, NONE, I, I]", actual); 116 119 actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 117 Assert.assertEquals("[FORWARD, FORWARD, FORWARD, FORWARD, BACKWARD, BACKWARD, NONE, I, I]", actual);120 assertEquals("[FORWARD, FORWARD, FORWARD, FORWARD, BACKWARD, BACKWARD, NONE, I, I]", actual); 118 121 } 119 122 … … 122 125 Relation relation = getRelation("associatedStreet"); 123 126 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(relation.getMembers())); 124 Assert.assertEquals("[NONE, I, I, I, NONE, I]", actual);127 assertEquals("[NONE, I, I, I, NONE, I]", actual); 125 128 actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 126 Assert.assertEquals("[FORWARD, FORWARD, I, I, I, I]", actual);129 assertEquals("[FORWARD, FORWARD, I, I, I, I]", actual); 127 130 } 128 131 … … 131 134 Relation relation = getRelation("loop"); 132 135 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(relation.getMembers())); 133 Assert.assertEquals("[FPH FORWARD, FP FORWARD, NONE, FPH FORWARD, NONE, FPH FORWARD, NONE]", actual);136 assertEquals("[FPH FORWARD, FP FORWARD, NONE, FPH FORWARD, NONE, FPH FORWARD, NONE]", actual); 134 137 //TODO Sorting doesn't work well in this case 135 138 actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 136 Assert.assertEquals("[BACKWARD, BACKWARD, BACKWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BPT BACKWARD]", actual);139 assertEquals("[BACKWARD, BACKWARD, BACKWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BPT BACKWARD]", actual); 137 140 } 138 141 … … 147 150 // Check the first way before sorting, otherwise the sorter 148 151 // might pick a different loop starting point than expected below 149 Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));152 assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name")); 150 153 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 151 154 String expected = "[" + … … 155 158 "L FORWARD, L FORWARD" + 156 159 "]"; 157 Assert.assertEquals(expected, actual);160 assertEquals(expected, actual); 158 161 } 159 162 … … 163 166 // Check the first way before sorting, otherwise the sorter 164 167 // might sort in reverse compared to what is expected below 165 Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));168 assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name")); 166 169 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 167 170 String expected = "[" + … … 171 174 "FORWARD" + 172 175 "]"; 173 Assert.assertEquals(expected, actual);176 assertEquals(expected, actual); 174 177 } 175 178 … … 183 186 "FPH FORWARD, FP FORWARD, FP FORWARD, FP FORWARD, FP FORWARD, BPT BACKWARD" + 184 187 "]"; 185 Assert.assertEquals(expected, actual);188 assertEquals(expected, actual); 186 189 } 187 190 … … 195 198 "FPH FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD" + 196 199 "]"; 197 Assert.assertEquals(expected, actual);200 assertEquals(expected, actual); 198 201 } 199 202 … … 208 211 "FPH FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD" + 209 212 "]"; 210 Assert.assertEquals(expected, actual);213 assertEquals(expected, actual); 211 214 } 212 215 … … 221 224 "BACKWARD, FPH FORWARD, FP FORWARD, FP FORWARD" + 222 225 "]"; 223 Assert.assertEquals(expected, actual);226 assertEquals(expected, actual); 224 227 } 225 228 … … 229 232 // TODO: This is not always sorted properly, only when the right 230 233 // way is already at the top, so check that 231 Assert.assertEquals("t6w1a", relation.getMembers().get(0).getMember().get("name"));234 assertEquals("t6w1a", relation.getMembers().get(0).getMember().get("name")); 232 235 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 233 236 String expected = "[" + 234 237 "FP FORWARD, FP FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BP BACKWARD" + 235 238 "]"; 236 Assert.assertEquals(expected, actual);239 assertEquals(expected, actual); 237 240 } 238 241 … … 256 259 List<WayConnectionType> returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 257 260 for (int i = 0; i < 4; i++) { 258 Assert.assertTrue(returned.get(i).onewayFollowsPrevious);259 Assert.assertTrue(returned.get(i).onewayFollowsNext);260 } 261 262 Assert.assertTrue(returned.get(4).onewayFollowsPrevious);263 Assert.assertFalse(returned.get(4).onewayFollowsNext);264 265 Assert.assertFalse(returned.get(5).onewayFollowsPrevious);266 Assert.assertFalse(returned.get(5).onewayFollowsNext);267 268 Assert.assertFalse(returned.get(6).onewayFollowsPrevious);269 Assert.assertTrue(returned.get(6).onewayFollowsNext);261 assertTrue(returned.get(i).onewayFollowsPrevious); 262 assertTrue(returned.get(i).onewayFollowsNext); 263 } 264 265 assertTrue(returned.get(4).onewayFollowsPrevious); 266 assertFalse(returned.get(4).onewayFollowsNext); 267 268 assertFalse(returned.get(5).onewayFollowsPrevious); 269 assertFalse(returned.get(5).onewayFollowsNext); 270 271 assertFalse(returned.get(6).onewayFollowsPrevious); 272 assertTrue(returned.get(6).onewayFollowsNext); 270 273 271 274 // Reverse the last oneway … … 276 279 returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 277 280 for (int i = 0; i < 4; i++) { 278 Assert.assertTrue(returned.get(i).onewayFollowsPrevious);279 Assert.assertTrue(returned.get(i).onewayFollowsNext);281 assertTrue(returned.get(i).onewayFollowsPrevious); 282 assertTrue(returned.get(i).onewayFollowsNext); 280 283 } 281 284 282 Assert.assertTrue(returned.get(4).onewayFollowsPrevious);283 Assert.assertFalse(returned.get(4).onewayFollowsNext);284 285 Assert.assertFalse(returned.get(5).onewayFollowsPrevious);286 Assert.assertTrue(returned.get(5).onewayFollowsNext);287 288 Assert.assertTrue(returned.get(6).onewayFollowsPrevious);289 Assert.assertTrue(returned.get(6).onewayFollowsNext);285 assertTrue(returned.get(4).onewayFollowsPrevious); 286 assertFalse(returned.get(4).onewayFollowsNext); 287 288 assertFalse(returned.get(5).onewayFollowsPrevious); 289 assertTrue(returned.get(5).onewayFollowsNext); 290 291 assertTrue(returned.get(6).onewayFollowsPrevious); 292 assertTrue(returned.get(6).onewayFollowsNext); 290 293 reverseWay(way); 291 294 } … … 298 301 returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 299 302 for (int i = 0; i < 7; i++) { 300 Assert.assertTrue(returned.get(i).onewayFollowsPrevious);301 Assert.assertTrue(returned.get(i).onewayFollowsNext);303 assertTrue(returned.get(i).onewayFollowsPrevious); 304 assertTrue(returned.get(i).onewayFollowsNext); 302 305 } 303 306 } … … 309 312 returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 310 313 for (int i = 0; i < 7; i++) { 311 Assert.assertTrue(returned.get(i).onewayFollowsPrevious);312 Assert.assertTrue(returned.get(i).onewayFollowsNext);314 assertTrue(returned.get(i).onewayFollowsPrevious); 315 assertTrue(returned.get(i).onewayFollowsNext); 313 316 } 314 317 } … … 326 329 List<WayConnectionType> returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 327 330 for (WayConnectionType type : returned) { 328 Assert.assertTrue(type.onewayFollowsNext);329 Assert.assertTrue(type.onewayFollowsPrevious);331 assertTrue(type.onewayFollowsNext); 332 assertTrue(type.onewayFollowsPrevious); 330 333 } 331 334 … … 334 337 returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 335 338 for (WayConnectionType type : returned) { 336 Assert.assertTrue(type.onewayFollowsNext);337 Assert.assertTrue(type.onewayFollowsPrevious);339 assertTrue(type.onewayFollowsNext); 340 assertTrue(type.onewayFollowsPrevious); 338 341 } 339 342 … … 346 349 for (int i = 0; i < returned.size() - 1; i++) { 347 350 WayConnectionType type = returned.get(i); 348 Assert.assertTrue(type.onewayFollowsNext);349 Assert.assertTrue(type.onewayFollowsPrevious);350 } 351 Assert.assertTrue(returned.get(6).onewayFollowsNext);352 Assert.assertFalse(returned.get(6).onewayFollowsPrevious);351 assertTrue(type.onewayFollowsNext); 352 assertTrue(type.onewayFollowsPrevious); 353 } 354 assertTrue(returned.get(6).onewayFollowsNext); 355 assertFalse(returned.get(6).onewayFollowsPrevious); 353 356 } 354 357 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanelTest.java
r18037 r18690 2 2 package org.openstreetmap.josm.gui.dialogs.validator; 3 3 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 import static org.junit.jupiter.api.Assertions.assertNotNull; … … 31 32 @Test 32 33 void testValidatorTreePanel() { 33 assert NotNull(new ValidatorTreePanel());34 assertDoesNotThrow(() -> new ValidatorTreePanel()); 34 35 35 36 ValidatorTreePanel vtp = new ValidatorTreePanel(new ArrayList<>(Arrays.asList( … … 59 60 vtp.setVisible(false); 60 61 Node n = new Node(10); 61 vtp.setErrors( Arrays.asList(TestError.builder(null, Severity.ERROR, 0)62 vtp.setErrors(Collections.singletonList(TestError.builder(null, Severity.ERROR, 0) 62 63 .message("") 63 64 .primitives(n) 64 65 .build())); 65 66 assertEquals(1, vtp.getErrors().size()); 66 vtp.selectRelatedErrors(Collections. <OsmPrimitive>singleton(n));67 vtp.selectRelatedErrors(Collections.singleton(n)); 67 68 vtp.expandAll(); 68 69 assertNotNull(vtp.getRoot()); 69 70 vtp.resetErrors(); 70 Set<? extends OsmPrimitive> filter = new HashSet<>( Arrays.asList(n));71 Set<? extends OsmPrimitive> filter = new HashSet<>(Collections.singletonList(n)); 71 72 vtp.setFilter(filter); 72 73 assertEquals(filter, vtp.getFilter()); 73 vtp.setFilter(new HashSet< OsmPrimitive>());74 vtp.setFilter(new HashSet<>()); 74 75 assertNull(vtp.getFilter()); 75 76 vtp.setFilter(null); -
trunk/test/unit/org/openstreetmap/josm/gui/history/HistoryLoadTaskTest.java
r17275 r18690 53 53 54 54 /** 55 * Unit test of {@link HistoryLoadTask#loadHistory }55 * Unit test of {@link HistoryLoadTask#loadHistory(OsmServerHistoryReader, ProgressMonitor)} 56 56 * @throws OsmTransferException if an error occurs 57 57 */ -
trunk/test/unit/org/openstreetmap/josm/gui/io/AsynchronousUploadPrimitivesTaskTest.java
r17275 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.io; 3 4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 3 6 4 7 import java.util.Collections; … … 7 10 import javax.swing.JOptionPane; 8 11 9 import org.junit.Assert;10 12 import org.junit.jupiter.api.AfterEach; 11 13 import org.junit.jupiter.api.BeforeEach; … … 94 96 Optional<AsynchronousUploadPrimitivesTask> task = AsynchronousUploadPrimitivesTask. 95 97 createAsynchronousUploadTask(strategy, layer, toUpload, changeset); 96 Assert.assertNotNull(uploadPrimitivesTask);97 Assert.assertFalse(task.isPresent());98 assertNotNull(uploadPrimitivesTask); 99 assertFalse(task.isPresent()); 98 100 } 99 101 } -
trunk/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java
r18008 r18690 5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 6 import static org.junit.jupiter.api.Assertions.assertFalse; 7 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 7 8 import static org.junit.jupiter.api.Assertions.assertNull; 8 9 import static org.junit.jupiter.api.Assertions.assertThrows; … … 88 89 /** 89 90 * Unit test of {@link GpxLayer#GpxLayer}. 90 * @throws Exception if any error occurs 91 */ 92 @Test 93 void testGpxLayer() throws Exception { 91 */ 92 @Test 93 void testGpxLayer() { 94 94 GpxLayer layer = new GpxLayer(new GpxData(), "foo", false); 95 95 GpxTrack trk = new GpxTrack(new ArrayList<IGpxTrackSegment>(), new HashMap<>()); … … 211 211 void testGetTimespanForTrack() throws Exception { 212 212 assertEquals("", GpxLayer.getTimespanForTrack( 213 new GpxTrack(new ArrayList<Collection<WayPoint>>(), new HashMap< String, Object>())));213 new GpxTrack(new ArrayList<Collection<WayPoint>>(), new HashMap<>()))); 214 214 215 215 assertEquals("2016-01-03 11:59:58 \u2013 12:00:00 (2.0 s)", GpxLayer.getTimespanForTrack(getMinimalGpxData().tracks.iterator().next())); … … 238 238 @Test 239 239 void testMergeFromIAE() { 240 assertThrows(IllegalArgumentException.class, () -> new GpxLayer(new GpxData()).mergeFrom(new OsmDataLayer(new DataSet(), "", null))); 240 final GpxLayer gpxLayer = new GpxLayer(new GpxData()); 241 final OsmDataLayer osmDataLayer = new OsmDataLayer(new DataSet(), "testMergeFromIAE", null); 242 assertThrows(IllegalArgumentException.class, () -> gpxLayer.mergeFrom(osmDataLayer)); 241 243 } 242 244 … … 297 299 assertNull(layer.getAssociatedFile()); 298 300 Object infoComponent = layer.getInfoComponent(); 299 assertTrue(infoComponent instanceof JScrollPane); 300 Component view = ((JScrollPane) infoComponent).getViewport().getView(); 301 assertTrue(view instanceof HtmlPanel); 302 String text = ((HtmlPanel) view).getEditorPane().getText().trim(); 301 Component view = assertInstanceOf(JScrollPane.class, infoComponent).getViewport().getView(); 302 String text = assertInstanceOf(HtmlPanel.class, view).getEditorPane().getText().trim(); 303 303 assertTrue(text.startsWith("<html>"), text); 304 304 assertTrue(text.endsWith("</html>"), text); 305 305 assertEquals("<html><br></html>", layer.getToolTipText()); 306 assertDoesNotThrow( () -> layer.jumpToNextMarker());307 assertDoesNotThrow( () -> layer.jumpToPreviousMarker());306 assertDoesNotThrow(layer::jumpToNextMarker); 307 assertDoesNotThrow(layer::jumpToPreviousMarker); 308 308 assertDoesNotThrow(() -> layer.visitBoundingBox(new BoundingXYVisitor())); 309 309 assertDoesNotThrow(() -> layer.filterTracksByDate(null, null, false)); -
trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java
r17275 r18690 9 9 import java.nio.file.Paths; 10 10 import java.util.Arrays; 11 import java.util.Collections; 11 12 import java.util.Comparator; 12 13 import java.util.List; … … 73 74 74 75 Config.getPref().put("gpx.convert-tags", "list"); 75 Config.getPref().putList("gpx.convert-tags.list.yes", Arrays.asList("ele"));76 Config.getPref().putList("gpx.convert-tags.list.no", Arrays.asList("time"));76 Config.getPref().putList("gpx.convert-tags.list.yes", Collections.singletonList("ele")); 77 Config.getPref().putList("gpx.convert-tags.list.no", Collections.singletonList("time")); 77 78 testFromTrack("tracks.gpx", "tracks-ele.osm"); 78 79 79 Config.getPref().putList("gpx.convert-tags.list.yes", Arrays.asList("time"));80 Config.getPref().putList("gpx.convert-tags.list.no", Arrays.asList("ele"));80 Config.getPref().putList("gpx.convert-tags.list.yes", Collections.singletonList("time")); 81 Config.getPref().putList("gpx.convert-tags.list.no", Collections.singletonList("ele")); 81 82 testFromTrack("tracks.gpx", "tracks-time.osm"); 82 83 … … 141 142 142 143 List<String> ways = osm.getWays().stream() 143 .map(w -> Integer.toString(w.getNodes().size()) + ":" + w.getKeys().entrySet().stream()144 .sorted( Comparator.comparing(Map.Entry::getKey)).collect(Collectors.toList()).toString())144 .map(w -> w.getNodes().size() + ":" + w.getKeys().entrySet().stream() 145 .sorted(Map.Entry.comparingByKey()).collect(Collectors.toList())) 145 146 .sorted() 146 147 .collect(Collectors.toList()); 147 148 148 149 List<String> waysExpected = osmExpected.getWays().stream() 149 .map(w -> Integer.toString(w.getNodes().size()) + ":" + w.getKeys().entrySet().stream()150 .sorted( Comparator.comparing(Map.Entry::getKey)).collect(Collectors.toList()).toString())150 .map(w -> w.getNodes().size() + ":" + w.getKeys().entrySet().stream() 151 .sorted(Map.Entry.comparingByKey()).collect(Collectors.toList())) 151 152 .sorted() 152 153 .collect(Collectors.toList()); -
trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java
r16159 r18690 3 3 4 4 import static java.util.concurrent.TimeUnit.MILLISECONDS; 5 import static org.junit. Assert.assertEquals;6 import static org.junit. Assert.assertNotNull;7 import static org.junit. Assert.assertNull;8 import static org.junit. Assert.assertTrue;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.assertNull; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 9 9 10 10 import java.util.Collections; -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/AllMappaintTests.java
r17275 r18690 2 2 package org.openstreetmap.josm.gui.mappaint; 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.gui.mappaint.mapcss.AllMapCSSTests; 7 7 … … 9 9 * All mappaint tests. 10 10 */ 11 @ RunWith(Suite.class)12 @S uite.SuiteClasses({11 @Suite 12 @SelectClasses({ 13 13 LabelCompositionStrategyTest.class, 14 14 MapCSSWithExtendedTextDirectivesTest.class, -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.java
r17275 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 5 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 7 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertTrue;8 8 9 9 import java.awt.Color; … … 46 46 TextLabel te = TextLabel.create(env, Color.WHITE, false /* no default annotate */); 47 47 assertNotNull(te.labelCompositionStrategy); 48 assert True(te.labelCompositionStrategy instanceof DeriveLabelFromNameTagsCompositionStrategy);48 assertInstanceOf(DeriveLabelFromNameTagsCompositionStrategy.class, te.labelCompositionStrategy); 49 49 } 50 50 … … 63 63 TextLabel te = TextLabel.create(env, Color.WHITE, false /* no default annotate */); 64 64 assertNotNull(te.labelCompositionStrategy); 65 assert True(te.labelCompositionStrategy instanceof TagLookupCompositionStrategy);65 assertInstanceOf(TagLookupCompositionStrategy.class, te.labelCompositionStrategy); 66 66 assertEquals("my_name", ((TagLookupCompositionStrategy) te.labelCompositionStrategy).getDefaultLabelTag()); 67 67 } -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/AllMapCSSTests.java
r14068 r18690 2 2 package org.openstreetmap.josm.gui.mappaint.mapcss; 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 7 7 /** 8 8 * All MapCSS tests. 9 9 */ 10 @ RunWith(Suite.class)11 @S uite.SuiteClasses({10 @Suite 11 @SelectClasses({ 12 12 KeyValueConditionTest.class, 13 13 ParsingLinkSelectorTest.class, -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionTest.java
r18037 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 … … 54 55 assertFalse(op.applies(genEnv(node4))); 55 56 56 assertTrue(op instanceof SimpleKeyValueCondition);57 TagCondition tc = assertInstanceOf(SimpleKeyValueCondition.class, op); 57 58 assertEquals("[k1=v1]", op.toString()); 58 assertEquals("k1", ((TagCondition) op).asTag(null).getKey());59 assertEquals("v1", ((TagCondition) op).asTag(null).getValue());59 assertEquals("k1", tc.asTag(null).getKey()); 60 assertEquals("v1", tc.asTag(null).getValue()); 60 61 } 61 62 -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
r17920 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 8 import static org.junit.jupiter.api.Assertions.assertNull; … … 16 17 import java.util.regex.Pattern; 17 18 18 import org.junit.Assert;19 19 import org.junit.jupiter.api.Test; 20 20 import org.junit.jupiter.api.extension.RegisterExtension; … … 80 80 void testClassCondition() throws Exception { 81 81 List<Condition> conditions = getParser("way[name=X].highway:closed").selector().getConditions(); 82 assert True(conditions.get(0) instanceof SimpleKeyValueCondition);82 assertInstanceOf(SimpleKeyValueCondition.class, conditions.get(0)); 83 83 assertTrue(conditions.get(0).applies(getEnvironment("name", "X"))); 84 assert True(conditions.get(1) instanceof ClassCondition);85 assert True(conditions.get(2) instanceof PseudoClassCondition);84 assertInstanceOf(ClassCondition.class, conditions.get(1)); 85 assertInstanceOf(PseudoClassCondition.class, conditions.get(2)); 86 86 assertFalse(conditions.get(2).applies(getEnvironment("name", "X"))); 87 87 } … … 106 106 107 107 @Test 108 void testClassMatching() throws Exception{108 void testClassMatching() { 109 109 MapCSSStyleSource css = new MapCSSStyleSource( 110 110 "way[highway=footway] { set .path; color: #FF6644; width: 2; }\n" + … … 147 147 void testEqualCondition() throws Exception { 148 148 Condition condition = getParser("[surface=paved]").condition(PRIMITIVE); 149 assertTrue(condition instanceof SimpleKeyValueCondition);150 assertEquals("surface", ((SimpleKeyValueCondition) condition).k);151 assertEquals("paved", ((SimpleKeyValueCondition) condition).v);149 SimpleKeyValueCondition simpleKeyValueCondition = assertInstanceOf(SimpleKeyValueCondition.class, condition); 150 assertEquals("surface", simpleKeyValueCondition.k); 151 assertEquals("paved", simpleKeyValueCondition.v); 152 152 assertTrue(condition.applies(getEnvironment("surface", "paved"))); 153 153 assertFalse(condition.applies(getEnvironment("surface", "unpaved"))); … … 315 315 private void tagRegex(Way way, String parserString, Boolean[] expected) throws Exception { 316 316 Selector selector = getParser(parserString).selector(); 317 Assert.assertEquals(expected[0], selector.matches(new Environment(way)));317 assertEquals(expected[0], selector.matches(new Environment(way))); 318 318 way.put("old_ref", null); 319 Assert.assertEquals(expected[1], selector.matches(new Environment(way)));319 assertEquals(expected[1], selector.matches(new Environment(way))); 320 320 way.put("no_match_tag", "false"); 321 Assert.assertEquals(expected[2], selector.matches(new Environment(way)));321 assertEquals(expected[2], selector.matches(new Environment(way))); 322 322 way.put("old_ref", "A22"); 323 Assert.assertEquals(expected[3], selector.matches(new Environment(way)));323 assertEquals(expected[3], selector.matches(new Environment(way))); 324 324 way.put("old_ref", null); 325 325 way.put("OLD_REF", "A23"); 326 Assert.assertEquals(expected[4], selector.matches(new Environment(way)));326 assertEquals(expected[4], selector.matches(new Environment(way))); 327 327 } 328 328 … … 368 368 369 369 @Test 370 void testTicket8568() throws Exception{370 void testTicket8568() { 371 371 MapCSSStyleSource sheet = new MapCSSStyleSource( 372 372 "way { width: 5; }\n" + … … 385 385 386 386 @Test 387 void testTicket8071() throws Exception{387 void testTicket8071() { 388 388 MapCSSStyleSource sheet = new MapCSSStyleSource( 389 389 "*[rcn_ref], *[name] {text: concat(tag(rcn_ref), \" \", tag(name)); }"); … … 421 421 422 422 @Test 423 void testColorParsing() throws Exception{423 void testColorParsing() { 424 424 assertEquals(new Color(0x12, 0x34, 0x56, 0x78), ColorHelper.html2color("#12345678")); 425 425 } … … 459 459 460 460 @Test 461 void testParentTags() throws Exception{461 void testParentTags() { 462 462 DataSet ds = new DataSet(); 463 463 Node n = new Node(new LatLon(1, 2)); … … 486 486 487 487 @Test 488 void testSort() throws Exception{489 assertEquals(Arrays.asList( new String[] {"alpha", "beta"}), Functions.sort(null, "beta", "alpha"));488 void testSort() { 489 assertEquals(Arrays.asList("alpha", "beta"), Functions.sort(null, "beta", "alpha")); 490 490 Way way1 = TestUtils.newWay("highway=residential name=Alpha alt_name=Beta ref=\"A9;A8\"", new Node(new LatLon(0.001, 0.001)), 491 491 new Node(new LatLon(0.002, 0.002))); … … 508 508 509 509 @Test 510 void testUniqueValues() throws Exception{511 assertEquals(Arrays.asList( new String[] {"alpha", "beta"}),510 void testUniqueValues() { 511 assertEquals(Arrays.asList("alpha", "beta"), 512 512 Functions.uniq(null, "alpha", "alpha", "alpha", "beta")); 513 assertEquals(Arrays.asList( new String[] {"one", "two", "three"}),514 Functions.uniq_list(Arrays.asList( new String[] {"one", "one", "two", "two", "two", "three"})));515 } 516 517 @Test 518 void testCountRoles() throws Exception{513 assertEquals(Arrays.asList("one", "two", "three"), 514 Functions.uniq_list(Arrays.asList("one", "one", "two", "two", "two", "three"))); 515 } 516 517 @Test 518 void testCountRoles() { 519 519 DataSet ds = new DataSet(); 520 520 Way way1 = TestUtils.newWay("highway=residential name=1", … … 596 596 597 597 @Test 598 void testInvalidBaseSelector() throws Exception{598 void testInvalidBaseSelector() { 599 599 MapCSSStyleSource css = new MapCSSStyleSource("invalid_base[key=value] {}"); 600 600 css.loadStyleSource(); … … 624 624 assertEquals(24.0, mc.getCascade(null).get("div")); 625 625 assertEquals(-13.0, mc.getCascade(null).get("neg")); 626 assertEquals( true, mc.getCascade(null).get("not"));626 assertEquals(Boolean.TRUE, mc.getCascade(null).get("not")); 627 627 assertNull(mc.getCascade(null).get("null0")); 628 628 assertNull(mc.getCascade(null).get("null1")); … … 631 631 632 632 @Test 633 void testMinMaxFunctions() throws Exception{633 void testMinMaxFunctions() { 634 634 MapCSSStyleSource sheet = new MapCSSStyleSource("* {" + 635 635 "min_value: min(tag(x), tag(y), tag(z)); " + … … 700 700 @Test 701 701 void testZoomIAE() { 702 assertThrows(IllegalArgumentException.class, () -> getParser("|z16-15").zoom()); 702 final MapCSSParser parser = getParser("|z16-15"); 703 assertThrows(IllegalArgumentException.class, parser::zoom); 703 704 } 704 705 -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/AbstractExtendedSourceEntryTestCase.java
r17531 r18690 23 23 protected static final List<String> errorsToIgnore = new ArrayList<>(); 24 24 25 protected static List<Object[]> getTestParameters(Collection<ExtendedSourceEntry> entries) throws Exception{25 protected static List<Object[]> getTestParameters(Collection<ExtendedSourceEntry> entries) { 26 26 return entries.stream().map(x -> new Object[] {x.getDisplayName(), cleanUrl(x.url), x}).collect(Collectors.toList()); 27 27 } … … 45 45 protected final void handleException(ExtendedSourceEntry source, Throwable e, Set<String> errors, List<String> ignoredErrors) { 46 46 e.printStackTrace(); 47 String s = source.url + " => " + e .toString();47 String s = source.url + " => " + e; 48 48 if (isIgnoredSubstring(source, s)) { 49 49 ignoredErrors.add(s); -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/ToolbarPreferencesTest.java
r17275 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.preferences; 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 3 5 4 6 import java.awt.event.ActionEvent; … … 11 13 import javax.swing.Action; 12 14 13 import org.junit.Assert;14 15 import org.junit.jupiter.api.Test; 15 16 import org.openstreetmap.josm.actions.ActionParameter; … … 54 55 expected.put((String) params[i], params[i+1]); 55 56 } 56 Assert.assertEquals(expected, a.getParameters());57 assertEquals(expected, a.getParameters()); 57 58 } 58 59 … … 73 74 checkAction(parser.loadAction("action(uknownParam=aa)")); 74 75 75 Assert.assertEquals("action(param1=value1,param2=value2)",76 parser.saveAction(parser.loadAction("action(param1=value1,param2=value2)")));77 Assert.assertEquals("action(param1=value1,param2=)",78 parser.saveAction(parser.loadAction("action(param1=value1)")));79 Assert.assertEquals("action(param1=value1,param2=2\\(\\=\\,\\\\)",80 parser.saveAction(parser.loadAction("action(param1=value1,param2=2\\(\\=\\,\\\\)")));76 assertEquals("action(param1=value1,param2=value2)", parser.saveAction(parser.loadAction("action(param1=value1,param2=value2)"))); 77 assertEquals("action(param1=value1,param2=)", parser.saveAction(parser.loadAction("action(param1=value1)"))); 78 assertEquals( 79 "action(param1=value1,param2=2\\(\\=\\,\\\\)", 80 parser.saveAction(parser.loadAction("action(param1=value1,param2=2\\(\\=\\,\\\\)")) 81 ); 81 82 } 82 83 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
r18211 r18690 146 146 147 147 private static boolean isIgnoredSubstring(String substring) { 148 return errorsToIgnore.parallelStream().anyMatch( x -> substring.contains(x));148 return errorsToIgnore.parallelStream().anyMatch(substring::contains); 149 149 } 150 150 … … 342 342 } 343 343 } catch (IOException | RuntimeException | WMSGetCapabilitiesException e) { 344 addError(info, info.getUrl() + ERROR_SEP + e .toString());344 addError(info, info.getUrl() + ERROR_SEP + e); 345 345 } 346 346 … … 394 394 return new WMTSTileSource(info, proj); 395 395 } catch (IOException | WMTSGetCapabilitiesException e) { 396 addError(info, info.getUrl() + ERROR_SEP + e .toString());396 addError(info, info.getUrl() + ERROR_SEP + e); 397 397 return null; 398 398 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
r17195 r18690 4 4 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; 5 5 import static java.util.concurrent.TimeUnit.MILLISECONDS; 6 import static org.junit. Assert.assertEquals;7 import static org.junit. Assert.assertFalse;8 import static org.junit. Assert.assertTrue;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; 9 9 10 10 import java.awt.Component; -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java
r17369 r18690 5 5 import static org.hamcrest.MatcherAssert.assertThat; 6 6 import static org.junit.jupiter.api.Assertions.assertEquals; 7 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; 8 9 import static org.junit.jupiter.api.Assertions.fail; … … 13 14 import java.util.stream.Collectors; 14 15 15 import org.junit.Assert;16 16 import org.junit.jupiter.api.Test; 17 17 import org.junit.jupiter.api.extension.RegisterExtension; … … 45 45 String presetfile = TestUtils.getRegressionDataFile(8954, "preset.xml"); 46 46 final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(presetfile, false); 47 Assert.assertEquals("Number of preset items", 1, presets.size());47 assertEquals(1, presets.size(), "Number of preset items"); 48 48 final TaggingPreset preset = presets.iterator().next(); 49 Assert.assertEquals("Number of entries", 1, preset.data.size());49 assertEquals(1, preset.data.size(), "Number of entries"); 50 50 final TaggingPresetItem item = preset.data.get(0); 51 Assert.assertTrue("Entry is not checkbox", item instanceof Check);51 assertInstanceOf(Check.class, item, "Entry is not checkbox"); 52 52 } 53 53 … … 93 93 String presetfile = "resource://data/defaultpresets.xml"; 94 94 final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(presetfile, true); 95 Assert.assertTrue("Default presets are empty", presets.size() > 0);95 assertTrue(presets.size() > 0, "Default presets are empty"); 96 96 } 97 97 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetsTest.java
r18683 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertAll; 5 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 5 6 import static org.junit.jupiter.api.Assertions.assertSame; 6 import static org.junit.jupiter.api.Assertions.assertTrue;7 7 8 8 import java.util.Collection; … … 62 62 assertAll(() -> assertSame(menu.presetSearchAction, presetsMenu.getItem(0).getAction()), 63 63 () -> assertSame(menu.presetSearchPrimitiveAction, presetsMenu.getItem(1).getAction()), 64 () -> assert True(presetsMenu.getItem(2).getAction() instanceof PreferencesAction),65 () -> assert True(presetsMenu.getMenuComponent(3) instanceof JSeparator));64 () -> assertInstanceOf(PreferencesAction.class, presetsMenu.getItem(2).getAction()), 65 () -> assertInstanceOf(JSeparator.class, presetsMenu.getMenuComponent(3))); 66 66 } 67 67 -
trunk/test/unit/org/openstreetmap/josm/gui/widgets/HistoryComboBoxTest.java
r18131 r18690 21 21 class HistoryComboBoxTest { 22 22 static Stream<Arguments> testNonRegression21203() { 23 return Stream.of(Arguments.of("Hello world"), Arguments.of(new AutoCompletionItem("Hello world2")), Arguments.of( new Double(42)));23 return Stream.of(Arguments.of("Hello world"), Arguments.of(new AutoCompletionItem("Hello world2")), Arguments.of(42.0)); 24 24 } 25 25 … … 59 59 historyComboBox.addCurrentItemToHistory(); 60 60 61 // add a new item61 // Add a new item 62 62 historyComboBox.getEditor().setItem(new AutoCompletionItem("testNonRegression21215_2")); 63 63 historyComboBox.addCurrentItemToHistory(); -
trunk/test/unit/org/openstreetmap/josm/io/CertificateAmendmentTestIT.java
r18228 r18690 2 2 package org.openstreetmap.josm.io; 3 3 4 import static org.junit.jupiter.api.Assertions.fail; 4 5 import static org.junit.jupiter.api.Assumptions.assumeFalse; 5 6 … … 12 13 import javax.net.ssl.SSLHandshakeException; 13 14 14 import org.junit.Assert;15 15 import org.junit.ClassRule; 16 16 import org.junit.jupiter.api.BeforeAll; … … 111 111 assumeFalse(errorsToIgnore.contains(error)); 112 112 if (!shouldWork) { 113 Assert.fail(error);113 fail(error); 114 114 } 115 115 } -
trunk/test/unit/org/openstreetmap/josm/io/GeoJSONReaderTest.java
r18464 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertNull; 7 8 import static org.junit.jupiter.api.Assertions.assertThrows; … … 221 222 assertEquals(1, primitives.size()); 222 223 OsmPrimitive primitive = primitives.get(0); 223 assertTrue(primitive instanceof Node); 224 Node n = (Node) primitive; 224 Node n = assertInstanceOf(Node.class, primitive); 225 225 assertNull(n.get("addr:building")); 226 226 assertEquals("06883", n.get("addr:postcode")); -
trunk/test/unit/org/openstreetmap/josm/io/OsmChangesetContentParserTest.java
r18037 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 import static org.junit.jupiter.api.Assertions.fail;8 8 9 9 import java.io.ByteArrayInputStream; … … 12 12 import java.util.Arrays; 13 13 14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 15 import org.junit.jupiter.api.Test; 14 16 import org.openstreetmap.josm.data.osm.ChangesetDataSet; 15 17 import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType; … … 21 23 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 22 24 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 23 import org.openstreetmap.josm.tools.Logging;24 25 import org.openstreetmap.josm.tools.XmlParsingException; 25 26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;27 import org.junit.jupiter.api.Test;28 26 29 27 /** … … 32 30 @BasicPreferences 33 31 class OsmChangesetContentParserTest { 34 private static void shouldFail(Runnable r) {35 try {36 r.run();37 fail("should throw exception");38 } catch (IllegalArgumentException e) {39 Logging.trace(e);40 }41 }42 43 32 /** 44 33 * Test various constructor invocations … … 51 40 new OsmChangesetContentParser(new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8))); 52 41 53 shouldFail(() -> { 54 new OsmChangesetContentParser((String) null); 55 }); 56 57 shouldFail(() -> { 58 new OsmChangesetContentParser((InputStream) null); 59 }); 42 assertThrows(IllegalArgumentException.class, () -> new OsmChangesetContentParser((String) null)); 43 44 assertThrows(IllegalArgumentException.class, () -> new OsmChangesetContentParser((InputStream) null)); 60 45 } 61 46 -
trunk/test/unit/org/openstreetmap/josm/io/OsmWriterTest.java
r18037 r18690 14 14 import java.util.ArrayList; 15 15 import java.util.Arrays; 16 import java.util.Collections;17 16 import java.util.List; 18 17 … … 48 47 } 49 48 50 Collections.sort(ids,OsmWriter.byIdComparator);49 ids.sort(OsmWriter.byIdComparator); 51 50 52 51 final long[] longIds = ids.stream().mapToLong(NodeData::getUniqueId).toArray(); -
trunk/test/unit/org/openstreetmap/josm/io/UrlPatternsTest.java
r17275 r18690 37 37 void testUrlPatterns() { 38 38 assertTrue(patterns.stream().flatMap(c -> Arrays.stream(c.getEnumConstants())).map(t -> ((UrlPattern) t).pattern()) 39 .map(Pattern::compile). count() > 0);39 .map(Pattern::compile).findAny().isPresent()); 40 40 } 41 41 } -
trunk/test/unit/org/openstreetmap/josm/io/nmea/NmeaReaderTest.java
r17715 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNull; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 … … 70 71 assertEquals("3d", wayPoints.get(0).get(GpxConstants.PT_FIX)); 71 72 assertEquals("0.7", wayPoints.get(0).get(GpxConstants.PT_HDOP).toString().trim()); 72 assert Equals(null,wayPoints.get(0).get(GpxConstants.PT_VDOP));73 assert Equals(null,wayPoints.get(0).get(GpxConstants.PT_PDOP));73 assertNull(wayPoints.get(0).get(GpxConstants.PT_VDOP)); 74 assertNull(wayPoints.get(0).get(GpxConstants.PT_PDOP)); 74 75 } 75 76 -
trunk/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java
r17659 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 5 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; … … 76 77 List<Layer> layers = testRead(file); 77 78 assertEquals(layers.size(), 1); 78 assertTrue(layers.get(0) instanceof OsmDataLayer); 79 OsmDataLayer osm = (OsmDataLayer) layers.get(0); 79 OsmDataLayer osm = assertInstanceOf(OsmDataLayer.class, layers.get(0)); 80 80 assertEquals(osm.getName(), "OSM layer name"); 81 81 } … … 92 92 List<Layer> layers = testRead(file); 93 93 assertEquals(layers.size(), 1); 94 assertTrue(layers.get(0) instanceof GpxLayer); 95 GpxLayer gpx = (GpxLayer) layers.get(0); 94 GpxLayer gpx = assertInstanceOf(GpxLayer.class, layers.get(0)); 96 95 assertEquals(gpx.getName(), "GPX layer name"); 97 96 } … … 135 134 final List<Layer> layers = testRead("bing.jos"); 136 135 assertEquals(layers.size(), 1); 137 assert True(layers.get(0) instanceof ImageryLayer);136 assertInstanceOf(ImageryLayer.class, layers.get(0)); 138 137 final AbstractTileSourceLayer<?> image = (AbstractTileSourceLayer<?>) layers.get(0); 139 138 assertEquals("Bing aerial imagery", image.getName()); … … 157 156 final List<Layer> layers = testRead("notes.joz"); 158 157 assertEquals(layers.size(), 1); 159 assertTrue(layers.get(0) instanceof NoteLayer); 160 final NoteLayer layer = (NoteLayer) layers.get(0); 158 final NoteLayer layer = assertInstanceOf(NoteLayer.class, layers.get(0)); 161 159 assertEquals("Notes", layer.getName()); 162 160 assertEquals(174, layer.getNoteData().getNotes().size()); -
trunk/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java
r18466 r18690 131 131 } 132 132 } 133 SessionWriter sw = new SessionWriter(layers, -1, exporters, new MultiMap< Layer, Layer>(), zip);133 SessionWriter sw = new SessionWriter(layers, -1, exporters, new MultiMap<>(), zip); 134 134 File file = new File(System.getProperty("java.io.tmpdir"), getClass().getName()+(zip ? ".joz" : ".jos")); 135 135 try { … … 214 214 */ 215 215 public static NoteLayer createNoteLayer() { 216 return new NoteLayer( Arrays.asList(new Note(LatLon.ZERO)), "layer name");216 return new NoteLayer(Collections.singletonList(new Note(LatLon.ZERO)), "layer name"); 217 217 } 218 218 … … 223 223 @Test 224 224 void testWriteEmptyJos() throws IOException { 225 testWrite(Collections. <Layer>emptyList(), false);225 testWrite(Collections.emptyList(), false); 226 226 } 227 227 … … 232 232 @Test 233 233 void testWriteEmptyJoz() throws IOException { 234 testWrite(Collections. <Layer>emptyList(), true);234 testWrite(Collections.emptyList(), true); 235 235 } 236 236 … … 241 241 @Test 242 242 void testWriteOsmJos() throws IOException { 243 testWrite(Collections. <Layer>singletonList(createOsmLayer()), false);243 testWrite(Collections.singletonList(createOsmLayer()), false); 244 244 } 245 245 … … 250 250 @Test 251 251 void testWriteOsmJoz() throws IOException { 252 testWrite(Collections. <Layer>singletonList(createOsmLayer()), true);252 testWrite(Collections.singletonList(createOsmLayer()), true); 253 253 } 254 254 … … 259 259 @Test 260 260 void testWriteGpxJos() throws IOException { 261 testWrite(Collections. <Layer>singletonList(createGpxLayer()), false);261 testWrite(Collections.singletonList(createGpxLayer()), false); 262 262 } 263 263 … … 268 268 @Test 269 269 void testWriteGpxJoz() throws IOException { 270 testWrite(Collections. <Layer>singletonList(createGpxLayer()), true);270 testWrite(Collections.singletonList(createGpxLayer()), true); 271 271 } 272 272 -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java
r17195 r18690 3 3 4 4 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; 5 import static org.junit. Assert.assertEquals;6 import static org.junit. Assert.assertFalse;7 import static org.junit. Assert.assertNotEquals;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.assertNotEquals; 8 8 9 9 import java.io.File; -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java
r17195 r18690 3 3 4 4 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; 5 import static org.junit. Assert.assertEquals;6 import static org.junit. Assert.assertFalse;7 import static org.junit. Assert.assertNotEquals;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.assertNotEquals; 8 8 9 9 import java.io.File; -
trunk/test/unit/org/openstreetmap/josm/testutils/ImagePatternMatching.java
r17275 r18690 38 38 .orElse(i -> paletteMap.getOrDefault(i, "#")); 39 39 pattern = Optional.ofNullable(pattern) 40 .orElseGet(() -> patternCache.computeIfAbsent(patternString, k -> Pattern.compile(k)));40 .orElseGet(() -> patternCache.computeIfAbsent(patternString, Pattern::compile)); 41 41 42 42 int[] columnOrRow = isColumn … … 48 48 49 49 if (assertMatch && !result.matches()) { 50 System.err.print ln(String.format("Full strip failing to match pattern %s: %s", pattern, stringRepr));50 System.err.printf("Full strip failing to match pattern %s: %s%n", pattern, stringRepr); 51 51 fail(String.format( 52 52 "%s %d failed to match pattern %s", -
trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
r18551 r18690 666 666 try { 667 667 eventManager.resetState(); 668 } catch (IllegalArgumentException ignored) {669 Logging.trace( ignored);668 } catch (IllegalArgumentException e) { 669 Logging.trace(e); 670 670 } 671 671 } -
trunk/test/unit/org/openstreetmap/josm/testutils/PluginServer.java
r17195 r18690 80 80 try { 81 81 jarFile = new JarFile(srcJar, false); 82 jarFile.getManifest().getMainAttributes().entrySet().forEach( 83 entry -> attrs.put(entry.getKey().toString(), entry.getValue().toString()) 84 ); 82 jarFile.getManifest().getMainAttributes() 83 .forEach((key, value) -> attrs.put(key.toString(), value.toString())); 85 84 } catch (IOException e) { 86 85 Logging.warn( -
trunk/test/unit/org/openstreetmap/josm/testutils/mockers/ExtendedDialogMocker.java
r18454 r18690 88 88 89 89 protected String getString(final ExtendedDialog instance) { 90 return Optional.ofNullable(this.simpleStringContentMemo.get(instance)) 91 .orElseGet(() -> instance.toString()); 90 return Optional.ofNullable(this.simpleStringContentMemo.get(instance)).orElseGet(instance::toString); 92 91 } 93 92 … … 185 184 @Mock 186 185 private void setVisible(final Invocation invocation, final boolean value) throws Throwable { 187 if (value == true) {186 if (value) { 188 187 try { 189 188 final ExtendedDialog instance = invocation.getInvokedInstance(); -
trunk/test/unit/org/openstreetmap/josm/tools/AlphanumComparatorTest.java
r17275 r18690 5 5 6 6 import java.util.Arrays; 7 import java.util.Collections;8 7 import java.util.List; 9 8 … … 21 20 void testNumeric() { 22 21 List<String> lst = Arrays.asList("1", "20", "-1", "00999", "100"); 23 Collections.sort(lst,AlphanumComparator.getInstance());22 lst.sort(AlphanumComparator.getInstance()); 24 23 assertEquals(Arrays.asList("-1", "1", "20", "100", "00999"), lst); 25 24 } … … 31 30 void testMixed() { 32 31 List<String> lst = Arrays.asList("b1", "b20", "a5", "a00999", "a100"); 33 Collections.sort(lst,AlphanumComparator.getInstance());32 lst.sort(AlphanumComparator.getInstance()); 34 33 assertEquals(Arrays.asList("a5", "a100", "a00999", "b1", "b20"), lst); 35 34 } -
trunk/test/unit/org/openstreetmap/josm/tools/LanguageInfoTest.java
r17275 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.tools; 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 3 5 4 6 import java.util.Arrays; … … 8 10 import java.util.stream.Stream; 9 11 10 import org.junit.Assert;11 12 import org.junit.jupiter.api.extension.RegisterExtension; 12 13 import org.junit.jupiter.api.Test; … … 59 60 .map(locale -> LanguageInfo.getWikiLanguagePrefix(locale, type)) 60 61 .collect(Collectors.toList()); 61 Assert.assertEquals(Arrays.asList(expected), actual);62 assertEquals(Arrays.asList(expected), actual); 62 63 } 63 64 … … 67 68 @Test 68 69 void testGetLocale() { 69 Assert.assertEquals(RU, LanguageInfo.getLocale("ru"));70 Assert.assertEquals(EN_GB, LanguageInfo.getLocale("en_GB"));71 Assert.assertEquals(CA_ES_VALENCIA, LanguageInfo.getLocale("ca_ES@valencia"));72 Assert.assertEquals(DE_DE, LanguageInfo.getLocale("de_DE"));73 Assert.assertEquals(DE_DE, LanguageInfo.getLocale("de_DE.UTF-8")); // LANG, LC_MEASUREMENT74 Assert.assertEquals(PT_BR, LanguageInfo.getLocale("pt_BR.UTF-8")); // LANG, LC_MEASUREMENT70 assertEquals(RU, LanguageInfo.getLocale("ru")); 71 assertEquals(EN_GB, LanguageInfo.getLocale("en_GB")); 72 assertEquals(CA_ES_VALENCIA, LanguageInfo.getLocale("ca_ES@valencia")); 73 assertEquals(DE_DE, LanguageInfo.getLocale("de_DE")); 74 assertEquals(DE_DE, LanguageInfo.getLocale("de_DE.UTF-8")); // LANG, LC_MEASUREMENT 75 assertEquals(PT_BR, LanguageInfo.getLocale("pt_BR.UTF-8")); // LANG, LC_MEASUREMENT 75 76 } 76 77 … … 80 81 @Test 81 82 void testGetJOSMLocaleCode() { 82 Assert.assertEquals("de", LanguageInfo.getJOSMLocaleCode(DE_DE));83 Assert.assertEquals("pt_BR", LanguageInfo.getJOSMLocaleCode(PT_BR));84 Assert.assertEquals("ca@valencia", LanguageInfo.getJOSMLocaleCode(CA_ES_VALENCIA));83 assertEquals("de", LanguageInfo.getJOSMLocaleCode(DE_DE)); 84 assertEquals("pt_BR", LanguageInfo.getJOSMLocaleCode(PT_BR)); 85 assertEquals("ca@valencia", LanguageInfo.getJOSMLocaleCode(CA_ES_VALENCIA)); 85 86 } 86 87 … … 90 91 @Test 91 92 void testGetJavaLocaleCode() { 92 Assert.assertEquals("ca__valencia", LanguageInfo.getJavaLocaleCode("ca@valencia"));93 assertEquals("ca__valencia", LanguageInfo.getJavaLocaleCode("ca@valencia")); 93 94 } 94 95 … … 98 99 @Test 99 100 void testGetLanguageCodeXML() { 100 Assert.assertEquals("ca-valencia.", LanguageInfo.getLanguageCodeXML());101 assertEquals("ca-valencia.", LanguageInfo.getLanguageCodeXML()); 101 102 } 102 103 … … 106 107 @Test 107 108 void testGetLanguageCodeManifest() { 108 Assert.assertEquals("ca-valencia_", LanguageInfo.getLanguageCodeManifest());109 assertEquals("ca-valencia_", LanguageInfo.getLanguageCodeManifest()); 109 110 } 110 111 … … 114 115 @Test 115 116 void testGetLanguageCodes() { 116 Assert.assertEquals(Arrays.asList("ca_ES@valencia", "ca@valencia", "ca_ES", "ca"), LanguageInfo.getLanguageCodes(CA_ES_VALENCIA));117 assertEquals(Arrays.asList("ca_ES@valencia", "ca@valencia", "ca_ES", "ca"), LanguageInfo.getLanguageCodes(CA_ES_VALENCIA)); 117 118 } 118 119 } -
trunk/test/unit/org/openstreetmap/josm/tools/MemoryManagerTest.java
r17275 r18690 65 65 MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, Object::new); 66 66 testMemory.free(); 67 assertThrows(IllegalStateException.class, () -> testMemory.get());67 assertThrows(IllegalStateException.class, testMemory::get); 68 68 } 69 69 … … 77 77 MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, Object::new); 78 78 testMemory.free(); 79 assertThrows(IllegalStateException.class, () -> testMemory.free());79 assertThrows(IllegalStateException.class, testMemory::free); 80 80 } 81 81 82 82 /** 83 83 * Test that too big allocations fail 84 * @throws NotEnoughMemoryException always85 84 */ 86 85 @Test 87 void testAllocationFails() throws NotEnoughMemoryException{86 void testAllocationFails() { 88 87 MemoryManager manager = MemoryManager.getInstance(); 89 88 long available = manager.getAvailableMemory(); … … 97 96 /** 98 97 * Test that allocations with null object fail 99 * @throws NotEnoughMemoryException never100 98 */ 101 99 @Test 102 void testSupplierFails() throws NotEnoughMemoryException{100 void testSupplierFails() { 103 101 MemoryManager manager = MemoryManager.getInstance(); 104 102 … … 119 117 /** 120 118 * Test {@link MemoryManager#isAvailable(long)} for negative number 121 * @throws NotEnoughMemoryException never122 119 */ 123 120 @Test 124 void testIsAvailableFails() throws NotEnoughMemoryException{121 void testIsAvailableFails() { 125 122 MemoryManager manager = MemoryManager.getInstance(); 126 123 … … 154 151 155 152 assertFalse(manager.resetState().isEmpty()); 156 assertThrows(IllegalStateException.class, () -> testMemory.get());153 assertThrows(IllegalStateException.class, testMemory::get); 157 154 } 158 155 -
trunk/test/unit/org/openstreetmap/josm/tools/OsmUrlToBoundsTest.java
r18037 r18690 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 4 6 import org.openstreetmap.josm.data.Bounds; 5 7 6 import org.junit.Assert;7 8 import org.junit.jupiter.api.Test; 8 9 … … 16 17 @Test 17 18 void testPositionToBounds() { 18 Assert.assertEquals(new Bounds(51.7167359, 8.7573485, 51.720724, 8.7659315), 19 OsmUrlToBounds.positionToBounds(51.71873, 8.76164, 17)); 20 Assert.assertEquals(new Bounds(40.8609329, -75.7523458, 40.8633671, -75.7480542), 21 OsmUrlToBounds.positionToBounds(40.86215, -75.75020, 18)); 19 assertEquals(new Bounds(51.7167359, 8.7573485, 51.720724, 8.7659315), OsmUrlToBounds.positionToBounds(51.71873, 8.76164, 17)); 20 assertEquals(new Bounds(40.8609329, -75.7523458, 40.8633671, -75.7480542), OsmUrlToBounds.positionToBounds(40.86215, -75.75020, 18)); 22 21 } 23 22 … … 89 88 Logging.trace(e); 90 89 } 91 Assert.assertEquals(item.url, item.bounds, bounds);90 assertEquals(item.bounds, bounds, item.url); 92 91 } 93 92 } … … 98 97 @Test 99 98 void testGetZoom() { 100 Assert.assertEquals(4, OsmUrlToBounds.getZoom(OsmUrlToBounds.positionToBounds(0, 0, 4)));101 Assert.assertEquals(10, OsmUrlToBounds.getZoom(OsmUrlToBounds.positionToBounds(5, 5, 10)));102 Assert.assertEquals(18, OsmUrlToBounds.getZoom(OsmUrlToBounds.positionToBounds(40, 20, 18)));99 assertEquals(4, OsmUrlToBounds.getZoom(OsmUrlToBounds.positionToBounds(0, 0, 4))); 100 assertEquals(10, OsmUrlToBounds.getZoom(OsmUrlToBounds.positionToBounds(5, 5, 10))); 101 assertEquals(18, OsmUrlToBounds.getZoom(OsmUrlToBounds.positionToBounds(40, 20, 18))); 103 102 } 104 103 } -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEntryTest.java
r17275 r18690 2 2 package org.openstreetmap.josm.tools.template_engine; 3 3 4 import static org.junit.jupiter.api.Assertions.assertTrue; 5 4 6 import java.util.Set; 5 7 6 import org.junit.Assert;7 8 import org.junit.jupiter.api.extension.RegisterExtension; 8 9 import org.junit.jupiter.api.Test; … … 34 35 TestUtils.assumeWorkingEqualsVerifier(); 35 36 Set<Class<? extends TemplateEntry>> templates = TestUtils.getJosmSubtypes(TemplateEntry.class); 36 Assert.assertTrue(templates.size() >= 3); // if it finds less than 3 classes, something is broken37 assertTrue(templates.size() >= 3); // if it finds less than 3 classes, something is broken 37 38 for (Class<?> c : templates) { 38 39 Logging.debug(c.toString()); -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateParserTest.java
r17275 r18690 8 8 import java.util.List; 9 9 10 import org.junit.Assert;11 10 import org.junit.jupiter.api.BeforeAll; 12 11 import org.junit.jupiter.api.Test; … … 145 144 StringBuilder sb = new StringBuilder(); 146 145 entry.appendText(sb, dataProvider); 147 Assert.assertEquals("waypointName uu i10i", sb.toString());146 assertEquals("waypointName uu i10i", sb.toString()); 148 147 } 149 148 … … 161 160 r.put("admin_level", "2"); 162 161 templateEntry.appendText(sb, r); 163 Assert.assertEquals("NUTS 1", sb.toString());162 assertEquals("NUTS 1", sb.toString()); 164 163 165 164 sb.setLength(0); 166 165 r.put("admin_level", "5"); 167 166 templateEntry.appendText(sb, r); 168 Assert.assertEquals("5", sb.toString());167 assertEquals("5", sb.toString()); 169 168 } 170 169 … … 179 178 StringBuilder sb = new StringBuilder(); 180 179 entry.appendText(sb, dataProvider); 181 Assert.assertEquals("name=waypointName, number=10", sb.toString());182 Assert.assertEquals("{special:everything}", entry.toString());180 assertEquals("name=waypointName, number=10", sb.toString()); 181 assertEquals("{special:everything}", entry.toString()); 183 182 } 184 183 … … 193 192 StringBuilder sb = new StringBuilder(); 194 193 entry.appendText(sb, dataProvider); 195 Assert.assertEquals("waypointName\n10", sb.toString());194 assertEquals("waypointName\n10", sb.toString()); 196 195 } 197 196 … … 207 206 StringBuilder sb = new StringBuilder(); 208 207 templateEntry.appendText(sb, dataProvider); 209 Assert.assertEquals("waypointNameulocalNameuspecialKey", sb.toString());208 assertEquals("waypointNameulocalNameuspecialKey", sb.toString()); 210 209 } 211 210 … … 239 238 entry.appendText(sb, child); 240 239 241 Assert.assertEquals("name_parent2", sb.toString());240 assertEquals("name_parent2", sb.toString()); 242 241 } 243 242 … … 258 257 entry.appendText(sb, child); 259 258 260 Assert.assertEquals("name_parent1", sb.toString());259 assertEquals("name_parent1", sb.toString()); 261 260 } 262 261 … … 285 284 entry.appendText(sb, child2); 286 285 287 Assert.assertEquals("name_parent1name_parent2", sb.toString());286 assertEquals("name_parent1name_parent2", sb.toString()); 288 287 } 289 288 … … 318 317 entry.appendText(sb, child2); 319 318 320 Assert.assertEquals("grandparent_namename_parent2", sb.toString());319 assertEquals("grandparent_namename_parent2", sb.toString()); 321 320 } 322 321 … … 324 323 void testErrorsNot() { 325 324 TemplateParser parser = new TemplateParser("!{-parent() '{name}'}"); 326 assertThrows(ParseError.class, () -> parser.parse());325 assertThrows(ParseError.class, parser::parse); 327 326 } 328 327 … … 330 329 void testErrorOr() { 331 330 TemplateParser parser = new TemplateParser("!{parent() | type=type1 '{name}'}"); 332 assertThrows(ParseError.class, () -> parser.parse());331 assertThrows(ParseError.class, parser::parse); 333 332 } 334 333 … … 356 355 entry.appendText(sb, parent2); 357 356 358 Assert.assertEquals("child2", sb.toString());357 assertEquals("child2", sb.toString()); 359 358 } 360 359 … … 364 363 final String s2 = new TemplateParser(s1).parse().toString(); 365 364 final String s3 = new TemplateParser(s2).parse().toString(); 366 Assert.assertEquals(s1, s2);367 Assert.assertEquals(s2, s3);365 assertEquals(s1, s2); 366 assertEquals(s2, s3); 368 367 } 369 368 }
Note:
See TracChangeset
for help on using the changeset viewer.