source: josm/trunk/test/unit/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClientTest.java@ 9339

Last change on this file since 9339 was 9227, checked in by Don-vip, 8 years ago

OAuth: add robustness, basic unit test, code cleanup

File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.oauth;
3
4import static org.junit.Assert.assertNotNull;
5
6import java.net.MalformedURLException;
7import java.net.URL;
8
9import org.junit.BeforeClass;
10import org.junit.Test;
11import org.openstreetmap.josm.JOSMFixture;
12import org.openstreetmap.josm.data.oauth.OAuthParameters;
13import org.openstreetmap.josm.data.oauth.OAuthToken;
14import org.openstreetmap.josm.io.OsmTransferCanceledException;
15
16/**
17 * Unit tests of {@link OsmOAuthAuthorizationClient} class.
18 */
19public class OsmOAuthAuthorizationClientTest {
20
21 /**
22 * Setup tests
23 */
24 @BeforeClass
25 public static void setUpBeforeClass() {
26 JOSMFixture.createUnitTestFixture().init();
27 }
28
29 /**
30 * Unit test of {@link OsmOAuthAuthorizationClient}.
31 * @throws OsmOAuthAuthorizationException if OAuth authorization error occurs
32 * @throws OsmTransferCanceledException if OSM transfer error occurs
33 * @throws MalformedURLException in case of invalid URL
34 */
35 @Test
36 public void testOsmOAuthAuthorizationClient() throws OsmTransferCanceledException, OsmOAuthAuthorizationException, MalformedURLException {
37 OsmOAuthAuthorizationClient client = new OsmOAuthAuthorizationClient(OAuthParameters.createDefault());
38 OAuthToken requestToken = client.getRequestToken(null);
39 assertNotNull(requestToken);
40 String url = client.getAuthoriseUrl(requestToken);
41 assertNotNull(url);
42 System.out.println(new URL(url));
43 //OAuthToken accessToken = client.getAccessToken(null);
44 //assertNotNull(accessToken);
45 }
46}
Note: See TracBrowser for help on using the repository browser.