提交 7b8aee67 编写于 作者: K kohsuke

tests the same in Maven as well

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@13175 71c3de6d-444a-0410-be80-ed276b4c234a
上级 07e9114a
......@@ -2,10 +2,12 @@ package hudson.matrix;
import hudson.model.Result;
import hudson.tasks.Ant;
import hudson.tasks.Maven;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.SingleFileSCM;
import java.util.List;
import java.io.IOException;
/**
* @author Kohsuke Kawaguchi
......@@ -14,14 +16,8 @@ public class MatrixProjectTest extends HudsonTestCase {
/**
* Tests that axes are available as build variables in the Ant builds.
*/
public void testBuildAxis() throws Exception {
MatrixProject p = (MatrixProject) hudson.createProject(MatrixProject.DESCRIPTOR, "test");
// set up 2x2 matrix
AxisList axes = new AxisList();
axes.add(new Axis("db","mysql","oracle"));
axes.add(new Axis("direction","north","south"));
p.setAxes(axes);
public void testBuildAxisInAnt() throws Exception {
MatrixProject p = createMatrixProject();
p.getBuildersList().add(new Ant("-Dprop=${db} test",null,null,null,null));
// we need a dummy build script that echos back our property
......@@ -36,4 +32,37 @@ public class MatrixProjectTest extends HudsonTestCase {
assertLogContains("assertion "+expectedDb+"="+expectedDb, run);
}
}
/**
* Tests that axes are available as build variables in the Maven builds.
*/
public void testBuildAxisInMaven() throws Exception {
MatrixProject p = createMatrixProject();
p.getBuildersList().add(new Maven("-Dprop=${db} validate",null));
// we need a dummy build script that echos back our property
p.setScm(new SingleFileSCM("pom.xml",getClass().getResource("echo-property.pom")));
MatrixBuild build = p.scheduleBuild2(0).get();
List<MatrixRun> runs = build.getRuns();
assertEquals(4,runs.size());
for (MatrixRun run : runs) {
assertBuildStatus(Result.SUCCESS, run);
String expectedDb = run.getParent().getCombination().get("db");
assertLogContains("assertion "+expectedDb+"="+expectedDb, run);
}
}
@Override
protected MatrixProject createMatrixProject() throws IOException {
MatrixProject p = super.createMatrixProject();
// set up 2x2 matrix
AxisList axes = new AxisList();
axes.add(new Axis("db","mysql","oracle"));
axes.add(new Axis("direction","north","south"));
p.setAxes(axes);
return p;
}
}
<!--
POM that echos back a few properties. Used by MatrixProjectTest
-->
<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>test</groupId>
<artifactId>test</artifactId>
<version>0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
<artifactId>maven-antrun-extended-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<configuration>
<tasks>
<echo>assertion ${prop}=${db}</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>m.g.o-public</id>
<url>http://maven.glassfish.org/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册