Index: trunk/test/unit/org/openstreetmap/josm/TestUtils.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/TestUtils.java	(revision 18985)
+++ trunk/test/unit/org/openstreetmap/josm/TestUtils.java	(revision 18991)
@@ -659,8 +659,8 @@
     /**
      * Determines if OSM DEV_API credential have been provided. Required for functional tests.
-     * @return {@code true} if {@code osm.username} and {@code osm.password} have been defined on the command line
+     * @return {@code true} if {@code osm.oauth2} have been defined on the command line
      */
     public static boolean areCredentialsProvided() {
-        return Utils.getSystemProperty("osm.username") != null && Utils.getSystemProperty("osm.password") != null;
+        return Utils.getSystemProperty("osm.oauth2") != null;
     }
 
Index: trunk/test/unit/org/openstreetmap/josm/data/oauth/OAuth20AuthorizationTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/oauth/OAuth20AuthorizationTest.java	(revision 18985)
+++ trunk/test/unit/org/openstreetmap/josm/data/oauth/OAuth20AuthorizationTest.java	(revision 18991)
@@ -186,5 +186,5 @@
         OAuth20Parameters parameters = (OAuth20Parameters) OAuthParameters.createDefault(OsmApi.getOsmApi().getBaseUrl(), OAuthVersion.OAuth20);
         RemoteControl.start();
