Skip to content
Permalink
Browse files

[JENKINS-34900] Added a test to reproduce JENKINS-34900. NPE when tri…

…ggering single Maven module.
  • Loading branch information...
ikedam committed May 21, 2016
1 parent 27f461a commit 6762fc835f6be057c1dc1582b2736778975c5aa5
Showing with 28 additions and 0 deletions.
  1. +28 −0 src/test/java/com/chikli/hudson/plugin/naginator/NaginatorListenerTest.java
@@ -7,8 +7,10 @@
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

import org.apache.commons.lang.StringUtils;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.SingleFileSCM;
import org.jvnet.hudson.test.FailureBuilder;
import org.jvnet.hudson.test.SleepBuilder;

@@ -22,6 +24,7 @@
import hudson.matrix.AxisList;
import hudson.matrix.Combination;
import hudson.matrix.MatrixProject;
import hudson.maven.MavenModuleSet;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
@@ -383,4 +386,29 @@ public void testVariableForMatrixBuild() throws Exception {
assertEquals("2", maxCountRecorder.getRecordedValue(p.getBuildByNumber(3).getExactRun(new Combination(axisList, "value2"))));
assertEquals("2", buildNumberRecorder.getRecordedValue(p.getBuildByNumber(3).getExactRun(new Combination(axisList, "value2"))));
}

@Bug(34900)
public void testMavenModuleSetWithoutNaginator() throws Exception {
final String SIMPLE_POM = StringUtils.join(new String[]{
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">",
" <modelVersion>4.0.0</modelVersion>",
" <groupId>com.exmaple</groupId>",
" <artifactId>test</artifactId>",
" <version>1.0</version>",
" <packaging>jar</packaging>",
"</project>"
}, "\n");

configureDefaultMaven();
MavenModuleSet p = createMavenProject();
p.setScm(new SingleFileSCM("pom.xml", SIMPLE_POM));
p.setGoals("clean");

// Run once to have the project read the module structure.
assertBuildStatusSuccess(p.scheduleBuild2(0));

// This results MavenModuleBuild#getRootBuild() to be `null`.
assertBuildStatusSuccess(p.getRootModule().scheduleBuild2(0));
}
}

0 comments on commit 6762fc8

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