diff --git a/pom.xml b/pom.xml index 403aff6..8c8d7f2 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,7 @@ 2.479 ${jenkins.baseline}.3 jenkinsci/${project.artifactId}-plugin + false diff --git a/src/test/java/org/jenkinsci/plugins/structs/SymbolLookupAnticacheTest.java b/src/test/java/org/jenkinsci/plugins/structs/SymbolLookupAnticacheTest.java index a5adb60..d7fbd79 100644 --- a/src/test/java/org/jenkinsci/plugins/structs/SymbolLookupAnticacheTest.java +++ b/src/test/java/org/jenkinsci/plugins/structs/SymbolLookupAnticacheTest.java @@ -3,43 +3,46 @@ import hudson.model.Descriptor; import jenkins.tasks.SimpleBuildStep; import org.jenkinsci.plugins.structs.symbolLookupAnticacheTest.TrivialBuilder; -import org.junit.Rule; -import org.junit.Test; -import org.jvnet.hudson.test.RealJenkinsRule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.jvnet.hudson.test.junit.jupiter.RealJenkinsExtension; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** * @author Sam Van Oort */ -public class SymbolLookupAnticacheTest { +class SymbolLookupAnticacheTest { - @Rule public RealJenkinsRule rjr = new RealJenkinsRule(); + @RegisterExtension + private final RealJenkinsExtension rjr = new RealJenkinsExtension(); /** Verify that if we install a new plugin with a Symbol use, that symbol is found. * Without the plugin we hit the "anticache" i.e. {@link SymbolLookup#noHitCache} that the symbol does not exist. * Once we add the plugin it should hit the cache. */ - @Test public void testAnticache() throws Throwable { - var plugin = rjr.createSyntheticPlugin(new RealJenkinsRule.SyntheticPlugin(TrivialBuilder.class).shortName("SymbolLookupAnticacheTest").header("Plugin-Dependencies", "structs:0")); + @Test + void testAnticache() throws Throwable { + var plugin = rjr.createSyntheticPlugin(new RealJenkinsExtension.SyntheticPlugin(TrivialBuilder.class).shortName("SymbolLookupAnticacheTest").header("Plugin-Dependencies", "structs:0")); rjr.then(rule -> { - Descriptor d = SymbolLookup.get().findDescriptor(SimpleBuildStep.class, "trivialBuilder"); - Descriptor stepDescriptor = SymbolLookup.get().find(Descriptor.class, "trivialBuilder"); - assertNull(d); - assertNull(stepDescriptor); - - rule.jenkins.getPluginManager().dynamicLoad(plugin); - - d = SymbolLookup.get().findDescriptor(SimpleBuildStep.class, "trivialBuilder"); - stepDescriptor = SymbolLookup.get().find(Descriptor.class, "trivialBuilder"); - assertNotNull(d); - assertNotNull(stepDescriptor); - assertEquals("simpleBuild", d.getDisplayName()); - assertEquals("TrivialBuilder", stepDescriptor.clazz.getSimpleName()); - - // Once more just to confirm there's no wackiness when hitting the normal cache too - assertEquals(SymbolLookup.get().findDescriptor(SimpleBuildStep.class, "trivialBuilder"), d); + Descriptor d = SymbolLookup.get().findDescriptor(SimpleBuildStep.class, "trivialBuilder"); + Descriptor stepDescriptor = SymbolLookup.get().find(Descriptor.class, "trivialBuilder"); + assertNull(d); + assertNull(stepDescriptor); + + rule.jenkins.getPluginManager().dynamicLoad(plugin); + + d = SymbolLookup.get().findDescriptor(SimpleBuildStep.class, "trivialBuilder"); + stepDescriptor = SymbolLookup.get().find(Descriptor.class, "trivialBuilder"); + assertNotNull(d); + assertNotNull(stepDescriptor); + assertEquals("simpleBuild", d.getDisplayName()); + assertEquals("TrivialBuilder", stepDescriptor.clazz.getSimpleName()); + + // Once more just to confirm there's no wackiness when hitting the normal cache too + assertEquals(SymbolLookup.get().findDescriptor(SimpleBuildStep.class, "trivialBuilder"), d); }); }