-        authorization.authorize(new OAuth20Parameters(parameters.getClientId(), parameters.getClientSecret(),
+        authorization.authorize(new OAuth20Parameters(CLIENT_ID_VALUE, parameters.getClientSecret(),
                 wireMockRuntimeInfo.getHttpBaseUrl() + "/oauth2", wireMockRuntimeInfo.getHttpBaseUrl() + "/api",
                 parameters.getRedirectUri()), consumer::set, OsmScopes.read_gpx);
Index: trunk/test/unit/org/openstreetmap/josm/data/oauth/OAuthParametersTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/oauth/OAuthParametersTest.java	(revision 18985)
+++ trunk/test/unit/org/openstreetmap/josm/data/oauth/OAuthParametersTest.java	(revision 18991)
@@ -24,14 +24,12 @@
     @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
     void testCreateDefault() {
-        OAuthParameters def = OAuthParameters.createDefault();
+        IOAuthParameters def = OAuthParameters.createDefault();
         assertNotNull(def);
-        assertEquals(def, OAuthParameters.createDefault(Config.getUrls().getDefaultOsmApiUrl()));
-        OAuthParameters dev = OAuthParameters.createDefault("https://api06.dev.openstreetmap.org/api");
+        assertEquals(def, OAuthParameters.createDefault(Config.getUrls().getDefaultOsmApiUrl(), OAuthVersion.OAuth20));
+        IOAuthParameters dev = OAuthParameters.createDefault("https://api06.dev.openstreetmap.org/api", OAuthVersion.OAuth20);
         assertNotNull(dev);
         assertNotEquals(def, dev);
         Logging.setLogLevel(Logging.LEVEL_TRACE); // enable trace for line coverage
-        assertEquals(def, OAuthParameters.createDefault("wrong_url"));
-        OAuthParameters dev2 = new OAuthParameters(dev);
-        assertEquals(dev, dev2);
+        assertEquals(def, OAuthParameters.createDefault("wrong_url", OAuthVersion.OAuth20));
     }
 
@@ -42,5 +40,5 @@
     void testEqualsContract() {
         TestUtils.assumeWorkingEqualsVerifier();
-        EqualsVerifier.forClass(OAuthParameters.class).usingGetClass().verify();
+        EqualsVerifier.forClass(OAuth20Parameters.class).usingGetClass().verify();
     }
 }
Index: trunk/test/unit/org/openstreetmap/josm/data/oauth/OAuthTokenTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/oauth/OAuthTokenTest.java	(revision 18985)
+++ 	(revision )
@@ -1,40 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.data.oauth;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.junit.jupiter.api.Test;
-import org.openstreetmap.josm.TestUtils;
-
-import nl.jqno.equalsverifier.EqualsVerifier;
-import oauth.signpost.OAuthConsumer;
-
-/**
- * Unit tests for class {@link OAuthToken}.
- */
-class OAuthTokenTest {
-
-    /**
-     * Unit test of method {@link OAuthToken#createToken}.
-     */
-    @Test
-    void testCreateToken() {
-        OAuthConsumer defCon = OAuthParameters.createDefault().buildConsumer();
-        assertNotNull(defCon);
-        OAuthToken defTok = OAuthToken.createToken(defCon);
-        assertNotNull(defTok);
-        assertEquals(defCon.getToken(), defTok.getKey());
-        assertEquals(defCon.getTokenSecret(), defTok.getSecret());
-        assertEquals(defTok, new OAuthToken(defTok));
-    }
-
-    /**
-     * Unit test of methods {@link OAuthToken#equals} and {@link OAuthToken#hashCode}.
-     */
-    @Test
-    void testEqualsContract() {
-        TestUtils.assumeWorkingEqualsVerifier();
-        EqualsVerifier.forClass(OAuthToken.class).usingGetClass().verify();
-    }
-}
Index: trunk/test/unit/org/openstreetmap/josm/data/oauth/SignpostAdaptersTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/oauth/SignpostAdaptersTest.java	(revision 18985)
+++ 	(revision )
@@ -1,99 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.data.oauth;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.junit.jupiter.api.Test;
-import org.openstreetmap.josm.data.oauth.SignpostAdapters.HttpRequest;
-import org.openstreetmap.josm.data.oauth.SignpostAdapters.HttpResponse;
-import org.openstreetmap.josm.data.oauth.SignpostAdapters.OAuthConsumer;
-import org.openstreetmap.josm.testutils.annotations.HTTPS;
-import org.openstreetmap.josm.tools.HttpClient;
-
-import net.trajano.commons.testing.UtilityClassTestUtil;
-
-/**
- * Unit tests for class {@link SignpostAdapters}.
- */
-@HTTPS
-class SignpostAdaptersTest {
-
-    private static HttpClient newClient() throws MalformedURLException {
-        return HttpClient.create(new URL("https://www.openstreetmap.org"));
-    }
-
-    /**
-     * Tests that {@code SignpostAdapters} satisfies utility class criteria.
-     * @throws ReflectiveOperationException if an error occurs
-     */
-    @Test
-    void testUtilityClass() throws ReflectiveOperationException {
-        UtilityClassTestUtil.assertUtilityClassWellDefined(SignpostAdapters.class);
-    }
-
-    /**
-     * Unit test of method {@link SignpostAdapters.OAuthConsumer#wrap}.
-     * @throws MalformedURLException never
-     */
-    @Test
-    void testOAuthConsumerWrap() throws MalformedURLException {
-        assertNotNull(new OAuthConsumer("", "").wrap(newClient()));
-    }
-
-    /**
-     * Unit test of method {@link SignpostAdapters.HttpRequest#getMessagePayload}.
-     * @throws IOException never
-     */
-    @Test
-    void testHttpRequestGetMessagePayload() throws IOException {
-        assertNull(new HttpRequest(newClient()).getMessagePayload());
-    }
-
-    /**
-     * Unit test of method {@link SignpostAdapters.HttpRequest#setRequestUrl}.
-     */
-    @Test
-    void testHttpRequestSetRequestUrl() {
-        assertThrows(IllegalStateException.class, () -> new HttpRequest(newClient()).setRequestUrl(null));
-    }
-
-    /**
-     * Unit test of method {@link SignpostAdapters.HttpRequest#getAllHeaders}.
-     */
-    @Test
-    void testHttpRequestGetAllHeaders() {
-        assertThrows(IllegalStateException.class, () -> new HttpRequest(newClient()).getAllHeaders());
-    }
-
-    /**
-     * Unit test of method {@link SignpostAdapters.HttpRequest#unwrap}.
-     */
-    @Test
-    void testHttpRequestUnwrap() {
-        assertThrows(IllegalStateException.class, () -> new HttpRequest(newClient()).unwrap());
-    }
-
-    /**
-     * Unit test of method {@link SignpostAdapters.HttpResponse#getReasonPhrase()}.
-     * @throws Exception never
-     */
-    @Test
-    void testHttpResponseGetReasonPhrase() throws Exception {
-        assertEquals("OK", new HttpResponse(new HttpRequest(newClient()).request.connect()).getReasonPhrase());
-    }
-
-    /**
-     * Unit test of method {@link SignpostAdapters.HttpResponse#unwrap}.
-     */
-    @Test
-    void testHttpResponseUnwrap() {
-        assertThrows(IllegalStateException.class, () -> new HttpResponse(new HttpRequest(newClient()).request.connect()).unwrap());
-    }
-}
Index: trunk/test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java	(revision 18985)
+++ trunk/test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java	(revision 18991)
@@ -9,15 +9,14 @@
 import java.awt.GraphicsEnvironment;
 import java.net.URL;
-import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.openstreetmap.josm.TestUtils;
 import org.openstreetmap.josm.data.UserIdentityManager;
 import org.openstreetmap.josm.gui.oauth.OAuthAuthorizationWizard;
-import org.openstreetmap.josm.spi.preferences.Config;
 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
 import org.openstreetmap.josm.testutils.annotations.OsmApi;
@@ -64,12 +63,4 @@
 
     /**
-     * These tests were written with {@link org.openstreetmap.josm.data.oauth.OAuthVersion#OAuth10a} as the default auth method.
-     */
-    @BeforeEach
-    void setup() {
-        Config.getPref().put("osm-server.auth-method", "oauth");
-    }
-
-    /**
      * Test of {@link DownloadOpenChangesetsTask} class when anonymous.
      */
@@ -80,12 +71,10 @@
             new WindowMocker();
         }
