Changeset 10937 in josm
- Timestamp:
- 2016-09-03T12:24:18+02:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.classpath
r10908 r10937 17 17 <classpathentry kind="lib" path="test/lib/equalsverifier-2.1.5.jar"/> 18 18 <classpathentry kind="lib" path="test/lib/reflections/reflections-0.9.10.jar"/> 19 <classpathentry kind="lib" path="test/lib/reflections/guava-19.0.jar"/> 20 <classpathentry kind="lib" path="test/lib/reflections/javassist-3.20.0-GA.jar"/> 19 21 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_102"/> 20 22 <classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/> -
trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
r10758 r10937 6 6 import static org.junit.Assert.assertNotNull; 7 7 import static org.junit.Assert.assertTrue; 8 import static org.junit.Assert.fail;9 8 10 9 import java.io.File; … … 40 39 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 41 40 41 /** 42 * Unit tests of {@link MultiFetchServerObjectReader}. 43 */ 42 44 public class MultiFetchServerObjectReaderTest { 43 45 private static Logger logger = Logger.getLogger(MultiFetchServerObjectReader.class.getName()); … … 138 140 } 139 141 142 /** 143 * Setup test. 144 * @throws Exception if an error occurs 145 */ 140 146 @BeforeClass 141 public static void init() throws OsmTransferException {147 public static void init() throws Exception { 142 148 logger.info("initializing ..."); 143 149 JOSMFixture.createFunctionalTestFixture().init(); … … 177 183 w.footer(); 178 184 } 179 } catch (IOException e) {180 fail(MessageFormat.format("failed to open file ''{0}'' for writing", dataSetCacheOutputFile.toString()));181 185 } 182 186 } … … 200 204 } 201 205 206 /** 207 * Test to multi-get 10 nodes. 208 * @throws OsmTransferException if an error occurs 209 */ 202 210 @Test 203 211 public void testMultiGet10Nodes() throws OsmTransferException { … … 217 225 } 218 226 227 /** 228 * Test to multi-get 10 ways. 229 * @throws OsmTransferException if an error occurs 230 */ 219 231 @Test 220 232 public void testMultiGet10Ways() throws OsmTransferException { … … 235 247 } 236 248 249 /** 250 * Test to multi-get 10 relations. 251 * @throws OsmTransferException if an error occurs 252 */ 237 253 @Test 238 254 public void testMultiGet10Relations() throws OsmTransferException { … … 253 269 } 254 270 271 /** 272 * Test to multi-get 800 nodes. 273 * @throws OsmTransferException if an error occurs 274 */ 255 275 @Test 256 276 public void testMultiGet800Nodes() throws OsmTransferException { … … 270 290 } 271 291 292 /** 293 * Test to multi-get non-existing node. 294 * @throws OsmTransferException if an error occurs 295 */ 272 296 @Test 273 297 public void testMultiGetWithNonExistingNode() throws OsmTransferException { -
trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
r10758 r10937 151 151 * @throws OsmTransferException if something goes wrong 152 152 * @throws CyclicUploadDependencyException if a cyclic dependency is detected 153 * @throws IOException if an I/O error occurs 153 154 */ 154 155 @BeforeClass 155 public static void setUpBeforeClass() throws OsmTransferException, CyclicUploadDependencyException { 156 public static void setUpBeforeClass() throws OsmTransferException, CyclicUploadDependencyException, IOException { 156 157 logger.info("initializing ..."); 157 158 … … 196 197 w.footer(); 197 198 } 198 } catch (IOException e) {199 fail(MessageFormat.format("failed to open file ''{0}'' for writing", dataSetCacheOutputFile.toString()));200 199 } 201 200 } … … 219 218 } 220 219 220 /** 221 * Test reading references for a node. 222 * @throws OsmTransferException if an error occurs 223 */ 221 224 @Test 222 225 public void testBackreferenceForNode() throws OsmTransferException { … … 272 275 } 273 276 277 /** 278 * Test reading full references for a node. 279 * @throws OsmTransferException if an error occurs 280 */ 274 281 @Test 275 282 public void testBackreferenceForNodeFull() throws OsmTransferException { … … 316 323 } 317 324 325 /** 326 * Test reading references for a way. 327 * @throws OsmTransferException if an error occurs 328 */ 318 329 @Test 319 330 public void testBackreferenceForWay() throws OsmTransferException { … … 356 367 } 357 368 369 /** 370 * Test reading full references for a way. 371 * @throws OsmTransferException if an error occurs 372 */ 358 373 @Test 359 374 public void testBackreferenceForWayFull() throws OsmTransferException { … … 390 405 } 391 406 407 /** 408 * Test reading references for a relation. 409 * @throws OsmTransferException if an error occurs 410 */ 392 411 @Test 393 412 public void testBackreferenceForRelation() throws OsmTransferException { … … 505 524 } 506 525 526 /** 527 * Test reading full references for a relation. 528 * @throws OsmTransferException if an error occurs 529 */ 507 530 @Test 508 531 public void testBackreferenceForRelationFull() throws OsmTransferException { -
trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java
r10758 r10937 4 4 import static org.junit.Assert.assertSame; 5 5 import static org.junit.Assert.assertTrue; 6 import static org.junit.Assert.fail;7 6 8 7 import java.awt.geom.Area; … … 54 53 * @param p primitive 55 54 * @param ds data set 55 * @throws ReflectiveOperationException if an error occurs 56 56 */ 57 public void addSelected(OsmPrimitive p, DataSet ds) { 58 try { 59 Method method = ds.getClass() 60 .getDeclaredMethod("addSelected", 61 new Class<?>[] {Collection.class, boolean.class}); 62 Utils.setObjectsAccessible(method); 63 method.invoke(ds, Collections.singleton(p), false); 64 } catch (ReflectiveOperationException e) { 65 e.printStackTrace(); 66 fail("Can't add OsmPrimitive to dataset: " + e.getMessage()); 67 } 57 public void addSelected(OsmPrimitive p, DataSet ds) throws ReflectiveOperationException { 58 Method method = ds.getClass().getDeclaredMethod("addSelected", 59 new Class<?>[] {Collection.class, boolean.class}); 60 Utils.setObjectsAccessible(method); 61 method.invoke(ds, Collections.singleton(p), false); 68 62 } 69 63 … … 72 66 * circle direction must equals way direction. 73 67 * see #7421 68 * @throws ReflectiveOperationException if an error occurs 74 69 */ 75 70 @Test 76 public void testTicket7421case0() { 71 public void testTicket7421case0() throws ReflectiveOperationException { 77 72 DataSet dataSet = new DataSet(); 78 73 OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null); … … 137 132 * circle direction depend on traffic hand. Simulate a left hand traffic. 138 133 * see #7421 134 * @throws ReflectiveOperationException if an error occurs 139 135 */ 140 136 @Test 141 public void testTicket7421case1() { 137 public void testTicket7421case1() throws ReflectiveOperationException { 142 138 DataSet dataSet = new DataSet(); 143 139 OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null); … … 155 151 156 152 // Mock left/right hand traffic database 157 try { 158 Field leftHandTrafficPolygons = RightAndLefthandTraffic.class 159 .getDeclaredField("leftHandTrafficPolygons"); 160 Field rlCache = RightAndLefthandTraffic.class.getDeclaredField("rlCache"); 161 Utils.setObjectsAccessible(leftHandTrafficPolygons, rlCache); 162 leftHandTrafficPolygons.set(null, new ArrayList<Area>()); 163 rlCache.set(null, new GeoPropertyIndex<>(new ConstantTrafficHand(true), 24)); 164 } catch (ReflectiveOperationException e) { 165 e.printStackTrace(); 166 fail("Impossible to mock left/right hand database: " + e.getMessage()); 167 } 153 Field leftHandTrafficPolygons = RightAndLefthandTraffic.class 154 .getDeclaredField("leftHandTrafficPolygons"); 155 Field rlCache = RightAndLefthandTraffic.class.getDeclaredField("rlCache"); 156 Utils.setObjectsAccessible(leftHandTrafficPolygons, rlCache); 157 leftHandTrafficPolygons.set(null, new ArrayList<Area>()); 158 rlCache.set(null, new GeoPropertyIndex<>(new ConstantTrafficHand(true), 24)); 168 159 169 160 CreateCircleAction action = new CreateCircleAction(); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java
r10876 r10937 5 5 import static org.junit.Assert.assertSame; 6 6 import static org.junit.Assert.assertTrue; 7 import static org.junit.Assert.fail;8 7 9 8 import java.awt.event.InputEvent; … … 35 34 36 35 class SelectActionMock extends SelectAction { 37 SelectActionMock(MapFrame mapFrame, DataSet dataSet, OsmDataLayer layer) { 36 SelectActionMock(MapFrame mapFrame, DataSet dataSet, OsmDataLayer layer) throws ReflectiveOperationException { 38 37 super(mapFrame); 39 try { 40 Field mv = SelectAction.class.getDeclaredField("mv"); 41 Utils.setObjectsAccessible(mv); 42 mv.set(this, new MapViewMock()); 43 } catch (ReflectiveOperationException e) { 44 e.printStackTrace(); 45 fail("Can't setup testing environnement"); 46 } 38 Field mv = SelectAction.class.getDeclaredField("mv"); 39 Utils.setObjectsAccessible(mv); 40 mv.set(this, new MapViewMock()); 47 41 } 48 42 … … 68 62 * Resulting way should be attach to the third node. 69 63 * see #10748 64 * @throws ReflectiveOperationException if an error occurs 70 65 */ 71 66 @Test 72 67 @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") 73 public void testTicket10748() { 68 public void testTicket10748() throws ReflectiveOperationException { 74 69 DataSet dataSet = new DataSet(); 75 70 OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null); -
trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java
r10758 r10937 28 28 29 29 @Test 30 public void testOneNewRelationOnly() { 30 public void testOneNewRelationOnly() throws CyclicUploadDependencyException { 31 31 Relation r = new Relation(); 32 32 r.put("name", "r1"); … … 36 36 APIDataSet apiDataSet = new APIDataSet(); 37 37 apiDataSet.init(ds); 38 try { 39 apiDataSet.adjustRelationUploadOrder(); 40 } catch (CyclicUploadDependencyException e) { 41 fail("unexpected exception:" + e); 42 } 38 apiDataSet.adjustRelationUploadOrder(); 43 39 List<OsmPrimitive> toAdd = apiDataSet.getPrimitivesToAdd(); 44 40 … … 48 44 49 45 @Test 50 public void testNewParentChildPair() { 51 DataSet ds = new DataSet(); 52 Relation r1 = new Relation(); 53 ds.addPrimitive(r1); 54 r1.put("name", "r1"); 55 56 Relation r2 = new Relation(); 57 ds.addPrimitive(r2); 58 r2.put("name", "r2"); 59 60 r1.addMember(new RelationMember("", r2)); 61 62 APIDataSet apiDataSet = new APIDataSet(); 63 apiDataSet.init(ds); 64 try { 65 apiDataSet.adjustRelationUploadOrder(); 66 } catch (CyclicUploadDependencyException e) { 67 fail("unexpected exception:" + e); 68 } 46 public void testNewParentChildPair() throws CyclicUploadDependencyException { 47 DataSet ds = new DataSet(); 48 Relation r1 = new Relation(); 49 ds.addPrimitive(r1); 50 r1.put("name", "r1"); 51 52 Relation r2 = new Relation(); 53 ds.addPrimitive(r2); 54 r2.put("name", "r2"); 55 56 r1.addMember(new RelationMember("", r2)); 57 58 APIDataSet apiDataSet = new APIDataSet(); 59 apiDataSet.init(ds); 60 apiDataSet.adjustRelationUploadOrder(); 69 61 List<OsmPrimitive> toAdd = apiDataSet.getPrimitivesToAdd(); 70 62 … … 75 67 76 68 @Test 77 public void testOneExistingAndThreNewInAChain() { 69 public void testOneExistingAndThreNewInAChain() throws CyclicUploadDependencyException { 78 70 DataSet ds = new DataSet(); 79 71 … … 100 92 APIDataSet apiDataSet = new APIDataSet(); 101 93 apiDataSet.init(ds); 102 try { 103 apiDataSet.adjustRelationUploadOrder(); 104 } catch (CyclicUploadDependencyException e) { 105 fail("unexpected exception:" + e); 106 } 94 apiDataSet.adjustRelationUploadOrder(); 107 95 List<OsmPrimitive> toAdd = apiDataSet.getPrimitivesToAdd(); 108 96 … … 118 106 119 107 @Test 120 public void testOneParentTwoNewChildren() { 108 public void testOneParentTwoNewChildren() throws CyclicUploadDependencyException { 121 109 DataSet ds = new DataSet(); 122 110 Relation r1 = new Relation(); … … 138 126 APIDataSet apiDataSet = new APIDataSet(); 139 127 apiDataSet.init(ds); 140 try { 141 apiDataSet.adjustRelationUploadOrder(); 142 } catch (CyclicUploadDependencyException e) { 143 fail("unexpected exception:" + e); 144 } 128 apiDataSet.adjustRelationUploadOrder(); 145 129 List<OsmPrimitive> toAdd = apiDataSet.getPrimitivesToAdd(); 146 130 … … 151 135 152 136 @Test // for ticket #9624 153 public void testDeleteOneParentTwoNewChildren() { 137 public void testDeleteOneParentTwoNewChildren() throws CyclicUploadDependencyException { 154 138 DataSet ds = new DataSet(); 155 139 Relation r1 = new Relation(1); … … 185 169 apiDataSet.getPrimitivesToDelete().add(r3); 186 170 apiDataSet.getPrimitivesToDelete().add(r4); 187 try { 188 apiDataSet.adjustRelationUploadOrder(); 189 } catch (CyclicUploadDependencyException e) { 190 fail("unexpected exception:" + e); 191 } 171 apiDataSet.adjustRelationUploadOrder(); 192 172 List<OsmPrimitive> toDelete = apiDataSet.getPrimitivesToDelete(); 193 173 … … 198 178 199 179 @Test // for ticket #9656 200 public void testDeleteWay() { 180 public void testDeleteWay() throws CyclicUploadDependencyException { 201 181 DataSet ds = new DataSet(); 202 182 final Way way = new Way(1, 2); … … 225 205 APIDataSet apiDataSet = new APIDataSet(); 226 206 apiDataSet.init(ds); 227 try { 228 apiDataSet.adjustRelationUploadOrder(); 229 } catch (CyclicUploadDependencyException e) { 230 fail("unexpected exception:" + e); 231 } 207 apiDataSet.adjustRelationUploadOrder(); 232 208 List<OsmPrimitive> toDelete = apiDataSet.getPrimitivesToDelete(); 233 209 -
trunk/test/unit/org/openstreetmap/josm/gui/TableCellRendererTest.java
r10758 r10937 2 2 package org.openstreetmap.josm.gui; 3 3 4 import static org.junit.Assert.assertNotNull; 5 4 6 import java.lang.reflect.Constructor; 5 import java.lang.reflect.InvocationTargetException;6 7 import java.lang.reflect.Modifier; 7 8 import java.util.Arrays; … … 53 54 /** 54 55 * Unit test of all table cell renderers against null values. 56 * @throws NoSuchMethodException no default constructor - to fix this, add a default constructor to the class 57 * or add the class to the SKIP_TEST list above 58 * @throws ReflectiveOperationException if an error occurs 55 59 */ 56 60 @Test 57 public void testTableCellRenderer() { 61 public void testTableCellRenderer() throws ReflectiveOperationException { 58 62 Reflections reflections = new Reflections("org.openstreetmap.josm"); 59 63 Set<Class<? extends TableCellRenderer>> renderers = reflections.getSubTypesOf(TableCellRenderer.class); … … 67 71 continue; 68 72 } 69 TableCellRenderer tcr = createInstance(klass); 70 try { 71 tcr.getTableCellRendererComponent(tbl, null, false, false, 0, 0); 72 } catch (NullPointerException npe) { 73 npe.printStackTrace(); 74 Assert.fail("NPE in getTableCellRendererComponent"); 75 } 73 assertNotNull(createInstance(klass).getTableCellRendererComponent(tbl, null, false, false, 0, 0)); 76 74 } 77 75 } … … 82 80 * @param klass the class 83 81 * @return an instance of the class 82 * @throws NoSuchMethodException no default constructor - to fix this, add a default constructor to the class 83 * or add the class to the SKIP_TEST list above 84 * @throws ReflectiveOperationException if an error occurs 84 85 */ 85 private static <T> T createInstance(Class<? extends T> klass) { 86 private static <T> T createInstance(Class<? extends T> klass) throws ReflectiveOperationException { 86 87 boolean needOuterClass = klass.isMemberClass() && !Modifier.isStatic(klass.getModifiers()); 87 88 Constructor<? extends T> c; 88 try { 89 if (needOuterClass) { 90 c = klass.getDeclaredConstructor(klass.getDeclaringClass()); 91 } else { 92 c = klass.getDeclaredConstructor(); 93 } 94 } catch (NoSuchMethodException ex) { 95 // no default constructor - to fix this, add a default constructor 96 // to the class or add the class to the SKIP_TEST list above 97 Assert.fail("No default constructor - cannot test TableCellRenderer: " + ex); 98 return null; 99 } catch (SecurityException ex) { 100 throw new RuntimeException(ex); 89 if (needOuterClass) { 90 c = klass.getDeclaredConstructor(klass.getDeclaringClass()); 91 } else { 92 c = klass.getDeclaredConstructor(); 101 93 } 102 94 Utils.setObjectsAccessible(c); 103 T o; 104 try { 105 if (needOuterClass) { 106 Object outerInstance = createInstance(klass.getDeclaringClass()); 107 o = c.newInstance(outerInstance); 108 } else { 109 o = c.newInstance(); 110 } 111 } catch (InstantiationException | IllegalArgumentException | IllegalAccessException | InvocationTargetException ex) { 112 throw new RuntimeException(ex); 95 if (needOuterClass) { 96 return c.newInstance(createInstance(klass.getDeclaringClass())); 97 } else { 98 return c.newInstance(); 113 99 } 114 return o;115 100 } 116 117 101 } -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModelTest.java
r10846 r10937 61 61 break; 62 62 } 63 try { 64 int[] rows = (int[]) idx[i]; 65 if (rows.length != 2) { 66 fail("illegal selection range. Either null or not length 2: " + Arrays.toString(rows)); 67 } 68 if (rows[0] > rows[1]) { 69 fail("illegal selection range. lower bound > upper bound "); 70 } 71 for (int j = rows[0]; j <= rows[1]; j++) { 72 assertTrue("expected row " + j + " to be selected", model.isSelectedIndex(j)); 73 } 74 } catch (ClassCastException e) { 75 fail("illegal selection range:" + idx[i]); 63 int[] rows = (int[]) idx[i]; 64 if (rows.length != 2) { 65 fail("illegal selection range. Either null or not length 2: " + Arrays.toString(rows)); 66 } 67 if (rows[0] > rows[1]) { 68 fail("illegal selection range. lower bound > upper bound "); 69 } 70 for (int j = rows[0]; j <= rows[1]; j++) { 71 assertTrue("expected row " + j + " to be selected", model.isSelectedIndex(j)); 76 72 } 77 73 } -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
r10339 r10937 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.fail;6 5 7 6 import java.io.BufferedReader; … … 41 40 /** 42 41 * Starts Remote control before testing requests. 42 * @throws GeneralSecurityException if a security error occurs 43 43 */ 44 44 @Before 45 public void setUp() { 45 public void setUp() throws GeneralSecurityException { 46 46 JOSMFixture.createUnitTestFixture().init(); 47 47 RemoteControl.PROP_REMOTECONTROL_HTTPS_ENABLED.put(true); … … 70 70 * <a href="http://stackoverflow.com/a/2893932/2257172">here</a> and 71 71 * <a href="http://stackoverflow.com/a/19542614/2257172">here</a> 72 * @throws GeneralSecurityException if a security error occurs 72 73 */ 73 public void disableCertificateValidation() { 74 public void disableCertificateValidation() throws GeneralSecurityException { 74 75 // Create a trust manager that does not validate certificate chains 75 76 TrustManager[] trustAllCerts = new TrustManager[] { … … 91 92 92 93 // Install the all-trusting trust manager 93 try { 94 SSLContext sc = SSLContext.getInstance("TLS"); 95 sc.init(null, trustAllCerts, new SecureRandom()); 96 HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); 97 } catch (GeneralSecurityException e) { 98 fail(e.getMessage()); 99 } 94 SSLContext sc = SSLContext.getInstance("TLS"); 95 sc.init(null, trustAllCerts, new SecureRandom()); 96 HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); 100 97 101 98 // Create all-trusting host name verifier … … 121 118 /** 122 119 * Tests that sending an HTTP request without command results in HTTP 400, with all available commands in error message. 120 * @throws Exception if an error occurs 123 121 */ 124 122 @Test 125 public void testHttpListOfCommands() { 123 public void testHttpListOfCommands() throws Exception { 126 124 testListOfCommands(httpBase); 127 125 } … … 129 127 /** 130 128 * Tests that sending an HTTPS request without command results in HTTP 400, with all available commands in error message. 129 * @throws Exception if an error occurs 131 130 */ 132 131 @Test 133 public void testHttpsListOfCommands() { 132 public void testHttpsListOfCommands() throws Exception { 134 133 testListOfCommands(httpsBase); 135 134 } 136 135 137 private void testListOfCommands(String url) { 138 try { 139 HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); 140 connection.connect(); 141 assertEquals(connection.getResponseCode(), HttpURLConnection.HTTP_BAD_REQUEST); 142 try (InputStream is = connection.getErrorStream()) { 143 // TODO this code should be refactored somewhere in Utils as it is used in several JOSM classes 144 StringBuilder responseBody = new StringBuilder(); 145 try (BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { 146 String s; 147 while ((s = in.readLine()) != null) { 148 responseBody.append(s); 149 responseBody.append("\n"); 150 } 136 private void testListOfCommands(String url) throws IOException, ReflectiveOperationException { 137 HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); 138 connection.connect(); 139 assertEquals(connection.getResponseCode(), HttpURLConnection.HTTP_BAD_REQUEST); 140 try (InputStream is = connection.getErrorStream()) { 141 // TODO this code should be refactored somewhere in Utils as it is used in several JOSM classes 142 StringBuilder responseBody = new StringBuilder(); 143 try (BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { 144 String s; 145 while ((s = in.readLine()) != null) { 146 responseBody.append(s); 147 responseBody.append("\n"); 151 148 } 152 assert responseBody.toString().contains(RequestProcessor.getUsageAsHtml());153 } catch (ReflectiveOperationException e) {154 e.printStackTrace();155 fail(e.getMessage());156 149 } 157 } catch (IOException e) { 158 e.printStackTrace(); 159 fail(e.getMessage()); 150 assert responseBody.toString().contains(RequestProcessor.getUsageAsHtml()); 160 151 } 161 152 } -
trunk/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java
r10571 r10937 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.io.session; 3 4 import static org.junit.Assert.fail;5 3 6 4 import java.io.File; … … 91 89 } 92 90 93 private void testWrite(List<Layer> layers, final boolean zip) { 91 private void testWrite(List<Layer> layers, final boolean zip) throws IOException { 94 92 Map<Layer, SessionLayerExporter> exporters = new HashMap<>(); 95 93 if (zip) { … … 107 105 try { 108 106 sw.write(file); 109 } catch (IOException e) {110 e.printStackTrace();111 fail(e.getMessage());112 107 } finally { 113 108 if (file.exists()) { … … 148 143 /** 149 144 * Tests to write an empty .jos file. 150 */ 151 @Test 152 public void testWriteEmptyJos() { 145 * @throws IOException if an I/O error occurs 146 */ 147 @Test 148 public void testWriteEmptyJos() throws IOException { 153 149 testWrite(Collections.<Layer>emptyList(), false); 154 150 } … … 156 152 /** 157 153 * Tests to write an empty .joz file. 158 */ 159 @Test 160 public void testWriteEmptyJoz() { 154 * @throws IOException if an I/O error occurs 155 */ 156 @Test 157 public void testWriteEmptyJoz() throws IOException { 161 158 testWrite(Collections.<Layer>emptyList(), true); 162 159 } … … 164 161 /** 165 162 * Tests to write a .jos file containing OSM data. 166 */ 167 @Test 168 public void testWriteOsmJos() { 163 * @throws IOException if an I/O error occurs 164 */ 165 @Test 166 public void testWriteOsmJos() throws IOException { 169 167 testWrite(Collections.<Layer>singletonList(createOsmLayer()), false); 170 168 } … … 172 170 /** 173 171 * Tests to write a .joz file containing OSM data. 174 */ 175 @Test 176 public void testWriteOsmJoz() { 172 * @throws IOException if an I/O error occurs 173 */ 174 @Test 175 public void testWriteOsmJoz() throws IOException { 177 176 testWrite(Collections.<Layer>singletonList(createOsmLayer()), true); 178 177 } … … 180 179 /** 181 180 * Tests to write a .jos file containing GPX data. 182 */ 183 @Test 184 public void testWriteGpxJos() { 181 * @throws IOException if an I/O error occurs 182 */ 183 @Test 184 public void testWriteGpxJos() throws IOException { 185 185 testWrite(Collections.<Layer>singletonList(createGpxLayer()), false); 186 186 } … … 188 188 /** 189 189 * Tests to write a .joz file containing GPX data. 190 */ 191 @Test 192 public void testWriteGpxJoz() { 190 * @throws IOException if an I/O error occurs 191 */ 192 @Test 193 public void testWriteGpxJoz() throws IOException { 193 194 testWrite(Collections.<Layer>singletonList(createGpxLayer()), true); 194 195 } … … 196 197 /** 197 198 * Tests to write a .joz file containing GPX and marker data. 198 */ 199 @Test 200 public void testWriteGpxAndMarkerJoz() { 199 * @throws IOException if an I/O error occurs 200 */ 201 @Test 202 public void testWriteGpxAndMarkerJoz() throws IOException { 201 203 GpxLayer gpx = createGpxLayer(); 202 204 testWrite(Arrays.asList(gpx, createMarkerLayer(gpx)), true); … … 205 207 /** 206 208 * Tests to write a .joz file containing an imagery layer. 207 */ 208 @Test 209 public void testWriteImageryLayer() { 209 * @throws IOException if an I/O error occurs 210 */ 211 @Test 212 public void testWriteImageryLayer() throws IOException { 210 213 final Layer layer = createImageryLayer(); 211 214 testWrite(Collections.singletonList(layer), true); … … 214 217 /** 215 218 * Tests to write a .joz file containing a note layer. 216 */ 217 @Test 218 public void testWriteNoteLayer() { 219 * @throws IOException if an I/O error occurs 220 */ 221 @Test 222 public void testWriteNoteLayer() throws IOException { 219 223 final Layer layer = createNoteLayer(); 220 224 testWrite(Collections.singletonList(layer), true);
Note:
See TracChangeset
for help on using the changeset viewer.