Changeset 32069 in osm for applications/editors/josm/plugins/mapillary/test
- Timestamp:
- 2016-02-15T14:58:49+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryURLTest.java
r31972 r32069 4 4 import static org.junit.Assert.assertNull; 5 5 import static org.junit.Assert.assertTrue; 6 import static org.junit.Assert.fail;7 6 8 7 import java.lang.reflect.InvocationTargetException; … … 13 12 import org.junit.Test; 14 13 import org.openstreetmap.josm.data.Bounds; 14 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryURL.IMAGE_SELECTOR; 15 15 16 16 public class MapillaryURLTest { 17 private static final String CLIENT_ID_QUERY_PART = "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"; 18 private static final String LIMIT_20_QUERY_PART = "limit=20"; 19 17 20 @Test 18 21 public void testBrowseEditURL() throws MalformedURLException { … … 21 24 MapillaryURL.browseEditURL("1234567890123456789012") 22 25 ); 23 try { 24 MapillaryURL.browseEditURL(null); 25 fail(); 26 } catch (IllegalArgumentException e) {} 27 try { 28 MapillaryURL.browseEditURL("123456789012345678901"); 29 fail(); 30 } catch (IllegalArgumentException e) {} 31 try { 32 MapillaryURL.browseEditURL("123456789012345678901+"); 33 fail(); 34 } catch (IllegalArgumentException e) {} 26 } 27 28 @Test(expected=IllegalArgumentException.class) 29 public void testIllegalBrowseEditURL() { 30 MapillaryURL.browseEditURL(null); 31 } 32 33 @Test(expected=IllegalArgumentException.class) 34 public void testIllegalBrowseEditURL2() { 35 MapillaryURL.browseEditURL("123456789012345678901"); 36 } 37 38 @Test(expected=IllegalArgumentException.class) 39 public void testIllegalBrowseEditURL3() { 40 MapillaryURL.browseEditURL("12345678901234567890123"); 41 } 42 43 @Test(expected=IllegalArgumentException.class) 44 public void testIllegalBrowseEditURL4() { 45 MapillaryURL.browseEditURL("123456789012345678901+"); 35 46 } 36 47 … … 41 52 MapillaryURL.browseImageURL("1234567890123456789012") 42 53 ); 43 try { 44 MapillaryURL.browseImageURL(null); 45 fail(); 46 } catch (IllegalArgumentException e) {} 47 try { 48 MapillaryURL.browseImageURL("123456789012345678901"); 49 fail(); 50 } catch (IllegalArgumentException e) {} 51 try { 52 MapillaryURL.browseImageURL("123456789012345678901+"); 53 fail(); 54 } catch (IllegalArgumentException e) {} 54 } 55 56 @Test(expected=IllegalArgumentException.class) 57 public void testIllegalBrowseImageURL() { 58 MapillaryURL.browseImageURL(null); 59 } 60 61 @Test(expected=IllegalArgumentException.class) 62 public void testIllegalBrowseImageURL2() { 63 MapillaryURL.browseImageURL("123456789012345678901"); 64 } 65 66 @Test(expected=IllegalArgumentException.class) 67 public void testIllegalBrowseImageURL3() { 68 MapillaryURL.browseImageURL("12345678901234567890123"); 69 } 70 71 @Test(expected=IllegalArgumentException.class) 72 public void testIllegalBrowseImageURL4() { 73 MapillaryURL.browseImageURL("123456789012345678901+"); 55 74 } 56 75 57 76 @Test 58 77 public void testBrowseUploadImageURL() throws MalformedURLException { 59 assertEquals(new URL("https://www.mapillary.com/map/upload/im /"), MapillaryURL.browseUploadImageURL());78 assertEquals(new URL("https://www.mapillary.com/map/upload/im"), MapillaryURL.browseUploadImageURL()); 60 79 } 61 80 … … 65 84 MapillaryURL.connectURL("http://redirect-host/ä"), 66 85 "https://www.mapillary.com/connect", 67 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz",86 CLIENT_ID_QUERY_PART, 68 87 "scope=user%3Aread+public%3Aupload+public%3Awrite", 69 88 "response_type=token", … … 74 93 MapillaryURL.connectURL(null), 75 94 "https://www.mapillary.com/connect", 76 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz",95 CLIENT_ID_QUERY_PART, 77 96 "scope=user%3Aread+public%3Aupload+public%3Awrite", 78 97 "response_type=token" … … 82 101 MapillaryURL.connectURL(""), 83 102 "https://www.mapillary.com/connect", 84 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz",103 CLIENT_ID_QUERY_PART, 85 104 "scope=user%3Aread+public%3Aupload+public%3Awrite", 86 105 "response_type=token" … … 91 110 public void testSearchImageURL() { 92 111 assertUrlEquals( 93 MapillaryURL.searchImageURL(new Bounds(1.1, 2.22, 3.333, 4.4444), 42), 94 "https://a.mapillary.com/v2/search/im /",95 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz",112 MapillaryURL.searchImageInfoURL(new Bounds(1.1, 2.22, 3.333, 4.4444), 42, null), 113 "https://a.mapillary.com/v2/search/im", 114 CLIENT_ID_QUERY_PART, 96 115 "min_lon=2.220000", 97 116 "max_lon=4.444400", 98 117 "min_lat=1.100000", 99 118 "max_lat=3.333000", 100 "limit=20",119 LIMIT_20_QUERY_PART, 101 120 "page=42" 102 121 ); 103 122 assertUrlEquals( 104 MapillaryURL.searchImageURL(null, -73), 105 "https://a.mapillary.com/v2/search/im /",106 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz",107 "limit=20",123 MapillaryURL.searchImageInfoURL(null, -73, null), 124 "https://a.mapillary.com/v2/search/im", 125 CLIENT_ID_QUERY_PART, 126 LIMIT_20_QUERY_PART, 108 127 "page=-73" 109 128 ); … … 114 133 assertUrlEquals( 115 134 MapillaryURL.searchSequenceURL(new Bounds(-55.55555, -66.666666, 77.7777777, 88.88888888, false), 42), 116 "https://a.mapillary.com/v2/search/s /",117 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz",135 "https://a.mapillary.com/v2/search/s", 136 CLIENT_ID_QUERY_PART, 118 137 "min_lon=-66.666666", 119 138 "max_lon=88.888889", … … 125 144 assertUrlEquals( 126 145 MapillaryURL.searchSequenceURL(null, -73), 127 "https://a.mapillary.com/v2/search/s /",128 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz",146 "https://a.mapillary.com/v2/search/s", 147 CLIENT_ID_QUERY_PART, 129 148 "limit=10", 130 149 "page=-73" … … 135 154 public void testSearchTrafficSignURL() { 136 155 assertUrlEquals( 137 MapillaryURL.search TrafficSignURL(new Bounds(1.1, 2.22, 3.333, 4.4444), -42),138 "https://a.mapillary.com/v2/search/im/or /",139 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz",156 MapillaryURL.searchImageInfoURL(new Bounds(1.1, 2.22, 3.333, 4.4444), -42, IMAGE_SELECTOR.OBJ_REC_ONLY), 157 "https://a.mapillary.com/v2/search/im/or", 158 CLIENT_ID_QUERY_PART, 140 159 "min_lon=2.220000", 141 160 "max_lon=4.444400", 142 161 "min_lat=1.100000", 143 162 "max_lat=3.333000", 144 "limit=20",163 LIMIT_20_QUERY_PART, 145 164 "page=-42" 146 165 ); 147 166 assertUrlEquals( 148 MapillaryURL.search TrafficSignURL(null, 73),149 "https://a.mapillary.com/v2/search/im/or /",150 "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz",151 "limit=20",167 MapillaryURL.searchImageInfoURL(null, 73, IMAGE_SELECTOR.OBJ_REC_ONLY), 168 "https://a.mapillary.com/v2/search/im/or", 169 CLIENT_ID_QUERY_PART, 170 LIMIT_20_QUERY_PART, 152 171 "page=73" 153 172 ); … … 157 176 public void testUploadSecretsURL() throws MalformedURLException { 158 177 assertEquals( 159 new URL("https://a.mapillary.com/v2/me/uploads/secrets /?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"),178 new URL("https://a.mapillary.com/v2/me/uploads/secrets?"+CLIENT_ID_QUERY_PART), 160 179 MapillaryURL.uploadSecretsURL() 161 180 ); … … 165 184 public void testUserURL() throws MalformedURLException { 166 185 assertEquals( 167 new URL("https://a.mapillary.com/v2/me /?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"),186 new URL("https://a.mapillary.com/v2/me?"+CLIENT_ID_QUERY_PART), 168 187 MapillaryURL.userURL() 169 188 ); … … 172 191 @Test 173 192 public void testString2MalformedURL() 174 throws NoSuchMethodException, SecurityException,IllegalAccessException, IllegalArgumentException, InvocationTargetException {175 Method method = MapillaryURL.class.getDeclaredMethod("string2URL", String.class); 193 throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { 194 Method method = MapillaryURL.class.getDeclaredMethod("string2URL", String[].class); 176 195 method.setAccessible(true); 177 assertNull(method.invoke(null, "bla"));196 assertNull(method.invoke(null, new Object[]{new String[]{"malformed URL"}})); // this simply invokes string2URL("malformed URL") 178 197 } 179 198
Note:
See TracChangeset
for help on using the changeset viewer.