-        final OAuthWizardMocker oaWizardMocker = new OAuthWizardMocker();
-        final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(
-            Collections.singletonMap(
-                "<html>Could not retrieve the list of your open changesets because<br>JOSM does not know "
+        final Map<String, Object> optionPaneMock = new HashMap<>(2);
+        optionPaneMock.put("<html>Could not retrieve the list of your open changesets because<br>JOSM does not know "
                 + "your identity.<br>You have either chosen to work anonymously or you are not "
-                + "entitled<br>to know the identity of the user on whose behalf you are working.</html>", JOptionPane.OK_OPTION
-            )
-        );
+                + "entitled<br>to know the identity of the user on whose behalf you are working.</html>", JOptionPane.OK_OPTION);
+        optionPaneMock.put("Obtain OAuth 2.0 token for authentication?", JOptionPane.NO_OPTION);
+        final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(optionPaneMock);
 
         DownloadOpenChangesetsTask task = new DownloadOpenChangesetsTask(new JPanel());
@@ -96,10 +85,12 @@
         assertNull(task.getChangesets());
 
-        assertEquals(1, jopsMocker.getInvocationLog().size());
-        Object[] invocationLogEntry = jopsMocker.getInvocationLog().get(0);
+        assertEquals(2, jopsMocker.getInvocationLog().size());
+        Object[] invocationLogEntry = jopsMocker.getInvocationLog().get(1);
         assertEquals(JOptionPane.OK_OPTION, (int) invocationLogEntry[0]);
         assertEquals("Missing user identity", invocationLogEntry[2]);
 
-        assertTrue(oaWizardMocker.called);
+        invocationLogEntry = jopsMocker.getInvocationLog().get(0);
+        assertEquals(JOptionPane.NO_OPTION, (int) invocationLogEntry[0]);
+        assertEquals("Obtain authentication to OSM servers", invocationLogEntry[2]);
     }
 
@@ -113,8 +104,8 @@
             new WindowMocker();
         }
-        final OAuthWizardMocker oaWizardMocker = new OAuthWizardMocker();
-        final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(
-            Collections.singletonMap("There are no open changesets", JOptionPane.OK_OPTION)
-        );
+        final Map<String, Object> optionPaneMock = new HashMap<>(2);
+        optionPaneMock.put("There are no open changesets", JOptionPane.OK_OPTION);
+        optionPaneMock.put("Obtain OAuth 2.0 token for authentication?", JOptionPane.NO_OPTION);
+        final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(optionPaneMock);
 
         DownloadOpenChangesetsTask task = new DownloadOpenChangesetsTask(new JPanel());
@@ -124,10 +115,12 @@
         assertNotNull(task.getChangesets());
 
-        assertEquals(1, jopsMocker.getInvocationLog().size());
-        Object[] invocationLogEntry = jopsMocker.getInvocationLog().get(0);
+        assertEquals(2, jopsMocker.getInvocationLog().size());
+        Object[] invocationLogEntry = jopsMocker.getInvocationLog().get(1);
         assertEquals(JOptionPane.OK_OPTION, (int) invocationLogEntry[0]);
         assertEquals("No open changesets", invocationLogEntry[2]);
 
