Changeset 18694 in josm for trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin
- Timestamp:
- 2023-03-16T22:09:01+01:00 (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
r18690 r18694 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; 21 25 import org.awaitility.Awaitility; 22 import org.junit. After;23 import org.junit. Before;24 import org.junit. Rule;25 import org.junit. Test;26 import org.junit.jupiter.api.AfterEach; 27 import org.junit.jupiter.api.BeforeEach; 28 import org.junit.jupiter.api.Test; 29 import org.junit.jupiter.api.extension.RegisterExtension; 26 30 import org.openstreetmap.josm.TestUtils; 27 31 import org.openstreetmap.josm.data.Preferences; … … 32 36 import org.openstreetmap.josm.plugins.PluginProxy; 33 37 import org.openstreetmap.josm.spi.preferences.Config; 34 import org.openstreetmap.josm.testutils.JOSMTestRules;35 38 import org.openstreetmap.josm.testutils.PluginServer; 39 import org.openstreetmap.josm.testutils.annotations.AssertionsInEDT; 40 import org.openstreetmap.josm.testutils.annotations.AssumeRevision; 41 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 42 import org.openstreetmap.josm.testutils.annotations.Main; 36 43 import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker; 37 44 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 38 39 import com.github.tomakehurst.wiremock.client.WireMock;40 import com.github.tomakehurst.wiremock.junit.WireMockRule;41 42 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;43 import mockit.MockUp;44 45 45 46 /** 46 47 * Higher level tests of {@link PluginPreference} class. 47 48 */ 48 public class PluginPreferenceHighLevelTest { 49 /** 50 * Setup test. 51 */ 52 @Rule 53 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 54 public JOSMTestRules test = new JOSMTestRules().assumeRevision( 55 "Revision: 10000\n" 56 ).preferences().main().assertionsInEDT(); 57 49 @AssumeRevision("Revision: 10000\n") 50 @AssertionsInEDT 51 @FullPreferences 52 @Main 53 class PluginPreferenceHighLevelTest { 58 54 /** 59 55 * Plugin server mock. 60 56 */ 61 @R ule62 public WireMockRule pluginServerRule = new WireMockRule(63 options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot())64 );57 @RegisterExtension 58 static WireMockExtension pluginServerRule = WireMockExtension.newInstance() 59 .options(options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot())) 60 .build(); 65 61 66 62 /** … … 68 64 * @throws ReflectiveOperationException never 69 65 */ 70 @Before 66 @BeforeEach 71 67 public void setUp() throws ReflectiveOperationException { 72 68 … … 88 84 Config.getPref().put("pluginmanager.lastupdate", "999"); 89 85 Config.getPref().putList("pluginmanager.sites", 90 Collections.singletonList( this.pluginServerRule.url("/plugins"))86 Collections.singletonList(pluginServerRule.url("/plugins")) 91 87 ); 92 88 … … 107 103 * @throws ReflectiveOperationException never 108 104 */ 109 @After 105 @AfterEach 110 106 public void tearDown() throws ReflectiveOperationException { 111 107 // restore actual PluginHandler#pluginList … … 136 132 */ 137 133 @Test 138 public void testInstallWithoutUpdate() throws Exception {134 void testInstallWithoutUpdate(WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception { 139 135 final PluginServer pluginServer = new PluginServer( 140 136 new PluginServer.RemotePlugin(this.referenceDummyJarNew), … … 142 138 new PluginServer.RemotePlugin(null, Collections.singletonMap("Plugin-Version", "2"), "irrelevant_plugin") 143 139 ); 144 pluginServer.applyToWireMockServer( this.pluginServerRule);140 pluginServer.applyToWireMockServer(wireMockRuntimeInfo); 145 141 Config.getPref().putList("plugins", Collections.singletonList("dummy_plugin")); 146 142 … … 169 165 Awaitility.await().atMost(2000, MILLISECONDS).until(() -> Config.getPref().getInt("pluginmanager.version", 999) != 999); 170 166 171 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));172 WireMock.resetAllRequests();167 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 168 pluginServerRule.resetRequests(); 173 169 174 170 final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( … … 183 179 assertEquals(model.getDisplayedPlugins(), model.getAvailablePlugins()); 184 180 185 assertEquals( 186 Arrays.asList("baz_plugin", "dummy_plugin", "irrelevant_plugin"), 187 model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 188 ); 189 assertEquals( 190 Collections.singletonList("dummy_plugin"), 191 model.getSelectedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 192 ); 193 assertEquals( 194 Arrays.asList("(null)", "31701", "(null)"), 195 model.getAvailablePlugins().stream().map( 196 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 197 ).collect(Collectors.toList()) 198 ); 199 assertEquals( 200 Arrays.asList("6", "31772", "2"), 201 model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList()) 202 ); 181 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin", "irrelevant_plugin"), 182 model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())); 183 assertEquals(Collections.singletonList("dummy_plugin"), 184 model.getSelectedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())); 185 assertEquals(Arrays.asList("(null)", "31701", "(null)"), model.getAvailablePlugins().stream().map( 186 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 187 ).collect(Collectors.toList())); 188 assertEquals(Arrays.asList("6", "31772", "2"), 189 model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList())); 203 190 204 191 // now we're going to choose to install baz_plugin 205 192 model.setPluginSelected("baz_plugin", true); 206 193 207 assertEquals( 208 Collections.singletonList("baz_plugin"), 209 model.getNewlyActivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 210 ); 211 assertTrue(model.getNewlyDeactivatedPlugins().isEmpty()); 212 assertEquals( 213 Collections.singletonList("baz_plugin"), 214 model.getPluginsScheduledForUpdateOrDownload().stream().map(PluginInformation::getName).collect(Collectors.toList()) 215 ); 194 assertEquals(Collections.singletonList("baz_plugin"), 195 model.getNewlyActivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())); 196 assertTrue(model.getNewlyDeactivatedPlugins().isEmpty()); 197 assertEquals(Collections.singletonList("baz_plugin"), 198 model.getPluginsScheduledForUpdateOrDownload().stream().map(PluginInformation::getName).collect(Collectors.toList())); 216 199 217 200 tabbedPane.savePreferences(); … … 233 216 assertFalse(targetBazJarNew.exists()); 234 217 235 // the adverti zed version of dummy_plugin shouldn't have been fetched236 this.pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar")));218 // the advertised version of dummy_plugin shouldn't have been fetched 219 pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar"))); 237 220 // but the advertized version of baz_plugin *should* have 238 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/baz_plugin.v6.jar")));221 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/baz_plugin.v6.jar"))); 239 222 240 223 // pluginmanager.version has been set to the current version … … 246 229 247 230 // baz_plugin should have been added to the plugins list 248 assertEquals( 249 Arrays.asList("baz_plugin", "dummy_plugin"), 250 Config.getPref().getList("plugins", null).stream().sorted().collect(Collectors.toList()) 251 ); 231 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin"), 232 Config.getPref().getList("plugins", null).stream().sorted().collect(Collectors.toList())); 252 233 } 253 234 … … 257 238 */ 258 239 @Test 259 public void testDisablePluginWithUpdatesAvailable() throws Exception {240 void testDisablePluginWithUpdatesAvailable(WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception { 260 241 final PluginServer pluginServer = new PluginServer( 261 242 new PluginServer.RemotePlugin(this.referenceDummyJarNew), … … 263 244 new PluginServer.RemotePlugin(null, null, "irrelevant_plugin") 264 245 ); 265 pluginServer.applyToWireMockServer( this.pluginServerRule);246 pluginServer.applyToWireMockServer(wireMockRuntimeInfo); 266 247 Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin")); 267 248 … … 289 270 Awaitility.await().atMost(2000, MILLISECONDS).until(() -> Config.getPref().getInt("pluginmanager.version", 999) != 999); 290 271 291 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));292 WireMock.resetAllRequests();272 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 273 pluginServerRule.resetRequests(); 293 274 294 275 final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( … … 303 284 assertEquals(model.getDisplayedPlugins(), model.getAvailablePlugins()); 304 285 305 assertEquals( 306 Arrays.asList("baz_plugin", "dummy_plugin", "irrelevant_plugin"), 307 model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 308 ); 309 assertEquals( 310 Arrays.asList("baz_plugin", "dummy_plugin"), 311 model.getSelectedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 312 ); 313 assertEquals( 314 Arrays.asList("6", "31701", "(null)"), 315 model.getAvailablePlugins().stream().map( 316 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 317 ).collect(Collectors.toList()) 318 ); 319 assertEquals( 320 Arrays.asList("7", "31772", "(null)"), 321 model.getAvailablePlugins().stream().map( 322 (pi) -> pi.version == null ? "(null)" : pi.version 323 ).collect(Collectors.toList()) 324 ); 286 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin", "irrelevant_plugin"), 287 model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())); 288 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin"), 289 model.getSelectedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())); 290 assertEquals(Arrays.asList("6", "31701", "(null)"), model.getAvailablePlugins().stream().map( 291 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 292 ).collect(Collectors.toList())); 293 assertEquals(Arrays.asList("7", "31772", "(null)"), model.getAvailablePlugins().stream().map( 294 (pi) -> pi.version == null ? "(null)" : pi.version 295 ).collect(Collectors.toList())); 325 296 326 297 // now we're going to choose to disable baz_plugin … … 328 299 329 300 assertTrue(model.getNewlyActivatedPlugins().isEmpty()); 330 assertEquals( 331 Collections.singletonList("baz_plugin"), 332 model.getNewlyDeactivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 333 ); 301 assertEquals(Collections.singletonList("baz_plugin"), 302 model.getNewlyDeactivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())); 334 303 // questionably correct 335 304 assertTrue(model.getPluginsScheduledForUpdateOrDownload().isEmpty()); … … 354 323 355 324 // neither of the new jars have been fetched 356 this.pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar")));357 this.pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/baz_plugin.v6.jar")));325 pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar"))); 326 pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/baz_plugin.v6.jar"))); 358 327 359 328 // pluginmanager.version has been set to the current version … … 365 334 366 335 // baz_plugin should have been removed from the installed plugins list 367 assertEquals( 368 Collections.singletonList("dummy_plugin"), 369 Config.getPref().getList("plugins", null).stream().sorted().collect(Collectors.toList()) 370 ); 336 assertEquals(Collections.singletonList("dummy_plugin"), 337 Config.getPref().getList("plugins", null).stream().sorted().collect(Collectors.toList())); 371 338 } 372 339 … … 379 346 */ 380 347 @Test 381 public void testUpdateOnlySelectedPlugin() throws Exception {348 void testUpdateOnlySelectedPlugin(WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception { 382 349 TestUtils.assumeWorkingJMockit(); 383 350 final PluginServer pluginServer = new PluginServer( … … 385 352 new PluginServer.RemotePlugin(this.referenceBazJarNew) 386 353 ); 387 pluginServer.applyToWireMockServer( this.pluginServerRule);354 pluginServer.applyToWireMockServer(wireMockRuntimeInfo); 388 355 Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin")); 389 356 … … 406 373 TestUtils.syncEDTAndWorkerThreads(); 407 374 408 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));409 WireMock.resetAllRequests();375 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 376 pluginServerRule.resetRequests(); 410 377 411 378 final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( … … 420 387 assertEquals(model.getDisplayedPlugins(), model.getAvailablePlugins()); 421 388 422 assertEquals( 423 Arrays.asList("baz_plugin", "dummy_plugin"), 424 model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 425 ); 426 assertEquals( 427 Arrays.asList("baz_plugin", "dummy_plugin"), 428 model.getSelectedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 429 ); 430 assertEquals( 431 Arrays.asList("6", "31701"), 432 model.getAvailablePlugins().stream().map( 433 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 434 ).collect(Collectors.toList()) 435 ); 436 assertEquals( 437 Arrays.asList("7", "31772"), 438 model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList()) 439 ); 389 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin"), 390 model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())); 391 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin"), 392 model.getSelectedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())); 393 assertEquals(Arrays.asList("6", "31701"), model.getAvailablePlugins().stream().map( 394 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 395 ).collect(Collectors.toList())); 396 assertEquals(Arrays.asList("7", "31772"), model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList())); 440 397 441 398 // now we're going to choose not to update baz_plugin … … 443 400 444 401 assertTrue(model.getNewlyActivatedPlugins().isEmpty()); 445 assertEquals( 446 Collections.singletonList("baz_plugin"), 447 model.getNewlyDeactivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 448 ); 402 assertEquals(Collections.singletonList("baz_plugin"), model.getNewlyDeactivatedPlugins().stream() 403 .map(PluginInformation::getName).collect(Collectors.toList())); 449 404 // questionably correct 450 405 assertTrue(model.getPluginsScheduledForUpdateOrDownload().isEmpty()); … … 481 436 // the plugin list was rechecked 482 437 // questionably necessary 483 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));438 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 484 439 // dummy_plugin has been fetched 485 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar")));440 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar"))); 486 441 // baz_plugin has not 487 this.pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/baz_plugin.v7.jar")));488 WireMock.resetAllRequests();442 pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/baz_plugin.v7.jar"))); 443 pluginServerRule.resetRequests(); 489 444 490 445 // pluginmanager.version has been set to the current version … … 496 451 497 452 // plugins list shouldn't have been altered, we haven't hit save yet 498 assertEquals( 499 Arrays.asList("baz_plugin", "dummy_plugin"), 500 Config.getPref().getList("plugins", null).stream().sorted().collect(Collectors.toList()) 501 ); 453 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin"), 454 Config.getPref().getList("plugins", null).stream().sorted().collect(Collectors.toList())); 502 455 503 456 // the model's selection state should be largely as before 504 457 assertTrue(model.getNewlyActivatedPlugins().isEmpty()); 505 assertEquals( 506 Collections.singletonList("baz_plugin"), 507 model.getNewlyDeactivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 508 ); 458 assertEquals(Collections.singletonList("baz_plugin"), model.getNewlyDeactivatedPlugins().stream() 459 .map(PluginInformation::getName).collect(Collectors.toList())); 509 460 assertTrue(model.getPluginsScheduledForUpdateOrDownload().isEmpty()); 510 461 … … 516 467 assertTrue(model.getNewlyActivatedPlugins().isEmpty()); 517 468 assertTrue(model.getNewlyDeactivatedPlugins().isEmpty()); 518 assertEquals( 519 Collections.singletonList("baz_plugin"), 520 model.getPluginsScheduledForUpdateOrDownload().stream().map(PluginInformation::getName).collect(Collectors.toList()) 521 ); 469 assertEquals(Collections.singletonList("baz_plugin"), model.getPluginsScheduledForUpdateOrDownload().stream() 470 .map(PluginInformation::getName).collect(Collectors.toList())); 522 471 523 472 // prepare jopsMocker to handle this message … … 552 501 553 502 // dummy_plugin was not fetched 554 this.pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar")));503 pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar"))); 555 504 // baz_plugin however was fetched 556 505 // questionably correct 557 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/baz_plugin.v7.jar")));506 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/baz_plugin.v7.jar"))); 558 507 559 508 assertEquals(10000, Config.getPref().getInt("pluginmanager.version", 111)); … … 567 516 */ 568 517 @Test 569 public void testUpdateWithNoAvailableUpdates() throws Exception {518 void testUpdateWithNoAvailableUpdates(WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception { 570 519 TestUtils.assumeWorkingJMockit(); 571 520 final PluginServer pluginServer = new PluginServer( … … 574 523 new PluginServer.RemotePlugin(null, Collections.singletonMap("Plugin-Version", "123"), "irrelevant_plugin") 575 524 ); 576 pluginServer.applyToWireMockServer( this.pluginServerRule);525 pluginServer.applyToWireMockServer(wireMockRuntimeInfo); 577 526 Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin")); 578 527 … … 600 549 TestUtils.syncEDTAndWorkerThreads(); 601 550 602 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));603 WireMock.resetAllRequests();551 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 552 pluginServerRule.resetRequests(); 604 553 605 554 final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( … … 613 562 assertEquals(model.getDisplayedPlugins(), model.getAvailablePlugins()); 614 563 615 assertEquals( 616 Arrays.asList("baz_plugin", "dummy_plugin", "irrelevant_plugin"), 617 model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 618 ); 619 assertEquals( 620 Arrays.asList("baz_plugin", "dummy_plugin"), 621 model.getSelectedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 622 ); 623 assertEquals( 624 Arrays.asList("6", "31701", "(null)"), 625 model.getAvailablePlugins().stream().map( 626 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 627 ).collect(Collectors.toList()) 628 ); 629 assertEquals( 630 Arrays.asList("6", "31701", "123"), 631 model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList()) 632 ); 564 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin", "irrelevant_plugin"), model.getAvailablePlugins().stream() 565 .map(PluginInformation::getName).collect(Collectors.toList())); 566 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin"), model.getSelectedPlugins().stream() 567 .map(PluginInformation::getName).collect(Collectors.toList())); 568 assertEquals(Arrays.asList("6", "31701", "(null)"), model.getAvailablePlugins().stream().map( 569 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 570 ).collect(Collectors.toList())); 571 assertEquals(Arrays.asList("6", "31701", "123"), model.getAvailablePlugins() 572 .stream().map((pi) -> pi.version).collect(Collectors.toList())); 633 573 634 574 GuiHelper.runInEDTAndWait( … … 654 594 // the plugin list was rechecked 655 595 // questionably necessary 656 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));596 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 657 597 // that should have been the only request to our PluginServer 658 assertEquals(1, this.pluginServerRule.getAllServeEvents().size());659 WireMock.resetAllRequests();598 assertEquals(1, pluginServerRule.getAllServeEvents().size()); 599 pluginServerRule.resetRequests(); 660 600 661 601 // pluginmanager.version has been set to the current version … … 666 606 667 607 // plugins list shouldn't have been altered 668 assertEquals( 669 Arrays.asList("baz_plugin", "dummy_plugin"), 670 Config.getPref().getList("plugins", null).stream().sorted().collect(Collectors.toList()) 671 ); 608 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin"), Config.getPref().getList("plugins", null) 609 .stream().sorted().collect(Collectors.toList())); 672 610 673 611 // the model's selection state should be largely as before … … 692 630 693 631 // none of PluginServer's URLs should have been touched 694 assertEquals(0, this.pluginServerRule.getAllServeEvents().size());632 assertEquals(0, pluginServerRule.getAllServeEvents().size()); 695 633 696 634 // pluginmanager.version has been set to the current version … … 706 644 */ 707 645 @Test 708 public void testInstallWithoutRestartRequired() throws Exception {646 void testInstallWithoutRestartRequired(WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception { 709 647 TestUtils.assumeWorkingJMockit(); 710 648 final boolean[] loadPluginsCalled = new boolean[] {false}; … … 727 665 new PluginServer.RemotePlugin(this.referenceBazJarNew) 728 666 ); 729 pluginServer.applyToWireMockServer( this.pluginServerRule);667 pluginServer.applyToWireMockServer(wireMockRuntimeInfo); 730 668 Config.getPref().putList("plugins", Collections.emptyList()); 731 669 … … 749 687 TestUtils.syncEDTAndWorkerThreads(); 750 688 751 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));752 WireMock.resetAllRequests();689 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 690 pluginServerRule.resetRequests(); 753 691 754 692 final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( … … 762 700 assertEquals(model.getDisplayedPlugins(), model.getAvailablePlugins()); 763 701 764 assertEquals( 765 Arrays.asList("baz_plugin", "dummy_plugin"), 766 model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 767 ); 702 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin"), model.getAvailablePlugins().stream() 703 .map(PluginInformation::getName).collect(Collectors.toList())); 768 704 assertTrue(model.getSelectedPlugins().isEmpty()); 769 assertEquals( 770 Arrays.asList("(null)", "(null)"), 771 model.getAvailablePlugins().stream().map( 772 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 773 ).collect(Collectors.toList()) 774 ); 775 assertEquals( 776 Arrays.asList("7", "31772"), 777 model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList()) 778 ); 705 assertEquals(Arrays.asList("(null)", "(null)"), model.getAvailablePlugins().stream().map( 706 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 707 ).collect(Collectors.toList())); 708 assertEquals(Arrays.asList("7", "31772"), model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList())); 779 709 780 710 // now we select dummy_plugin … … 782 712 783 713 // model should now reflect this 784 assertEquals( 785 Collections.singletonList("dummy_plugin"), 786 model.getNewlyActivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 787 ); 714 assertEquals(Collections.singletonList("dummy_plugin"), model.getNewlyActivatedPlugins().stream() 715 .map(PluginInformation::getName).collect(Collectors.toList())); 788 716 assertTrue(model.getNewlyDeactivatedPlugins().isEmpty()); 789 717 … … 804 732 805 733 // dummy_plugin was fetched 806 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar")));734 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar"))); 807 735 808 736 // the dummy_plugin jar has been installed … … 826 754 * @throws Exception on failure 827 755 */ 828 @ JOSMTestRules.OverrideAssumeRevision("Revision: 7000\n")756 @AssumeRevision("Revision: 7000\n") 829 757 @Test 830 public void testInstallMultiVersion() throws Exception {758 void testInstallMultiVersion(WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception { 831 759 TestUtils.assumeWorkingJMockit(); 832 760 … … 835 763 new PluginServer.RemotePlugin(this.referenceDummyJarNew), 836 764 new PluginServer.RemotePlugin(this.referenceBazJarNew, Collections.singletonMap( 837 "6800_Plugin-Url", "6;" + this.pluginServerRule.url(bazOldServePath)765 "6800_Plugin-Url", "6;" + pluginServerRule.url(bazOldServePath) 838 766 )) 839 767 ); 840 pluginServer.applyToWireMockServer( this.pluginServerRule);768 pluginServer.applyToWireMockServer(wireMockRuntimeInfo); 841 769 // need to actually serve this older jar from somewhere 842 this.pluginServerRule.stubFor(770 pluginServerRule.stubFor( 843 771 WireMock.get(WireMock.urlEqualTo(bazOldServePath)).willReturn( 844 772 WireMock.aResponse().withStatus(200).withHeader("Content-Type", "application/java-archive").withBodyFile( … … 870 798 TestUtils.syncEDTAndWorkerThreads(); 871 799 872 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));873 WireMock.resetAllRequests();800 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 801 pluginServerRule.resetRequests(); 874 802 875 803 final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( … … 883 811 assertEquals(model.getDisplayedPlugins(), model.getAvailablePlugins()); 884 812 885 assertEquals( 886 Arrays.asList("baz_plugin", "dummy_plugin"), 887 model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 888 ); 813 assertEquals(Arrays.asList("baz_plugin", "dummy_plugin"), model.getAvailablePlugins().stream() 814 .map(PluginInformation::getName).collect(Collectors.toList())); 889 815 assertTrue(model.getSelectedPlugins().isEmpty()); 890 assertEquals( 891 Arrays.asList("(null)", "(null)"), 892 model.getAvailablePlugins().stream().map( 893 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 894 ).collect(Collectors.toList()) 895 ); 896 assertEquals( 897 Arrays.asList("6", "31772"), 898 model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList()) 899 ); 816 assertEquals(Arrays.asList("(null)", "(null)"), model.getAvailablePlugins().stream().map( 817 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 818 ).collect(Collectors.toList())); 819 assertEquals(Arrays.asList("6", "31772"), model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList())); 900 820 901 821 // now we select dummy_plugin … … 903 823 904 824 // model should now reflect this 905 assertEquals( 906 Collections.singletonList("baz_plugin"), 907 model.getNewlyActivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList()) 908 ); 825 assertEquals(Collections.singletonList("baz_plugin"), model.getNewlyActivatedPlugins().stream() 826 .map(PluginInformation::getName).collect(Collectors.toList())); 909 827 assertTrue(model.getNewlyDeactivatedPlugins().isEmpty()); 910 828 … … 925 843 926 844 // dummy_plugin was fetched 927 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo(bazOldServePath)));845 pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo(bazOldServePath))); 928 846 929 847 // the "old" baz_plugin jar has been installed
Note:
See TracChangeset
for help on using the changeset viewer.