Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-43990] Update to parent POM 2.X. Bump core version as well a…
…s fix some tests.
  • Loading branch information
Evaristo Gutiérrez committed May 2, 2017
1 parent 4cc2761 commit 5c0ca45
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 54 deletions.
36 changes: 15 additions & 21 deletions pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.609</version>
<version>2.26</version>
</parent>
<artifactId>matrix-project</artifactId>
<version>1.10-SNAPSHOT</version>
Expand All @@ -12,8 +12,8 @@
<description>Multi-configuration (matrix) project type.</description>
<url>https://wiki.jenkins-ci.org/display/JENKINS/Matrix+Project+Plugin</url>
<properties>
<findbugs-maven-plugin.version>3.0.1</findbugs-maven-plugin.version>
<findbugs.failOnError>true</findbugs.failOnError>
<jenkins.version>1.609</jenkins.version>
<java.level>6</java.level>
</properties>
<licenses>
<license>
Expand All @@ -40,10 +40,22 @@
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-test-harness-tools</artifactId>
<version>2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1.20</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-auth</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
Expand Down Expand Up @@ -116,24 +128,6 @@
<argLine>-XX:MaxPermSize=128m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs-maven-plugin.version}</version>
<configuration>
<xmlOutput>true</xmlOutput>
<failOnError>${findbugs.failOnError}</failOnError>
</configuration>
<executions>
<execution>
<id>run-findbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
11 changes: 6 additions & 5 deletions src/test/java/hudson/matrix/AxisTest.java
Expand Up @@ -50,7 +50,7 @@ public class AxisTest {
@Before
public void setUp() throws Exception {
wc = j.createWebClient();
p = j.createMatrixProject();
p = j.createProject(MatrixProject.class);

// Setup to make all axes available
j.jenkins.getJDKs().add(new JDK("jdk1.7", "/fake/home"));
Expand All @@ -59,7 +59,7 @@ public void setUp() throws Exception {

@Test
public void submitEmptyAxisName() throws Exception {
wc.setThrowExceptionOnFailingStatusCode(false);
wc.getOptions().setThrowExceptionOnFailingStatusCode(false);

final String expectedMsg = "Matrix axis name '' is invalid: Axis name can not be empty";
assertFailedWith(expectedMsg, withName("", "User-defined Axis"));
Expand All @@ -69,7 +69,7 @@ public void submitEmptyAxisName() throws Exception {

@Test
public void submitInvalidAxisName() throws Exception {
wc.setThrowExceptionOnFailingStatusCode(false);
wc.getOptions().setThrowExceptionOnFailingStatusCode(false);

String expectedMsg = "Matrix axis name 'a,b' is invalid: ‘,’ is an unsafe character";
assertFailedWith(expectedMsg, withName("a,b", "User-defined Axis"));
Expand All @@ -84,7 +84,7 @@ public void submitInvalidAxisName() throws Exception {

@Test
public void submitInvalidAxisValue() throws Exception {
wc.setThrowExceptionOnFailingStatusCode(false);
wc.getOptions().setThrowExceptionOnFailingStatusCode(false);

HtmlForm form = addAxis("User-defined Axis");
form.getInputByName("_.name").setValueAttribute("a_name");
Expand Down Expand Up @@ -140,8 +140,9 @@ private void assertFailedWith(String expected, HtmlPage res) {
private HtmlForm addAxis(String axis) throws Exception {
HtmlPage page = wc.getPage(p, "configure");
HtmlForm form = page.getFormByName("config");
form.getButtonByCaption("Add axis").click();
j.getButtonByCaption(form, "Add axis").click();
page.getAnchorByText(axis).click();
Thread.sleep(300);
return form;
}
}
2 changes: 1 addition & 1 deletion src/test/java/hudson/matrix/LabelExpAxisTest.java
Expand Up @@ -39,7 +39,7 @@ public class LabelExpAxisTest {
public void test() throws Exception {
j.jenkins.setLabelString("aaaa bbbb");

MatrixProject project = j.createMatrixProject("project");
MatrixProject project = j.createProject(MatrixProject.class,"project");
DescriptorImpl descriptor = new LabelExpAxis.DescriptorImpl();

assertEquals(FormValidation.Kind.ERROR, descriptor.doCheckLabelExpr(project, "").kind);
Expand Down
Expand Up @@ -19,7 +19,7 @@ public class MatrixConfigurationSorterTest {
@Rule public JenkinsRule j = new JenkinsRule();

@Test public void testConfigRoundtrip() throws Exception {
MatrixProject p = j.createMatrixProject();
MatrixProject p = j.createProject(MatrixProject.class);
j.configRoundtrip((Item)p);
j.assertEqualDataBoundBeans(new NoopMatrixConfigurationSorter(),strategy(p).getSorter());

Expand Down
14 changes: 7 additions & 7 deletions src/test/java/hudson/matrix/MatrixConfigurationTest.java
Expand Up @@ -43,7 +43,7 @@ public class MatrixConfigurationTest {

@Test
public void testDelete() throws Exception{
MatrixProject project = r.createMatrixProject();
MatrixProject project = r.createProject(MatrixProject.class);
AxisList axes = new AxisList(
new Axis("a","active1","active2", "unactive"));
project.setAxes(axes);
Expand All @@ -62,12 +62,12 @@ public void testDelete() throws Exception{

@Test @Issue("JENKINS-32423")
public void doNotServeConfigurePage() throws Exception {
MatrixProject p = r.createMatrixProject();
MatrixProject p = r.createProject(MatrixProject.class);
p.setAxes(new AxisList(new Axis("a", "b")));

WebClient wc = r.createWebClient();
wc.setThrowExceptionOnFailingStatusCode(false);
wc.setPrintContentOnFailingStatusCode(false);
wc.getOptions().setThrowExceptionOnFailingStatusCode(false);
wc.getOptions().setPrintContentOnFailingStatusCode(false);

HtmlPage page = wc.getPage(p.getItem("a=b"), "configure");
assertEquals("Page should not exist", 404, page.getWebResponse().getStatusCode());
Expand All @@ -78,11 +78,11 @@ public void labelAxis() throws Exception {
LabelAxis label = new LabelAxis("label", Arrays.asList("a", "b"));
LabelExpAxis expr = new LabelExpAxis("expr", Arrays.asList("a||b", "a&&b"));

MatrixProject labelP = r.createMatrixProject();
MatrixProject labelP = r.createProject(MatrixProject.class);
labelP.setAxes(new AxisList(label));
MatrixProject exprP = r.createMatrixProject();
MatrixProject exprP = r.createProject(MatrixProject.class);
exprP.setAxes(new AxisList(expr));
MatrixProject combinedP = r.createMatrixProject();
MatrixProject combinedP = r.createProject(MatrixProject.class);
combinedP.setAxes(new AxisList(expr, label));

Collection<MatrixConfiguration> lc = labelP.getItems();
Expand Down
Expand Up @@ -42,7 +42,7 @@ public class MatrixProjectCustomWorkspaceTest {

@Test
public void customWorkspaceForParentAndChild() throws Exception {
MatrixProject p = j.createMatrixProject();
MatrixProject p = j.createProject(MatrixProject.class);
File dir = tmp.newFolder();
p.setCustomWorkspace(dir.getPath());
p.setChildCustomWorkspace("xyz");
Expand All @@ -61,7 +61,7 @@ public void customWorkspaceForParentAndChild() throws Exception {

@Test
public void customWorkspaceForParent() throws Exception {
MatrixProject p = j.createMatrixProject();
MatrixProject p = j.createProject(MatrixProject.class);
File dir = tmp.newFolder();
p.setCustomWorkspace(dir.getPath());
p.setChildCustomWorkspace(null);
Expand All @@ -87,7 +87,7 @@ public void customWorkspaceForParent() throws Exception {

@Test
public void customWorkspaceForChild() throws Exception {
MatrixProject p = j.createMatrixProject();
MatrixProject p = j.createProject(MatrixProject.class);
p.setCustomWorkspace(null);
p.setChildCustomWorkspace(".");

Expand All @@ -111,7 +111,7 @@ public void customWorkspaceForChild() throws Exception {
*/
@Test
public void noCustomWorkspace() throws Exception {
MatrixProject p = j.createMatrixProject();
MatrixProject p = j.createProject(MatrixProject.class);
p.setCustomWorkspace(null);
p.setChildCustomWorkspace(null);

Expand Down
Expand Up @@ -28,7 +28,7 @@ public class MatrixProjectDependencyTest {
* the DependencyGraph
*/
@Test public void matrixProjectTriggersDependencies() throws Exception {
MatrixProject matrixProject = j.createMatrixProject();
MatrixProject matrixProject = j.createProject(MatrixProject.class);
FreeStyleProject freestyleProject = j.createFreeStyleProject();
matrixProject.getPublishersList().add(new BuildTrigger(freestyleProject.getName(), false));

Expand Down
14 changes: 7 additions & 7 deletions src/test/java/hudson/matrix/MatrixProjectTest.java
Expand Up @@ -40,6 +40,7 @@

import org.jvnet.hudson.test.Email;
import org.jvnet.hudson.test.SingleFileSCM;
import org.jvnet.hudson.test.ToolInstallations;
import org.jvnet.hudson.test.UnstableBuilder;
import org.jvnet.hudson.test.recipes.LocalData;

Expand Down Expand Up @@ -96,7 +97,6 @@
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.RandomlyFails;
import org.junit.rules.TemporaryFolder;

/**
Expand All @@ -115,7 +115,7 @@ public class MatrixProjectTest {
@Test
public void testBuildAxisInAnt() throws Exception {
MatrixProject p = createMatrixProject();
Ant.AntInstallation ant = j.configureDefaultAnt();
Ant.AntInstallation ant = ToolInstallations.configureDefaultAnt(tmp);
p.getBuildersList().add(new Ant("-Dprop=${db} test", ant.getName(), null, null, null));

// we need a dummy build script that echos back our property
Expand All @@ -137,7 +137,7 @@ public void testBuildAxisInAnt() throws Exception {
@Test
public void testBuildAxisInMaven() throws Exception {
MatrixProject p = createMatrixProject();
Maven.MavenInstallation maven = j.configureDefaultMaven();
Maven.MavenInstallation maven = ToolInstallations.configureDefaultMaven();
p.getBuildersList().add(new Maven("-Dprop=${db} validate", maven.getName()));

// we need a dummy build script that echos back our property
Expand Down Expand Up @@ -184,7 +184,7 @@ public void testTouchStone() throws Exception {
}

protected MatrixProject createMatrixProject() throws IOException {
MatrixProject p = j.createMatrixProject();
MatrixProject p = j.createProject(MatrixProject.class);

// set up 2x2 matrix
AxisList axes = new AxisList();
Expand Down Expand Up @@ -214,7 +214,7 @@ public void testFingerprinting() throws Exception {

void assertRectangleTable(MatrixProject p) throws Exception {
HtmlPage html = j.createWebClient().getPage(p);
HtmlTable table = html.selectSingleNode("id('matrix')/table");
HtmlTable table = html.getFirstByXPath("id('matrix')/table");

// remember cells that are extended from rows above.
Map<Integer,Integer> rowSpans = new HashMap<Integer,Integer>();
Expand Down Expand Up @@ -552,7 +552,7 @@ public void testUpgrade() throws Exception {

@Issue("JENKINS-17337")
@Test public void reload() throws Exception {
MatrixProject p = j.createMatrixProject();
MatrixProject p = j.createProject(MatrixProject.class);
AxisList axes = new AxisList();
axes.add(new TextAxis("p", "only"));
p.setAxes(axes);
Expand All @@ -578,7 +578,7 @@ public void testUpgrade() throws Exception {
public void dontRunOnExclusiveSlave() throws Exception {
List<MatrixProject> projects = new ArrayList<MatrixProject>();
for (int i = 0; i <= 10; i++) {
MatrixProject m = j.createMatrixProject();
MatrixProject m = j.createProject(MatrixProject.class);
AxisList axes = new AxisList();
axes.add(new TextAxis("p", "only"));
m.setAxes(axes);
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/hudson/matrix/MatrixTest.java
Expand Up @@ -80,7 +80,7 @@ public class MatrixTest {
@Issue("JENKINS-9293")
@Test public void configurationACL() throws Exception {
j.jenkins.setAuthorizationStrategy(new ProjectMatrixAuthorizationStrategy());
MatrixProject mp = j.createMatrixProject();
MatrixProject mp = j.createProject(MatrixProject.class);
mp.setAxes(new AxisList(new Axis("foo", "a", "b")));
MatrixConfiguration mc = mp.getItem("foo=a");
assertNotNull(mc);
Expand All @@ -93,7 +93,7 @@ public class MatrixTest {
}

@Test public void api() throws Exception {
MatrixProject project = j.createMatrixProject();
MatrixProject project = j.createProject(MatrixProject.class);
project.setAxes(new AxisList(
new Axis("FOO", "abc", "def"),
new Axis("BAR", "uvw", "xyz")));
Expand All @@ -103,7 +103,7 @@ public class MatrixTest {

@Issue("JENKINS-27162")
@Test public void completedLogging() throws Exception {
MatrixProject project = j.createMatrixProject();
MatrixProject project = j.createProject(MatrixProject.class);
project.setAxes(new AxisList(
new Axis("axis", "a", "b")
));
Expand All @@ -118,7 +118,7 @@ public class MatrixTest {

@Issue("SECURITY-125")
@Test public void combinationFilterSecurity() throws Exception {
MatrixProject project = j.createMatrixProject();
MatrixProject project = j.createProject(MatrixProject.class);
String combinationFilter = "jenkins.model.Jenkins.getInstance().setSystemMessage('hacked')";
expectRejection(project, combinationFilter, "staticMethod jenkins.model.Jenkins getInstance");
assertNull(j.jenkins.getSystemMessage());
Expand Down Expand Up @@ -146,7 +146,7 @@ private static void expectRejection(MatrixProject project, String combinationFil
@Issue("JENKINS-34389")
@Test public void axisValuesChanged() throws Exception {
// create project with dynamic axis
MatrixProject project = j.createMatrixProject();
MatrixProject project = j.createProject(MatrixProject.class);
project.setAxes(new AxisList(
new DynamicTestAxis("axis")
));
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/hudson/matrix/RestartingRestoreTest.java
Expand Up @@ -53,7 +53,7 @@ public class RestartingRestoreTest {
@Test public void persistenceOfParentInMatrixRun() {
r.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
MatrixProject p = r.j.createMatrixProject("project");
MatrixProject p = r.j.createProject(MatrixProject.class, "project");
p.setAxes(new AxisList(new TextAxis("AXIS", "VALUE")));

// Schedule and wait for build to finish
Expand All @@ -80,7 +80,7 @@ public class RestartingRestoreTest {
@Test public void resumeAllCombinations() throws Exception {
r.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
MatrixProject project = r.j.createMatrixProject("p");
MatrixProject project = r.j.createProject(MatrixProject.class, "p");
project.setConcurrentBuild(true);
project.setAxes(new AxisList(new LabelAxis("labels", Arrays.asList("foo", "bar"))));

Expand Down

0 comments on commit 5c0ca45

Please sign in to comment.