-        assertTrue(oaWizardMocker.called);
+        invocationLogEntry = jopsMocker.getInvocationLog().get(0);
+        assertEquals(JOptionPane.NO_OPTION, (int) invocationLogEntry[0]);
+        assertEquals("Obtain authentication to OSM servers", invocationLogEntry[2]);
     }
 }
Index: trunk/test/unit/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUITest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUITest.java	(revision 18985)
+++ trunk/test/unit/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUITest.java	(revision 18991)
@@ -2,10 +2,11 @@
 package org.openstreetmap.josm.gui.oauth;
 
-import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
+import org.openstreetmap.josm.data.oauth.OAuthVersion;
 import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
-
-import org.junit.jupiter.api.Test;
 
 /**
@@ -17,7 +18,8 @@
      * Unit test of {@link FullyAutomaticAuthorizationUI#FullyAutomaticAuthorizationUI}.
      */
-    @Test
-    void testFullyAutomaticAuthorizationUI() {
-        assertNotNull(new FullyAutomaticAuthorizationUI("", MainApplication.worker));
+    @ParameterizedTest
+    @EnumSource(OAuthVersion.class)
+    void testFullyAutomaticAuthorizationUI(OAuthVersion version) {
+        assertDoesNotThrow(() -> new FullyAutomaticAuthorizationUI("", MainApplication.worker, version));
     }
 }
Index: trunk/test/unit/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUITest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUITest.java	(revision 18985)
+++ trunk/test/unit/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUITest.java	(revision 18991)
@@ -2,7 +2,8 @@
 package org.openstreetmap.josm.gui.oauth;
 
-import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 
 import org.junit.jupiter.api.Test;
+import org.openstreetmap.josm.data.oauth.OAuthVersion;
 import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
@@ -18,5 +19,5 @@
     @Test
     void testManualAuthorizationUI() {
-        assertNotNull(new ManualAuthorizationUI("", MainApplication.worker));
+        assertDoesNotThrow(() -> new ManualAuthorizationUI("", MainApplication.worker, OAuthVersion.OAuth20));
     }
 }
