Ticket #16700: v1-0002-tests-add-new-tests-exercising-handling-of-plugin.patch
File v1-0002-tests-add-new-tests-exercising-handling-of-plugin.patch, 35.5 KB (added by , 7 years ago) |
---|
-
new file 2001
From 6269764196d35f2737cf62b7cb1c9007400dfc16 Mon Sep 17 00:00:00 2001 From: Robert Scott <code@humanleg.org.uk> Date: Wed, 29 Aug 2018 20:10:21 +0100 Subject: [PATCH v1 2/2] tests: add new tests exercising handling of plugins that advertise multiple versions for compatibility --- test/data/__files/plugin/qux_plugin.v345.jar | Bin 0 -> 3919 bytes test/data/__files/plugin/qux_plugin.v346.jar | Bin 0 -> 3918 bytes test/data/__files/plugin/qux_plugin.v432.jar | Bin 0 -> 3918 bytes test/data/__files/plugin/qux_plugin.v435.jar | Bin 0 -> 3919 bytes .../plugin/PluginPreferenceHighLevelTest.java | 126 +++++++++++- .../josm/plugins/PluginHandlerJOSMTooOldTest.java | 76 ++++++++ .../plugins/PluginHandlerMultiVersionTest.java | 215 +++++++++++++++++++++ 7 files changed, 416 insertions(+), 1 deletion(-) create mode 100644 test/data/__files/plugin/qux_plugin.v345.jar create mode 100644 test/data/__files/plugin/qux_plugin.v346.jar create mode 100644 test/data/__files/plugin/qux_plugin.v432.jar create mode 100644 test/data/__files/plugin/qux_plugin.v435.jar create mode 100644 test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java diff --git a/test/data/__files/plugin/qux_plugin.v345.jar b/test/data/__files/plugin/qux_plugin.v345.jar new file mode 100644 index 0000000000000000000000000000000000000000..4d8b0710cfd10535c74bd0cca9e94d2c642fea47 GIT binary patch literal 3919 zcmeH}c|4T+9>*U`ne1VZC1s+zvP⋙TRF4i7ERq7-L*!n6ZqwugcO%93k78ELSFk zknK`R$r2%Lvg_a!SrZY;ea1GEGwS?%U$67b>-RjbXI|gW=lA<Pzwht&eIrddIJp4; z0s!-Nk_dq5+5vC^2slb#(Zt+H`D+sZAlE`6z#JHQaX11EWdnd>u!(@OjZlQXxrq_n z5~YMNa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X<DH^}zl}5bZNQgks^C3;y*hM(DCTRMZ2mpe> zxIX>40m-X8y)I=<)N}#;qFqn`?;BDkzGm*66-=(kS2`zwnYn?M>)rmDK<RMF5G650 z>!`_)vVu*9v}Ut(9X%Natl*Pj@DVgvMbWJlbQonQpddc|dDAg}qRl<hVU3}Ov(&Gl zDq|3=V3lEVc59RMozFZXR`AL&`|pp<R#A5A(a~X+VL1O|!&S6hH)IXB>z1?&+TdZg zhPsStt%^36e1^ym6m8A8%s#Bpf#G8f0xt`nHIQKTVRb$;d~|lON}L~^)=1NBbl?UA Oz~5(ZMtVH-xBmf_r$P1r
-
new file 0
literal 0 HcmV?d00001 diff --git a/test/data/__files/plugin/qux_plugin.v346.jar b/test/data/__files/plugin/qux_plugin.v346.jar new file mode 100644 index 0000000000000000000000000000000000000000..7b0a7ab71e0def48c20c64f806991a8dde9edfd9 GIT binary patch literal 3918 zcmWIWW@h1HVBlb2SP?Dl%YXzp8CV#6T|*poJ^kGD|D9rB2!JZ(U|0@R+P|E4rwAhh z!zLgW0cwLQ^>y^~baM?3(erhSop8|qu!6+V_rAaE3$8E+OvusR9;vUUw<}|hRM7sd z8QeT8R{q~x5}Z_~wCDX_x%bJ-d+Z!Keu&mwxaM)hBUCK<v;R%2tKS+XO=~laoa*}6 z(Y50E_WRxS&a2F~J)2=z^7TciHAB{#@@uPS{CK^oLTZ_x^q$~bHGf;zxyC;Ctb66Q zX44HGEtbwT?>kBpoW3v=hV<3kFc2y?VlA4JwrTz|<H<LzIo4j+oA+B<y86QlgPCQ4 zY#fXS*SJlewTs)}t*YSq8*JgyXRhn_c*c3FdF&N>8NcjC^n4|M^;_xh9B2D?{*s8D zFy&vHF!RJ!lSSoU21zg9HFIbF^s=fDS(a6oRRi?W^j>V5Y#eK5cRXdH$A?WC-SV(d zWMBwlpYM$n-VE$OPG)XmdTOygZbiHZMVZO@dB{qg+N4k-P#9gQkx7M-36k0VXbxZj zYRE52$D=|Bsv^H2HLtj&C^fYtH?aVZdU34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/__files/plugin/qux_plugin.v432.jar b/test/data/__files/plugin/qux_plugin.v432.jar new file mode 100644 index 0000000000000000000000000000000000000000..377a1c5190ba81139b8a8116dcd00fe487df0cf4 GIT binary patch literal 3918 zcmWIWW@h1HVBlb2@QRl9Wk3R)3@i-3t|5-Po_=on|4uP51VEK?Fn9u$uAk)aOoWkv zVG|IG0JXuD`a1e~y1532==r+E1~~d1HW1k3eoDTkrTOiRDP}*yPO)}!X$7o5!FBt{ zgd6LwJ3jnwp&QXL`RUD>H)r0>%I0gB_)c*_VVK~-RhuGi+n>1gdKvSi4JLaMPj9-x zazXIki?`R$tdIPv6*h^>QBSTpuS!8$d=Iyk+TYYjo3F{)I(M^@?dyHRuZK=mue|!m zE3M#iwu@^_#>~$NhHMQM8RzfG@|~IQaiZ_>k+R1n*HYffCJ6WRKmT*>C?At$&$gKp z<pel=sy=A0{IBk_S7hSU6`7&IJF5hpPA(NPoopl;-@ma~F>+qqrqjFFlkG)bCVg39 z@!v3AOzFD1mhC4?GvC6^&-Tr{JkxP|!<{AkMLTCaX*xf5Pp<JtOEoVmzg@nOHO#P3 zWMBwlpYM$n-VE$OPG)XmdTOygZbiHZMVZO@dB{qg+N4k-P#9gQkx7M-36k0VXbxZj zYRE52$D=|Bsv^H2HLtj&C^fYtH?aVZdU34kv+|2`ku*7=xmzB$rh=T(^h^{_&uKyR zv@&7MNr_c>Y$w8i!qN)30UY3Hbp4k<3*=W221TQfr?abHuxs(>@8JbSJV6{BrJp{Q zgfS$A?@tKVL&`{?ByjC=?55RB3=GSFSPG~Yngk%R3yCtIi}ecf(ixXAMgHv!@N?(o zk^<&g23}7OmmnZ50m2+?K=MJk?GGTuQtadz!T|&|94Q?@K4*bPWHAE+-w_aIoT|+y z4HT3tag8Vm&QB{TPb^AhC@(M9%goCzPEIUH)dMDi+3#$Cj$u;vba4#v=v;a&Hlr_5 zg8jq&oMW?kYqoGyzjerT{ZzO~HC{7tnn$39D*LHUW=jX%^ivo4WIS8S6k4VzZOv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(XPa8qzW(kp<MEoiKFhND)vp>|oPTA)hX3a)A3Jsb z<y>MPI_dht#L0;-1+Oh*GCZ=PU)aN9gKOEEvaRBo&x$^s4X#v+=D5J|VMnXnG>-1@ zp3N7NJ>KX1{u$QrR4i<R*Nq*0NA7$HIVF@<>#a0VO{}^5&dMnPTU(V&7JqV$E}W40 zn9WBySpUChqLaa=xI-;>zrNu2I{t75>rtV+56i!<X8OeS;buyH`(Lixzb>cWcbI?r z`-JlwdfIw+os^D{NMG0*t?DgnoMFuF-*8)a-Ss)aski?$c`g4Xx^@4{TQOzZmb~s2 z)_*zcMM7WZpWJ!*`%dO{#{J+8@MdHZVaDBn29=2n3<3;q9YHj_jSOi{!?a>=P=hpp zz>-F7APLus)VxNv99v@&tQ~B5Auwgao0c$ZF<YRZ#w9}2G=wHtQxl;TTVoTU^&q-d zSkn_>0Jg>_!hlae10YRN+&VywQG^Z=VDkwx(;){Dx{aX58bZGdR{hYXD#8)i8mkCH zDsdYE%lXJI!q#|27`BbDVUVUQZr6btvj_vf6E+aiw1pXny>SaOa!I2Fu&{$RbrIfz zXhN^@5t>SXnsB#qk<G!@bU>IB4s7sZF$da^KsE<k`HV2fiW6JHAyiric(Z~U+zk9c M_!H<Odu|X901=Tgx&QzG
-
new file 0
literal 0 HcmV?d00001 diff --git a/test/data/__files/plugin/qux_plugin.v435.jar b/test/data/__files/plugin/qux_plugin.v435.jar new file mode 100644 index 0000000000000000000000000000000000000000..a4218e18223ccb50206920bf094130617d82eb30 GIT binary patch literal 3919 zcmWIWW@h1HVBlb2V6K(+Wk3R)3@i-3t|5-Po_=on|4uP51VEK?Ffaj?`sseI5oKgx z*aXBPKy7fPzK(vLZmz*0dcJP46Ab+i8wj+1_xQ;#m$*T;eF{tdQXP+wfW}=)+A+e; zNxSXXTkHETH?_{t*<bzs-R|33i}@QG-yK}M%}wZFmre9+`%|}8ZethP8nGwwdgZo{ z3z+s?yuJSD{SA*ouc(SP#n@C`<#RB*X8k&}<L7CcYN=&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BA{ zG=RX8Mr|Mo*NW7>Mz$PVV-l<#Y<UqdWx|`5Fl#YeprFPjLeq4FCRkGwp%q(W6QT7G zx>i`z6JY?h#wWsn&p-npO;OxBK#fs^4pCt92{Y3n2NAlBpvD?PzbjV#(55QF5!f25 z2t%rH8v@Ju$S%Uxctsetov>k$rYvsPff}<21Ah=U5Yn`T8Hl}c3o~*_qb0DggEn;$ z-hyaCuksO^N`abiw{elp!Pay@m=ghP@M19s+K@mt2V41!Fvpq`Tf!k!S_gQuf*RZm O{6P2<=pzSi5Dx$(mo^sw
-
test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
literal 0 HcmV?d00001 diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java index de22b0332..e78ddf742 100644
a b public class PluginPreferenceHighLevelTest { 803 803 TestUtils.syncEDTAndWorkerThreads(); 804 804 805 805 assertEquals(1, jopsMocker.getInvocationLog().size()); 806 org.openstreetmap.josm.tools.Logging.error(jopsMocker.getInvocationLog().get(0)[0].toString());807 806 Object[] invocationLogEntry = jopsMocker.getInvocationLog().get(0); 808 807 assertEquals(JOptionPane.OK_OPTION, (int) invocationLogEntry[0]); 809 808 assertEquals("Warning", invocationLogEntry[2]); … … public class PluginPreferenceHighLevelTest { 817 816 // dummy_plugin was fetched 818 817 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar"))); 819 818 819 // the dummy_plugin jar has been installed 820 TestUtils.assertFileContentsEqual(this.referenceDummyJarNew, this.targetDummyJar); 821 // the baz_plugin jar has not 822 assertFalse(this.targetBazJar.exists()); 823 820 824 // loadPlugins(...) was called (with expected parameters) 821 825 assertTrue(loadPluginsCalled[0]); 822 826 … … public class PluginPreferenceHighLevelTest { 826 830 // questionably correct 827 831 assertEquals("999", Config.getPref().get("pluginmanager.lastupdate", "111")); 828 832 } 833 834 /** 835 * Tests installing a single plugin which has multiple versions advertised, with our JOSM version 836 * preventing us from using the latest version 837 * @throws Exception on failure 838 */ 839 @JOSMTestRules.OverrideAssumeRevision("Revision: 7000\n") 840 @Test 841 public void testInstallMultiVersion() throws Exception { 842 TestUtils.assumeWorkingJMockit(); 843 844 final String bazOldServePath = "/baz/old.jar"; 845 final PluginServer pluginServer = new PluginServer( 846 new PluginServer.RemotePlugin(this.referenceDummyJarNew), 847 new PluginServer.RemotePlugin(this.referenceBazJarNew, ImmutableMap.of( 848 "6800_Plugin-Url", "6;http://localhost:" + this.pluginServerRule.port() + bazOldServePath 849 )) 850 ); 851 pluginServer.applyToWireMockServer(this.pluginServerRule); 852 // need to actually serve this older jar from somewhere 853 this.pluginServerRule.stubFor( 854 WireMock.get(WireMock.urlEqualTo(bazOldServePath)).willReturn( 855 WireMock.aResponse().withStatus(200).withHeader("Content-Type", "application/java-archive").withBodyFile( 856 "plugin/baz_plugin.v6.jar" 857 ) 858 ) 859 ); 860 Config.getPref().putList("plugins", ImmutableList.of()); 861 862 final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(ImmutableMap.of( 863 "<html>The following plugin has been downloaded <strong>successfully</strong>:" 864 + "<ul><li>baz_plugin (6)</li></ul>" 865 + "You have to restart JOSM for some settings to take effect.<br/><br/>" 866 + "Would you like to restart now?</html>", 867 "Cancel" 868 )); 869 final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(); 870 871 final PreferenceTabbedPane tabbedPane = new PreferenceTabbedPane(); 872 873 tabbedPane.buildGui(); 874 // PluginPreference is already added to PreferenceTabbedPane by default 875 tabbedPane.selectTabByPref(PluginPreference.class); 876 877 GuiHelper.runInEDTAndWait( 878 () -> ((javax.swing.JButton) TestUtils.getComponentByName(tabbedPane, "downloadListButton")).doClick() 879 ); 880 881 TestUtils.syncEDTAndWorkerThreads(); 882 883 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 884 WireMock.resetAllRequests(); 885 886 final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( 887 tabbedPane.getPluginPreference(), 888 "model" 889 ); 890 891 assertTrue(model.getNewlyActivatedPlugins().isEmpty()); 892 assertTrue(model.getNewlyDeactivatedPlugins().isEmpty()); 893 assertTrue(model.getPluginsScheduledForUpdateOrDownload().isEmpty()); 894 assertEquals(model.getDisplayedPlugins(), model.getAvailablePlugins()); 895 896 assertEquals( 897 ImmutableList.of("baz_plugin", "dummy_plugin"), 898 model.getAvailablePlugins().stream().map((pi) -> pi.getName()).collect(ImmutableList.toImmutableList()) 899 ); 900 assertTrue(model.getSelectedPlugins().isEmpty()); 901 assertEquals( 902 ImmutableList.of("(null)", "(null)"), 903 model.getAvailablePlugins().stream().map( 904 (pi) -> pi.localversion == null ? "(null)" : pi.localversion 905 ).collect(ImmutableList.toImmutableList()) 906 ); 907 assertEquals( 908 ImmutableList.of("6", "31772"), 909 model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(ImmutableList.toImmutableList()) 910 ); 911 912 // now we select dummy_plugin 913 model.setPluginSelected("baz_plugin", true); 914 915 // model should now reflect this 916 assertEquals( 917 ImmutableList.of("baz_plugin"), 918 model.getNewlyActivatedPlugins().stream().map( 919 pi -> pi.getName() 920 ).collect(ImmutableList.toImmutableList()) 921 ); 922 assertTrue(model.getNewlyDeactivatedPlugins().isEmpty()); 923 924 tabbedPane.savePreferences(); 925 926 TestUtils.syncEDTAndWorkerThreads(); 927 928 assertEquals(1, haMocker.getInvocationLog().size()); 929 Object[] invocationLogEntry = haMocker.getInvocationLog().get(0); 930 assertEquals(1, (int) invocationLogEntry[0]); 931 assertEquals("Restart", invocationLogEntry[2]); 932 933 assertTrue(jopsMocker.getInvocationLog().isEmpty()); 934 935 // any .jar.new files should have been deleted 936 assertFalse(targetDummyJarNew.exists()); 937 assertFalse(targetBazJarNew.exists()); 938 939 // dummy_plugin was fetched 940 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo(bazOldServePath))); 941 942 // the "old" baz_plugin jar has been installed 943 TestUtils.assertFileContentsEqual(this.referenceBazJarOld, this.targetBazJar); 944 // the dummy_plugin jar has not 945 assertFalse(this.targetDummyJar.exists()); 946 947 // pluginmanager.version has been set to the current version 948 assertEquals(7000, Config.getPref().getInt("pluginmanager.version", 111)); 949 // pluginmanager.lastupdate hasn't been updated 950 // questionably correct 951 assertEquals("999", Config.getPref().get("pluginmanager.lastupdate", "111")); 952 } 829 953 } -
test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java
diff --git a/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java b/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java index ec880aee1..dd3785f1c 100644
a b public class PluginHandlerJOSMTooOldTest { 66 66 this.referenceDummyJarNew = new File(TestUtils.getTestDataRoot(), "__files/plugin/dummy_plugin.v31772.jar"); 67 67 this.referenceBazJarOld = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v6.jar"); 68 68 this.referenceBazJarNew = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v7.jar"); 69 this.referenceQuxJarOld = new File(TestUtils.getTestDataRoot(), "__files/" + referencePathQuxJarOld); 70 this.referenceQuxJarNew = new File(TestUtils.getTestDataRoot(), "__files/" + referencePathQuxJarNew); 71 this.referenceQuxJarNewer = new File(TestUtils.getTestDataRoot(), "__files/" + referencePathQuxJarNewer); 69 72 this.pluginDir = Preferences.main().getPluginsDirectory(); 70 73 this.targetDummyJar = new File(this.pluginDir, "dummy_plugin.jar"); 71 74 this.targetDummyJarNew = new File(this.pluginDir, "dummy_plugin.jar.new"); 72 75 this.targetBazJar = new File(this.pluginDir, "baz_plugin.jar"); 73 76 this.targetBazJarNew = new File(this.pluginDir, "baz_plugin.jar.new"); 77 this.targetQuxJar = new File(this.pluginDir, "qux_plugin.jar"); 78 this.targetQuxJarNew = new File(this.pluginDir, "qux_plugin.jar.new"); 74 79 this.pluginDir.mkdirs(); 75 80 } 76 81 82 private static final String referencePathQuxJarOld = "plugin/qux_plugin.v345.jar"; 83 private static final String referencePathQuxJarNew = "plugin/qux_plugin.v346.jar"; 84 private static final String referencePathQuxJarNewer = "plugin/qux_plugin.v432.jar"; 85 77 86 private File pluginDir; 78 87 private File referenceDummyJarOld; 79 88 private File referenceDummyJarNew; 80 89 private File referenceBazJarOld; 81 90 private File referenceBazJarNew; 91 private File referenceQuxJarOld; 92 private File referenceQuxJarNew; 93 private File referenceQuxJarNewer; 82 94 private File targetDummyJar; 83 95 private File targetDummyJarNew; 84 96 private File targetBazJar; 85 97 private File targetBazJarNew; 98 private File targetQuxJar; 99 private File targetQuxJarNew; 86 100 87 101 private final String bazPluginVersionReqString = "JOSM version 8,001 required for plugin baz_plugin."; 88 102 private final String dummyPluginVersionReqString = "JOSM version 7,001 required for plugin dummy_plugin."; … … public class PluginHandlerJOSMTooOldTest { 282 296 assertEquals(Config.getPref().getInt("pluginmanager.version", 111), 6000); 283 297 assertNotEquals(Config.getPref().get("pluginmanager.lastupdate", "999"), "999"); 284 298 } 299 300 /** 301 * When a plugin advertises several versions for compatibility with older JOSMs, but even the 302 * oldest of those is newer than our JOSM version, the user is prompted to upgrade to the newest 303 * version anyway. 304 * 305 * While this behaviour is not incorrect, it's probably less helpful than it could be - the 306 * version that's most likely to work best in this case will be the "oldest" still-available 307 * version, however this test documents the behaviour. 308 * @throws IOException never 309 */ 310 @Test 311 @JOSMTestRules.OverrideAssumeRevision("Revision: 7200\n") 312 public void testUpdatePluginsMultiVersionInsufficient() throws Exception { 313 TestUtils.assumeWorkingJMockit(); 314 315 final String quxNewServePath = "/qux/new.jar"; 316 final PluginServer pluginServer = new PluginServer( 317 new PluginServer.RemotePlugin(this.referenceBazJarOld), 318 new PluginServer.RemotePlugin(this.referenceQuxJarNewer, ImmutableMap.of( 319 "7499_Plugin-Url", "346;http://localhost:" + this.pluginServerRule.port() + "/dont/bother.jar" 320 )) 321 ); 322 pluginServer.applyToWireMockServer(this.pluginServerRule); 323 Config.getPref().putList("plugins", ImmutableList.of("qux_plugin", "baz_plugin")); 324 325 new ExtendedDialogMocker(ImmutableMap.of("JOSM version 7,500 required for plugin qux_plugin.", "Download Plugin")); 326 327 Files.copy(this.referenceQuxJarOld.toPath(), this.targetQuxJar.toPath()); 328 Files.copy(this.referenceBazJarOld.toPath(), this.targetBazJar.toPath()); 329 330 final List<PluginInformation> updatedPlugins = PluginHandler.updatePlugins( 331 MainApplication.getMainFrame(), 332 null, 333 null, 334 false 335 ).stream().sorted((a, b) -> a.name.compareTo(b.name)).collect(ImmutableList.toImmutableList()); 336 337 assertEquals(2, updatedPlugins.size()); 338 339 assertEquals("baz_plugin", updatedPlugins.get(0).name); 340 assertEquals("6", updatedPlugins.get(0).localversion); 341 342 assertEquals("qux_plugin", updatedPlugins.get(1).name); 343 // questionably correct 344 assertEquals("432", updatedPlugins.get(1).localversion); 345 346 assertFalse(targetQuxJarNew.exists()); 347 348 TestUtils.assertFileContentsEqual(this.referenceBazJarOld, this.targetBazJar); 349 // questionably correct 350 TestUtils.assertFileContentsEqual(this.referenceQuxJarNewer, this.targetQuxJar); 351 352 assertEquals(2, WireMock.getAllServeEvents().size()); 353 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 354 // questionably correct 355 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/qux_plugin.v432.jar"))); 356 357 assertEquals(7200, Config.getPref().getInt("pluginmanager.version", 111)); 358 // not mocking the time so just check it's not its original value 359 assertNotEquals("999", Config.getPref().get("pluginmanager.lastupdate", "999")); 360 } 285 361 } -
new file test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java
diff --git a/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java b/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java new file mode 100644 index 000000000..6ca9e853a
- + 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins; 3 4 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; 5 import static org.junit.Assert.assertEquals; 6 import static org.junit.Assert.assertFalse; 7 import static org.junit.Assert.assertNotEquals; 8 9 import java.io.File; 10 import java.nio.file.Files; 11 import java.util.List; 12 13 import org.junit.Before; 14 import org.junit.Rule; 15 import org.junit.Test; 16 import org.openstreetmap.josm.TestUtils; 17 import org.openstreetmap.josm.data.Preferences; 18 import org.openstreetmap.josm.gui.MainApplication; 19 import org.openstreetmap.josm.spi.preferences.Config; 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 import org.openstreetmap.josm.testutils.PluginServer; 22 import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; 23 24 import com.github.tomakehurst.wiremock.client.WireMock; 25 import com.github.tomakehurst.wiremock.junit.WireMockRule; 26 import com.google.common.collect.ImmutableList; 27 import com.google.common.collect.ImmutableMap; 28 29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 30 31 /** 32 * Test parts of {@link PluginHandler} class with plugins that advertise multiple versions for compatibility. 33 */ 34 public class PluginHandlerMultiVersionTest { 35 /** 36 * Setup test. 37 */ 38 @Rule 39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 40 public JOSMTestRules test = new JOSMTestRules().preferences().main(); 41 42 /** 43 * Plugin server mock. 44 */ 45 @Rule 46 public WireMockRule pluginServerRule = new WireMockRule( 47 options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot()) 48 ); 49 50 /** 51 * Setup test. 52 */ 53 @Before 54 public void setUp() { 55 Config.getPref().putInt("pluginmanager.version", 999); 56 Config.getPref().put("pluginmanager.lastupdate", "999"); 57 Config.getPref().putList("pluginmanager.sites", 58 ImmutableList.of(String.format("http://localhost:%s/plugins", this.pluginServerRule.port())) 59 ); 60 61 this.referenceBazJarOld = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v6.jar"); 62 this.referenceBazJarNew = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v7.jar"); 63 this.referenceQuxJarOld = new File(TestUtils.getTestDataRoot(), "__files/" + referencePathQuxJarOld); 64 this.referenceQuxJarNew = new File(TestUtils.getTestDataRoot(), "__files/" + referencePathQuxJarNew); 65 this.referenceQuxJarNewer = new File(TestUtils.getTestDataRoot(), "__files/" + referencePathQuxJarNewer); 66 this.referenceQuxJarNewest = new File(TestUtils.getTestDataRoot(), "__files/" + referencePathQuxJarNewest); 67 this.pluginDir = Preferences.main().getPluginsDirectory(); 68 this.targetBazJar = new File(this.pluginDir, "baz_plugin.jar"); 69 this.targetBazJarNew = new File(this.pluginDir, "baz_plugin.jar.new"); 70 this.targetQuxJar = new File(this.pluginDir, "qux_plugin.jar"); 71 this.targetQuxJarNew = new File(this.pluginDir, "qux_plugin.jar.new"); 72 this.pluginDir.mkdirs(); 73 } 74 75 private static final String referencePathQuxJarOld = "plugin/qux_plugin.v345.jar"; 76 private static final String referencePathQuxJarNew = "plugin/qux_plugin.v346.jar"; 77 private static final String referencePathQuxJarNewer = "plugin/qux_plugin.v432.jar"; 78 private static final String referencePathQuxJarNewest = "plugin/qux_plugin.v435.jar"; 79 80 private File pluginDir; 81 private File referenceBazJarOld; 82 private File referenceBazJarNew; 83 private File referenceQuxJarOld; 84 private File referenceQuxJarNew; 85 private File referenceQuxJarNewer; 86 private File referenceQuxJarNewest; 87 private File targetBazJar; 88 private File targetBazJarNew; 89 private File targetQuxJar; 90 private File targetQuxJarNew; 91 92 /** 93 * test update of plugins when our current JOSM version prevents us from using the latest version, 94 * but an additional version is listed which *does* support our version 95 * @throws Exception on failure 96 */ 97 @JOSMTestRules.OverrideAssumeRevision("Revision: 7501\n") 98 @Test 99 public void testUpdatePluginsOneMultiVersion() throws Exception { 100 TestUtils.assumeWorkingJMockit(); 101 102 final String quxNewerServePath = "/qux/newer.jar"; 103 final PluginServer pluginServer = new PluginServer( 104 new PluginServer.RemotePlugin(this.referenceBazJarOld), 105 new PluginServer.RemotePlugin(this.referenceQuxJarNewest, ImmutableMap.of( 106 "7500_Plugin-Url", "432;http://localhost:" + this.pluginServerRule.port() + quxNewerServePath, 107 "7499_Plugin-Url", "346;http://localhost:" + this.pluginServerRule.port() + "/not/served.jar", 108 "6999_Plugin-Url", "345;http://localhost:" + this.pluginServerRule.port() + "/not/served/either.jar" 109 )) 110 ); 111 pluginServer.applyToWireMockServer(this.pluginServerRule); 112 // need to actually serve this older jar from somewhere 113 this.pluginServerRule.stubFor( 114 WireMock.get(WireMock.urlEqualTo(quxNewerServePath)).willReturn( 115 WireMock.aResponse().withStatus(200).withHeader("Content-Type", "application/java-archive").withBodyFile( 116 referencePathQuxJarNewer 117 ) 118 ) 119 ); 120 Config.getPref().putList("plugins", ImmutableList.of("qux_plugin", "baz_plugin")); 121 122 // catch any (unexpected) attempts to show us an ExtendedDialog 123 new ExtendedDialogMocker(); 124 125 Files.copy(this.referenceQuxJarOld.toPath(), this.targetQuxJar.toPath()); 126 Files.copy(this.referenceBazJarOld.toPath(), this.targetBazJar.toPath()); 127 128 final List<PluginInformation> updatedPlugins = PluginHandler.updatePlugins( 129 MainApplication.getMainFrame(), 130 null, 131 null, 132 false 133 ).stream().sorted((a, b) -> a.name.compareTo(b.name)).collect(ImmutableList.toImmutableList()); 134 135 assertEquals(2, updatedPlugins.size()); 136 137 assertEquals("baz_plugin", updatedPlugins.get(0).name); 138 assertEquals("6", updatedPlugins.get(0).localversion); 139 140 assertEquals("qux_plugin", updatedPlugins.get(1).name); 141 assertEquals("432", updatedPlugins.get(1).localversion); 142 143 assertFalse(targetBazJarNew.exists()); 144 assertFalse(targetQuxJarNew.exists()); 145 146 TestUtils.assertFileContentsEqual(this.referenceBazJarOld, this.targetBazJar); 147 TestUtils.assertFileContentsEqual(this.referenceQuxJarNewer, this.targetQuxJar); 148 149 assertEquals(2, WireMock.getAllServeEvents().size()); 150 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 151 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo(quxNewerServePath))); 152 153 assertEquals(7501, Config.getPref().getInt("pluginmanager.version", 111)); 154 // not mocking the time so just check it's not its original value 155 assertNotEquals("999", Config.getPref().get("pluginmanager.lastupdate", "999")); 156 } 157 158 /** 159 * test update of plugins when our current JOSM version prevents us from using all but the version 160 * we already have, which is still listed. 161 * @throws Exception on failure 162 */ 163 @JOSMTestRules.OverrideAssumeRevision("Revision: 7000\n") 164 @Test 165 public void testUpdatePluginsExistingVersionLatestPossible() throws Exception { 166 TestUtils.assumeWorkingJMockit(); 167 168 final PluginServer pluginServer = new PluginServer( 169 new PluginServer.RemotePlugin(this.referenceBazJarOld), 170 new PluginServer.RemotePlugin(this.referenceQuxJarNewest, ImmutableMap.of( 171 "7500_Plugin-Url", "432;http://localhost:" + this.pluginServerRule.port() + "/dont.jar", 172 "7499_Plugin-Url", "346;http://localhost:" + this.pluginServerRule.port() + "/even.jar", 173 "6999_Plugin-Url", "345;http://localhost:" + this.pluginServerRule.port() + "/bother.jar" 174 )) 175 ); 176 pluginServer.applyToWireMockServer(this.pluginServerRule); 177 Config.getPref().putList("plugins", ImmutableList.of("qux_plugin", "baz_plugin")); 178 179 // catch any (unexpected) attempts to show us an ExtendedDialog 180 new ExtendedDialogMocker(); 181 182 Files.copy(this.referenceQuxJarOld.toPath(), this.targetQuxJar.toPath()); 183 Files.copy(this.referenceBazJarOld.toPath(), this.targetBazJar.toPath()); 184 185 final List<PluginInformation> updatedPlugins = PluginHandler.updatePlugins( 186 MainApplication.getMainFrame(), 187 null, 188 null, 189 false 190 ).stream().sorted((a, b) -> a.name.compareTo(b.name)).collect(ImmutableList.toImmutableList()); 191 192 assertEquals(2, updatedPlugins.size()); 193 194 assertEquals("baz_plugin", updatedPlugins.get(0).name); 195 assertEquals("6", updatedPlugins.get(0).localversion); 196 197 assertEquals("qux_plugin", updatedPlugins.get(1).name); 198 assertEquals("345", updatedPlugins.get(1).localversion); 199 200 assertFalse(targetBazJarNew.exists()); 201 assertFalse(targetQuxJarNew.exists()); 202 203 // should be as before 204 TestUtils.assertFileContentsEqual(this.referenceBazJarOld, this.targetBazJar); 205 TestUtils.assertFileContentsEqual(this.referenceQuxJarOld, this.targetQuxJar); 206 207 // only the plugins list should have been downloaded 208 assertEquals(1, WireMock.getAllServeEvents().size()); 209 this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); 210 211 assertEquals(7000, Config.getPref().getInt("pluginmanager.version", 111)); 212 // not mocking the time so just check it's not its original value 213 assertNotEquals("999", Config.getPref().get("pluginmanager.lastupdate", "999")); 214 } 215 }