Add test covering methods for "is*ForNewerJava()"
This way at least we know the backend methods should not be broken without
noticing.
@@ -153,6 +153,31 @@ public class UpdateSiteTest {
assertNotEquals("plugin data is present", Collections.emptyMap(), site.getData().plugins);
}
+ @Test public void minimumJavaVersion() throws Exception {
+ // TODO: factor out the sites init
+ PersistedList<UpdateSite> sites = j.jenkins.getUpdateCenter().getSites();
+ sites.clear();
+ URL url = new URL(baseUrl, "/plugins/minJavaVersion-update-center.json");
+ UpdateSite site = new UpdateSite(UpdateCenter.ID_DEFAULT, url.toString());
+ sites.add(site);
+ assertEquals(FormValidation.ok(), site.updateDirectly(false).get());
+ // END TODO
+
+ final UpdateSite.Plugin tasksPlugin = site.getPlugin("tasks");
+ assertNotNull(tasksPlugin);
+ assertFalse(tasksPlugin.isNeededDependenciesForNewerJava());
+ assertFalse(tasksPlugin.isForNewerJava());
+
+ final UpdateSite.Plugin pluginCompiledForTooRecentJava = site.getPlugin("java-too-recent");
+ assertFalse(pluginCompiledForTooRecentJava.isNeededDependenciesForNewerJava());
+ assertTrue(pluginCompiledForTooRecentJava.isForNewerJava());
+
+ final UpdateSite.Plugin pluginDependingOnPluginCompiledForTooRecentJava = site.getPlugin("depending-on-too-recent-java");
+ assertTrue(pluginDependingOnPluginCompiledForTooRecentJava.isNeededDependenciesForNewerJava());
+ assertFalse(pluginDependingOnPluginCompiledForTooRecentJava.isForNewerJava());
+
+ }
+
@Issue("JENKINS-31448")
@Test public void isLegacyDefault() throws Exception {
assertFalse("isLegacyDefault should be false with null id",new UpdateSite(null,"url").isLegacyDefault());
