Skip to content
Permalink
Browse files

[FIXED JENKINS-34239] Need to rerun doAddSpecificDescriptors in case …

…a MultiBranchProjectFactoryDescriptor is added first, then a SCMNavigatorDescriptor.
  • Loading branch information...
jglick committed Sep 2, 2016
1 parent 7eb7644 commit e05c287883ec4b46b4820004d9d540ef70c12cea
15 pom.xml
@@ -29,7 +29,8 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.7</version>
<version>2.14</version>
<relativePath/>
</parent>

<artifactId>branch-api</artifactId>
@@ -44,7 +45,7 @@
<licenses>
<license>
<name>The MIT license</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<url>https://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>
@@ -57,9 +58,9 @@
</developers>

<scm>
<connection>scm:git:git://github.com/jenkinsci/branch-api-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/branch-api-plugin.git</developerConnection>
<url>http://github.com/jenkinsci/branch-api-plugin</url>
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
<url>http://github.com/jenkinsci/${project.artifactId}-plugin</url>
<tag>HEAD</tag>
</scm>

@@ -70,14 +71,14 @@
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

@@ -122,6 +122,7 @@ public static void addSpecificDescriptors() {
LOGGER.fine("ran addSpecificDescriptors");
doAddSpecificDescriptors();
ExtensionList.lookup(MultiBranchProjectFactoryDescriptor.class).addListener(new ListenerImpl());
ExtensionList.lookup(SCMNavigatorDescriptor.class).addListener(new ListenerImpl());
}

private static class ListenerImpl extends ExtensionListListener {
@@ -34,6 +34,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import jenkins.scm.api.SCMNavigator;
import jenkins.scm.api.SCMNavigatorDescriptor;
import jenkins.scm.api.SCMSourceObserver;
@@ -43,12 +44,15 @@
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.LoggerRule;
import org.jvnet.hudson.test.TestExtension;

public class CustomOrganizationFolderDescriptorTest {

@Rule
public JenkinsRule r = new JenkinsRule();
@Rule
public LoggerRule logger = new LoggerRule().record(CustomOrganizationFolderDescriptor.class, Level.ALL);

@Test
public void noNavigatorNoFactoryInstalled() throws Exception {
@@ -98,6 +102,16 @@ public void dynamicLoad() throws Exception {
assertEquals(Collections.singletonList("MockNavigator"), newItemTypes());
}

@Issue("JENKINS-34239")
@SuppressWarnings("deprecation") // ExtensionList.add simulating dynamic installation
@Test
public void dynamicLoadReversed() throws Exception {
assertEquals(Collections.emptyList(), newItemTypes());
ExtensionList.lookup(MultiBranchProjectFactoryDescriptor.class).add(new SomeNavigatorSomeFactoryInstalledDescriptor2());
ExtensionList.lookup(SCMNavigatorDescriptor.class).add(new SomeNavigatorSomeFactoryInstalledDescriptor1());
assertEquals(Collections.singletonList("MockNavigator"), newItemTypes());
}

@Issue("JENKINS-31949")
@Test
public void insideFolder() throws Exception {

0 comments on commit e05c287

Please sign in to comment.
You can’t perform that action at this time.