Changeset 9934 in josm for trunk/test/unit/org
- Timestamp:
- 2016-03-05T21:25:09+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClientTest.java
r9669 r9934 4 4 import static org.junit.Assert.assertNotNull; 5 5 6 import java.net.CookieHandler; 7 import java.net.CookieManager; 6 8 import java.net.MalformedURLException; 9 import java.net.URI; 7 10 import java.net.URL; 11 import java.util.Collections; 8 12 9 13 import org.junit.BeforeClass; … … 44 48 //assertNotNull(accessToken); 45 49 } 50 51 /** 52 * Unit test for correct cookie handling when logging in to the OSM website. 53 * 54 * https://josm.openstreetmap.de/ticket/12584 55 * @throws Exception if any error occurs 56 */ 57 @Test 58 public void testCookieHandling() throws Exception { 59 final OAuthParameters parameters = OAuthParameters.createDefault(); 60 final OsmOAuthAuthorizationClient client = new OsmOAuthAuthorizationClient(parameters); 61 assertNotNull(client.fetchOsmWebsiteSessionId()); 62 63 // emulate Java Web Start behaviour 64 // see https://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/accessingCookies.html 65 final CookieManager cm = new CookieManager(); 66 cm.put(new URI(parameters.getOsmLoginUrl()), 67 Collections.singletonMap("Cookie", Collections.singletonList("_osm_session=" + String.valueOf(Math.PI).substring(2)))); 68 CookieHandler.setDefault(cm); 69 assertNotNull(client.fetchOsmWebsiteSessionId()); 70 } 46 71 }
Note:
See TracChangeset
for help on using the changeset viewer.