Skip to content

Commit

Permalink
[FIXED JENKINS-34239] Need to rerun doAddSpecificDescriptors in case …
Browse files Browse the repository at this point in the history
…a MultiBranchProjectFactoryDescriptor is added first, then a SCMNavigatorDescriptor.
  • Loading branch information
jglick authored and svanoort committed Sep 3, 2016
1 parent 0d50f62 commit d297b94
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pom.xml
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -60,7 +61,7 @@
<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>
<tag>branch-api-1.10</tag>
<tag>branch-api-1.10.1</tag>
</scm>

<properties>
Expand All @@ -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>

Expand Down
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d297b94

Please sign in to comment.