From e69a370619ed812c429bede8cbcd0bf70fe79ecf Mon Sep 17 00:00:00 2001 From: abayer Date: Thu, 10 Sep 2009 22:38:57 +0000 Subject: [PATCH] Belatedly adding a test in MavenMultiModuleTest, adding MavenJellyTest to test maven-plugin's Jelly scripts git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@21600 71c3de6d-444a-0410-be80-ed276b4c234a --- .../java/hudson/maven/MavenJellyTest.java | 42 +++++++++++++++++++ .../hudson/maven/MavenMultiModuleTest.java | 39 ++++++++++++++++- 2 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 test/src/test/java/hudson/maven/MavenJellyTest.java diff --git a/test/src/test/java/hudson/maven/MavenJellyTest.java b/test/src/test/java/hudson/maven/MavenJellyTest.java new file mode 100644 index 0000000000..bdf0d700e3 --- /dev/null +++ b/test/src/test/java/hudson/maven/MavenJellyTest.java @@ -0,0 +1,42 @@ +/* + * The MIT License + * + * Copyright (c) 2004-2009, Sun Microsystems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson.maven; + +import hudson.model.Hudson; +import hudson.remoting.Which; +import junit.framework.Test; +import junit.framework.TestCase; +import org.jvnet.hudson.test.JellyTestSuiteBuilder; +import java.io.File; + +/** + * Runs Jelly checks on maven-plugin. + * + * @author Andrew Bayer + */ +public class MavenJellyTest extends TestCase { + public static Test suite() throws Exception { + return JellyTestSuiteBuilder.build(Which.jarFile(MavenModuleSet.class)); + } +} diff --git a/test/src/test/java/hudson/maven/MavenMultiModuleTest.java b/test/src/test/java/hudson/maven/MavenMultiModuleTest.java index 5bd7e6e75d..d57a44782d 100644 --- a/test/src/test/java/hudson/maven/MavenMultiModuleTest.java +++ b/test/src/test/java/hudson/maven/MavenMultiModuleTest.java @@ -86,7 +86,8 @@ public class MavenMultiModuleTest extends HudsonTestCase { ExtractChangeLogSet changeSet = (ExtractChangeLogSet) pBuild.getChangeSet(); assertFalse("ExtractChangeLogSet should not be empty.", changeSet.isEmptySet()); - + assertEquals("Parent build should have Result.UNSTABLE", pBuild.getResult(), Result.UNSTABLE); + for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { if (modBuild.getParent().getModuleName().toString().equals("org.jvnet.hudson.main.test.multimod.incr:moduleA")) { assertEquals("moduleA should have Result.UNSTABLE", modBuild.getResult(), Result.UNSTABLE); @@ -98,7 +99,41 @@ public class MavenMultiModuleTest extends HudsonTestCase { assertEquals("moduleC should have Result.SUCCESS", modBuild.getResult(), Result.SUCCESS); } if (modBuild.getParent().getModuleName().toString().equals("org.jvnet.hudson.main.test.multimod.incr:moduleD")) { - assertEquals("moduleC should have Result.NOT_BUILT", modBuild.getResult(), Result.NOT_BUILT); + assertEquals("moduleD should have Result.NOT_BUILT", modBuild.getResult(), Result.NOT_BUILT); + } + + } + + } + + /** + * Test failures in a child module should lead to the parent being marked as unstable. + */ + @Bug(4378) + public void testMultiModWithTestFailuresMaven() throws Exception { + configureDefaultMaven("apache-maven-2.2.1"); + MavenModuleSet m = createMavenProject(); + m.getReporters().add(new TestReporter()); + m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod-incr.zip"))); + + assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); + + MavenModuleSetBuild pBuild = m.getLastBuild(); + + assertEquals("Parent build should have Result.UNSTABLE", pBuild.getResult(), Result.UNSTABLE); + + for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { + if (modBuild.getParent().getModuleName().toString().equals("org.jvnet.hudson.main.test.multimod.incr:moduleA")) { + assertEquals("moduleA should have Result.UNSTABLE", modBuild.getResult(), Result.UNSTABLE); + } + if (modBuild.getParent().getModuleName().toString().equals("org.jvnet.hudson.main.test.multimod.incr:moduleB")) { + assertEquals("moduleB should have Result.SUCCESS", modBuild.getResult(), Result.SUCCESS); + } + if (modBuild.getParent().getModuleName().toString().equals("org.jvnet.hudson.main.test.multimod.incr:moduleC")) { + assertEquals("moduleC should have Result.SUCCESS", modBuild.getResult(), Result.SUCCESS); + } + if (modBuild.getParent().getModuleName().toString().equals("org.jvnet.hudson.main.test.multimod.incr:moduleD")) { + assertEquals("moduleD should have Result.SUCCESS", modBuild.getResult(), Result.SUCCESS); } }