Changeset 11324 in josm for trunk/test/unit/org/openstreetmap/josm/data
- Timestamp:
- 2016-11-27T05:16:30+01:00 (7 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/data
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/AutosaveTaskTest.java
r11035 r11324 8 8 import static org.junit.Assert.assertTrue; 9 9 10 import java.io.BufferedWriter; 10 11 import java.io.File; 11 import java.io.FileWriter;12 import java.io.FilenameFilter;13 12 import java.io.IOException; 13 import java.nio.charset.StandardCharsets; 14 14 import java.nio.file.Files; 15 15 import java.nio.file.Paths; … … 143 143 144 144 private int countFiles() { 145 return task.getAutosaveDir().toFile().list(new FilenameFilter() { 146 @Override 147 public boolean accept(File dir, String name) { 148 return name.endsWith(".osm"); 149 } 150 }).length; 145 String[] files = task.getAutosaveDir().toFile().list((dir, name) -> name.endsWith(".osm")); 146 return files != null ? files.length : 0; 151 147 } 152 148 … … 194 190 public void testDiscardUnsavedLayersIgnoresCurrentInstance() throws IOException { 195 191 runAutosaveTaskSeveralTimes(1); 196 try (FileWriter file = new FileWriter(new File(task.getAutosaveDir().toFile(), "any_other_file.osm"))) { 192 try (BufferedWriter file = Files.newBufferedWriter( 193 new File(task.getAutosaveDir().toFile(), "any_other_file.osm").toPath(), StandardCharsets.UTF_8)) { 197 194 file.append(""); 198 195 } … … 237 234 public void testRecoverLayers() throws Exception { 238 235 runAutosaveTaskSeveralTimes(1); 239 try (FileWriter file = new FileWriter(new File(task.getAutosaveDir().toFile(), "any_other_file.osm"))) { 236 try (BufferedWriter file = Files.newBufferedWriter( 237 new File(task.getAutosaveDir().toFile(), "any_other_file.osm").toPath(), StandardCharsets.UTF_8)) { 240 238 file.append("<?xml version=\"1.0\"?><osm version=\"0.6\"><node id=\"1\" lat=\"1\" lon=\"2\" version=\"1\"/></osm>"); 241 239 } -
trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCacheManagerTest.java
r10962 r11324 45 45 File cacheFile = new File("foobar/testUseBigDiskFile_BLOCK_v2.data"); 46 46 if (!cacheFile.exists()) { 47 cacheFile.createNewFile(); 47 if (!cacheFile.createNewFile()) { 48 System.err.println("Unable to create " + cacheFile.getAbsolutePath()); 49 } 48 50 } 49 51 try (FileOutputStream fileOutputStream = new FileOutputStream(cacheFile, false)) { -
trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java
r11121 r11324 31 31 */ 32 32 @Test 33 @SuppressFBWarnings(value = "NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS") 33 34 public void testSetKeys() { 34 35 final Changeset cs = new Changeset(); -
trunk/test/unit/org/openstreetmap/josm/data/osm/NodeDataTest.java
r10946 r11324 15 15 import org.openstreetmap.josm.data.coor.LatLon; 16 16 17 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 18 17 19 public class NodeDataTest { 18 20 21 @SuppressFBWarnings(value = "OBJECT_DESERIALIZATION") 19 22 private static NodeData serializeUnserialize(NodeData data) throws IOException, ClassNotFoundException { 20 23 try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); -
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r11269 r11324 4 4 import java.io.FileInputStream; 5 5 import java.io.InputStream; 6 import java.security.SecureRandom; 6 7 import java.util.ArrayList; 7 8 import java.util.Arrays; … … 193 194 194 195 // force splits in quad buckets 195 Random random = new Random(31);196 Random random = new SecureRandom(); 196 197 for (int i = 0; i < NUM_COMPLETE_WAYS; i++) { 197 198 Way w = new Way(wayId++); … … 213 214 214 215 // add some incomplete nodes 215 List<Node> incompleteNodes = new ArrayList<>();216 216 for (int i = 0; i < NUM_INCOMPLETE_NODES; i++) { 217 217 Node n = new Node(nodeId++); 218 incompleteNodes.add(n);219 218 n.setIncomplete(true); 220 219 ds.addPrimitive(n); -
trunk/test/unit/org/openstreetmap/josm/data/osm/WayDataTest.java
r10733 r11324 11 11 import org.junit.Test; 12 12 13 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 14 13 15 public class WayDataTest { 16 14 17 @Test 18 @SuppressFBWarnings(value = "OBJECT_DESERIALIZATION") 15 19 public void testSerializationForDragAndDrop() throws Exception { 16 20 final WayData data = new WayData(); -
trunk/test/unit/org/openstreetmap/josm/data/projection/EllipsoidTest.java
r10758 r11324 2 2 package org.openstreetmap.josm.data.projection; 3 3 4 import java.security.SecureRandom; 4 5 import java.util.Random; 5 6 … … 20 21 @Test 21 22 public void testLatLon2Cart2LatLon() { 22 Random r = new Random(System.currentTimeMillis());23 Random r = new SecureRandom(); 23 24 double maxErrLat = 0, maxErrLon = 0; 24 25 Ellipsoid ellips = Ellipsoid.WGS84; -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java
r10758 r11324 6 6 import java.io.File; 7 7 import java.io.FileInputStream; 8 import java.io.FileNotFoundException;9 8 import java.io.FileOutputStream; 10 9 import java.io.IOException; … … 14 13 import java.io.OutputStreamWriter; 15 14 import java.nio.charset.StandardCharsets; 15 import java.security.SecureRandom; 16 16 import java.util.ArrayList; 17 17 import java.util.Arrays; … … 38 38 import org.openstreetmap.josm.tools.Pair; 39 39 import org.openstreetmap.josm.tools.Utils; 40 41 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 40 42 41 43 /** … … 72 74 } 73 75 74 static Random rand = new Random(); 75 76 public static void main(String[] args) throws FileNotFoundException, IOException { 76 static Random rand = new SecureRandom(); 77 78 /** 79 * Program entry point. 80 * @param args no argument is expected 81 * @throws IOException in case of I/O error 82 */ 83 public static void main(String[] args) throws IOException { 77 84 Collection<RefEntry> refs = readData(); 78 85 refs = updateData(refs); … … 200 207 201 208 /** 202 * Run external cs2cs command from the PROJ.4 library to convert lat/lon to 203 * east/north value. 209 * Run external cs2cs command from the PROJ.4 library to convert lat/lon to east/north value. 204 210 * @param def the proj.4 projection definition string 205 211 * @param ll the LatLon 206 212 * @return projected EastNorth or null in case of error 207 213 */ 214 @SuppressFBWarnings(value = "COMMAND_INJECTION") 208 215 private static EastNorth latlon2eastNorthProj4(String def, LatLon ll) { 209 216 List<String> args = new ArrayList<>(); -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r10758 r11324 12 12 import java.io.OutputStreamWriter; 13 13 import java.nio.charset.StandardCharsets; 14 import java.security.SecureRandom; 14 15 import java.util.ArrayList; 15 16 import java.util.HashMap; … … 86 87 } 87 88 88 Random rand = new Random();89 Random rand = new SecureRandom(); 89 90 try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter( 90 91 new FileOutputStream(PROJECTION_DATA_FILE), StandardCharsets.UTF_8))) { -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java
r10758 r11324 2 2 package org.openstreetmap.josm.data.projection; 3 3 4 import java.security.SecureRandom; 4 5 import java.util.Arrays; 5 6 import java.util.Collection; … … 18 19 public class ProjectionTest { 19 20 20 private static Random rand = new Random(System.currentTimeMillis());21 private static Random rand = new SecureRandom(); 21 22 22 23 boolean error;
Note:
See TracChangeset
for help on using the changeset viewer.