1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.oauth;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertNotNull;
|
---|
5 |
|
---|
6 | import java.net.MalformedURLException;
|
---|
7 | import java.net.URL;
|
---|
8 |
|
---|
9 | import org.junit.BeforeClass;
|
---|
10 | import org.junit.Test;
|
---|
11 | import org.openstreetmap.josm.JOSMFixture;
|
---|
12 | import org.openstreetmap.josm.data.oauth.OAuthParameters;
|
---|
13 | import org.openstreetmap.josm.data.oauth.OAuthToken;
|
---|
14 | import org.openstreetmap.josm.io.OsmTransferCanceledException;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Unit tests of {@link OsmOAuthAuthorizationClient} class.
|
---|
18 | */
|
---|
19 | public 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 | }
|
---|