diff --git a/test/pom.xml b/test/pom.xml index 015a6d99a577b4968cc3716ea86ddefd5bbe1e5d..790ad4ae6af392efa3869532e6efd9824c8bb4d7 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -161,12 +161,6 @@ THE SOFTWARE. geb-implicit-assertions 0.7.2 - - org.jenkins-ci.test - sample-plexus-component - 1.0 - test - diff --git a/test/src/test/java/hudson/maven/AbortedMavenBuildTest.java b/test/src/test/java/hudson/maven/AbortedMavenBuildTest.java deleted file mode 100644 index 9275040c8c3a0f89dd9f9192d14ae3d74c80c3e1..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/AbortedMavenBuildTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package hudson.maven; - -import hudson.Launcher; -import hudson.model.BuildListener; -import hudson.model.Result; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.HudsonTestCase; - -import java.io.IOException; - -public class AbortedMavenBuildTest extends HudsonTestCase { - @Bug(8054) - public void testBuildWrapperSeesAbortedStatus() throws Exception { - configureDefaultMaven(); - MavenModuleSet project = createMavenProject(); - TestBuildWrapper wrapper = new TestBuildWrapper(); - project.getBuildWrappersList().add(wrapper); - project.getReporters().add(new AbortingReporter()); - project.setGoals("clean"); - project.setScm(new ExtractResourceSCM(getClass().getResource("maven-empty-mod.zip"))); - MavenModuleSetBuild build = project.scheduleBuild2(0).get(); - assertEquals(Result.ABORTED, build.getResult()); - assertEquals(Result.ABORTED, wrapper.buildResultInTearDown); - } - - private static class AbortingReporter extends MavenReporter { - private static final long serialVersionUID = 1L; - - @Override - public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { - throw new InterruptedException(); - } - } -} diff --git a/test/src/test/java/hudson/maven/AbstractMaven3xBuildTest.java b/test/src/test/java/hudson/maven/AbstractMaven3xBuildTest.java deleted file mode 100755 index b69a03e573592fb8a8ccd7b4d5929433b14c1123..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/AbstractMaven3xBuildTest.java +++ /dev/null @@ -1,263 +0,0 @@ -package hudson.maven; - -/* - * Olivier Lamy - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import hudson.Launcher; -import hudson.model.BuildListener; -import hudson.model.ParametersDefinitionProperty; -import hudson.model.Result; -import hudson.model.StringParameterDefinition; -import hudson.tasks.Maven.MavenInstallation; -import hudson.tasks.test.AbstractTestResultAction; -import hudson.tasks.test.TestResultProjectAction; -import org.apache.commons.io.FileUtils; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.Email; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.HudsonTestCase; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; - -/** - * @author Olivier Lamy - */ -public abstract class AbstractMaven3xBuildTest - extends HudsonTestCase { - - public abstract MavenInstallation configureMaven3x() throws Exception; - - public void testSimpleMaven3Build() throws Exception { - - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureMaven3x(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven3-project.zip"))); - m.setGoals( "clean install" ); - MavenModuleSetBuild b = buildAndAssertSuccess(m); - assertTrue( MavenUtil.maven3orLater( b.getMavenVersionUsed() ) ); - } - - public void testSimpleMaven3BuildRedeployPublisher() throws Exception { - - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureMaven3x(); - m.setMaven( mavenInstallation.getName() ); - File repo = createTmpDir(); - FileUtils.cleanDirectory( repo ); - m.getReporters().add(new TestReporter()); - m.getPublishersList().add(new RedeployPublisher("",repo.toURI().toString(),true, false)); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven3-project.zip"))); - m.setGoals( "clean install" ); - MavenModuleSetBuild b = buildAndAssertSuccess(m); - assertTrue( MavenUtil.maven3orLater( b.getMavenVersionUsed() ) ); - File artifactDir = new File(repo,"com/mycompany/app/my-app/1.7-SNAPSHOT/"); - String[] files = artifactDir.list( new FilenameFilter() - { - - public boolean accept( File dir, String name ) - { - System.out.println("file name : " +name ); - return name.endsWith( ".jar" ); - } - }); - assertTrue("SNAPSHOT exist",!files[0].contains( "SNAPSHOT" )); - assertTrue("file not ended with -1.jar", files[0].endsWith( "-1.jar" )); - } - - public void testSiteBuildWithForkedMojo() throws Exception { - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureMaven3x(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven3-project.zip"))); - m.setGoals( "clean site" ); - MavenModuleSetBuild b = buildAndAssertSuccess(m); - assertTrue( MavenUtil.maven3orLater( b.getMavenVersionUsed() ) ); - } - - @Bug(value=8395) - public void testMaven3BuildWrongScope() throws Exception { - - File pom = new File(this.getClass().getResource("test-pom-8395.xml").toURI()); - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureMaven3x(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setRootPOM(pom.getAbsolutePath()); - m.setGoals( "clean validate" ); - MavenModuleSetBuild mmsb = m.scheduleBuild2( 0 ).get(); - assertBuildStatus( Result.FAILURE, mmsb ); - System.out.println("mmsb.getProject().getModules " + mmsb.getProject().getModules() ); - assertTrue( mmsb.getProject().getModules().isEmpty()); - } - - @Bug(value=8390) - public void testMaven3BuildWrongInheritence() throws Exception { - - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureMaven3x(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("incorrect-inheritence-testcase.zip"))); - m.setGoals( "clean validate" ); - MavenModuleSetBuild mmsb = m.scheduleBuild2( 0 ).get(); - assertBuildStatus( Result.FAILURE, mmsb ); - System.out.println("mmsb.getProject().getModules " + mmsb.getProject().getModules() ); - assertTrue( mmsb.getProject().getModules().isEmpty()); - } - - @Bug(value=8445) - public void testMavenSeveralModulesInDirectory() throws Exception { - - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureMaven3x(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("several-modules-in-directory.zip"))); - m.setGoals( "clean validate" ); - MavenModuleSetBuild mmsb = buildAndAssertSuccess(m); - assertFalse( mmsb.getProject().getModules().isEmpty()); - } - - @Email("https://groups.google.com/d/msg/hudson-users/Xhw00UopVN0/FA9YqDAIsSYJ") - public void testMavenWithDependencyVersionInEnvVar() throws Exception { - - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureMaven3x(); - ParametersDefinitionProperty parametersDefinitionProperty = - new ParametersDefinitionProperty(new StringParameterDefinition( "JUNITVERSION", "3.8.2" )); - - m.addProperty( parametersDefinitionProperty ); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("envars-maven-project.zip"))); - m.setGoals( "clean test-compile" ); - MavenModuleSetBuild mmsb = buildAndAssertSuccess(m); - assertFalse( mmsb.getProject().getModules().isEmpty()); - } - - @Bug(8484) - public void testMultiModMavenNonRecursive() throws Exception { - MavenInstallation mavenInstallation = configureMaven3x(); - MavenModuleSet m = createMavenProject(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod.zip"))); - m.setGoals( "-N validate" ); - assertTrue("MavenModuleSet.isNonRecursive() should be true", m.isNonRecursive()); - buildAndAssertSuccess(m); - assertEquals("not only one module", 1, m.getModules().size()); - } - - @Bug(8573) - public void testBuildTimeStampProperty() throws Exception { - MavenInstallation mavenInstallation = configureMaven3x(); - MavenModuleSet m = createMavenProject(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("JENKINS-8573.zip"))); - m.setGoals( "process-resources" ); - buildAndAssertSuccess(m); - String content = m.getLastBuild().getWorkspace().child( "target/classes/test.txt" ).readToString(); - assertFalse( content.contains( "${maven.build.timestamp}") ); - assertFalse( content.contains( "${maven.build.timestamp}") ); - } - - @Bug(1557) - public void testDuplicateTestResults() throws Exception { - MavenInstallation mavenInstallation = configureMaven3x(); - MavenModuleSet m = createMavenProject(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("JENKINS-1557.zip"))); - m.setGoals("verify"); - buildAndAssertSuccess(m); - - int totalCount = m.getModules().iterator().next() - .getAction(TestResultProjectAction.class).getLastTestResultAction().getTotalCount(); - assertEquals(4, totalCount); - } - - @Bug(9326) - public void testTychoTestResults() throws Exception { - MavenInstallation mavenInstallation = configureMaven3x(); - MavenModuleSet m = createMavenProject(); - m.setRootPOM( "org.foobar.build/pom.xml" ); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("JENKINS-9326.zip"),"foobar")); - m.setGoals("verify"); - buildAndAssertSuccess(m); - - System.out.println("modules size " + m.getModules()); - - - MavenModule testModule = null; - for (MavenModule mavenModule : m.getModules()) { - System.out.println("module " + mavenModule.getName() + "/" + mavenModule.getDisplayName()); - if ("org.foobar:org.foobar.test".equals( mavenModule.getName() )) testModule = mavenModule; - } - - AbstractTestResultAction trpa = testModule.getLastBuild().getTestResultAction(); - - int totalCount = trpa.getTotalCount(); - assertEquals(1, totalCount); - } - - @Bug(9326) - public void testTychoEclipseTestResults() throws Exception { - MavenInstallation mavenInstallation = configureMaven3x(); - MavenModuleSet m = createMavenProject(); - m.setRootPOM( "org.foobar.build/pom.xml" ); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("foobar_eclipse_with_fix.zip"),"foobar_eclipse")); - m.setGoals("verify"); - buildAndAssertSuccess(m); - - System.out.println("modules size " + m.getModules()); - - - MavenModule testModule = null; - for (MavenModule mavenModule : m.getModules()) { - System.out.println("module " + mavenModule.getName() + "/" + mavenModule.getDisplayName()); - if ("org.foobar:org.foobar.test".equals( mavenModule.getName() )) testModule = mavenModule; - } - - AbstractTestResultAction trpa = testModule.getLastBuild().getTestResultAction(); - - int totalCount = trpa.getTotalCount(); - assertEquals(1, totalCount); - } - - private static class TestReporter extends MavenReporter { - @Override - public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { - assertNotNull(build.getProject().getWorkspace()); - assertNotNull(build.getWorkspace()); - return true; - } - } - -} diff --git a/test/src/test/java/hudson/maven/Maven30xBuildTest.java b/test/src/test/java/hudson/maven/Maven30xBuildTest.java deleted file mode 100755 index 5c236ce046163c100d1cbed84602b88c35cf5089..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/Maven30xBuildTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package hudson.maven; - -/* - * Olivier Lamy - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import hudson.Launcher; -import hudson.model.BuildListener; -import hudson.model.ParametersDefinitionProperty; -import hudson.model.Result; -import hudson.model.StringParameterDefinition; -import hudson.tasks.Maven; -import hudson.tasks.Maven.MavenInstallation; -import hudson.tasks.test.AbstractTestResultAction; -import hudson.tasks.test.TestResultProjectAction; -import org.apache.commons.io.FileUtils; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.Email; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.HudsonTestCase; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; - -/** - * @author Olivier Lamy - */ -public class Maven30xBuildTest - extends AbstractMaven3xBuildTest { - - @Override - public MavenInstallation configureMaven3x() - throws Exception - { - return configureMaven3(); - } - -} diff --git a/test/src/test/java/hudson/maven/Maven31xBuildTest.java b/test/src/test/java/hudson/maven/Maven31xBuildTest.java deleted file mode 100755 index 449d7824924af522204d706ea604ccc6c64f0332..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/Maven31xBuildTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package hudson.maven; - -/* - * Olivier Lamy - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import hudson.Launcher; -import hudson.model.BuildListener; -import hudson.model.ParametersDefinitionProperty; -import hudson.model.Result; -import hudson.model.StringParameterDefinition; -import hudson.tasks.Maven; -import hudson.tasks.Maven.MavenInstallation; -import hudson.tasks.test.AbstractTestResultAction; -import hudson.tasks.test.TestResultProjectAction; -import org.apache.commons.io.FileUtils; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.Email; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.HudsonTestCase; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; - -/** - * @author Olivier Lamy - */ -public class Maven31xBuildTest - extends AbstractMaven3xBuildTest { - - @Override - public MavenInstallation configureMaven3x() - throws Exception - { - return configureMaven31(); - } -} diff --git a/test/src/test/java/hudson/maven/MavenArgumentInterceptorTest.java b/test/src/test/java/hudson/maven/MavenArgumentInterceptorTest.java deleted file mode 100644 index 6709fd36b63a1b9cfff8bbfd3de82c7b47096648..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenArgumentInterceptorTest.java +++ /dev/null @@ -1,171 +0,0 @@ -package hudson.maven; - -/* - * The MIT License - * - * Copyright (c) 2011, Dominik Bartholdi - * - * 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. - */ -import hudson.Extension; -import hudson.Launcher; -import hudson.model.AbstractBuild; -import hudson.model.AbstractProject; -import hudson.model.BuildListener; -import hudson.model.Result; -import hudson.tasks.BuildWrapper; -import hudson.tasks.BuildWrapperDescriptor; -import hudson.tasks.Maven.MavenInstallation; -import hudson.util.ArgumentListBuilder; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -import net.sf.json.JSONObject; - -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.HudsonTestCase; -import org.kohsuke.stapler.StaplerRequest; - -/** - * @author Dominik Bartholdi (imod) - */ -public class MavenArgumentInterceptorTest extends HudsonTestCase { - - public void testSimpleMaven3BuildWithArgInterceptor_Goals() throws Exception { - - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureMaven3(); - m.setMaven(mavenInstallation.getName()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven3-project.zip"))); - m.setGoals("dummygoal"); // build would fail with this goal - - // add an action to build, redefining the goals and options to be - // executed - m.getBuildWrappersList().add(new TestMvnBuildWrapper("clean")); - - MavenModuleSetBuild b = buildAndAssertSuccess(m); - assertTrue(MavenUtil.maven3orLater(b.getMavenVersionUsed())); - } - - public void testSimpleMaven3BuildWithArgInterceptor_ArgBuilder() throws Exception { - - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureMaven3(); - m.setMaven(mavenInstallation.getName()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip"))); - m.setGoals("clean install"); // build would fail because of failing unit - // tests - - // add an action to build, adding argument to skip the test execution - m.getBuildWrappersList().add(new TestMvnBuildWrapper(Arrays.asList("-DskipTests"))); - - MavenModuleSetBuild b = buildAndAssertSuccess(m); - assertTrue(MavenUtil.maven3orLater(b.getMavenVersionUsed())); - } - - private static class TestMvnArgInterceptor implements MavenArgumentInterceptorAction { - private String goalsAndOptions; - private List args; - - public TestMvnArgInterceptor(String goalsAndOptions) { - this.goalsAndOptions = goalsAndOptions; - } - - public TestMvnArgInterceptor(List args) { - this.args = args; - } - - public String getIconFileName() { - return null; - } - - public String getDisplayName() { - return null; - } - - public String getUrlName() { - return null; - } - - public String getGoalsAndOptions(MavenModuleSetBuild build) { - return goalsAndOptions; - } - - public ArgumentListBuilder intercept(ArgumentListBuilder mavenargs, MavenModuleSetBuild build) { - if (args != null) { - for (String arg : this.args) { - mavenargs.add(arg); - } - } - return mavenargs; - } - } - - public static class TestMvnBuildWrapper extends BuildWrapper { - public Result buildResultInTearDown; - private String goalsAndOptions; - private List args; - - public TestMvnBuildWrapper(String goalsAndOptions) { - this.goalsAndOptions = goalsAndOptions; - } - - public TestMvnBuildWrapper(List args) { - this.args = args; - } - - @Override - public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { - - if (goalsAndOptions != null) { - build.addAction(new TestMvnArgInterceptor(goalsAndOptions)); - } else if (args != null) { - build.addAction(new TestMvnArgInterceptor(args)); - } - - return new BuildWrapper.Environment() { - @Override - public boolean tearDown(AbstractBuild build, BuildListener listener) throws IOException, InterruptedException { - buildResultInTearDown = build.getResult(); - return true; - } - }; - } - - @Extension - public static class TestMvnBuildWrapperDescriptor extends BuildWrapperDescriptor { - @Override - public boolean isApplicable(AbstractProject project) { - return true; - } - - @Override - public BuildWrapper newInstance(StaplerRequest req, JSONObject formData) { - throw new UnsupportedOperationException(); - } - - @Override - public String getDisplayName() { - return this.getClass().getName(); - } - } - } -} diff --git a/test/src/test/java/hudson/maven/MavenBuildSurefireFailedTest.java b/test/src/test/java/hudson/maven/MavenBuildSurefireFailedTest.java deleted file mode 100755 index 1bcece674b0ee9897e7b0676a5c49fc02ab042f8..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenBuildSurefireFailedTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package hudson.maven; - -import hudson.model.Result; -import hudson.tasks.Shell; -import java.util.concurrent.Callable; - -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.HudsonTestCase; -import org.jvnet.hudson.test.RunLoadCounter; - -/** - * @author Olivier Lamy - */ -public class MavenBuildSurefireFailedTest extends HudsonTestCase { - - @Bug(8415) - public void testMaven2Unstable() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setGoals( "test" ); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip"))); - assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); - } - - @Bug(8415) - public void testMaven2Failed() throws Exception { - configureDefaultMaven(); - final MavenModuleSet m = createMavenProject(); - m.setGoals( "test -Dmaven.test.failure.ignore=false" ); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip"))); - assertBuildStatus(Result.FAILURE, m.scheduleBuild2(0).get()); - // JENKINS-18895: - MavenModule failing = m.getModule("com.mycompany.app:my-app"); - assertEquals(Result.FAILURE, failing.getLastBuild().getResult()); - RunLoadCounter.prepare(failing); - assertEquals(Result.FAILURE, RunLoadCounter.assertMaxLoads(failing, 0, new Callable() { - @Override public Result call() throws Exception { - return m.getLastBuild().getResult(); - } - })); - } - - @Bug(8415) - public void testMaven3Unstable() throws Exception { - MavenModuleSet m = createMavenProject(); - m.setMaven( configureMaven3().getName() ); - m.setGoals( "test" ); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip"))); - assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); - } - - @Bug(8415) - public void testMaven3Failed() throws Exception { - MavenModuleSet m = createMavenProject(); - m.setMaven( configureMaven3().getName() ); - m.setGoals( "test -Dmaven.test.failure.ignore=false" ); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip"))); - assertBuildStatus(Result.FAILURE, m.scheduleBuild2(0).get()); - } - - @Bug(14102) - public void testMaven3SkipPostBuilder() throws Exception { - MavenModuleSet m = createMavenProject(); - m.setMaven( configureMaven3().getName() ); - m.setGoals( "test" ); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip"))); - // run dummy command only if build state is SUCCESS - m.setRunPostStepsIfResult(Result.SUCCESS); - m.addPostBuilder(new Shell("no-valid-command")); - assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); - } - - @Bug(14102) - public void testMaven2SkipPostBuilder() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setGoals( "test" ); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip"))); - // run dummy command only if build state is SUCCESS - m.setRunPostStepsIfResult(Result.SUCCESS); - m.addPostBuilder(new Shell("no-valid-command")); - assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); - } -} diff --git a/test/src/test/java/hudson/maven/MavenBuildTest.java b/test/src/test/java/hudson/maven/MavenBuildTest.java deleted file mode 100755 index 9dd02c337e4e180692e066e82659d460493b77a8..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenBuildTest.java +++ /dev/null @@ -1,204 +0,0 @@ -package hudson.maven; - -import hudson.Launcher; -import hudson.model.BuildListener; -import hudson.model.ParametersDefinitionProperty; -import hudson.model.Result; -import hudson.model.StringParameterDefinition; -import hudson.tasks.Maven.MavenInstallation; -import hudson.tasks.test.AbstractTestResultAction; -import hudson.tasks.test.AggregatedTestResultAction; - -import java.io.File; -import java.io.IOException; -import java.util.Map; - -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.Email; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.HudsonTestCase; -import org.jvnet.hudson.test.SingleFileSCM; - -/** - * @author Kohsuke Kawaguchi - */ -public class MavenBuildTest extends HudsonTestCase { - - /** - * NPE in {@code build.getProject().getWorkspace()} for {@link MavenBuild}. - */ - @Bug(4192) - public void testMavenWorkspaceExists() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("HUDSON-4192.zip"))); - buildAndAssertSuccess(m); - } - - /** - * {@link Result} getting set to SUCCESS even if there's a test failure, when the test failure - * does not happen in the final task segment. - */ - @Bug(4177) - public void testTestFailureInEarlyTaskSegment() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setGoals("clean install findbugs:findbugs"); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-test-failure-findbugs.zip"))); - assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); - } - - /** - * Verify that a compilation error properly shows up as a failure. - */ - public void testCompilationFailure() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setGoals("clean install"); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-compilation-failure.zip"))); - assertBuildStatus(Result.FAILURE, m.scheduleBuild2(0).get()); - } - - /** - * Workspace determination problem on non-aggregator style build. - */ - @Bug(4226) - public void testParallelModuleBuild() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setScm(new ExtractResourceSCM(getClass().getResource("multimodule-maven.zip"))); - - buildAndAssertSuccess(m); - - m.setAggregatorStyleBuild(false); - - // run module builds - buildAndAssertSuccess(m.getModule("test$module1")); - buildAndAssertSuccess(m.getModule("test$module1")); - } - - @Bug(value=8395) - public void testMaven2BuildWrongScope() throws Exception { - - File pom = new File(this.getClass().getResource("test-pom-8395.xml").toURI()); - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureDefaultMaven(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setRootPOM(pom.getAbsolutePath()); - m.setGoals( "clean validate" ); - MavenModuleSetBuild mmsb = buildAndAssertSuccess(m); - assertFalse( mmsb.getProject().getModules().isEmpty()); - } - - @Bug(value=8390) - public void testMaven2BuildWrongInheritence() throws Exception { - - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureDefaultMaven(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("incorrect-inheritence-testcase.zip"))); - m.setGoals( "clean validate" ); - MavenModuleSetBuild mmsb = buildAndAssertSuccess(m); - assertFalse( mmsb.getProject().getModules().isEmpty()); - } - - @Bug(value=8445) - public void testMaven2SeveralModulesInDirectory() throws Exception { - - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureDefaultMaven(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("several-modules-in-directory.zip"))); - m.setGoals( "clean validate" ); - MavenModuleSetBuild mmsb = buildAndAssertSuccess(m); - assertFalse( mmsb.getProject().getModules().isEmpty()); - } - - @Email("https://groups.google.com/d/msg/hudson-users/Xhw00UopVN0/FA9YqDAIsSYJ") - public void testMavenWithDependencyVersionInEnvVar() throws Exception { - - MavenModuleSet m = createMavenProject(); - MavenInstallation mavenInstallation = configureDefaultMaven(); - ParametersDefinitionProperty parametersDefinitionProperty = - new ParametersDefinitionProperty(new StringParameterDefinition( "JUNITVERSION", "3.8.2" )); - - m.addProperty( parametersDefinitionProperty ); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("envars-maven-project.zip"))); - m.setGoals( "clean test-compile" ); - MavenModuleSetBuild mmsb = buildAndAssertSuccess(m); - assertFalse( mmsb.getProject().getModules().isEmpty()); - } - - @Bug(8573) - public void testBuildTimeStampProperty() throws Exception { - MavenInstallation mavenInstallation = configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setMaven( mavenInstallation.getName() ); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("JENKINS-8573.zip"))); - m.setGoals( "process-resources" ); - buildAndAssertSuccess(m); - String content = m.getLastBuild().getWorkspace().child( "target/classes/test.txt" ).readToString(); - assertFalse( content.contains( "${maven.build.timestamp}") ); - assertFalse( content.contains( "${maven.build.timestamp}") ); - - System.out.println( "content " + content ); - } - - @Bug(value=15865) - public void testMavenFailsafePluginTestResultsAreRecorded() throws Exception { - - // GIVEN: a Maven project with maven-failsafe-plugin and Maven 2.2.1 - MavenModuleSet mavenProject = createMavenProject(); - MavenInstallation mavenInstallation = configureDefaultMaven(); - mavenProject.setMaven(mavenInstallation.getName()); - mavenProject.getReporters().add(new TestReporter()); - mavenProject.setScm(new ExtractResourceSCM(getClass().getResource("JENKINS-15865.zip"))); - mavenProject.setGoals( "clean install" ); - - // WHEN project is build - MavenModuleSetBuild mmsb = buildAndAssertSuccess(mavenProject); - - // THEN we have a testresult recorded - AggregatedTestResultAction aggregatedTestResultAction = mmsb.getAggregatedTestResultAction(); - assertNotNull(aggregatedTestResultAction); - assertEquals(1, aggregatedTestResultAction.getTotalCount()); - - Map moduleBuilds = mmsb.getModuleLastBuilds(); - assertEquals(1, moduleBuilds.size()); - MavenBuild moduleBuild = moduleBuilds.values().iterator().next(); - AbstractTestResultAction testResultAction = moduleBuild.getTestResultAction(); - assertNotNull(testResultAction); - assertEquals(1, testResultAction.getTotalCount()); - } - - @Bug(18178) - public void testExtensionsConflictingWithCore() throws Exception { - MavenModuleSet m = createMavenProject(); - m.setMaven(configureDefaultMaven().getName()); - m.setScm(new SingleFileSCM("pom.xml", - "4.0.0" + - "ga0" + - "" + - "org.springframework.build.awsorg.springframework.build.aws.maven3.0.0.RELEASE" + - "")); - buildAndAssertSuccess(m); - } - - private static class TestReporter extends MavenReporter { - private static final long serialVersionUID = 1L; - - @Override - public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { - assertNotNull(build.getWorkspace()); - return true; - } - } - -} diff --git a/test/src/test/java/hudson/maven/MavenEmptyModuleTest.java b/test/src/test/java/hudson/maven/MavenEmptyModuleTest.java deleted file mode 100644 index b8ad72048a519ff7eeafd5984c8cc69ae72526e8..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenEmptyModuleTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package hudson.maven; - -import org.jvnet.hudson.test.HudsonTestCase; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.ExtractResourceSCM; - - -import hudson.Launcher; -import hudson.model.BuildListener; - -import java.io.IOException; - -/** - * @author Andrew Bayer - */ -public class MavenEmptyModuleTest extends HudsonTestCase { - /** - * Verify that a build will work with a module and a module - */ - @Bug(4442) - public void testEmptyModuleParsesAndBuilds() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-empty-mod.zip"))); - buildAndAssertSuccess(m); - } - - private static class TestReporter extends MavenReporter { - private static final long serialVersionUID = 1L; - - @Override - public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { - assertNotNull(build.getWorkspace()); - return true; - } - } -} \ No newline at end of file diff --git a/test/src/test/java/hudson/maven/MavenEnvironmentContributingActionTest.java b/test/src/test/java/hudson/maven/MavenEnvironmentContributingActionTest.java deleted file mode 100644 index 414a0c515679113c59e288840d862479d50a0b78..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenEnvironmentContributingActionTest.java +++ /dev/null @@ -1,143 +0,0 @@ -package hudson.maven; - -import hudson.EnvVars; -import hudson.Extension; -import hudson.Launcher; -import hudson.model.Action; -import hudson.model.BuildListener; -import hudson.model.EnvironmentContributingAction; -import hudson.model.InvisibleAction; -import hudson.model.Result; -import hudson.model.AbstractBuild; -import hudson.model.AbstractProject; -import hudson.model.Cause; -import hudson.tasks.BuildWrapper; -import hudson.tasks.BuildWrapperDescriptor; -import hudson.util.ArgumentListBuilder; - -import java.io.IOException; -import java.util.Collection; -import java.util.Collections; - -import net.sf.json.JSONObject; - -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.JenkinsRule; -import org.kohsuke.stapler.StaplerRequest; - -/** - * This test case verifies that a maven build also takes EnvironmentContributingAction into account to resolve variables on the command line - * - * @see EnvironmentContributingAction - * @author Dominik Bartholdi (imod) - */ -public class MavenEnvironmentContributingActionTest { - - @Rule - public JenkinsRule j = new JenkinsRule(); - - @Test - @Bug(17555) - public void envVariableFromEnvironmentContributingActionMustBeAvailableInMavenModuleSetBuild() throws Exception { - j.jenkins.getInjector().injectMembers(this); - - final MavenModuleSet p = j.createMavenProject("mvn"); - - p.setMaven(j.configureMaven3().getName()); - p.setScm(new ExtractResourceSCM(getClass().getResource("maven3-project.zip"))); - p.setGoals("initialize -Dval=${KEY}"); - - p.getBuildWrappersList().add(new TestMvnBuildWrapper("-Dval=MY_VALUE")); - - j.assertBuildStatus(Result.SUCCESS, p.scheduleBuild2(0, new Cause.UserIdCause()).get()); - } - - /** - * This action contributes env variables - */ - private static final class TestAction extends InvisibleAction implements EnvironmentContributingAction { - private final String key, value; - - public TestAction(String key, String value) { - this.key = key; - this.value = value; - } - - @Override - public void buildEnvVars(AbstractBuild arg0, EnvVars vars) { - vars.put(key, value); - } - - } - - /** - * This action verifies that the variable in the maven arguments got replaced - */ - private static class MvnCmdLineVerifier extends InvisibleAction implements MavenArgumentInterceptorAction { - private String containsString; - - public MvnCmdLineVerifier(String containsString) { - this.containsString = containsString; - } - - @Override - public ArgumentListBuilder intercept(ArgumentListBuilder cli, MavenModuleSetBuild arg1) { - String all = cli.toString(); - Assert.assertTrue(containsString + " was not found in the goals arguments", all.contains(containsString)); - return cli; - } - - @Override - public String getGoalsAndOptions(MavenModuleSetBuild arg0) { - return null; - } - } - - /** - * This wrapper adds a EnvironmentContributingAction to the build (see TestAction) and also adds the MvnCmdLineVerifier to the build to test whether the variable really got replaced - */ - public static class TestMvnBuildWrapper extends BuildWrapper { - private String containsString; - - public TestMvnBuildWrapper(String expectedString) { - this.containsString = expectedString; - } - - @Override - public Collection getProjectActions(AbstractProject job) { - return Collections.singletonList(new TestAction("KEY", "MY_VALUE")); - } - - @Override - public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { - - build.addAction(new MvnCmdLineVerifier(containsString)); - - return new BuildWrapper.Environment() { - }; - } - - @Extension - public static class TestMvnBuildWrapperDescriptor extends BuildWrapperDescriptor { - @Override - public boolean isApplicable(AbstractProject project) { - return true; - } - - @Override - public BuildWrapper newInstance(StaplerRequest req, JSONObject formData) { - throw new UnsupportedOperationException(); - } - - @Override - public String getDisplayName() { - return this.getClass().getName(); - } - } - } - -} diff --git a/test/src/test/java/hudson/maven/MavenJellyTest.java b/test/src/test/java/hudson/maven/MavenJellyTest.java deleted file mode 100644 index d50136286265c3f2ff0dbfb523e3b275dc5c98cc..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenJellyTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.remoting.Which; -import junit.framework.Test; -import junit.framework.TestCase; -import org.jvnet.hudson.test.JellyTestSuiteBuilder; - -/** - * 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),true); - } -} diff --git a/test/src/test/java/hudson/maven/MavenModuleSetTest.java b/test/src/test/java/hudson/maven/MavenModuleSetTest.java deleted file mode 100644 index 2b379d7c017fc0f7825a1b42ebf50542a1f8c345..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenModuleSetTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package hudson.maven; - -import hudson.maven.local_repo.PerJobLocalRepositoryLocator; -import hudson.model.Item; -import org.jvnet.hudson.test.Bug; - -import org.jvnet.hudson.test.HudsonTestCase; - -/** - * @author Kohsuke Kawaguchi - */ -public class MavenModuleSetTest extends HudsonTestCase { - public void testConfigRoundtripLocalRepository() throws Exception { - MavenModuleSet p = createMavenProject(); - configRoundtrip((Item) p); - - assertNull(p.getExplicitLocalRepository()); - - // make sure it roundtrips - PerJobLocalRepositoryLocator before = new PerJobLocalRepositoryLocator(); - p.setLocalRepository(before); - configRoundtrip((Item)p); - assertEqualDataBoundBeans(p.getLocalRepository(),before); - assertTrue(before!=p.getLocalRepository()); - } - - @Bug(17402) - public void testGetItem() throws Exception { - assertNull(createMavenProject().getItem("invalid")); - } - -} diff --git a/test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifactsTest.java b/test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifactsTest.java deleted file mode 100644 index 114c78355252abccc5c59d34ffb6417d3a022921..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifactsTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * - */ -package hudson.maven; - -import hudson.FilePath; -import hudson.Launcher; -import hudson.maven.reporters.MavenFingerprinter; -import hudson.model.BuildListener; -import hudson.tasks.LogRotator; -import hudson.tasks.Maven.MavenInstallation; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; - -import org.apache.commons.io.FileUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.ExtractResourceWithChangesSCM; -import org.jvnet.hudson.test.For; -import org.jvnet.hudson.test.JenkinsRule; - -/** - * - * Test that looks in jobs archive with 2 builds. When LogRotator set as build - * discarder with settings to keep only 1 build with artifacts, test searches - * for jars in archive for build one and build two, expecting no jars in build 1 - * and expecting jars in build 2. - * - * - */ -public class MavenMultiModuleLogRotatorCleanArtifactsTest { - - - @Rule - public JenkinsRule j = new JenkinsRule(); - private MavenModuleSet m; - private FilePath jobs; - - private static class TestReporter extends MavenReporter { - /** - * - */ - private static final long serialVersionUID = 1L; - - @Override - public boolean end(MavenBuild build, Launcher launcher, - BuildListener listener) throws InterruptedException, - IOException { - Assert.assertNotNull(build.getProject().getSomeWorkspace()); - Assert.assertNotNull(build.getWorkspace()); - return true; - } - } - - @Before - public void setUp() throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - m = j.createMavenProject(); - m.setBuildDiscarder(new LogRotator("-1", "2", "-1", "1")); - m.getReporters().add(new TestReporter()); - m.getReporters().add(new MavenFingerprinter()); - m.setScm(new ExtractResourceWithChangesSCM(getClass().getResource( - "maven-multimod.zip"), getClass().getResource( - "maven-multimod-changes.zip"))); - j.buildAndAssertSuccess(m); - // Now run a second build with the changes. - m.setIncrementalBuild(false); - j.buildAndAssertSuccess(m); - FilePath workspace = m.getSomeWorkspace(); - FilePath parent = workspace.getParent().getParent(); - jobs = new FilePath(parent, "jobs"); - } - - @Test - @Bug(17508) - @For({MavenModuleSetBuild.class, LogRotator.class}) - @SuppressWarnings("unchecked") - public void testArtifactsAreDeletedInBuildOneWhenBuildDiscarderRun() - throws Exception { - File directory = new File(new FilePath(jobs, "test0/builds/1").getRemote()); - Collection files = FileUtils.listFiles(directory, - new String[] { "jar" }, true); - Assert.assertTrue( - "Found jars in previous build, that should not happen", - files.isEmpty()); - Collection files2 = FileUtils.listFiles(new File(new FilePath( - jobs, "test0/builds/2").getRemote()), new String[] { "jar" }, true); - Assert.assertFalse("No jars in last build ALERT!", files2.isEmpty()); - } - - /** - * Performs a third build and expecting build one to be deleted - * @throws Exception - */ - @For({MavenModuleSetBuild.class, LogRotator.class}) - @Test - public void testArtifactsOldBuildsDeletedWhenBuildDiscarderRun() - throws Exception { - j.buildAndAssertSuccess(m); - File directory = new File(new FilePath(jobs, "test0/builds/1").getRemote()); - Assert.assertFalse("oops the build should have been deleted", directory.exists()); - } - -} diff --git a/test/src/test/java/hudson/maven/MavenMultiModuleTest.java b/test/src/test/java/hudson/maven/MavenMultiModuleTest.java deleted file mode 100644 index 91137ba10129931e47434cdc410cde14b8989240..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenMultiModuleTest.java +++ /dev/null @@ -1,622 +0,0 @@ -package hudson.maven; - -import com.gargoylesoftware.htmlunit.html.HtmlPage; -import hudson.FilePath; -import hudson.Functions; -import org.junit.Assert; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.ExtractResourceWithChangesSCM; -import org.jvnet.hudson.test.ExtractChangeLogSet; - -import hudson.Launcher; -import hudson.Util; -import hudson.maven.reporters.MavenArtifactRecord; -import hudson.maven.reporters.MavenFingerprinter; -import hudson.model.AbstractBuild; -import hudson.model.BuildListener; -import hudson.model.Job; -import hudson.model.PermalinkProjectAction; -import hudson.model.Result; -import hudson.model.Run; -import hudson.tasks.Fingerprinter.FingerprintAction; -import hudson.tasks.Maven.MavenInstallation; -import java.io.File; - -import java.io.IOException; -import java.util.Collections; -import java.util.Map; -import java.util.TreeMap; -import jenkins.model.ArtifactManager; -import java.util.Set; -import java.util.TreeSet; -import jenkins.model.ArtifactManagerConfiguration; -import jenkins.model.ArtifactManagerFactory; -import jenkins.util.VirtualFile; -import static org.junit.Assert.*; -import org.junit.Assume; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.jvnet.hudson.test.JenkinsRule; - -/** - * @author Andrew Bayer - */ -public class MavenMultiModuleTest { - - @Rule public JenkinsRule j = new JenkinsRule(); - - /** - * NPE in {@code build.getProject().getWorkspace()} for {@link MavenBuild}. - */ - @Bug(4192) - @Test public void multiModMavenWsExists() throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = j.createMavenProject(); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod.zip"))); - assertFalse("MavenModuleSet.isNonRecursive() should be false", m.isNonRecursive()); - j.buildAndAssertSuccess(m); - } - - @Bug(18846) - @Test public void symlinksUpdated() throws Exception { - Assume.assumeFalse(Functions.isWindows()); - j.configureDefaultMaven(); - MavenModuleSet mms = j.createMavenProject(); - mms.setScm(new ExtractResourceSCM(MavenMultiModuleTest.class.getResource("maven-multimod.zip"))); - j.buildAndAssertSuccess(mms); - MavenModule mm = mms.getModule("org.jvnet.hudson.main.test.multimod:moduleA"); - j.buildAndAssertSuccess(mms); - assertEquals(2, mms.getLastStableBuild().number); - assertEquals(mms.getLastBuild().getId(), Util.resolveSymlink(new File(mms.getRootDir(), "builds/2"))); - assertEquals("2", Util.resolveSymlink(new File(mms.getRootDir(), "builds/lastStableBuild"))); - assertEquals("builds/lastStableBuild", Util.resolveSymlink(new File(mms.getRootDir(), "lastStable"))); - assertEquals("[lastBuild, lastStableBuild, lastSuccessfulBuild]", permalinks(mms).toString()); - assertEquals(2, mm.getLastStableBuild().number); - assertEquals(mm.getLastBuild().getId(), Util.resolveSymlink(new File(mm.getRootDir(), "builds/2"))); - assertEquals("2", Util.resolveSymlink(new File(mm.getRootDir(), "builds/lastStableBuild"))); - assertEquals("builds/lastStableBuild", Util.resolveSymlink(new File(mm.getRootDir(), "lastStable"))); - assertEquals("[lastBuild, lastStableBuild, lastSuccessfulBuild]", permalinks(mm).toString()); - } - private static Set permalinks(Job j) { - Set r = new TreeSet(); - for (PermalinkProjectAction.Permalink l : j.getPermalinks()) { - if (l.resolve(j) != null) { - r.add(l.getId()); - } - } - return r; - } - - @Test public void incrementalMultiModMaven() throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = j.createMavenProject(); - m.getReporters().add(new TestReporter()); - m.getReporters().add(new MavenFingerprinter()); - m.setScm(new ExtractResourceWithChangesSCM(getClass().getResource("maven-multimod.zip"), - getClass().getResource("maven-multimod-changes.zip"))); - - j.buildAndAssertSuccess(m); - - // Now run a second build with the changes. - m.setIncrementalBuild(true); - j.buildAndAssertSuccess(m); - - MavenModuleSetBuild pBuild = m.getLastBuild(); - ExtractChangeLogSet changeSet = (ExtractChangeLogSet) pBuild.getChangeSet(); - - assertFalse("ExtractChangeLogSet should not be empty.", changeSet.isEmptySet()); - - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - String parentModuleName = modBuild.getParent().getModuleName().toString(); - if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleA")) { - assertEquals("moduleA should have Result.NOT_BUILT", Result.NOT_BUILT, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleB")) { - assertEquals("moduleB should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleC")) { - assertEquals("moduleC should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - } - - long summedModuleDuration = 0; - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - summedModuleDuration += modBuild.getDuration(); - } - assertTrue("duration of moduleset build should be greater-equal than sum of the module builds", - pBuild.getDuration() >= summedModuleDuration); - - assertFingerprintWereRecorded(pBuild); - } - - private void assertFingerprintWereRecorded(MavenModuleSetBuild modulesetBuild) { - boolean mustHaveFingerprints = false; - for (MavenBuild moduleBuild : modulesetBuild.getModuleLastBuilds().values()) { - if (moduleBuild.getResult() != Result.NOT_BUILT && moduleBuild.getResult() != Result.ABORTED) { - assertFingerprintWereRecorded(moduleBuild); - mustHaveFingerprints = true; - } - } - - if (mustHaveFingerprints) { - FingerprintAction action = modulesetBuild.getAction(FingerprintAction.class); - Assert.assertNotNull(action); - Assert.assertFalse(action.getFingerprints().isEmpty()); - } - } - - private void assertFingerprintWereRecorded(MavenBuild moduleBuild) { - FingerprintAction action = moduleBuild.getAction(FingerprintAction.class); - Assert.assertNotNull(action); - Assert.assertFalse(action.getFingerprints().isEmpty()); - - MavenArtifactRecord artifactRecord = moduleBuild.getAction(MavenArtifactRecord.class); - Assert.assertNotNull(artifactRecord); - String fingerprintName = artifactRecord.mainArtifact.groupId + ":" + artifactRecord.mainArtifact.fileName; - - Assert.assertTrue("Expected fingerprint " + fingerprintName + " in module build " + moduleBuild, - action.getFingerprints().containsKey(fingerprintName)); - - // we should assert more - i.e. that all dependencies are fingerprinted, too, - // but it's complicated to find out the dependencies of the build - } - - @Bug(5357) - @Test public void incrRelMultiModMaven() throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = j.createMavenProject(); - m.setRootPOM("parent/pom.xml"); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceWithChangesSCM(getClass().getResource("maven-multimod-rel-base.zip"), - getClass().getResource("maven-multimod-changes.zip"))); - - j.buildAndAssertSuccess(m); - - // Now run a second build with the changes. - m.setIncrementalBuild(true); - j.buildAndAssertSuccess(m); - - MavenModuleSetBuild pBuild = m.getLastBuild(); - ExtractChangeLogSet changeSet = (ExtractChangeLogSet) pBuild.getChangeSet(); - - assertFalse("ExtractChangeLogSet should not be empty.", changeSet.isEmptySet()); - - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - String parentModuleName = modBuild.getParent().getModuleName().toString(); - if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleA")) { - assertEquals("moduleA should have Result.NOT_BUILT", Result.NOT_BUILT, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleB")) { - assertEquals("moduleB should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleC")) { - assertEquals("moduleC should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - } - - long summedModuleDuration = 0; - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - summedModuleDuration += modBuild.getDuration(); - } - assertTrue("duration of moduleset build should be greater-equal than sum of the module builds", - pBuild.getDuration() >= summedModuleDuration); - } - - - @Bug(6544) - @Ignore("kutzi 10/10/11 ignore test until I can figure out why it fails sometimes") - @Test public void estimatedDurationForIncrementalMultiModMaven() - throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = j.createMavenProject(); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceWithChangesSCM(getClass().getResource( - "maven-multimod.zip"), getClass().getResource( - "maven-multimod-changes.zip"))); - - j.buildAndAssertSuccess(m); - - // Now run a second, incremental build with the changes. - m.setIncrementalBuild(true); - j.buildAndAssertSuccess(m); - - MavenModuleSetBuild lastBuild = m.getLastBuild(); - MavenModuleSetBuild previousBuild = lastBuild.getPreviousBuild(); - assertNull("There should be only one previous build", previousBuild.getPreviousBuild()); - - // Since the estimated duration is calculated based on the previous builds - // and there was only one previous build (which built all modules) and this build - // did only build one module, the estimated duration of this build must be - // smaller than the duration of the previous build. - // (It's highly unlikely that the durations are equal, but I've already seen it fail. - // Therefore <= instead of <) - assertTrue("Estimated duration should be <= " + previousBuild.getDuration() - + ", but is " + lastBuild.getEstimatedDuration(), - lastBuild.getEstimatedDuration() <= previousBuild.getDuration()); - } - - /** - * NPE in {@code getChangeSetFor(m)} in {@link MavenModuleSetBuild} when incremental build is - * enabled and a new module is added. - */ - @Test public void newModMultiModMaven() throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = j.createMavenProject(); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceWithChangesSCM(getClass().getResource("maven-multimod.zip"), - getClass().getResource("maven-multimod-changes.zip"))); - - m.setIncrementalBuild(true); - j.buildAndAssertSuccess(m); - } - - /** - * When "-N' or "--non-recursive" show up in the goals, any child modules should be ignored. - */ - @Bug(4491) - @Test public void multiModMavenNonRecursiveParsing() throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = j.createMavenProject(); - m.setGoals("clean install -N"); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod.zip"))); - - j.buildAndAssertSuccess(m); - - MavenModuleSetBuild pBuild = m.getLastBuild(); - - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - String parentModuleName = modBuild.getParent().getModuleName().toString(); - if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:multimod-top")) { - assertEquals("moduleA should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleA")) { - assertEquals("moduleA should have Result.NOT_BUILT", Result.NOT_BUILT, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleB")) { - assertEquals("moduleB should have Result.NOT_BUILT", Result.NOT_BUILT, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleC")) { - assertEquals("moduleC should have Result.NOT_BUILT", Result.NOT_BUILT, modBuild.getResult()); - } - - } - - } - - /** - * Module failures in build X should lead to those modules being re-run in build X+1, even if - * incremental build is enabled and nothing changed in those modules. - */ - @Bug(4152) - @Test public void incrementalMultiModWithErrorsMaven() throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = j.createMavenProject(); - m.setIncrementalBuild(true); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceWithChangesSCM(getClass().getResource("maven-multimod-incr.zip"), - getClass().getResource("maven-multimod-changes.zip"))); - - j.assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); - MavenModuleSetBuild pBuild = m.getLastBuild(); - - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - String parentModuleName = modBuild.getParent().getModuleName().toString(); - if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleA")) { - assertEquals("moduleA should have Result.UNSTABLE", Result.UNSTABLE, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleB")) { - assertEquals("moduleB should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleC")) { - assertEquals("moduleC should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleD")) { - assertEquals("moduleD should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - } - - // Now run a second build with the changes. - j.assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); - - pBuild = m.getLastBuild(); - ExtractChangeLogSet changeSet = (ExtractChangeLogSet) pBuild.getChangeSet(); - - assertFalse("ExtractChangeLogSet should not be empty.", changeSet.isEmptySet()); - // changelog contains a change for module B - assertEquals("Parent build should have Result.UNSTABLE", Result.UNSTABLE, pBuild.getResult()); - - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - String parentModuleName = modBuild.getParent().getModuleName().toString(); - // A must be build again, because it was UNSTABLE before - if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleA")) { - assertEquals("moduleA should have Result.UNSTABLE", Result.UNSTABLE, modBuild.getResult()); - } - // B must be build, because it has changes - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleB")) { - assertEquals("moduleB should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - // C must be build, because it depends on B - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleC")) { - assertEquals("moduleC should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - // D must not be build - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleD")) { - assertEquals("moduleD should have Result.NOT_BUILT", Result.NOT_BUILT, modBuild.getResult()); - } - } - } - - /** - * If "deploy modules" is checked and aggregator build failed - * then all modules build this time, have to be build next time, again. - */ - @Bug(5121) - @Test public void incrementalRedeployAfterAggregatorError() throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = j.createMavenProject(); - m.setIncrementalBuild(true); - m.getReporters().add(new TestReporter()); - m.getPublishers().add(new DummyRedeployPublisher()); - m.setScm(new ExtractResourceWithChangesSCM(getClass().getResource("maven-multimod-incr.zip"), - getClass().getResource("maven-multimod-changes.zip"))); - - j.assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); - MavenModuleSetBuild pBuild = m.getLastBuild(); - - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - String parentModuleName = modBuild.getParent().getModuleName().toString(); - if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleA")) { - assertEquals("moduleA should have Result.UNSTABLE", Result.UNSTABLE, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleB")) { - assertEquals("moduleB should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleC")) { - assertEquals("moduleC should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleD")) { - assertEquals("moduleD should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - } - - // Now run a second build. - j.assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); - - pBuild = m.getLastBuild(); - ExtractChangeLogSet changeSet = (ExtractChangeLogSet) pBuild.getChangeSet(); - - assertFalse("ExtractChangeLogSet should not be empty.", changeSet.isEmptySet()); - // changelog contains a change for module B - assertEquals("Parent build should have Result.UNSTABLE", Result.UNSTABLE, pBuild.getResult()); - - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - String parentModuleName = modBuild.getParent().getModuleName().toString(); - // A must be build again, because it was UNSTABLE before - if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleA")) { - assertEquals("moduleA should have Result.UNSTABLE", Result.UNSTABLE, modBuild.getResult()); - } - // B must be build, because it has changes - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleB")) { - assertEquals("moduleB should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - // C must be build, because it depends on B - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleC")) { - assertEquals("moduleC should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - // D must be build again, because it needs to be deployed now - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleD")) { - assertEquals("moduleD should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - } - } - - /** - * Test failures in a child module should lead to the parent being marked as unstable. - */ - @Bug(4378) - @Test public void multiModWithTestFailuresMaven() throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = j.createMavenProject(); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod-incr.zip"))); - - j.assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); - - MavenModuleSetBuild pBuild = m.getLastBuild(); - - assertEquals("Parent build should have Result.UNSTABLE", Result.UNSTABLE, pBuild.getResult()); - - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - String parentModuleName = modBuild.getParent().getModuleName().toString(); - if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleA")) { - assertEquals("moduleA should have Result.UNSTABLE", Result.UNSTABLE, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleB")) { - assertEquals("moduleB should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleC")) { - assertEquals("moduleC should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:moduleD")) { - assertEquals("moduleD should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - } - } - - @Bug(8484) - @Test public void multiModMavenNonRecursive() throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = j.createMavenProject(); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod.zip"))); - m.setGoals( "-N validate" ); - assertTrue("MavenModuleSet.isNonRecursive() should be true", m.isNonRecursive()); - j.buildAndAssertSuccess(m); - assertEquals("not only one module", 1, m.getModules().size()); - } - - @Bug(17713) - @Test public void modulesPageLinks() throws Exception { - j.configureMaven3(); - MavenModuleSet ms = j.createMavenProject(); - ms.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod.zip"))); - j.buildAndAssertSuccess(ms); - MavenModule m = ms.getModule("org.jvnet.hudson.main.test.multimod:moduleA"); - assertNotNull(m); - assertEquals(1, m.getLastBuild().getNumber()); - JenkinsRule.WebClient wc = j.createWebClient(); - HtmlPage modulesPage = wc.getPage(ms, "modules"); - modulesPage.getAnchorByText(m.getDisplayName()).openLinkInNewWindow(); - } - - @Bug(17236) - @Test public void artifactArchiving() throws Exception { - ArtifactManagerConfiguration.get().getArtifactManagerFactories().add(new TestAMF()); - j.configureDefaultMaven(); // using Maven 2 so we can test single-module builds - MavenModuleSet mms = j.createMavenProject(); - mms.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod.zip"))); - mms.setAssignedNode(j.createOnlineSlave()); - j.buildAndAssertSuccess(mms); - // We want all the artifacts in a given module to be archived in one operation. But modules are archived separately. - Map> expected = new TreeMap>(); - FilePath ws = mms.getModule("org.jvnet.hudson.main.test.multimod$multimod-top").getBuildByNumber(1).getWorkspace(); - expected.put("org.jvnet.hudson.main.test.multimod:multimod-top", Collections.singletonMap("org.jvnet.hudson.main.test.multimod/multimod-top/1.0-SNAPSHOT/multimod-top-1.0-SNAPSHOT.pom", new FilePath(ws.getChannel(), "…/org/jvnet/hudson/main/test/multimod/multimod-top/1.0-SNAPSHOT/multimod-top-1.0-SNAPSHOT.pom"))); - for (String module : new String[] {"moduleA", "moduleB", "moduleC"}) { - Map m = new TreeMap(); - ws = mms.getModule("org.jvnet.hudson.main.test.multimod$" + module).getBuildByNumber(1).getWorkspace(); - m.put("org.jvnet.hudson.main.test.multimod/" + module + "/1.0-SNAPSHOT/" + module + "-1.0-SNAPSHOT.pom", ws.child("pom.xml")); - m.put("org.jvnet.hudson.main.test.multimod/" + module + "/1.0-SNAPSHOT/" + module + "-1.0-SNAPSHOT.jar", ws.child("target/" + module + "-1.0-SNAPSHOT.jar")); - expected.put("org.jvnet.hudson.main.test.multimod:" + module, m); - } - assertEquals(expected.toString(), TestAM.archivings.toString()); // easy to read - assertEquals(expected, TestAM.archivings); // compares also FileChannel - // Also check single-module build. - expected.clear(); - TestAM.archivings.clear(); - MavenBuild isolated = j.buildAndAssertSuccess(mms.getModule("org.jvnet.hudson.main.test.multimod$moduleA")); - assertEquals(2, isolated.number); - Map m = new TreeMap(); - ws = isolated.getWorkspace(); - m.put("org.jvnet.hudson.main.test.multimod/moduleA/1.0-SNAPSHOT/moduleA-1.0-SNAPSHOT.pom", ws.child("pom.xml")); - m.put("org.jvnet.hudson.main.test.multimod/moduleA/1.0-SNAPSHOT/moduleA-1.0-SNAPSHOT.jar", ws.child("target/moduleA-1.0-SNAPSHOT.jar")); - expected.put("org.jvnet.hudson.main.test.multimod:moduleA", m); - assertEquals(expected, TestAM.archivings); - } - - public static final class TestAMF extends ArtifactManagerFactory { - @Override public ArtifactManager managerFor(Run build) { - return new TestAM(build); - } - } - public static final class TestAM extends ArtifactManager { - static final Map> archivings = new TreeMap>(); - transient Run build; - TestAM(Run build) { - onLoad(build); - } - @Override public void onLoad(Run build) { - this.build = build; - } - @Override public void archive(FilePath workspace, Launcher launcher, BuildListener listener, Map artifacts) throws IOException, InterruptedException { - String name = build.getParent().getName(); - if (archivings.containsKey(name)) { - // Would be legitimate only if some archived files for a given module were outside workspace, such as repository parent POM, *and* others were inside, which is not the case in this test. - throw new IOException("repeated archiving to " + name); - } - Map m = new TreeMap(); - for (Map.Entry e : artifacts.entrySet()) { - FilePath f = workspace.child(e.getValue()); - if (f.exists()) { - if (f.getRemote().replace('\\', '/').contains("/org/jvnet/hudson/main/test/")) { - // Inside the local repository. Hard to know exactly what that path might be, so just mask it out. - f = new FilePath(f.getChannel(), f.getRemote().replaceFirst("^.+(?=[/\\\\]org[/\\\\]jvnet[/\\\\]hudson[/\\\\]main[/\\\\]test[/\\\\])", "…")); - } - m.put(e.getKey(), f); - } else { - throw new IOException("no such file " + f); - } - } - archivings.put(name, m); - } - @Override public boolean delete() throws IOException, InterruptedException { - throw new IOException(); - } - @Override public VirtualFile root() { - throw new UnsupportedOperationException(); - } - } - - /* - @Test public void parallelMultiModMavenWsExists() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setAggregatorStyleBuild(false); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod.zip"))); - assertBuildStatusSuccess(m.scheduleBuild2(0).get()); - - for (MavenModule mod : m.sortedActiveModules) { - while (mod.getLastBuild() == null) { - Thread.sleep(500); - } - - while (mod.getLastBuild().isBuilding()) { - Thread.sleep(500); - } - - assertBuildStatusSuccess(mod.getLastBuild()); - } - - - - } - - @Test public void privateRepoParallelMultiModMavenWsExists() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setAggregatorStyleBuild(false); - m.setUsePrivateRepository(true); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod.zip"))); - assertBuildStatusSuccess(m.scheduleBuild2(0).get()); - - for (MavenModule mod : m.sortedActiveModules) { - while (mod.getLastBuild() == null) { - Thread.sleep(500); - } - - while (mod.getLastBuild().isBuilding()) { - Thread.sleep(500); - } - - assertBuildStatusSuccess(mod.getLastBuild()); - } - - } - */ - private static class TestReporter extends MavenReporter { - @Override - public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { - assertNotNull(build.getProject().getWorkspace()); - assertNotNull(build.getWorkspace()); - return true; - } - } - - private static class DummyRedeployPublisher extends RedeployPublisher { - public DummyRedeployPublisher() { - super("", "", false, false); - } - - @Override - public boolean perform(AbstractBuild build, Launcher launcher, - BuildListener listener) throws InterruptedException, - IOException { - return true; - } - } -} diff --git a/test/src/test/java/hudson/maven/MavenMultiModuleTestIncremental.java b/test/src/test/java/hudson/maven/MavenMultiModuleTestIncremental.java deleted file mode 100755 index 2ebaee49c2041b5c51099081cf6715acbbff42e3..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenMultiModuleTestIncremental.java +++ /dev/null @@ -1,70 +0,0 @@ -package hudson.maven; - -import hudson.Launcher; -import hudson.model.BuildListener; -import hudson.model.Result; -import hudson.tasks.Maven.MavenInstallation; - -import java.io.IOException; - -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.ExtractChangeLogSet; -import org.jvnet.hudson.test.ExtractResourceWithChangesSCM; -import org.jvnet.hudson.test.HudsonTestCase; - -/** - * @author Andrew Bayer - */ -public class MavenMultiModuleTestIncremental extends HudsonTestCase { - - @Bug(7684) - public void testRelRootPom() throws Exception { - configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = createMavenProject(); - m.setRootPOM("parent/pom.xml"); - m.getReporters().add(new TestReporter()); - m.setScm(new ExtractResourceWithChangesSCM(getClass().getResource("maven-multimod-rel-base.zip"), - getClass().getResource("maven-multimod-changes.zip"))); - - buildAndAssertSuccess(m); - - // Now run a second build with the changes. - m.setIncrementalBuild(true); - buildAndAssertSuccess(m); - - MavenModuleSetBuild pBuild = m.getLastBuild(); - ExtractChangeLogSet changeSet = (ExtractChangeLogSet) pBuild.getChangeSet(); - - assertFalse("ExtractChangeLogSet should not be empty.", changeSet.isEmptySet()); - - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - String parentModuleName = modBuild.getParent().getModuleName().toString(); - if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleA")) { - assertEquals("moduleA should have Result.NOT_BUILT", Result.NOT_BUILT, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleB")) { - assertEquals("moduleB should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod:moduleC")) { - assertEquals("moduleC should have Result.SUCCESS", Result.SUCCESS, modBuild.getResult()); - } - } - - long summedModuleDuration = 0; - for (MavenBuild modBuild : pBuild.getModuleLastBuilds().values()) { - summedModuleDuration += modBuild.getDuration(); - } - assertTrue("duration of moduleset build should be greater-equal than sum of the module builds", - pBuild.getDuration() >= summedModuleDuration); - } - - private static class TestReporter extends MavenReporter { - private static final long serialVersionUID = 1L; - - @Override - public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { - assertNotNull(build.getWorkspace()); - return true; - } - } -} diff --git a/test/src/test/java/hudson/maven/MavenOptsTest.java b/test/src/test/java/hudson/maven/MavenOptsTest.java deleted file mode 100644 index a86bd1969a60732421c0cbc2fb294ccd294bc6db..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenOptsTest.java +++ /dev/null @@ -1,127 +0,0 @@ -package hudson.maven; - -import hudson.maven.MavenModuleSet.DescriptorImpl; -import org.jvnet.hudson.test.HudsonTestCase; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.ExtractResourceSCM; -import hudson.EnvVars; -import hudson.model.Result; -import hudson.tasks.Maven.MavenInstallation; - -/** - * @author Andrew Bayer - */ -public class MavenOptsTest extends HudsonTestCase { - DescriptorImpl d; - - @Override - protected void setUp() throws Exception { - super.setUp(); - d = jenkins.getDescriptorByType(DescriptorImpl.class); - } - - @Override - protected void tearDown() throws Exception { - d.setGlobalMavenOpts(null); - super.tearDown(); - } - - public void testEnvMavenOptsNoneInProject() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-opts-echo.zip"))); - m.setGoals("validate"); - m.setAssignedLabel(createSlave(new EnvVars("MAVEN_OPTS", "-Dhudson.mavenOpt.test=foo")).getSelfLabel()); - - buildAndAssertSuccess(m); - - assertLogContains("[hudson.mavenOpt.test=foo]", m.getLastBuild()); - } - - - public void testEnvMavenOptsOverriddenByProject() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-opts-echo.zip"))); - m.setGoals("validate"); - m.setMavenOpts("-Dhudson.mavenOpt.test=bar"); - m.setAssignedLabel(createSlave(new EnvVars("MAVEN_OPTS", "-Dhudson.mavenOpt.test=foo")).getSelfLabel()); - - buildAndAssertSuccess(m); - - assertLogContains("[hudson.mavenOpt.test=bar]", m.getLastBuild()); - } - - public void testEnvAndGlobalMavenOptsOverriddenByProject() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-opts-echo.zip"))); - m.setGoals("validate"); - d.setGlobalMavenOpts("-Dhudson.mavenOpt.test=bar"); - m.setAssignedLabel(createSlave(new EnvVars("MAVEN_OPTS", "-Dhudson.mavenOpt.test=foo")).getSelfLabel()); - m.setMavenOpts("-Dhudson.mavenOpt.test=baz"); - - buildAndAssertSuccess(m); - - assertLogContains("[hudson.mavenOpt.test=baz]", m.getLastBuild()); - } - - - public void testGlobalMavenOpts() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-opts-echo.zip"))); - m.setGoals("validate"); - d.setGlobalMavenOpts("-Dhudson.mavenOpt.test=bar"); - - buildAndAssertSuccess(m); - - assertLogContains("[hudson.mavenOpt.test=bar]", m.getLastBuild()); - } - - public void testGlobalMavenOptsOverridenByProject() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-opts-echo.zip"))); - m.setGoals("validate"); - d.setGlobalMavenOpts("-Dhudson.mavenOpt.test=bar"); - m.setMavenOpts("-Dhudson.mavenOpt.test=foo"); - - buildAndAssertSuccess(m); - - assertLogContains("[hudson.mavenOpt.test=foo]", m.getLastBuild()); - } - - @Bug(5651) - public void testNewlinesInOptsRemoved() throws Exception { - configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet m = createMavenProject(); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-surefire-unstable.zip"))); - m.setMavenOpts("-XX:MaxPermSize=512m\r\n-Xms128m\r\n-Xmx512m"); - m.setGoals("install"); - - assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); - MavenModuleSetBuild pBuild = m.getLastBuild(); - - assertEquals("Parent build should have Result.UNSTABLE", Result.UNSTABLE, pBuild.getResult()); - - } - - /** - * Makes sure that environment variables in MAVEN_OPTS are properly expanded. - */ - public void testEnvironmentVariableExpansion() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setMavenOpts("$FOO"); - m.setScm(new ExtractResourceSCM(getClass().getResource("maven-opts-echo.zip"))); - m.setGoals("validate"); - m.setAssignedLabel(createSlave(new EnvVars("FOO", "-Dhudson.mavenOpt.test=foo -Dhudson.mavenOpt.test2=bar")).getSelfLabel()); - - buildAndAssertSuccess(m); - - assertLogContains("[hudson.mavenOpt.test=foo]", m.getLastBuild()); - } - -} - diff --git a/test/src/test/java/hudson/maven/MavenProjectTest.java b/test/src/test/java/hudson/maven/MavenProjectTest.java deleted file mode 100644 index 0fbfd3ead37df9525ea4700468e78dc438e556e1..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenProjectTest.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-2010, 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.maven.local_repo.DefaultLocalRepositoryLocator; -import hudson.maven.local_repo.PerJobLocalRepositoryLocator; -import hudson.model.AbstractProject; -import hudson.model.Item; -import hudson.model.Result; -import hudson.tasks.Maven.MavenInstallation; -import hudson.tasks.Shell; - -import java.io.File; - -import jenkins.model.Jenkins; -import jenkins.mvn.DefaultGlobalSettingsProvider; -import jenkins.mvn.DefaultSettingsProvider; -import jenkins.mvn.FilePathGlobalSettingsProvider; -import jenkins.mvn.FilePathSettingsProvider; -import jenkins.mvn.GlobalMavenConfig; - -import org.junit.Assert; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.HudsonTestCase; - -import java.net.HttpURLConnection; - -/** - * @author huybrechts - */ -public class MavenProjectTest extends HudsonTestCase { - - - public void testOnMaster() throws Exception { - MavenModuleSet project = createSimpleProject(); - project.setGoals("validate"); - - buildAndAssertSuccess(project); - } - - @Bug(16499) - public void testCopyFromExistingMavenProject() throws Exception { - MavenModuleSet project = createSimpleProject(); - project.setGoals("abcdefg"); - project.save(); - - MavenModuleSet copy = (MavenModuleSet) Jenkins.getInstance().copy((AbstractProject)project, "copy" + System.currentTimeMillis()); - assertNotNull("Copied project must not be null", copy); - assertEquals(project.getGoals(), copy.getGoals()); - } - - private MavenModuleSet createSimpleProject() throws Exception { - return createProject("/simple-projects.zip"); - } - - private MavenModuleSet createProject(final String scmResource) throws Exception { - MavenModuleSet project = createMavenProject(); - MavenInstallation mi = configureDefaultMaven(); - project.setScm(new ExtractResourceSCM(getClass().getResource( - scmResource))); - project.setMaven(mi.getName()); - project.setLocalRepository(new PerJobLocalRepositoryLocator()); - return project; - } - - public void testOnSlave() throws Exception { - MavenModuleSet project = createSimpleProject(); - project.setGoals("validate"); - project.setAssignedLabel(createSlave().getSelfLabel()); - - buildAndAssertSuccess(project); - } - - /** - * Check if the generated site is linked correctly. - */ - @Bug(3497) - public void testSiteBuild() throws Exception { - MavenModuleSet project = createSimpleProject(); - project.setGoals("site"); - - buildAndAssertSuccess(project); - - // this should succeed - HudsonTestCase.WebClient wc = new WebClient(); - wc.getPage(project,"site"); - wc.assertFails(project.getUrl() + "site/no-such-file", HttpURLConnection.HTTP_NOT_FOUND); - } - - /** - * Check if the generated site is linked correctly for multi module projects. - */ - public void testMultiModuleSiteBuild() throws Exception { - MavenModuleSet project = createProject("maven-multimodule-site.zip"); - project.setGoals("site"); - - buildAndAssertSuccess(project); - - // this should succeed - HudsonTestCase.WebClient wc = new WebClient(); - wc.getPage(project, "site"); - wc.getPage(project, "site/core"); - wc.getPage(project, "site/client"); - - //@Bug(7577): check that site generation succeeds also if only a single module is build - MavenModule coreModule = project.getModule("mmtest:core"); - Assert.assertEquals("site", coreModule.getGoals()); - buildAndAssertSuccess(coreModule); - wc.getPage(project, "site/core"); - } - - /** - * Check if the the site goal will work when run from a slave. - */ - @Bug(5943) - public void testMultiModuleSiteBuildOnSlave() throws Exception { - MavenModuleSet project = createProject("maven-multimodule-site.zip"); - project.setGoals("site"); - project.setAssignedLabel(createSlave().getSelfLabel()); - - buildAndAssertSuccess(project); - - // this should succeed - HudsonTestCase.WebClient wc = new WebClient(); - wc.getPage(project, "site"); - wc.getPage(project, "site/core"); - wc.getPage(project, "site/client"); - } - - @Bug(6779) - public void testDeleteSetBuildDeletesModuleBuilds() throws Exception { - MavenModuleSet project = createProject("maven-multimod.zip"); - project.setLocalRepository(new DefaultLocalRepositoryLocator()); - project.setGoals("install"); - buildAndAssertSuccess(project); - buildAndAssertSuccess(project.getModule("org.jvnet.hudson.main.test.multimod:moduleB")); - buildAndAssertSuccess(project); - assertEquals(2, project.getBuilds().size()); // Module build does not add a ModuleSetBuild - project.getFirstBuild().delete(); - // A#1, B#1 and B#2 should all be deleted too - assertEquals(1, project.getModule("org.jvnet.hudson.main.test.multimod:moduleA").getBuilds().size()); - assertEquals(1, project.getModule("org.jvnet.hudson.main.test.multimod:moduleB").getBuilds().size()); - } - @Bug(7261) - public void testAbsolutePathPom() throws Exception { - File pom = new File(this.getClass().getResource("test-pom-7162.xml").toURI()); - MavenModuleSet project = createMavenProject(); - MavenInstallation mi = configureDefaultMaven(); - project.setMaven(mi.getName()); - project.setRootPOM(pom.getAbsolutePath()); - project.setGoals("install"); - buildAndAssertSuccess(project); - } - - @Bug(17177) - public void testCorrectResultInPostStepAfterFailedPreBuildStep() throws Exception { - MavenModuleSet p = createSimpleProject(); - MavenInstallation mi = configureDefaultMaven(); - p.setMaven(mi.getName()); - p.setGoals("initialize"); - - Shell pre = new Shell("exit 1"); // must fail to simulate scenario! - p.getPrebuilders().add(pre); - ResultExposingBuilder resultExposer = new ResultExposingBuilder(); - p.getPostbuilders().add(resultExposer); - - assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0).get()); - assertEquals("The result passed to the post build step was not the one from the pre build step", Result.FAILURE, resultExposer.getResult()); - } - - - /** - * Config roundtrip test around pre/post build step - */ - public void testConfigRoundtrip() throws Exception { - MavenModuleSet m = createMavenProject(); - Shell b1 = new Shell("1"); - Shell b2 = new Shell("2"); - m.getPrebuilders().add(b1); - m.getPostbuilders().add(b2); - configRoundtrip((Item)m); - - assertEquals(1, m.getPrebuilders().size()); - assertNotSame(b1,m.getPrebuilders().get(Shell.class)); - assertEquals("1",m.getPrebuilders().get(Shell.class).getCommand()); - - assertEquals(1, m.getPostbuilders().size()); - assertNotSame(b2,m.getPostbuilders().get(Shell.class)); - assertEquals("2",m.getPostbuilders().get(Shell.class).getCommand()); - - for (Result r : new Result[]{Result.SUCCESS, Result.UNSTABLE, Result.FAILURE}) { - m.setRunPostStepsIfResult(r); - configRoundtrip((Item)m); - assertEquals(r,m.getRunPostStepsIfResult()); - } - } - - - public void testDefaultSettingsProvider() throws Exception { - { - MavenModuleSet m = createMavenProject(); - - assertNotNull(m); - assertEquals(DefaultSettingsProvider.class, m.getSettings().getClass()); - assertEquals(DefaultGlobalSettingsProvider.class, m.getGlobalSettings().getClass()); - } - - { - GlobalMavenConfig globalMavenConfig = GlobalMavenConfig.get(); - assertNotNull("No global Maven Config available", globalMavenConfig); - globalMavenConfig.setSettingsProvider(new FilePathSettingsProvider("/tmp/settigns.xml")); - globalMavenConfig.setGlobalSettingsProvider(new FilePathGlobalSettingsProvider("/tmp/global-settigns.xml")); - - MavenModuleSet m = createMavenProject(); - assertEquals(FilePathSettingsProvider.class, m.getSettings().getClass()); - assertEquals("/tmp/settigns.xml", ((FilePathSettingsProvider)m.getSettings()).getPath()); - assertEquals("/tmp/global-settigns.xml", ((FilePathGlobalSettingsProvider)m.getGlobalSettings()).getPath()); - } - } -} diff --git a/test/src/test/java/hudson/maven/MavenSnapshotTriggerTest.java b/test/src/test/java/hudson/maven/MavenSnapshotTriggerTest.java deleted file mode 100644 index b898e29b185d61998bed2d37ab87cc8a5bc50e07..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/MavenSnapshotTriggerTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package hudson.maven; - -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.HudsonTestCase; - -/** - * Tests that Maven jobs are triggered, when snapshot dependencies of them were build. - * - * @author Andrew Bayer - */ -public class MavenSnapshotTriggerTest extends HudsonTestCase { - /** - * Verifies dependency build ordering of SNAPSHOT dependency. - * Note - has to build the projects once each first in order to get dependency info. - */ - public void testSnapshotDependencyBuildTrigger() throws Exception { - - configureDefaultMaven(); - MavenModuleSet projA = createMavenProject("snap-dep-test-up"); - projA.setGoals("clean install"); - projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A.zip"))); - MavenModuleSet projB = createMavenProject("snap-dep-test-down"); - projB.setGoals("clean install"); - projB.setIgnoreUpstremChanges(false); - projB.setQuietPeriod(0); - projB.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-B.zip"))); - - buildAndAssertSuccess(projA); - buildAndAssertSuccess(projB); - - projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A-changed.zip"))); - buildAndAssertSuccess(projA); - - // at this point runB2 should be in the queue, so wait until that completes. - waitUntilNoActivityUpTo(90*1000); - assertEquals("Expected most recent build of second project to be #2", 2, projB.getLastBuild().getNumber()); - } - - /** - * Verifies dependency build ordering of multiple SNAPSHOT dependencies. - * Note - has to build the projects once each first in order to get dependency info. - * B depends on A, C depends on A and B. Build order should be A->B->C. - */ - public void testMixedTransitiveSnapshotTrigger() throws Exception { - configureDefaultMaven(); - - MavenModuleSet projA = createMavenProject("snap-dep-test-up"); - projA.setGoals("clean install"); - projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A.zip"))); - - MavenModuleSet projB = createMavenProject("snap-dep-test-mid"); - projB.setGoals("clean install"); - projB.setIgnoreUpstremChanges(false); - projB.setQuietPeriod(0); - projB.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-B.zip"))); - - MavenModuleSet projC = createMavenProject("snap-dep-test-down"); - projC.setGoals("clean install"); - projC.setIgnoreUpstremChanges(false); - projC.setQuietPeriod(0); - projC.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-C.zip"))); - - buildAndAssertSuccess(projA); - buildAndAssertSuccess(projB); - buildAndAssertSuccess(projC); - - projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A-changed.zip"))); - - buildAndAssertSuccess(projA); - - waitUntilNoActivityUpTo(90*1000); // wait until dependency build trickles down - assertEquals("Expected most recent build of second project to be #2", 2, projB.getLastBuild().getNumber()); - assertEquals("Expected most recent build of third project to be #2", 2, projC.getLastBuild().getNumber()); - } -} diff --git a/test/src/test/java/hudson/maven/ModuleDependencyLocator.java b/test/src/test/java/hudson/maven/ModuleDependencyLocator.java deleted file mode 100644 index 88f3620e4aed6e47569e20c0657bd9982fe88b2d..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/ModuleDependencyLocator.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi - * - * 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.ExtensionPoint; -import hudson.ExtensionList; -import hudson.Extension; -import jenkins.model.Jenkins; -import org.apache.maven.project.MavenProject; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -/** - * Extension point in Hudson to find additional dependencies from {@link MavenProject}. - * - *

- * Maven plugin configurations often have additional configuration entries to specify - * artifacts that a build depends on. Plugins can contribute an implementation of - * this interface to find such hidden dependencies. - * - *

- * To register implementations, put {@link Extension} on your subclass. - * - * @author Kohsuke Kawaguchi - * @since 1.264 - * @see HUDSON-2685 - */ -public abstract class ModuleDependencyLocator implements ExtensionPoint { - /** - * Discovers hidden dependencies. - * - * @param project - * In memory representation of Maven project, from which the hidden dependencies will be extracted. - * Never null. - * @param pomInfo - * Partially filled {@link PomInfo} object. Dependencies returned from this method will be - * added to this object by the caller. - */ - public abstract Collection find(MavenProject project, PomInfo pomInfo); - - /** - * Returns all the registered {@link ModuleDependencyLocator} descriptors. - */ - public static ExtensionList all() { - return Jenkins.getInstance().getExtensionList(ModuleDependencyLocator.class); - } - - /** - * Facade of {@link ModuleDependencyLocator}. - */ - /*package*/ static class ModuleDependencyLocatorFacade extends ModuleDependencyLocator { - @Override - public Collection find(MavenProject project, PomInfo pomInfo) { - Set r = new HashSet(); - for (ModuleDependencyLocator m : all()) - r.addAll(m.find(project,pomInfo)); - return r; - } - } -} diff --git a/test/src/test/java/hudson/maven/PlexusModuleContributorTest.java b/test/src/test/java/hudson/maven/PlexusModuleContributorTest.java deleted file mode 100644 index 9c893fe4460c8c08f07c567e00a0bc0cec069131..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/PlexusModuleContributorTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package hudson.maven; - -import hudson.FilePath; -import hudson.model.AbstractBuild; -import hudson.remoting.Which; -import hudson.slaves.DumbSlave; -import hudson.tasks.Maven.MavenInstallation; -import org.junit.Rule; -import org.junit.Test; -import org.jvnet.hudson.test.JenkinsRule; -import org.jvnet.hudson.test.SingleFileSCM; -import org.jvnet.hudson.test.TestExtension; -import test.BogusPlexusComponent; - -import java.io.File; -import java.io.IOException; - -/** - * @author Kohsuke Kawaguchi - */ -public class PlexusModuleContributorTest { - @Rule - public JenkinsRule j = new JenkinsRule(); - - - /** - * Tests the effect of PlexusModuleContributor by trying to parse a POM that uses a custom packaging - * that only exists inside our custom jar. - */ - @Test - public void testCustomPlexusComponent() throws Exception { - j.configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); - MavenModuleSet p = j.createMavenProject(); - p.setScm(new SingleFileSCM("pom.xml",getClass().getResource("custom-plexus-component.pom"))); - p.setGoals("clean"); - j.assertBuildStatusSuccess(p.scheduleBuild2(0)); - } - - @Test - public void testCustomPlexusComponent_Maven3() throws Exception { - j.configureDefaultMaven("apache-maven-3.0.1", MavenInstallation.MAVEN_30); - MavenModuleSet p = j.createMavenProject(); - p.setScm(new SingleFileSCM("pom.xml",getClass().getResource("custom-plexus-component.pom"))); - p.setGoals("clean"); - j.assertBuildStatusSuccess(p.scheduleBuild2(0)); - } - - @Test - public void testCustomPlexusComponent_Maven3_slave() throws Exception { - j.configureDefaultMaven("apache-maven-3.0.1", MavenInstallation.MAVEN_30); - DumbSlave s = j.createSlave(); - s.toComputer().connect(false).get(); - - MavenModuleSet p = j.createMavenProject(); - p.setAssignedLabel(s.getSelfLabel()); - - p.setScm(new SingleFileSCM("pom.xml",getClass().getResource("custom-plexus-component.pom"))); - p.setGoals("clean"); - j.assertBuildStatusSuccess(p.scheduleBuild2(0)); - } - - @TestExtension - public static class PlexusLoader extends PlexusModuleContributorFactory { - @Override - public PlexusModuleContributor createFor(AbstractBuild context) throws IOException, InterruptedException { - File bogusPlexusJar = Which.jarFile(BogusPlexusComponent.class); - final FilePath localJar = context.getBuiltOn().getRootPath().child("cache/bogusPlexus.jar"); - localJar.copyFrom(new FilePath(bogusPlexusJar)); - - return PlexusModuleContributor.of(localJar); - } - } -} diff --git a/test/src/test/java/hudson/maven/RedeployPublisherTest.java b/test/src/test/java/hudson/maven/RedeployPublisherTest.java deleted file mode 100644 index d1d46e8e599eaf2ded4a7ff85124bbd5b5b1086d..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/RedeployPublisherTest.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi - * - * 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.Result; -import hudson.tasks.Maven.MavenInstallation; - -import org.apache.commons.lang.StringUtils; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.SingleFileSCM; -import org.jvnet.hudson.test.Email; - -import java.io.File; -import java.io.FilenameFilter; -import java.util.Arrays; -import static org.junit.Assert.*; -import org.junit.Assume; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.jvnet.hudson.test.JenkinsRule; - -/** - * @author Kohsuke Kawaguchi - */ -public class RedeployPublisherTest { - - @Rule public JenkinsRule j = new JenkinsRule(); - @Rule public TemporaryFolder tmp = new TemporaryFolder(); - - @Bug(2593) - @Test - public void testBug2593() throws Exception { - Assume.assumeFalse("Not a v4.0.0 POM. for project org.jvnet.maven-antrun-extended-plugin:maven-antrun-extended-plugin at /home/jenkins/.m2/repository/org/jvnet/maven-antrun-extended-plugin/maven-antrun-extended-plugin/1.39/maven-antrun-extended-plugin-1.39.pom", "https://jenkins.ci.cloudbees.com/job/core/job/jenkins_main_trunk/".equals(System.getenv("JOB_URL"))); - j.configureDefaultMaven(); - MavenModuleSet m2 = j.createMavenProject(); - File repo = tmp.getRoot(); - - // a fake build - m2.setScm(new SingleFileSCM("pom.xml",getClass().getResource("big-artifact.pom"))); - m2.getPublishersList().add(new RedeployPublisher("",repo.toURI().toString(),true, false)); - - MavenModuleSetBuild b = m2.scheduleBuild2(0).get(); - j.assertBuildStatus(Result.SUCCESS, b); - - // TODO: confirm that the artifacts use a consistent timestamp - // TODO: we need to somehow introduce a large delay between deploy since timestamp is only second precision - // TODO: or maybe we could use a btrace like capability to count the # of invocations? - - System.out.println(repo); - } - - @Test - public void testConfigRoundtrip() throws Exception { - MavenModuleSet p = j.createMavenProject(); - RedeployPublisher rp = new RedeployPublisher("theId", "http://some.url/", true, true); - p.getPublishersList().add(rp); - j.submit(j.new WebClient().getPage(p,"configure").getFormByName("config")); - j.assertEqualBeans(rp,p.getPublishersList().get(RedeployPublisher.class),"id,url,uniqueVersion,evenIfUnstable"); - } - -// /** -// * Makes sure that the webdav wagon component we bundle is compatible. -// */ -// public void testWebDavDeployment() throws Exception { -// configureDefaultMaven(); -// MavenModuleSet m2 = createMavenProject(); -// -// // a fake build -// m2.setScm(new SingleFileSCM("pom.xml",getClass().getResource("big-artifact.pom"))); -// m2.getPublishersList().add(new RedeployPublisher("","dav:http://localhost/dav/",true)); -// -// MavenModuleSetBuild b = m2.scheduleBuild2(0).get(); -// assertBuildStatus(Result.SUCCESS, b); -// } - - /** - * Are we having a problem in handling file names with multiple extensions, like ".tar.gz"? - */ - @Email("http://www.nabble.com/tar.gz-becomes-.gz-after-Hudson-deployment-td25391364.html") - @Bug(3814) - @Test - public void testTarGz() throws Exception { - j.configureDefaultMaven(); - MavenModuleSet m2 = j.createMavenProject(); - File repo = tmp.getRoot(); - - // a fake build - m2.setScm(new SingleFileSCM("pom.xml",getClass().getResource("targz-artifact.pom"))); - m2.getPublishersList().add(new RedeployPublisher("",repo.toURI().toString(),false, false)); - - MavenModuleSetBuild b = m2.scheduleBuild2(0).get(); - j.assertBuildStatus(Result.SUCCESS, b); - - assertTrue("tar.gz doesn't exist",new File(repo,"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT-bin.tar.gz").exists()); - } - - @Test - public void testTarGzUniqueVersionTrue() throws Exception { - j.configureDefaultMaven(); - MavenModuleSet m2 = j.createMavenProject(); - File repo = tmp.getRoot(); - - // a fake build - m2.setScm(new SingleFileSCM("pom.xml",getClass().getResource("targz-artifact.pom"))); - m2.getPublishersList().add(new RedeployPublisher("",repo.toURI().toString(),true, false)); - - MavenModuleSetBuild b = m2.scheduleBuild2(0).get(); - j.assertBuildStatus(Result.SUCCESS, b); - - File artifactDir = new File(repo,"test/test/0.1-SNAPSHOT/"); - String[] files = artifactDir.list( new FilenameFilter() - { - - public boolean accept( File dir, String name ) - { - System.out.print( "deployed file " + name ); - return name.contains( "-bin.tar.gz" ) || name.endsWith( ".jar" ) || name.endsWith( "-bin.zip" ); - } - }); - System.out.println("deployed files " + Arrays.asList( files )); - assertFalse("tar.gz doesn't exist",new File(repo,"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT-bin.tar.gz").exists()); - assertTrue("tar.gz doesn't exist",!files[0].contains( "SNAPSHOT" )); - for (String file : files) { - if (file.endsWith( "-bin.tar.gz" )) { - String ver = StringUtils.remove( file, "-bin.tar.gz" ); - ver = ver.substring( ver.length() - 1, ver.length() ); - assertEquals("-bin.tar.gz not ended with 1 , file " + file , "1", ver); - } - if (file.endsWith( ".jar" )) { - String ver = StringUtils.remove( file, ".jar" ); - ver = ver.substring( ver.length() - 1, ver.length() ); - assertEquals(".jar not ended with 1 , file " + file , "1", ver); - } - if (file.endsWith( "-bin.zip" )) { - String ver = StringUtils.remove( file, "-bin.zip" ); - ver = ver.substring( ver.length() - 1, ver.length() ); - assertEquals("-bin.zip not ended with 1 , file " + file , "1", ver); - } - } - - } - - @Test - public void testTarGzMaven3() throws Exception { - - MavenModuleSet m3 = j.createMavenProject(); - MavenInstallation mvn = j.configureMaven3(); - m3.setMaven( mvn.getName() ); - File repo = tmp.getRoot(); - // a fake build - m3.setScm(new SingleFileSCM("pom.xml",getClass().getResource("targz-artifact.pom"))); - m3.getPublishersList().add(new RedeployPublisher("",repo.toURI().toString(),false, false)); - - MavenModuleSetBuild b = m3.scheduleBuild2(0).get(); - j.assertBuildStatus(Result.SUCCESS, b); - - assertTrue( MavenUtil.maven3orLater( b.getMavenVersionUsed() ) ); - File artifactDir = new File(repo,"test/test/0.1-SNAPSHOT/"); - String[] files = artifactDir.list( new FilenameFilter() - { - - public boolean accept( File dir, String name ) - { - return name.endsWith( "tar.gz" ); - } - }); - assertFalse("tar.gz doesn't exist",new File(repo,"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT-bin.tar.gz").exists()); - assertTrue("tar.gz doesn't exist",!files[0].contains( "SNAPSHOT" )); - } - - @Test - public void testTarGzUniqueVersionTrueMaven3() throws Exception { - MavenModuleSet m3 = j.createMavenProject(); - MavenInstallation mvn = j.configureMaven3(); - m3.setMaven( mvn.getName() ); - File repo = tmp.getRoot(); - // a fake build - m3.setScm(new SingleFileSCM("pom.xml",getClass().getResource("targz-artifact.pom"))); - m3.getPublishersList().add(new RedeployPublisher("",repo.toURI().toString(),true, false)); - - MavenModuleSetBuild b = m3.scheduleBuild2(0).get(); - j.assertBuildStatus(Result.SUCCESS, b); - - assertTrue( MavenUtil.maven3orLater( b.getMavenVersionUsed() ) ); - - File artifactDir = new File(repo,"test/test/0.1-SNAPSHOT/"); - String[] files = artifactDir.list( new FilenameFilter() - { - - public boolean accept( File dir, String name ) - { - return name.contains( "-bin.tar.gz" ) || name.endsWith( ".jar" ) || name.endsWith( "-bin.zip" ); - } - }); - System.out.println("deployed files " + Arrays.asList( files )); - assertFalse("tar.gz doesn't exist",new File(repo,"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT-bin.tar.gz").exists()); - assertTrue("tar.gz doesn't exist",!files[0].contains( "SNAPSHOT" )); - for (String file : files) { - if (file.endsWith( "-bin.tar.gz" )) { - String ver = StringUtils.remove( file, "-bin.tar.gz" ); - ver = ver.substring( ver.length() - 1, ver.length() ); - assertEquals("-bin.tar.gz not ended with 1 , file " + file , "1", ver); - } - if (file.endsWith( ".jar" )) { - String ver = StringUtils.remove( file, ".jar" ); - ver = ver.substring( ver.length() - 1, ver.length() ); - assertEquals(".jar not ended with 1 , file " + file , "1", ver); - } - if (file.endsWith( "-bin.zip" )) { - String ver = StringUtils.remove( file, "-bin.zip" ); - ver = ver.substring( ver.length() - 1, ver.length() ); - assertEquals("-bin.zip not ended with 1 , file " + file , "1", ver); - } - } - } - - @Bug(3773) - @Test - public void testDeployUnstable() throws Exception { - j.configureDefaultMaven(); - MavenModuleSet m2 = j.createMavenProject(); - File repo = tmp.getRoot(); - // a build with a failing unit tests - m2.setScm(new ExtractResourceSCM(getClass().getResource("maven-test-failure-findbugs.zip"))); - m2.getPublishersList().add(new RedeployPublisher("",repo.toURI().toString(),false, true)); - - MavenModuleSetBuild b = m2.scheduleBuild2(0).get(); - j.assertBuildStatus(Result.UNSTABLE, b); - - assertTrue("Artifact should have been published even when the build is unstable", - new File(repo,"test/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.jar").exists()); - } -} diff --git a/test/src/test/java/hudson/maven/ResultExposingBuilder.java b/test/src/test/java/hudson/maven/ResultExposingBuilder.java deleted file mode 100644 index 2bc74dd15d75897f10348f547202f71531865b85..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/ResultExposingBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2013, Dominik Bartholdi - * - * 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.Launcher; -import hudson.model.BuildListener; -import hudson.model.Result; -import hudson.model.AbstractBuild; -import hudson.tasks.Builder; - -import java.io.IOException; - -/** - * @author Dominik Bartholdi (imod) - */ -public class ResultExposingBuilder extends Builder { - private Result result; - - public ResultExposingBuilder() { - } - - @Override - public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { - result = build.getResult(); - return super.perform(build, launcher, listener); - } - - public Result getResult() { - return result; - } -} \ No newline at end of file diff --git a/test/src/test/java/hudson/maven/reporters/MavenMailerTest.java b/test/src/test/java/hudson/maven/reporters/MavenMailerTest.java deleted file mode 100644 index 3c1c727e12c1904cfea8a8703612dd3c5e256036..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/reporters/MavenMailerTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2011, Dominik Bartholdi - * - * 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.reporters; - -import hudson.maven.MavenModuleSet; -import hudson.model.Result; -import hudson.tasks.Mailer; -import hudson.tasks.Mailer.DescriptorImpl; - -import javax.mail.Address; -import javax.mail.internet.InternetAddress; - -import jenkins.model.Jenkins; - -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.HudsonTestCase; -import org.jvnet.mock_javamail.Mailbox; - -/** - * - * @author imod (Dominik Bartholdi) - * - */ -public class MavenMailerTest extends HudsonTestCase { - - @Bug(5695) - public void testMulipleMails() throws Exception { - - // there is one module failing in the build, therefore we expect one mail for the failed module and one for the over all build status - final Mailbox inbox = runMailTest(true); - assertEquals(2, inbox.size()); - - } - - @Bug(5695) - public void testSingleMails() throws Exception { - - final Mailbox inbox = runMailTest(false); - assertEquals(1, inbox.size()); - - } - - public Mailbox runMailTest(boolean perModuleEamil) throws Exception { - - final DescriptorImpl mailDesc = Jenkins.getInstance().getDescriptorByType(Mailer.DescriptorImpl.class); - - // intentionally give the whole thin in a double quote - Mailer.descriptor().setAdminAddress("\"me \""); - - String recipient = "you "; - Mailbox yourInbox = Mailbox.get(new InternetAddress(recipient)); - yourInbox.clear(); - - configureDefaultMaven(); - MavenModuleSet mms = createMavenProject(); - mms.setGoals("test"); - mms.setScm(new ExtractResourceSCM(getClass().getResource("/hudson/maven/maven-multimodule-unit-failure.zip"))); - assertBuildStatus(Result.UNSTABLE, mms.scheduleBuild2(0).get()); - - MavenMailer m = new MavenMailer(); - m.recipients = recipient; - m.perModuleEmail = perModuleEamil; - mms.getReporters().add(m); - - mms.scheduleBuild2(0).get(); - - Address[] senders = yourInbox.get(0).getFrom(); - assertEquals(1, senders.length); - assertEquals("me ", senders[0].toString()); - - return yourInbox; - } - -} diff --git a/test/src/test/java/hudson/maven/reporters/MavenSiteArchiverTest.java b/test/src/test/java/hudson/maven/reporters/MavenSiteArchiverTest.java deleted file mode 100644 index 359fb4913e67cff94b1b48903c502c165daaa7a7..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/reporters/MavenSiteArchiverTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package hudson.maven.reporters; - -import org.jvnet.hudson.test.HudsonTestCase; -import hudson.maven.MavenProjectTest; - -/** - * @author Kohsuke Kawaguchi - */ -public class MavenSiteArchiverTest extends HudsonTestCase { - /** - * Makes sure that the site archiving happens automatically. - * The actual test resides in {@link MavenProjectTest#testSiteBuild()} - */ - public void testSiteArchiving() throws Exception { - } -} diff --git a/test/src/test/java/hudson/maven/reporters/SurefireArchiverTest.java b/test/src/test/java/hudson/maven/reporters/SurefireArchiverTest.java deleted file mode 100644 index 7e3ae538ee0fc37ab306f7842bce261c7019cb64..0000000000000000000000000000000000000000 --- a/test/src/test/java/hudson/maven/reporters/SurefireArchiverTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2010, InfraDNA, 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.reporters; - -import hudson.maven.MavenBuild; -import hudson.maven.MavenModuleSet; -import hudson.maven.MavenModuleSetBuild; -import hudson.maven.MavenProjectActionBuilder; -import hudson.maven.reporters.SurefireArchiver.FactoryImpl; -import hudson.model.Result; -import org.jvnet.hudson.test.ExtractResourceSCM; -import org.jvnet.hudson.test.HudsonTestCase; - -/** - * @author Kohsuke Kawaguchi - */ -public class SurefireArchiverTest extends HudsonTestCase { - public void testSerialization() throws Exception { - configureDefaultMaven(); - MavenModuleSet m = createMavenProject(); - m.setScm(new ExtractResourceSCM(getClass().getResource("../maven-surefire-unstable.zip"))); - m.setGoals("install"); - - MavenModuleSetBuild b = m.scheduleBuild2(0).get(); - assertBuildStatus(Result.UNSTABLE, b); - - - MavenBuild mb = b.getModuleLastBuilds().values().iterator().next(); - boolean foundFactory=false,foundSurefire=false; - for (MavenProjectActionBuilder x : mb.getProjectActionBuilders()) { - if (x instanceof FactoryImpl) - foundFactory = true; - if (x instanceof SurefireArchiver) - foundSurefire = true; - } - - assertTrue(foundFactory); - assertFalse(foundSurefire); - } - -} diff --git a/test/src/test/resources/hudson/maven/HUDSON-4192.zip b/test/src/test/resources/hudson/maven/HUDSON-4192.zip deleted file mode 100644 index 24e286e883e6dadfd1ad92dd5e44fec0e9486672..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/HUDSON-4192.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/JENKINS-1557.zip b/test/src/test/resources/hudson/maven/JENKINS-1557.zip deleted file mode 100644 index 95a102f9f39f5b676e1e80dfe57dd730b8910ea0..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/JENKINS-1557.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/JENKINS-15865.zip b/test/src/test/resources/hudson/maven/JENKINS-15865.zip deleted file mode 100644 index db7d1644b5e852ffbabf58e3ba75bed6db3d1a69..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/JENKINS-15865.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/JENKINS-8573.zip b/test/src/test/resources/hudson/maven/JENKINS-8573.zip deleted file mode 100644 index e271ee1ce2211a792fa75363abbbcba5c1c5fcd3..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/JENKINS-8573.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/JENKINS-9326.zip b/test/src/test/resources/hudson/maven/JENKINS-9326.zip deleted file mode 100644 index a9b50b23ae9b516ccdf022681c0d75665101bf9a..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/JENKINS-9326.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/big-artifact.pom b/test/src/test/resources/hudson/maven/big-artifact.pom deleted file mode 100644 index b7812b68e8d6d54c033919c4d06f7e2e066bd144..0000000000000000000000000000000000000000 --- a/test/src/test/resources/hudson/maven/big-artifact.pom +++ /dev/null @@ -1,67 +0,0 @@ - - - - - 4.0.0 - test - test - 0.1-SNAPSHOT - - - - - org.jvnet.maven-antrun-extended-plugin - maven-antrun-extended-plugin - 1.39 - - - package - - - This is my artifact - So is this - - - - - - run - - - - - - - - - - m.g.o-public - http://maven.glassfish.org/content/groups/public/ - - - - \ No newline at end of file diff --git a/test/src/test/resources/hudson/maven/custom-plexus-component.pom b/test/src/test/resources/hudson/maven/custom-plexus-component.pom deleted file mode 100644 index 941a182de9c6ae5dcc427c1c81f0d69a16f7f4d9..0000000000000000000000000000000000000000 --- a/test/src/test/resources/hudson/maven/custom-plexus-component.pom +++ /dev/null @@ -1,34 +0,0 @@ - - - - - 4.0.0 - test - test - 0.1-SNAPSHOT - bogus - \ No newline at end of file diff --git a/test/src/test/resources/hudson/maven/envars-maven-project.zip b/test/src/test/resources/hudson/maven/envars-maven-project.zip deleted file mode 100644 index 802d3c0e4a4b2546c69ab679c2934bdee196c304..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/envars-maven-project.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/foobar_eclipse_with_fix.zip b/test/src/test/resources/hudson/maven/foobar_eclipse_with_fix.zip deleted file mode 100644 index 5d7f2f2cd5d2ad00f32789209bd4e65b9eb96b1c..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/foobar_eclipse_with_fix.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/incorrect-inheritence-testcase.zip b/test/src/test/resources/hudson/maven/incorrect-inheritence-testcase.zip deleted file mode 100755 index 0a30bcca61d4003e96117ceb532d736c6669c095..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/incorrect-inheritence-testcase.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-compilation-failure.zip b/test/src/test/resources/hudson/maven/maven-compilation-failure.zip deleted file mode 100644 index 771d0e861a0ca63fd43788078fc997146ac6533a..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-compilation-failure.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-dep-test-A-changed.zip b/test/src/test/resources/hudson/maven/maven-dep-test-A-changed.zip deleted file mode 100644 index 853579d789d9b31e1a9b2cd35734668b37514a94..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-dep-test-A-changed.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-dep-test-A.zip b/test/src/test/resources/hudson/maven/maven-dep-test-A.zip deleted file mode 100755 index 719c6618efab37cdd92478bf3b8afdbe7d5d134c..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-dep-test-A.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-dep-test-B.zip b/test/src/test/resources/hudson/maven/maven-dep-test-B.zip deleted file mode 100755 index 21fb317024853d4761e7c458600dcc5128a18e05..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-dep-test-B.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-dep-test-C.zip b/test/src/test/resources/hudson/maven/maven-dep-test-C.zip deleted file mode 100755 index c789f277b15393bb48be64c62f3b98155a600858..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-dep-test-C.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-empty-mod.zip b/test/src/test/resources/hudson/maven/maven-empty-mod.zip deleted file mode 100644 index d02e3b63cbb5cd362c05e9feb838c6fdafda355e..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-empty-mod.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-multimod-changes.zip b/test/src/test/resources/hudson/maven/maven-multimod-changes.zip deleted file mode 100644 index edcd030d4d5d5a793013f093fe1efa2fc644d3df..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-multimod-changes.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-multimod-incr.zip b/test/src/test/resources/hudson/maven/maven-multimod-incr.zip deleted file mode 100644 index 71e0e08e3aac1132cc5c24b766efbabd7198f28a..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-multimod-incr.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-multimod-rel-base.zip b/test/src/test/resources/hudson/maven/maven-multimod-rel-base.zip deleted file mode 100644 index 912f30cc8c2fb1d07486697fa7f6934942314b92..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-multimod-rel-base.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-multimod.zip b/test/src/test/resources/hudson/maven/maven-multimod.zip deleted file mode 100644 index ffecf2a09302297b9848ab049a96eb03ea880a67..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-multimod.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-multimodule-site.zip b/test/src/test/resources/hudson/maven/maven-multimodule-site.zip deleted file mode 100644 index 14b13b4483ef520d2b959f0665161e20621b9944..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-multimodule-site.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-multimodule-unit-failure.zip b/test/src/test/resources/hudson/maven/maven-multimodule-unit-failure.zip deleted file mode 100755 index 9d1d6207d4c281f9b172363ec1f6fee976695590..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-multimodule-unit-failure.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-opts-echo.zip b/test/src/test/resources/hudson/maven/maven-opts-echo.zip deleted file mode 100644 index a0c358b94d577f1594658c3eed2ec87a7fd51b2a..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-opts-echo.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-surefire-unstable.zip b/test/src/test/resources/hudson/maven/maven-surefire-unstable.zip deleted file mode 100644 index a0c2f9657f6d31943d9a365ff777e3a3a6ac6f1b..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-surefire-unstable.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven-test-failure-findbugs.zip b/test/src/test/resources/hudson/maven/maven-test-failure-findbugs.zip deleted file mode 100755 index 878cff23c5174f6c2303510fd19c9a8854b07cbd..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven-test-failure-findbugs.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/maven3-project.zip b/test/src/test/resources/hudson/maven/maven3-project.zip deleted file mode 100644 index 35c1bec72cdde33e790fbb67046662aae72a03a5..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/maven3-project.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/multimodule-maven.zip b/test/src/test/resources/hudson/maven/multimodule-maven.zip deleted file mode 100644 index 6cca3718fbc00e21446f70c20378c3649e5648a0..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/multimodule-maven.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/several-modules-in-directory.zip b/test/src/test/resources/hudson/maven/several-modules-in-directory.zip deleted file mode 100644 index 927ef95e7efc53b7b342f03942ababc5be65f6cf..0000000000000000000000000000000000000000 Binary files a/test/src/test/resources/hudson/maven/several-modules-in-directory.zip and /dev/null differ diff --git a/test/src/test/resources/hudson/maven/targz-artifact.pom b/test/src/test/resources/hudson/maven/targz-artifact.pom deleted file mode 100644 index 3a2e44fc786ae0524ecd2d68fb7cc3c19eef4523..0000000000000000000000000000000000000000 --- a/test/src/test/resources/hudson/maven/targz-artifact.pom +++ /dev/null @@ -1,54 +0,0 @@ - - - - - 4.0.0 - test - test - 0.1-SNAPSHOT - - - - - maven-assembly-plugin - - - bin - - - - - package - - single - - - - - - - \ No newline at end of file diff --git a/test/src/test/resources/hudson/maven/test-pom-7162.xml b/test/src/test/resources/hudson/maven/test-pom-7162.xml deleted file mode 100644 index 2b6f1903981d39608bbc65bccb40ccd28da4b9e7..0000000000000000000000000000000000000000 --- a/test/src/test/resources/hudson/maven/test-pom-7162.xml +++ /dev/null @@ -1,26 +0,0 @@ - - 4.0.0 - - com.infradna.support - query - 1.0-SNAPSHOT - jar - - query - http://maven.apache.org - - - UTF-8 - bar - - - - - junit - junit - 3.8.1 - test - - - diff --git a/test/src/test/resources/hudson/maven/test-pom-8395.xml b/test/src/test/resources/hudson/maven/test-pom-8395.xml deleted file mode 100755 index 0ef0ff59ac5e4c20688cb9675c1aa23968f92cbe..0000000000000000000000000000000000000000 --- a/test/src/test/resources/hudson/maven/test-pom-8395.xml +++ /dev/null @@ -1,25 +0,0 @@ - - 4.0.0 - org.hudson-ci.testcase - testcase-wrong-plugin-dep-scope - 1.0-SNAPSHOT - jar - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.6 - - - ant - ant-nodeps - 1.8.2 - test - - - - - -