Changeset 19050 in josm for trunk/test/unit
- Timestamp:
- 2024-04-22T20:59:26+02:00 (8 months ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/UploadActionTest.java
r18870 r19050 85 85 } 86 86 87 private static class UploadDialogMock extends MockUp<UploadDialog> {87 private static final class UploadDialogMock extends MockUp<UploadDialog> { 88 88 @Mock 89 89 public void pack(final Invocation invocation) { … … 101 101 102 102 @Mock 103 public finalboolean isCanceled(final Invocation invocation) {103 public boolean isCanceled(final Invocation invocation) { 104 104 if (!GraphicsEnvironment.isHeadless()) { 105 105 return Boolean.TRUE.equals(invocation.proceed()); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyActionTest.java
r18965 r19050 51 51 private static final int HEIGHT = 600; 52 52 53 private static class AlwaysDeleteCallback implements DeleteCommand.DeletionCallback {53 private static final class AlwaysDeleteCallback implements DeleteCommand.DeletionCallback { 54 54 @Override 55 55 public boolean checkAndConfirmOutlyingDelete(Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> ignore) { -
trunk/test/unit/org/openstreetmap/josm/actions/upload/UploadNotesTaskTest.java
r18870 r19050 157 157 } 158 158 159 private static class FakeOsmApiMocker extends MockUp<FakeOsmApi> {159 private static final class FakeOsmApiMocker extends MockUp<FakeOsmApi> { 160 160 Collection<Note> closed = new ArrayList<>(); 161 161 Collection<Note> commented = new ArrayList<>(); -
trunk/test/unit/org/openstreetmap/josm/command/CommandTest.java
r18037 r19050 4 4 import java.util.Arrays; 5 5 6 import org.junit.jupiter.api.Test; 6 7 import org.openstreetmap.josm.TestUtils; 7 8 import org.openstreetmap.josm.data.coor.LatLon; … … 19 20 import nl.jqno.equalsverifier.EqualsVerifier; 20 21 import nl.jqno.equalsverifier.Warning; 21 import org.junit.jupiter.api.Test;22 22 23 23 /** … … 100 100 * @return The way. 101 101 */ 102 public Way createWay(int id, Node... nodes) {102 public Way createWay(int id, Node... nodes) { 103 103 Way way = new Way(); 104 104 way.setOsmId(id, 1); … … 115 115 * @return The relation. 116 116 */ 117 public Relation createRelation(int id, RelationMember... members) {117 public Relation createRelation(int id, RelationMember... members) { 118 118 Relation relation = new Relation(id, 1); 119 119 for (RelationMember member : members) { -
trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java
r18106 r19050 85 85 } 86 86 87 private static class Listener implements ICachedLoaderListener {87 private static final class Listener implements ICachedLoaderListener { 88 88 private CacheEntryAttributes attributes; 89 89 private boolean ready; … … 513 513 */ 514 514 @Test 515 publicvoid testCheckUsing304() throws IOException {515 void testCheckUsing304() throws IOException { 516 516 ICacheAccess<String, CacheEntry> cache = getCache(); 517 517 long expires = TimeUnit.DAYS.toMillis(1); -
trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java
r18870 r19050 457 457 } 458 458 459 private static class TestChangeListener implements GpxDataChangeListener {459 private static final class TestChangeListener implements GpxDataChangeListener { 460 460 461 461 private GpxDataChangeEvent lastEvent; -
trunk/test/unit/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJobTest.java
r18106 r19050 99 99 } 100 100 101 private static class Listener implements TileLoaderListener {101 private static final class Listener implements TileLoaderListener { 102 102 private CacheEntryAttributes attributes; 103 103 private boolean ready; -
trunk/test/unit/org/openstreetmap/josm/data/imagery/vectortile/mapbox/MapboxVectorTileSourceTest.java
r18766 r19050 27 27 */ 28 28 class MapboxVectorTileSourceTest implements TileSourceTest { 29 private static class SelectLayerDialogMocker extends ExtendedDialogMocker {29 private static final class SelectLayerDialogMocker extends ExtendedDialogMocker { 30 30 int index; 31 31 @Override -
trunk/test/unit/org/openstreetmap/josm/data/oauth/OAuth20AuthorizationTest.java
r18991 r19050 17 17 import java.util.stream.Stream; 18 18 19 import com.github.tomakehurst.wiremock.client.WireMock;20 import com.github.tomakehurst.wiremock.common.FileSource;21 import com.github.tomakehurst.wiremock.core.WireMockConfiguration;22 import com.github.tomakehurst.wiremock.extension.Parameters;23 import com.github.tomakehurst.wiremock.extension.ResponseTransformer;24 import com.github.tomakehurst.wiremock.http.FixedDelayDistribution;25 import com.github.tomakehurst.wiremock.http.HttpHeader;26 import com.github.tomakehurst.wiremock.http.HttpHeaders;27 import com.github.tomakehurst.wiremock.http.QueryParameter;28 import com.github.tomakehurst.wiremock.http.Request;29 import com.github.tomakehurst.wiremock.http.Response;30 import com.github.tomakehurst.wiremock.junit5.WireMockExtension;31 import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;32 import com.github.tomakehurst.wiremock.matching.AnythingPattern;33 import com.github.tomakehurst.wiremock.matching.EqualToPattern;34 import com.github.tomakehurst.wiremock.matching.StringValuePattern;35 import mockit.Mock;36 import mockit.MockUp;37 19 import org.junit.jupiter.api.AfterEach; 38 20 import org.junit.jupiter.api.BeforeEach; … … 50 32 import org.openstreetmap.josm.tools.Logging; 51 33 34 import com.github.tomakehurst.wiremock.client.WireMock; 35 import com.github.tomakehurst.wiremock.core.WireMockConfiguration; 36 import com.github.tomakehurst.wiremock.extension.ResponseTransformerV2; 37 import com.github.tomakehurst.wiremock.http.FixedDelayDistribution; 38 import com.github.tomakehurst.wiremock.http.HttpHeader; 39 import com.github.tomakehurst.wiremock.http.HttpHeaders; 40 import com.github.tomakehurst.wiremock.http.QueryParameter; 41 import com.github.tomakehurst.wiremock.http.Request; 42 import com.github.tomakehurst.wiremock.http.Response; 43 import com.github.tomakehurst.wiremock.junit5.WireMockExtension; 44 import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; 45 import com.github.tomakehurst.wiremock.matching.AnythingPattern; 46 import com.github.tomakehurst.wiremock.matching.EqualToPattern; 47 import com.github.tomakehurst.wiremock.matching.StringValuePattern; 48 import com.github.tomakehurst.wiremock.stubbing.ServeEvent; 49 import mockit.Mock; 50 import mockit.MockUp; 51 52 52 @BasicPreferences 53 53 @HTTP … … 70 70 } 71 71 72 private static class OAuthServerWireMock extends ResponseTransformer{72 private static final class OAuthServerWireMock implements ResponseTransformerV2 { 73 73 String stateToReturn; 74 74 ConnectionProblems connectionProblems = ConnectionProblems.NONE; 75 75 76 @Override 76 public Response transform(Request request, Response response, FileSource files, Parameters parameters) { 77 public Response transform(Response response, ServeEvent serveEvent) { 78 final var request = serveEvent.getRequest(); 77 79 try { 78 80 if (request.getUrl().startsWith("/oauth2/authorize")) { … … 158 160 /** 159 161 * Set up the default wiremock information 160 * @param wireMockRuntimeInfo The info to set up161 162 */ 162 163 @BeforeEach 163 void setupWireMock(WireMockRuntimeInfo wireMockRuntimeInfo) { 164 void setupWireMock() { 165 final WireMockRuntimeInfo wireMockRuntimeInfo = wml.getRuntimeInfo(); 164 166 Config.getPref().put("osm-server.url", wireMockRuntimeInfo.getHttpBaseUrl() + "/api/"); 165 167 new MockUp<JosmUrls>() { … … 195 197 196 198 @Test 197 void testAuthorize( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {199 void testAuthorize() throws IOException { 198 200 final AtomicReference<Optional<IOAuthToken>> consumer = new AtomicReference<>(); 199 final HttpClient client = generateClient(w ireMockRuntimeInfo, consumer);201 final HttpClient client = generateClient(wml.getRuntimeInfo(), consumer); 200 202 try { 201 203 HttpClient.Response response = client.connect(); … … 212 214 213 215 @Test 214 void testAuthorizeBadState( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {216 void testAuthorizeBadState() throws IOException { 215 217 oauthServer.stateToReturn = "Bad_State"; 216 218 final AtomicReference<Optional<IOAuthToken>> consumer = new AtomicReference<>(); 217 final HttpClient client = generateClient(w ireMockRuntimeInfo, consumer);219 final HttpClient client = generateClient(wml.getRuntimeInfo(), consumer); 218 220 try { 219 221 HttpClient.Response response = client.connect(); … … 228 230 229 231 @Test 230 void testSocketTimeout( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {232 void testSocketTimeout() throws Exception { 231 233 // 1s before timeout 232 234 Config.getPref().putInt("socket.timeout.connect", 1); … … 235 237 236 238 final AtomicReference<Optional<IOAuthToken>> consumer = new AtomicReference<>(); 237 final HttpClient client = generateClient(w ireMockRuntimeInfo, consumer)239 final HttpClient client = generateClient(wml.getRuntimeInfo(), consumer) 238 240 .setConnectTimeout(15_000).setReadTimeout(30_000); 239 241 try { -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r18870 r19050 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.projection; 3 4 import static org.junit.jupiter.api.Assertions.fail; 3 5 4 6 import java.io.BufferedReader; … … 45 47 private static final String PROJECTION_DATA_FILE = "nodist/data/projection/projection-regression-test-data"; 46 48 47 private static class TestData {49 private static final class TestData { 48 50 public String code; 49 51 public LatLon ll; … … 185 187 if (fail.length() > 0) { 186 188 System.err.println(fail); 187 throw new AssertionError(fail.toString());189 fail(fail.toString()); 188 190 } 189 191 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java
r18866 r19050 324 324 } 325 325 326 private static class PasteMembersActionMock extends MockUp<PasteMembersAction> {326 private static final class PasteMembersActionMock extends MockUp<PasteMembersAction> { 327 327 @Mock 328 p rotectedvoid updateEnabledState() {328 public void updateEnabledState() { 329 329 // Do nothing 330 330 } -
trunk/test/unit/org/openstreetmap/josm/gui/io/SaveLayersDialogTest.java
r19011 r19050 162 162 } 163 163 164 private static class GraphicsEnvironmentMock extends MockUp<GraphicsEnvironment> {164 private static final class GraphicsEnvironmentMock extends MockUp<GraphicsEnvironment> { 165 165 @Mock 166 166 public static boolean isHeadless(Invocation invocation) { … … 169 169 } 170 170 171 private static class SaveLayersDialogMock extends MockUp<SaveLayersDialog> {171 private static final class SaveLayersDialogMock extends MockUp<SaveLayersDialog> { 172 172 private final SaveLayersModel model = new SaveLayersModel(); 173 173 private int getUserActionCalled = 0; -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
r18694 r19050 19 19 import javax.swing.JOptionPane; 20 20 21 import com.github.tomakehurst.wiremock.client.WireMock;22 import com.github.tomakehurst.wiremock.junit5.WireMockExtension;23 import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;24 import mockit.MockUp;25 21 import org.awaitility.Awaitility; 26 22 import org.junit.jupiter.api.AfterEach; … … 44 40 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 45 41 42 import com.github.tomakehurst.wiremock.client.WireMock; 43 import com.github.tomakehurst.wiremock.junit5.WireMockExtension; 44 import mockit.MockUp; 45 46 46 /** 47 47 * Higher level tests of {@link PluginPreference} class. … … 132 132 */ 133 133 @Test 134 void testInstallWithoutUpdate( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {134 void testInstallWithoutUpdate() throws Exception { 135 135 final PluginServer pluginServer = new PluginServer( 136 136 new PluginServer.RemotePlugin(this.referenceDummyJarNew), … … 138 138 new PluginServer.RemotePlugin(null, Collections.singletonMap("Plugin-Version", "2"), "irrelevant_plugin") 139 139 ); 140 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);140 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 141 141 Config.getPref().putList("plugins", Collections.singletonList("dummy_plugin")); 142 142 … … 238 238 */ 239 239 @Test 240 void testDisablePluginWithUpdatesAvailable( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {240 void testDisablePluginWithUpdatesAvailable() throws Exception { 241 241 final PluginServer pluginServer = new PluginServer( 242 242 new PluginServer.RemotePlugin(this.referenceDummyJarNew), … … 244 244 new PluginServer.RemotePlugin(null, null, "irrelevant_plugin") 245 245 ); 246 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);246 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 247 247 Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin")); 248 248 … … 346 346 */ 347 347 @Test 348 void testUpdateOnlySelectedPlugin( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {348 void testUpdateOnlySelectedPlugin() throws Exception { 349 349 TestUtils.assumeWorkingJMockit(); 350 350 final PluginServer pluginServer = new PluginServer( … … 352 352 new PluginServer.RemotePlugin(this.referenceBazJarNew) 353 353 ); 354 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);354 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 355 355 Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin")); 356 356 … … 516 516 */ 517 517 @Test 518 void testUpdateWithNoAvailableUpdates( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {518 void testUpdateWithNoAvailableUpdates() throws Exception { 519 519 TestUtils.assumeWorkingJMockit(); 520 520 final PluginServer pluginServer = new PluginServer( … … 523 523 new PluginServer.RemotePlugin(null, Collections.singletonMap("Plugin-Version", "123"), "irrelevant_plugin") 524 524 ); 525 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);525 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 526 526 Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin")); 527 527 … … 644 644 */ 645 645 @Test 646 void testInstallWithoutRestartRequired( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {646 void testInstallWithoutRestartRequired() throws Exception { 647 647 TestUtils.assumeWorkingJMockit(); 648 648 final boolean[] loadPluginsCalled = new boolean[] {false}; … … 665 665 new PluginServer.RemotePlugin(this.referenceBazJarNew) 666 666 ); 667 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);667 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 668 668 Config.getPref().putList("plugins", Collections.emptyList()); 669 669 … … 756 756 @AssumeRevision("Revision: 7000\n") 757 757 @Test 758 void testInstallMultiVersion( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {758 void testInstallMultiVersion() throws Exception { 759 759 TestUtils.assumeWorkingJMockit(); 760 760 … … 766 766 )) 767 767 ); 768 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);768 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 769 769 // need to actually serve this older jar from somewhere 770 770 pluginServerRule.stubFor( -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AuthorizationHandlerTest.java
r18650 r19050 20 20 */ 21 21 class AuthorizationHandlerTest { 22 private static class TestAuthorizationConsumer implements AuthorizationHandler.AuthorizationConsumer {22 private static final class TestAuthorizationConsumer implements AuthorizationHandler.AuthorizationConsumer { 23 23 boolean validated; 24 24 boolean handled; -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java
r18870 r19050 34 34 import com.github.tomakehurst.wiremock.client.WireMock; 35 35 import com.github.tomakehurst.wiremock.junit5.WireMockExtension; 36 import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;37 36 38 37 /** … … 110 109 */ 111 110 @Test 112 void testUpdatePluginsDownloadBoth( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {111 void testUpdatePluginsDownloadBoth() throws IOException { 113 112 TestUtils.assumeWorkingJMockit(); 114 113 final PluginServer pluginServer = new PluginServer( … … 116 115 new PluginServer.RemotePlugin(this.referenceBazJarNew) 117 116 ); 118 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);117 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 119 118 Config.getPref().putList("plugins", Arrays.asList("dummy_plugin", "baz_plugin")); 120 119 … … 172 171 */ 173 172 @Test 174 void testUpdatePluginsSkipOne( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {173 void testUpdatePluginsSkipOne() throws IOException { 175 174 TestUtils.assumeWorkingJMockit(); 176 175 final PluginServer pluginServer = new PluginServer( … … 178 177 new PluginServer.RemotePlugin(this.referenceBazJarNew) 179 178 ); 180 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);179 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 181 180 Config.getPref().putList("plugins", Arrays.asList("dummy_plugin", "baz_plugin")); 182 181 … … 244 243 */ 245 244 @Test 246 void testUpdatePluginsUnexpectedlyJOSMTooOld( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {245 void testUpdatePluginsUnexpectedlyJOSMTooOld() throws IOException { 247 246 TestUtils.assumeWorkingJMockit(); 248 247 final PluginServer pluginServer = new PluginServer( … … 250 249 new PluginServer.RemotePlugin(this.referenceBazJarNew, Collections.singletonMap("Plugin-Mainversion", "5500")) 251 250 ); 252 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);251 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 253 252 Config.getPref().putList("plugins", Collections.singletonList("baz_plugin")); 254 253 … … 299 298 @Test 300 299 @AssumeRevision("Revision: 7200\n") 301 void testUpdatePluginsMultiVersionInsufficient( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {300 void testUpdatePluginsMultiVersionInsufficient() throws IOException { 302 301 TestUtils.assumeWorkingJMockit(); 303 302 … … 308 307 )) 309 308 ); 310 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);309 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 311 310 Config.getPref().putList("plugins", Arrays.asList("qux_plugin", "baz_plugin")); 312 311 -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java
r18870 r19050 91 91 @AssumeRevision("Revision: 7501\n") 92 92 @Test 93 void testUpdatePluginsOneMultiVersion( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {93 void testUpdatePluginsOneMultiVersion() throws Exception { 94 94 TestUtils.assumeWorkingJMockit(); 95 95 96 96 final String quxNewerServePath = "/qux/newer.jar"; 97 final Map<String, String> attrOverrides = new HashMap< String, String>() {{97 final Map<String, String> attrOverrides = new HashMap<>() {{ 98 98 put("7500_Plugin-Url", "432;" + pluginServerRule.url(quxNewerServePath)); 99 99 put("7499_Plugin-Url", "346;" + pluginServerRule.url("/not/served.jar")); … … 104 104 new PluginServer.RemotePlugin(this.referenceQuxJarNewest, attrOverrides) 105 105 ); 106 final WireMockRuntimeInfo wireMockRuntimeInfo = pluginServerRule.getRuntimeInfo(); 106 107 pluginServer.applyToWireMockServer(wireMockRuntimeInfo); 107 108 // need to actually serve this older jar from somewhere … … 158 159 @AssumeRevision("Revision: 7000\n") 159 160 @Test 160 void testUpdatePluginsExistingVersionLatestPossible( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {161 void testUpdatePluginsExistingVersionLatestPossible() throws Exception { 161 162 TestUtils.assumeWorkingJMockit(); 162 163 163 final Map<String, String> attrOverrides = new HashMap< String, String>() {{164 final Map<String, String> attrOverrides = new HashMap<>() {{ 164 165 put("7500_Plugin-Url", "432;" + pluginServerRule.url("/dont.jar")); 165 166 put("7499_Plugin-Url", "346;" + pluginServerRule.url("/even.jar")); … … 170 171 new PluginServer.RemotePlugin(this.referenceQuxJarNewest, attrOverrides) 171 172 ); 172 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);173 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 173 174 Config.getPref().putList("plugins", Arrays.asList("qux_plugin", "baz_plugin")); 174 175 -
trunk/test/unit/org/openstreetmap/josm/spi/lifecycle/LifecycleTest.java
r18893 r19050 19 19 @Projection 20 20 class LifecycleTest { 21 private static class InitStatusListenerStub implements InitStatusListener {21 private static final class InitStatusListenerStub implements InitStatusListener { 22 22 23 23 boolean updated; -
trunk/test/unit/org/openstreetmap/josm/tools/LanguageInfoTest.java
r18870 r19050 46 46 } 47 47 48 private static void testGetWikiLanguagePrefixes(LanguageInfo.LocaleType type, String... expected) {48 private static void testGetWikiLanguagePrefixes(LanguageInfo.LocaleType type, String... expected) { 49 49 final List<String> actual = Stream.of(EN_NZ, DE_DE, PT_BR, CA_ES_VALENCIA, ZN_CN, ZN_TW, AST, EN_GB, RU, NB) 50 50 .map(locale -> LanguageInfo.getWikiLanguagePrefix(locale, type))
Note:
See TracChangeset
for help on using the changeset viewer.