Index: trunk/test/unit/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClientTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClientTest.java	(revision 18985)
+++ 	(revision )
@@ -1,116 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.gui.oauth;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import java.net.CookieHandler;
-import java.net.CookieManager;
-import java.net.URI;
-import java.util.Collections;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Timeout;
-import org.openstreetmap.josm.data.oauth.OAuthParameters;
-import org.openstreetmap.josm.data.oauth.OAuthToken;
-import org.openstreetmap.josm.io.OsmTransferCanceledException;
-import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
-import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
-import org.openstreetmap.josm.testutils.annotations.HTTP;
-
-import com.github.tomakehurst.wiremock.WireMockServer;
-
-/**
- * Unit tests of {@link OsmOAuthAuthorizationClient} class.
- */
-@Timeout(20)
-@BasicWiremock
-// Needed for OAuthParameters
-@BasicPreferences
-@HTTP
-class OsmOAuthAuthorizationClientTest {
-    /**
-     * HTTP mock.
-     */
-    @BasicWiremock
-    WireMockServer wireMockServer;
-
-    /**
-     * Unit test of {@link OsmOAuthAuthorizationClient}.
-     * @throws OsmOAuthAuthorizationException if OAuth authorization error occurs
-     * @throws OsmTransferCanceledException  if OSM transfer error occurs
-     */
-    @Test
-    void testOsmOAuthAuthorizationClient() throws OsmTransferCanceledException, OsmOAuthAuthorizationException {
-        // request token
-        wireMockServer.stubFor(get(urlEqualTo("/oauth/request_token"))
-                .willReturn(aResponse().withStatus(200).withBody(String.join("&",
-                        "oauth_token=entxUGuwRKV6KyVDF0OWScdGhbqXGMGmosXuiChR",
-                        "oauth_token_secret=nsBD2Hr5lLGDUeNoh3SnLaGsUV1TiPYM4qUr7tPB"))));
-        OsmOAuthAuthorizationClient client = new OsmOAuthAuthorizationClient(OAuthParameters.createDefault(
-                wireMockServer.url("/api")));
-
-        OAuthToken requestToken = client.getRequestToken(null);
-        assertEquals("entxUGuwRKV6KyVDF0OWScdGhbqXGMGmosXuiChR", requestToken.getKey(), "requestToken.key");
-        assertEquals("nsBD2Hr5lLGDUeNoh3SnLaGsUV1TiPYM4qUr7tPB", requestToken.getSecret(), "requestToken.secret");
-        String url = client.getAuthoriseUrl(requestToken);
-        assertEquals(wireMockServer.url("/oauth/authorize?oauth_token=entxUGuwRKV6KyVDF0OWScdGhbqXGMGmosXuiChR"), url, "url");
-
-        // access token
-        wireMockServer.stubFor(get(urlEqualTo("/oauth/access_token"))
-                .willReturn(aResponse().withStatus(200).withBody(String.join("&",
-                        "oauth_token=eGMGmosXuiChRntxUGuwRKV6KyVDF0OWScdGhbqX",
-                        "oauth_token_secret=nsBUeNor7tPh3SHr5lLaGsGDUD2PYMV1TinL4qUB"))));
-
-        OAuthToken accessToken = client.getAccessToken(null);
-        assertEquals("eGMGmosXuiChRntxUGuwRKV6KyVDF0OWScdGhbqX", accessToken.getKey(), "accessToken.key");
-        assertEquals("nsBUeNor7tPh3SHr5lLaGsGDUD2PYMV1TinL4qUB", accessToken.getSecret(), "accessToken.secret");
-    }
-
-    /**
-     * Unit test for correct cookie handling when logging in to the OSM website.
-     *
-     * https://josm.openstreetmap.de/ticket/12584
-     * @throws Exception if any error occurs
-     */
-    @Test
-    void testCookieHandlingMock() throws Exception {
-        wireMockServer.stubFor(get(urlEqualTo("/login?cookie_test=true"))
-                .willReturn(aResponse()
-                        .withStatus(200)
-                        .withHeader("Set-Cookie", "_osm_session=7fe8e2ea36c6b803cb902301b28e0a; path=/; HttpOnly; SameSite=Lax")
-                .withBody("<input type=\"hidden\" " +
-                        "name=\"authenticity_token\" " +
-                        "value=\"fzp6CWJhp6Vns09re3s2Tw==\" />")));
-        final OAuthParameters parameters = OAuthParameters.createDefault(wireMockServer.url("/api"));
-        final OsmOAuthAuthorizationClient client = new OsmOAuthAuthorizationClient(parameters);
-        final OsmOAuthAuthorizationClient.SessionId sessionId = client.fetchOsmWebsiteSessionId();
-        assertNotNull(sessionId);
-        assertEquals("7fe8e2ea36c6b803cb902301b28e0a", sessionId.id, "sessionId.id");
-        assertEquals("fzp6CWJhp6Vns09re3s2Tw==", sessionId.token, "sessionId.token");
-        assertNull(sessionId.userName, "sessionId.userName");
-    }
-
-    /**
-     * Unit test for correct cookie handling when logging in to the OSM website.
-     *
-     * https://josm.openstreetmap.de/ticket/12584
-     * @throws Exception if any error occurs
-     */
-    @Test
-    void testCookieHandlingCookieManager() throws Exception {
-        // emulate Java Web Start behaviour
-        // see https://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/accessingCookies.html
-        final OAuthParameters parameters = OAuthParameters.createDefault();
-        final OsmOAuthAuthorizationClient client = new OsmOAuthAuthorizationClient(parameters);
-        final CookieManager cm = new CookieManager();
-        cm.put(new URI(parameters.getOsmLoginUrl()),
-                Collections.singletonMap("Cookie", Collections.singletonList("_osm_session=" + String.valueOf(Math.PI).substring(2))));
-        CookieHandler.setDefault(cm);
-        assertNotNull(client.fetchOsmWebsiteSessionId());
-    }
-}
Index: trunk/test/unit/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUITest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUITest.java	(revision 18985)
+++ 	(revision )
@@ -1,22 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.gui.oauth;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.junit.jupiter.api.Test;
-import org.openstreetmap.josm.gui.MainApplication;
-import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
-
-/**
- * Unit tests of {@link SemiAutomaticAuthorizationUI} class.
- */
-@BasicPreferences
-class SemiAutomaticAuthorizationUITest {
-    /**
-     * Unit test of {@link SemiAutomaticAuthorizationUI#SemiAutomaticAuthorizationUI}.
-     */
-    @Test
-    void testSemiAutomaticAuthorizationUI() {
-        assertNotNull(new SemiAutomaticAuthorizationUI("", MainApplication.worker));
-    }
-}
Index: trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanelTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanelTest.java	(revision 18985)
+++ trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanelTest.java	(revision 18991)
@@ -21,10 +21,8 @@
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.EnumSource;
-import org.openstreetmap.josm.data.oauth.IOAuthToken;
 import org.openstreetmap.josm.data.oauth.OAuth20Exception;
 import org.openstreetmap.josm.data.oauth.OAuth20Parameters;
 import org.openstreetmap.josm.data.oauth.OAuth20Token;
 import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder;
