Changeset 8876 in josm for trunk/test/unit/org
- Timestamp:
- 2015-10-14T23:35:44+02:00 (9 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/CopyActionTest.java
r8857 r8876 26 26 } 27 27 28 /** 29 * Test of {@link CopyAction#getCopyString} method for a single way. 30 */ 28 31 @Test 29 public void testCopyStringWay() throws Exception{32 public void testCopyStringWay() { 30 33 final Way way = new Way(123L); 31 34 assertEquals("way 123", CopyAction.getCopyString(Collections.singleton(way))); 32 35 } 33 36 37 /** 38 * Test of {@link CopyAction#getCopyString} method for a way and a relation. 39 */ 34 40 @Test 35 public void testCopyStringWayRelation() throws Exception{41 public void testCopyStringWayRelation() { 36 42 final Way way = new Way(123L); 37 43 final Relation relation = new Relation(456); -
trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java
r8857 r8876 4 4 import static org.junit.Assert.assertSame; 5 5 import static org.junit.Assert.assertTrue; 6 import static org.junit.Assert.fail; 6 7 7 8 import java.awt.geom.Area; … … 50 51 * I don't know why, but in other tests there are no problem to add selected primitives 51 52 * but in this case there is a problem with an even listener of selection change. 53 * @param p primitive 54 * @param ds data set 52 55 */ 53 56 public void addSelected(OsmPrimitive p, DataSet ds) { … … 60 63 } catch (Exception e) { 61 64 e.printStackTrace(); 62 assertTrue("Can't add OsmPrimitive to dataset", false);65 fail("Can't add OsmPrimitive to dataset: " + e.getMessage()); 63 66 } 64 67 } … … 162 165 } catch (Exception e) { 163 166 e.printStackTrace(); 164 assertTrue("Impossible to mock left/right hand database", false);167 fail("Impossible to mock left/right hand database: " + e.getMessage()); 165 168 } 166 169 -
trunk/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java
r8857 r8876 42 42 */ 43 43 @Test 44 public void test 11184() throws Exception{44 public void testTicket11184() { 45 45 DataSet dataSet = new DataSet(); 46 46 OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null); -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
r8510 r8876 10 10 import java.io.InputStreamReader; 11 11 import java.net.HttpURLConnection; 12 import java.net.MalformedURLException;13 12 import java.net.URL; 14 13 import java.nio.charset.StandardCharsets; … … 112 111 /** 113 112 * Tests that sending an HTTP request without command results in HTTP 400, with all available commands in error message. 114 * @throws IOException if an I/O error occurs115 * @throws MalformedURLException if HTTP URL is invalid116 113 */ 117 114 @Test 118 public void testHttpListOfCommands() throws MalformedURLException, IOException{115 public void testHttpListOfCommands() { 119 116 testListOfCommands(httpBase); 120 117 } … … 122 119 /** 123 120 * Tests that sending an HTTPS request without command results in HTTP 400, with all available commands in error message. 124 * @throws IOException if an I/O error occurs125 * @throws MalformedURLException if HTTPS URL is invalid126 121 */ 127 122 @Test 128 public void testHttpsListOfCommands() throws MalformedURLException, IOException{123 public void testHttpsListOfCommands() { 129 124 testListOfCommands(httpsBase); 130 125 } 131 126 132 private void testListOfCommands(String url) throws MalformedURLException, IOException { 133 HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); 134 connection.connect(); 135 assertEquals(connection.getResponseCode(), HttpURLConnection.HTTP_BAD_REQUEST); 136 try (InputStream is = connection.getErrorStream()) { 137 // TODO this code should be refactored somewhere in Utils as it is used in several JOSM classes 138 StringBuilder responseBody = new StringBuilder(); 139 try (BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { 140 String s; 141 while ((s = in.readLine()) != null) { 142 responseBody.append(s); 143 responseBody.append("\n"); 127 private void testListOfCommands(String url) { 128 try { 129 HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); 130 connection.connect(); 131 assertEquals(connection.getResponseCode(), HttpURLConnection.HTTP_BAD_REQUEST); 132 try (InputStream is = connection.getErrorStream()) { 133 // TODO this code should be refactored somewhere in Utils as it is used in several JOSM classes 134 StringBuilder responseBody = new StringBuilder(); 135 try (BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { 136 String s; 137 while ((s = in.readLine()) != null) { 138 responseBody.append(s); 139 responseBody.append("\n"); 140 } 144 141 } 142 assert responseBody.toString().contains(RequestProcessor.getUsageAsHtml()); 143 } catch (IllegalAccessException | InstantiationException e) { 144 e.printStackTrace(); 145 fail(e.getMessage()); 145 146 } 146 assert responseBody.toString().contains(RequestProcessor.getUsageAsHtml()); 147 } catch (IllegalAccessException e) { 148 fail(e.getMessage()); 149 } catch (InstantiationException e) { 147 } catch (IOException e) { 148 e.printStackTrace(); 150 149 fail(e.getMessage()); 151 150 } -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java
r8857 r8876 2 2 package org.openstreetmap.josm.io.remotecontrol.handler; 3 3 4 import static org.junit.Assert.assert That;4 import static org.junit.Assert.assertEquals; 5 5 6 import org.hamcrest.CoreMatchers;7 6 import org.junit.Test; 8 7 … … 12 11 public class ImportHandlerTest { 13 12 13 /** 14 * Non-regression test for bug #7434. 15 */ 14 16 @Test 15 public void test7434() throws Exception { 16 17 public void testTicket7434() { 17 18 final ImportHandler req = new ImportHandler(); 18 19 req.setUrl("http://localhost:8111/import?url=http://localhost:8888/relations?relations=19711&mode=recursive"); 19 assert That(req.args.get("url"), CoreMatchers.is("http://localhost:8888/relations?relations=19711&mode=recursive"));20 assertEquals("http://localhost:8888/relations?relations=19711&mode=recursive", req.args.get("url")); 20 21 } 21 22 } -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandlerTest.java
r8857 r8876 45 45 } 46 46 47 /** 48 * Test request parameter - case 1 49 */ 47 50 @Test 48 51 public void testRequestParameter1() { … … 53 56 } 54 57 58 /** 59 * Test request parameter - case 2 60 */ 55 61 @Test 56 public void testRequestParameter 12() {62 public void testRequestParameter2() { 57 63 assertEquals(Collections.singletonMap("query", "a&b==c"), 58 64 getRequestParameter("http://example.com/?query=a%26b==c")); 59 65 } 60 66 67 /** 68 * Test request parameter - case 3 69 */ 61 70 @Test 62 71 public void testRequestParameter3() { … … 66 75 67 76 /** 77 * Test request parameter - case 4 68 78 * @see <a href="http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding"> 69 79 * What every web developer must know about URL encoding</a> … … 77 87 } 78 88 89 /** 90 * Test request parameter - case 5 91 */ 79 92 @Test 80 93 public void testRequestParameter5() { -
trunk/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java
r8857 r8876 114 114 } 115 115 116 /** 117 * Tests to read a .jos file containing Bing imagery. 118 * @throws IOException if any I/O error occurs 119 * @throws IllegalDataException is the test file is considered as invalid 120 */ 116 121 @Test 117 122 public void testReadImage() throws IOException, IllegalDataException { -
trunk/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java
r8837 r8876 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; 3 5 4 6 import java.io.File; … … 85 87 } 86 88 87 private void testWrite(List<Layer> layers, final boolean zip) throws IOException{89 private void testWrite(List<Layer> layers, final boolean zip) { 88 90 Map<Layer, SessionLayerExporter> exporters = new HashMap<>(); 89 91 if (zip) { … … 101 103 try { 102 104 sw.write(file); 105 } catch (IOException e) { 106 e.printStackTrace(); 107 fail(e.getMessage()); 103 108 } finally { 104 109 if (file.exists()) { … … 135 140 /** 136 141 * Tests to write an empty .jos file. 137 * @throws IOException if any I/O error occurs 138 */ 139 @Test 140 public void testWriteEmptyJos() throws IOException { 142 */ 143 @Test 144 public void testWriteEmptyJos() { 141 145 testWrite(Collections.<Layer>emptyList(), false); 142 146 } … … 144 148 /** 145 149 * Tests to write an empty .joz file. 146 * @throws IOException if any I/O error occurs 147 */ 148 @Test 149 public void testWriteEmptyJoz() throws IOException { 150 */ 151 @Test 152 public void testWriteEmptyJoz() { 150 153 testWrite(Collections.<Layer>emptyList(), true); 151 154 } … … 153 156 /** 154 157 * Tests to write a .jos file containing OSM data. 155 * @throws IOException if any I/O error occurs 156 */ 157 @Test 158 public void testWriteOsmJos() throws IOException { 158 */ 159 @Test 160 public void testWriteOsmJos() { 159 161 testWrite(Collections.<Layer>singletonList(createOsmLayer()), false); 160 162 } … … 162 164 /** 163 165 * Tests to write a .joz file containing OSM data. 164 * @throws IOException if any I/O error occurs 165 */ 166 @Test 167 public void testWriteOsmJoz() throws IOException { 166 */ 167 @Test 168 public void testWriteOsmJoz() { 168 169 testWrite(Collections.<Layer>singletonList(createOsmLayer()), true); 169 170 } … … 171 172 /** 172 173 * Tests to write a .jos file containing GPX data. 173 * @throws IOException if any I/O error occurs 174 */ 175 @Test 176 public void testWriteGpxJos() throws IOException { 174 */ 175 @Test 176 public void testWriteGpxJos() { 177 177 testWrite(Collections.<Layer>singletonList(createGpxLayer()), false); 178 178 } … … 180 180 /** 181 181 * Tests to write a .joz file containing GPX data. 182 * @throws IOException if any I/O error occurs 183 */ 184 @Test 185 public void testWriteGpxJoz() throws IOException { 182 */ 183 @Test 184 public void testWriteGpxJoz() { 186 185 testWrite(Collections.<Layer>singletonList(createGpxLayer()), true); 187 186 } … … 189 188 /** 190 189 * Tests to write a .joz file containing GPX and marker data. 191 * @throws IOException if any I/O error occurs 192 */ 193 @Test 194 public void testWriteGpxAndMarkerJoz() throws IOException { 190 */ 191 @Test 192 public void testWriteGpxAndMarkerJoz() { 195 193 GpxLayer gpx = createGpxLayer(); 196 194 testWrite(Arrays.asList(gpx, createMarkerLayer(gpx)), true); … … 199 197 /** 200 198 * Tests to write a .joz file containing an imagery layer. 201 * @throws IOException if any I/O error occurs 202 */ 203 @Test 204 public void testWriteImageryLayer() throws IOException { 199 */ 200 @Test 201 public void testWriteImageryLayer() { 205 202 final Layer layer = createImageryLayer(); 206 203 testWrite(Collections.singletonList(layer), true); -
trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java
r8549 r8876 21 21 } 22 22 23 /** 24 * Test of {@link Geometry#getLineLineIntersection} method. 25 */ 23 26 @Test 24 27 public void testLineLineIntersection() { -
trunk/test/unit/org/openstreetmap/josm/tools/OverpassTurboQueryWizardTest.java
r8857 r8876 22 22 } 23 23 24 /** 25 * Test key=value. 26 */ 24 27 @Test 25 28 public void testKeyValue() { … … 40 43 } 41 44 45 /** 46 * Test erroneous value. 47 */ 42 48 @Test(expected = OverpassTurboQueryWizard.ParseException.class) 43 49 public void testErroneous() { -
trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
r8857 r8876 10 10 */ 11 11 public class DateUtilsTest { 12 13 /** 14 * Test to parse date as returned for map data. 15 */ 12 16 @Test 13 public void testMapDate() throws Exception{17 public void testMapDate() { 14 18 assertEquals(1344870637000L, DateUtils.fromString("2012-08-13T15:10:37Z").getTime()); 15 16 19 } 17 20 21 /** 22 * Test to parse date as returned for note data. 23 */ 18 24 @Test 19 public void testNoteDate() throws Exception{25 public void testNoteDate() { 20 26 assertEquals(1417298930000L, DateUtils.fromString("2014-11-29 22:08:50 UTC").getTime()); 21 27 }
Note:
See TracChangeset
for help on using the changeset viewer.