Changeset 14201 in josm
- Timestamp:
- 2018-08-29T19:40:53+02:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/BuildProjectionDefinitions.java
r13708 r14201 8 8 import java.nio.charset.StandardCharsets; 9 9 import java.util.Arrays; 10 import java.util.Collections; 10 11 import java.util.LinkedHashMap; 11 12 import java.util.List; … … 74 75 75 76 static List<String> initList(String baseDir, String ext) { 76 return Arrays.asList(new File(baseDir + File.separator + PROJ_DIR) 77 .list((dir, name) -> !name.contains(".") || name.toLowerCase(Locale.ENGLISH).endsWith(ext))); 77 String[] result = new File(baseDir + File.separator + PROJ_DIR) 78 .list((dir, name) -> !name.contains(".") || name.toLowerCase(Locale.ENGLISH).endsWith(ext)); 79 return result != null ? Arrays.asList(result) : Collections.emptyList(); 78 80 } 79 81 -
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r14153 r14201 320 320 } 321 321 322 Pattern urlPattern = Pattern.compile(".*(https?://.*)"); 322 323 for (File urlFile: urlFiles) { 323 324 try (BufferedReader reader = Files.newBufferedReader(urlFile.toPath(), StandardCharsets.UTF_8)) { 324 325 String line; 325 326 while ((line = reader.readLine()) != null) { 326 Matcher m = Pattern.compile(".*(https?://.*)").matcher(line);327 Matcher m = urlPattern.matcher(line); 327 328 if (m.matches()) { 328 329 String url = m.group(1); -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r14128 r14201 425 425 * Add a new map paint style. 426 426 * @param entry map paint style 427 * @return loaded style source , or {@code null}427 * @return loaded style source 428 428 */ 429 429 public static StyleSource addStyle(SourceEntry entry) { -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r14153 r14201 653 653 Collection<String> parameters = new ArrayList<>(); 654 654 NodeList paramNl = parametersEl.getElementsByTagName("param"); 655 for (int i = 0; i < paramNl.getLength(); i++) { 655 int length = paramNl.getLength(); 656 for (int i = 0; i < length; i++) { 656 657 Element paramEl = (Element) paramNl.item(i); 657 658 parameters.add(paramEl.getTextContent()); -
trunk/test/performance/org/openstreetmap/josm/data/osm/KeyValuePerformanceTest.java
r14093 r14201 157 157 */ 158 158 @Test 159 @SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") 159 160 public void testKeyValueGet() { 160 161 for (double tagNodeRatio : TAG_NODE_RATIOS) { -
trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/PluginDownloadTaskTest.java
r14149 r14201 9 9 import java.io.FileInputStream; 10 10 import java.io.FileOutputStream; 11 import java.nio.charset.StandardCharsets; 11 12 import java.util.Collections; 12 13 … … 35 36 @Rule 36 37 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 37 public JOSMTestRules test = new JOSMTestRules().https().assumeRevision(38 public JOSMTestRules testRule = new JOSMTestRules().https().assumeRevision( 38 39 "Revision: 8000\n" 39 40 ).preferences(); … … 68 69 // put existing "plugin file" in place 69 70 pluginFile.getParentFile().mkdirs(); 70 final byte[] existingPluginContents = "Existing plugin contents 123".getBytes( );71 final byte[] existingPluginContents = "Existing plugin contents 123".getBytes(StandardCharsets.UTF_8); 71 72 try (FileOutputStream existingPluginOutputStream = new FileOutputStream(pluginFile)) { 72 73 existingPluginOutputStream.write(existingPluginContents); … … 111 112 112 113 pluginFile.getParentFile().mkdirs(); 113 final byte[] existingPluginContents = "Existing plugin contents 123".getBytes( );114 final byte[] existingPluginContents = "Existing plugin contents 123".getBytes(StandardCharsets.UTF_8); 114 115 try (FileOutputStream existingPluginOutputStream = new FileOutputStream(pluginFile)) { 115 116 existingPluginOutputStream.write(existingPluginContents); -
trunk/test/unit/org/openstreetmap/josm/data/UserIdentityManagerTest.java
r12849 r14201 102 102 */ 103 103 @Test(expected = IllegalArgumentException.class) 104 @SuppressFBWarnings(value = "NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS") 104 105 public void testSetPartiallyIdentifiedNull() { 105 106 UserIdentityManager.getInstance().setPartiallyIdentified(null); … … 149 150 */ 150 151 @Test(expected = IllegalArgumentException.class) 152 @SuppressFBWarnings(value = "NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS") 151 153 public void testSetFullyIdentifiedNullName() { 152 154 UserIdentityManager.getInstance().setFullyIdentified(null, newUserInfo()); -
trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java
r13779 r14201 545 545 assertArrayEquals("cached dummy".getBytes(StandardCharsets.UTF_8), listener.data); 546 546 assertTrue(testStart + expires <= listener.attributes.getExpirationTime()); 547 listener =submitJob(job, false);547 submitJob(job, false); 548 548 tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test"))); // no more requests were made 549 549 } -
trunk/test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java
r13079 r14201 7 7 8 8 import java.text.DecimalFormat; 9 import java.util.Arrays; 10 import java.util.List; 9 11 10 12 import org.junit.Rule; … … 34 36 * Lat/Lon sample values for unit tests 35 37 */ 36 @SuppressFBWarnings(value = "MS_PKGPROTECT") 37 public static final double[] SAMPLE_VALUES = new double[]{ 38 public static final List<Double> SAMPLE_VALUES = Arrays.asList( 38 39 // CHECKSTYLE.OFF: SingleSpaceSeparator 39 40 -180.0, -179.9, -179.6, -179.5, -179.4, -179.1, -179.0, -100.0, -99.9, -10.0, -9.9, -1.0, -0.1, … … 44 45 100.12, 100.123, 100.1234, 100.12345, 100.123456, 100.1234567 45 46 // CHECKSTYLE.ON: SingleSpaceSeparator 46 };47 ); 47 48 48 49 /** -
trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetCacheTest.java
r14166 r14201 60 60 protected final void await() { 61 61 try { 62 latch.await(2, TimeUnit.SECONDS);62 Logging.trace(Boolean.toString(latch.await(2, TimeUnit.SECONDS))); 63 63 } catch (InterruptedException e) { 64 64 Logging.error(e); -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolutionUtilTest.java
r11614 r14201 5 5 import static org.junit.Assert.assertFalse; 6 6 import static org.junit.Assert.assertNull; 7 import static org.junit.Assert.assertSame;8 7 import static org.junit.Assert.assertTrue; 9 8 … … 82 81 tc.add(otherSource); // other source should prevent resolution 83 82 TagConflictResolutionUtil.applyAutomaticTagConflictResolution(tc); 84 assert Same(18, tc.getValues("source").size());83 assertEquals(18, tc.getValues("source").size()); 85 84 tc.remove(otherSource); 86 85 TagConflictResolutionUtil.applyAutomaticTagConflictResolution(tc); … … 373 372 public void testGroupChoices() { 374 373 Collection<AutomaticChoiceGroup> groups = AutomaticChoiceGroup.groupChoices(Arrays.asList(choiceKey1Group1, choiceKey1Group2)); 375 assert Same(2, groups.size());374 assertEquals(2, groups.size()); 376 375 377 376 groups = AutomaticChoiceGroup.groupChoices(Arrays.asList( 378 377 choiceKey1Group1, choiceKey1Group2, choiceKey2Group1, choiceKey2Group2, choiceEmpty)); 379 assert Same(5, groups.size());378 assertEquals(5, groups.size()); 380 379 381 380 groups = AutomaticChoiceGroup.groupChoices(Arrays.asList(choiceKey1Group1, choiceKey1Group1bis)); 382 assert Same(1, groups.size());381 assertEquals(1, groups.size()); 383 382 AutomaticChoiceGroup group1 = groups.iterator().next(); 384 383 assertEquals(group1.key, choiceKey1Group1.key); … … 389 388 choiceKey1Group1, choiceKey1Group1bis, choiceKey1Group2, choiceKey1Group2bis, 390 389 choiceKey2Group1, choiceKey2Group1bis, choiceKey2Group2, choiceKey2Group2bis)); 391 assert Same(4, groups.size());390 assertEquals(4, groups.size()); 392 391 for (AutomaticChoiceGroup group: groups) { 393 392 for (AutomaticChoice choice: group.choices) { -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
r14149 r14201 16 16 import java.util.Arrays; 17 17 import java.util.Map; 18 import java.util.Objects; 18 19 import java.util.concurrent.Callable; 19 20 import java.util.regex.Matcher; … … 113 114 // sources should all come before any separators 114 115 break; 115 } else if ( ((JMenuItem) c).getText() == label) {116 } else if (Objects.equals(((JMenuItem) c).getText(), label)) { 116 117 ((JMenuItem) c).doClick(); 117 118 return; … … 127 128 } 128 129 129 pr otectedMinimapDialog minimap;130 pr otectedSlippyMapBBoxChooser slippyMap;131 pr otectedSourceButton sourceButton;132 pr otectedCallable<Boolean> slippyMapTasksFinished;133 134 pr otectedstatic BufferedImage paintedSlippyMap;130 private MinimapDialog minimap; 131 private SlippyMapBBoxChooser slippyMap; 132 private SourceButton sourceButton; 133 private Callable<Boolean> slippyMapTasksFinished; 134 135 private static BufferedImage paintedSlippyMap; 135 136 136 137 protected void setUpMiniMap() { -
trunk/test/unit/org/openstreetmap/josm/gui/layer/AutosaveTaskTest.java
r14138 r14201 12 12 import java.io.IOException; 13 13 import java.nio.charset.StandardCharsets; 14 import java.nio.file.DirectoryStream; 14 15 import java.nio.file.Files; 15 16 import java.nio.file.Path; … … 115 116 } 116 117 // cleanup 117 for (Path entry : Files.newDirectoryStream(task.getAutosaveDir(), "*.{osm,pid}")) { 118 Files.delete(entry); 118 try (DirectoryStream<Path> stream = Files.newDirectoryStream(task.getAutosaveDir(), "*.{osm,pid}")) { 119 for (Path entry : stream) { 120 Files.delete(entry); 121 } 119 122 } 120 123 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTestIT.java
r13655 r14201 6 6 7 7 import java.util.Collection; 8 import java.util.Collections;9 8 import java.util.HashMap; 10 9 import java.util.Map; … … 84 83 } 85 84 } 86 if (style != null) { 87 System.out.println(style.isValid() ? " => OK" : " => KO"); 88 Collection<Throwable> errors = style.getErrors(); 89 Collection<String> warnings = style.getWarnings(); 90 if (!errors.isEmpty()) { 91 allErrors.put(source.url, errors); 92 } 93 if (!warnings.isEmpty()) { 94 allWarnings.put(source.url, warnings); 95 } 96 } else { 97 allWarnings.put(source.url, Collections.singleton("MapPaintStyles.addStyle() returned null")); 85 System.out.println(style.isValid() ? " => OK" : " => KO"); 86 Collection<Throwable> errors = style.getErrors(); 87 Collection<String> warnings = style.getWarnings(); 88 if (!errors.isEmpty()) { 89 allErrors.put(source.url, errors); 90 } 91 if (!warnings.isEmpty()) { 92 allWarnings.put(source.url, warnings); 98 93 } 99 94 } -
trunk/test/unit/org/openstreetmap/josm/io/OsmChangesetContentParserTest.java
r14047 r14201 53 53 */ 54 54 @Test 55 @SuppressFBWarnings(value = "NP_NULL_PARAM_DEREF_NONVIRTUAL") 55 56 public void test_Constructor() { 56 57 57 58 // should be OK 58 new OsmChangesetContentParser(new ByteArrayInputStream("".getBytes( )));59 new OsmChangesetContentParser(new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8))); 59 60 60 61 shouldFail(() -> { -
trunk/test/unit/org/openstreetmap/josm/io/OsmJsonReaderTest.java
r14086 r14201 9 9 import java.io.InputStream; 10 10 import java.nio.charset.StandardCharsets; 11 import java.text.SimpleDateFormat;12 11 import java.util.Iterator; 13 12 … … 39 38 public JOSMTestRules test = new JOSMTestRules(); 40 39 41 private static final SimpleDateFormat iso8601 = DateUtils.newIsoDateTimeFormat();42 43 40 /** 44 41 * Setup test … … 46 43 @BeforeClass 47 44 public static void setUp() { 48 iso8601.setTimeZone(DateUtils.UTC);45 DateUtils.newIsoDateTimeFormat().setTimeZone(DateUtils.UTC); 49 46 } 50 47 … … 122 119 assertEquals(1, n.getUniqueId()); 123 120 assertEquals(new LatLon(2.0, -3.0), n.getCoor()); 124 assertEquals("2018-01-01T00:00:00Z", iso8601.format(n.getTimestamp()));121 assertEquals("2018-01-01T00:00:00Z", DateUtils.newIsoDateTimeFormat().format(n.getTimestamp())); 125 122 assertEquals(4, n.getVersion()); 126 123 assertEquals(5, n.getChangesetId()); -
trunk/test/unit/org/openstreetmap/josm/io/OsmWriterTest.java
r13559 r14201 7 7 import java.io.ByteArrayOutputStream; 8 8 import java.io.IOException; 9 import java.io.OutputStreamWriter; 9 10 import java.io.PrintWriter; 11 import java.nio.charset.StandardCharsets; 10 12 import java.util.ArrayList; 11 13 import java.util.Arrays; … … 15 17 import org.junit.Test; 16 18 import org.openstreetmap.josm.data.osm.DownloadPolicy; 19 import org.openstreetmap.josm.data.osm.NodeData; 17 20 import org.openstreetmap.josm.data.osm.UploadPolicy; 18 import org.openstreetmap.josm.data.osm.NodeData;19 21 20 22 /** … … 60 62 private static void doTestHeader(DownloadPolicy download, UploadPolicy upload, String expected) throws IOException { 61 63 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 62 try (PrintWriter out = new PrintWriter( baos);64 try (PrintWriter out = new PrintWriter(new OutputStreamWriter(baos, StandardCharsets.UTF_8)); 63 65 OsmWriter writer = OsmWriterFactory.createOsmWriter(out, true, OsmWriter.DEFAULT_API_VERSION)) { 64 66 writer.header(download, upload); -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
r14168 r14201 46 46 private String httpsBase; 47 47 48 private static class PlatformHookWindowsMock extends MockUp<PlatformHookWindows> { 49 @Mock 50 public boolean setupHttpsCertificate(String entryAlias, TrustedCertificateEntry trustedCert) { 51 return true; 52 } 53 } 54 48 55 /** 49 56 * Starts Remote control before testing requests. … … 59 66 // appveyor doesn't like us tinkering with the root keystore, so mock this out 60 67 TestUtils.assumeWorkingJMockit(); 61 new MockUp<PlatformHookWindows>() { 62 @Mock 63 public boolean setupHttpsCertificate(String entryAlias, TrustedCertificateEntry trustedCert) { 64 return true; 65 } 66 }; 68 new PlatformHookWindowsMock(); 67 69 } 68 70 -
trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
r14153 r14201 8 8 import java.io.File; 9 9 import java.io.IOException; 10 import java.nio.charset.StandardCharsets; 10 11 import java.security.GeneralSecurityException; 11 12 import java.text.MessageFormat; … … 360 361 MockVersion(final String propertiesString) { 361 362 super.initFromRevisionInfo( 362 new ByteArrayInputStream(propertiesString.getBytes( ))363 new ByteArrayInputStream(propertiesString.getBytes(StandardCharsets.UTF_8)) 363 364 ); 364 365 } -
trunk/test/unit/org/openstreetmap/josm/testutils/TileSourceRule.java
r14066 r14201 47 47 * this cache 48 48 */ 49 public static HashMap<ConstSource, ByteArrayWrapper> constPayloadCache = new HashMap<>();49 public static final HashMap<ConstSource, ByteArrayWrapper> constPayloadCache = new HashMap<>(); 50 50 51 51 /** -
trunk/test/unit/org/openstreetmap/josm/testutils/mockers/HelpAwareOptionPaneMocker.java
r14062 r14201 165 165 "Invalid result for HelpAwareOptionPane: %s (in call with options = %s)", 166 166 retval, 167 options167 Arrays.asList(options) 168 168 )); 169 169 } -
trunk/test/unit/org/openstreetmap/josm/tools/ImageProviderTest.java
r13823 r14201 22 22 23 23 import com.kitfox.svg.SVGConst; 24 25 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 24 26 25 27 /** … … 85 87 */ 86 88 @Test 89 @SuppressFBWarnings(value = "LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE") 87 90 public void testTicket14319() throws IOException { 88 91 LogHandler14319 handler = new LogHandler14319();
Note:
See TracChangeset
for help on using the changeset viewer.