-import org.openstreetmap.josm.data.oauth.OAuthToken;
 import org.openstreetmap.josm.data.oauth.OAuthVersion;
 import org.openstreetmap.josm.io.OsmApi;
@@ -47,5 +45,5 @@
         List<Exception> exceptionList = new ArrayList<>();
         try {
-            CredentialsManager.getInstance().storeOAuthAccessToken(null);
+            CredentialsManager.getInstance().storeOAuthAccessToken(OsmApi.getOsmApi().getServerUrl(), null);
         } catch (CredentialsAgentException exception) {
             exceptionList.add(exception);
@@ -61,5 +59,5 @@
 
     @ParameterizedTest
-    @EnumSource(value = OAuthVersion.class, names = {"OAuth10a", "OAuth20"})
+    @EnumSource(value = OAuthVersion.class, names = "OAuth20")
     void testRemoveToken(OAuthVersion oAuthVersion) throws ReflectiveOperationException, CredentialsAgentException, OAuth20Exception {
         final OAuthAuthenticationPreferencesPanel panel = new OAuthAuthenticationPreferencesPanel(oAuthVersion);
@@ -76,6 +74,6 @@
         assertSame(pnlAlreadyAuthorised.get(panel), holder.getComponent(0), "Authentication should now be set");
         assertNotNull(getAuthorization(oAuthVersion));
-        final JPanel buttons = (JPanel) ((JPanel) pnlAlreadyAuthorised.get(panel)).getComponent(6);
-        final JButton action = (JButton) buttons.getComponent(oAuthVersion == OAuthVersion.OAuth10a ? 2 : 1);
+        final JPanel buttons = (JPanel) ((JPanel) pnlAlreadyAuthorised.get(panel)).getComponent(5);
+        final JButton action = (JButton) buttons.getComponent(2);
         assertEquals(tr("Remove token"), action.getText(), "The selected button should be for removing the token");
         action.getAction().actionPerformed(null);
@@ -97,7 +95,4 @@
     private static void addAuthorization(OAuthVersion oAuthVersion) throws CredentialsAgentException, OAuth20Exception {
         switch (oAuthVersion) {
-            case OAuth10a:
-                CredentialsManager.getInstance().storeOAuthAccessToken(new OAuthToken("fake_key", "fake_secret"));
-                break;
             case OAuth20:
             case OAuth21:
@@ -117,16 +112,8 @@
     private static Object getAuthorization(OAuthVersion oAuthVersion) {
         OAuthAccessTokenHolder.getInstance().clear();
-        OAuthAccessTokenHolder.getInstance().setAccessToken(OsmApi.getOsmApi().getHost(), (IOAuthToken) null);
+        OAuthAccessTokenHolder.getInstance().setAccessToken(OsmApi.getOsmApi().getServerUrl(), null);
         OAuthAccessTokenHolder.getInstance().init(CredentialsManager.getInstance());
         // Ensure that we are not saving authorization data
-        switch (oAuthVersion) {
-            case OAuth10a:
-                return OAuthAccessTokenHolder.getInstance().getAccessToken();
-            case OAuth20:
-            case OAuth21:
-                return OAuthAccessTokenHolder.getInstance().getAccessToken(OsmApi.getOsmApi().getHost(), oAuthVersion);
-            default:
-                throw new AssertionError("OAuth version not understood");
-        }
+        return OAuthAccessTokenHolder.getInstance().getAccessToken(OsmApi.getOsmApi().getServerUrl(), oAuthVersion);
     }
 }
Index: trunk/test/unit/org/openstreetmap/josm/io/auth/CredentialsAgentTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/io/auth/CredentialsAgentTest.java	(revision 18985)
+++ trunk/test/unit/org/openstreetmap/josm/io/auth/CredentialsAgentTest.java	(revision 18991)
@@ -19,5 +19,4 @@
 import org.openstreetmap.josm.data.oauth.OAuth20Parameters;
 import org.openstreetmap.josm.data.oauth.OAuth20Token;
-import org.openstreetmap.josm.data.oauth.OAuthToken;
 import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
@@ -76,16 +75,4 @@
     }
 
-    @Test
-    default void testLookUpAndStoreOAuth10() throws CredentialsAgentException {
-        final T agent = createAgent();
-        assertNull(agent.lookupOAuthAccessToken());
-        final OAuthToken token = new OAuthToken("foo", "bar");
-        agent.storeOAuthAccessToken(token);
-        final OAuthToken actual = agent.lookupOAuthAccessToken();
-        assertEquals(token, actual);
-        agent.storeOAuthAccessToken(null);
-        assertNull(agent.lookupOAuthAccessToken());
-    }
-
     @ParameterizedTest
     @MethodSource("getHosts")
Index: trunk/test/unit/org/openstreetmap/josm/testutils/annotations/BasicPreferences.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/testutils/annotations/BasicPreferences.java	(revision 18985)
+++ trunk/test/unit/org/openstreetmap/josm/testutils/annotations/BasicPreferences.java	(revision 18991)
@@ -65,4 +65,7 @@
             if (AnnotationSupport.isAnnotated(context.getElement(), BasicPreferences.class)) {
                 this.afterAll(context);
+                if (AnnotationSupport.isAnnotated(context.getTestClass(), BasicPreferences.class)) {
+                    this.beforeAll(context);
+                }
             }
         }
Index: trunk/test/unit/org/openstreetmap/josm/testutils/annotations/TestUser.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/testutils/annotations/TestUser.java	(revision 18985)
+++ trunk/test/unit/org/openstreetmap/josm/testutils/annotations/TestUser.java	(revision 18991)
@@ -10,5 +10,4 @@
 import java.lang.annotation.Target;
 import java.net.Authenticator;
-import java.net.PasswordAuthentication;
 
 import org.junit.jupiter.api.extension.AfterEachCallback;
@@ -19,4 +18,7 @@
 import org.openstreetmap.josm.TestUtils;
 import org.openstreetmap.josm.data.UserIdentityManager;
+import org.openstreetmap.josm.data.oauth.OAuth20Token;
+import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder;
+import org.openstreetmap.josm.data.oauth.OAuthParameters;
 import org.openstreetmap.josm.io.auth.CredentialsManager;
 import org.openstreetmap.josm.spi.preferences.Config;
@@ -51,15 +53,18 @@
         public void beforeEach(ExtensionContext context) throws Exception {
             assumeTrue(TestUtils.areCredentialsProvided(),
-                    "OSM DEV API credentials not provided. Please define them with -Dosm.username and -Dosm.password");
-            final String username = Utils.getSystemProperty("osm.username");
-            final String password = Utils.getSystemProperty("osm.password");
-            assumeTrue(username != null && !username.isEmpty(), "Please add -Dosm.username for the OSM DEV API");
-            assumeTrue(password != null && !password.isEmpty(), "Please add -Dosm.password for the OSM DEV API");
-            Config.getPref().put("osm-server.auth-method", "basic");
+                    "OSM DEV API credentials not provided. Please define them with -Dosm.oauth2");
+            final String oauth2 = Utils.getSystemProperty("osm.oauth2");
+            Config.getPref().put("osm-server.auth-method", "oauth20");
 
             // don't use atomic upload, the test API server can't cope with large diff uploads
             Config.getPref().putBoolean("osm-server.atomic-upload", false);
-            CredentialsManager.getInstance().store(Authenticator.RequestorType.SERVER, org.openstreetmap.josm.io.OsmApi.getOsmApi().getHost(),
-                    new PasswordAuthentication(username, password.toCharArray()));
+            final String serverUrl = org.openstreetmap.josm.io.OsmApi.getOsmApi().getServerUrl();
+            final OAuth20Token token = new OAuth20Token(OAuthParameters.createDefault(),
+                    "{\"token_type\":\"bearer\", \"access_token\": \"" + oauth2 + "\"}");
+            OAuthAccessTokenHolder.getInstance().setAccessToken(serverUrl, token);
+            CredentialsManager.getInstance().storeOAuthAccessToken(serverUrl, token);
+            if (!UserIdentityManager.getInstance().isFullyIdentified()) {
+                UserIdentityManager.getInstance().initFromOAuth();
+            }
         }
     }
