diff --git a/.gitignore b/.gitignore
index f03078a7c..343ccbd7a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,7 +11,5 @@ build
.java-version
.checkstyle
nbactions.xml
-/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsexe/src/test/repository/CVSROOT/history
-/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsjava/src/test/repository/CVSROOT/history
.DS_Store
-.factorypath
\ No newline at end of file
+.factorypath
diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/AbstractJUnit4MojoTestCase.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/AbstractJUnit4MojoTestCase.java
new file mode 100644
index 000000000..54560b78c
--- /dev/null
+++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/AbstractJUnit4MojoTestCase.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+package org.apache.maven.scm.plugin;
+
+import java.io.File;
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.scm.PlexusJUnit4TestCase;
+import org.junit.After;
+import org.junit.Before;
+
+public abstract class AbstractJUnit4MojoTestCase extends AbstractMojoTestCase {
+ private static final PlexusJUnit4TestCase plexusJUnit4TestCase = new PlexusJUnit4TestCase();
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ plexusJUnit4TestCase.setUp();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ plexusJUnit4TestCase.tearDown();
+ }
+
+ public static String getBasedir() {
+ return plexusJUnit4TestCase.getBasedir();
+ }
+
+ public static File getTestFile(final String path) {
+ return plexusJUnit4TestCase.getTestFile(getBasedir(), path);
+ }
+}
diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java
index 440b5d626..fbb45a86a 100644
--- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java
+++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java
@@ -20,8 +20,11 @@
import java.io.File;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
* Unit Test for BootstrapMojo
@@ -29,7 +32,8 @@
* @author Arne Degenring
*
*/
-public class BootstrapMojoTest extends AbstractMojoTestCase {
+@RunWith(JUnit4.class)
+public class BootstrapMojoTest extends AbstractJUnit4MojoTestCase {
File checkoutDir;
File projectDir;
@@ -38,7 +42,8 @@ public class BootstrapMojoTest extends AbstractMojoTestCase {
BootstrapMojo bootstrapMojo;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
checkoutDir = getTestFile("target/checkout");
@@ -54,6 +59,7 @@ protected void setUp() throws Exception {
bootstrapMojo = new BootstrapMojo();
}
+ @Test
public void testDetermineWorkingDirectoryPath() throws Exception {
// only checkout dir
assertEquals(checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "", ""));
diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BranchMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BranchMojoTest.java
index 3de6c088f..8ee79bc95 100644
--- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BranchMojoTest.java
+++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BranchMojoTest.java
@@ -20,22 +20,29 @@
import java.io.File;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.PlexusJUnit4TestCase;
import org.apache.maven.scm.provider.svn.SvnScmTestUtils;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.apache.maven.scm.ScmTestCase.checkScmPresence;
/**
* @author Emmanuel Venisse
*
*/
-public class BranchMojoTest extends AbstractMojoTestCase {
+@RunWith(JUnit4.class)
+public class BranchMojoTest extends AbstractJUnit4MojoTestCase {
File checkoutDir;
File repository;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
checkoutDir = getTestFile("target/checkout");
@@ -46,17 +53,11 @@ protected void setUp() throws Exception {
FileUtils.forceDelete(repository);
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp");
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVNADMIN_COMMAND_LINE);
SvnScmTestUtils.initializeRepository(repository);
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, "setUp");
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
CheckoutMojo checkoutMojo = (CheckoutMojo)
lookupMojo("checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml"));
@@ -72,32 +73,31 @@ protected void setUp() throws Exception {
checkoutMojo.execute();
}
+ @Test
public void testBranch() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVNADMIN_COMMAND_LINE);
- BranchMojo mojo = (BranchMojo) lookupMojo("branch", getTestFile("src/test/resources/mojos/branch/branch.xml"));
+ BranchMojo mojo = (BranchMojo)
+ lookupMojo("branch", PlexusJUnit4TestCase.getTestFile("src/test/resources/mojos/branch/branch.xml"));
mojo.setWorkingDirectory(checkoutDir);
String connectionUrl = mojo.getConnectionUrl();
- connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir());
+ connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", PlexusJUnit4TestCase.getBasedir());
connectionUrl = StringUtils.replace(connectionUrl, "\\", "/");
mojo.setConnectionUrl(connectionUrl);
mojo.execute();
- CheckoutMojo checkoutMojo =
- (CheckoutMojo) lookupMojo("checkout", getTestFile("src/test/resources/mojos/branch/checkout.xml"));
- checkoutMojo.setWorkingDirectory(new File(getBasedir()));
+ CheckoutMojo checkoutMojo = (CheckoutMojo) lookupMojo(
+ "checkout", PlexusJUnit4TestCase.getTestFile("src/test/resources/mojos/branch/checkout.xml"));
+ checkoutMojo.setWorkingDirectory(new File(PlexusJUnit4TestCase.getBasedir()));
connectionUrl = checkoutMojo.getConnectionUrl();
- connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir());
+ connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", PlexusJUnit4TestCase.getBasedir());
connectionUrl = StringUtils.replace(connectionUrl, "\\", "/");
checkoutMojo.setConnectionUrl(connectionUrl);
- File branchCheckoutDir = getTestFile("target/branches/mybranch");
+ File branchCheckoutDir = PlexusJUnit4TestCase.getTestFile("target/branches/mybranch");
if (branchCheckoutDir.exists()) {
FileUtils.deleteDirectory(branchCheckoutDir);
}
diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ChangeLogMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ChangeLogMojoTest.java
index 83578f85a..fa66f0284 100644
--- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ChangeLogMojoTest.java
+++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ChangeLogMojoTest.java
@@ -20,65 +20,64 @@
import java.io.File;
-import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.PlexusJUnit4TestCase;
import org.apache.maven.scm.provider.svn.SvnScmTestUtils;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.apache.maven.scm.ScmTestCase.checkScmPresence;
/**
* @author Emmanuel Venisse
*
*/
-public class ChangeLogMojoTest extends AbstractMojoTestCase {
+@RunWith(JUnit4.class)
+public class ChangeLogMojoTest extends AbstractJUnit4MojoTestCase {
File repository;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
repository = getTestFile("target/repository");
FileUtils.forceDelete(repository);
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp");
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVNADMIN_COMMAND_LINE);
SvnScmTestUtils.initializeRepository(repository);
}
+ @Test
public void testChangeLog() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
-
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
ChangeLogMojo mojo = (ChangeLogMojo)
lookupMojo("changelog", getTestFile("src/test/resources/mojos/changelog/changelog.xml"));
String connectionUrl = mojo.getConnectionUrl();
- connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir());
+ connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", PlexusJUnit4TestCase.getBasedir());
connectionUrl = StringUtils.replace(connectionUrl, "\\", "/");
mojo.setConnectionUrl(connectionUrl);
- mojo.setWorkingDirectory(new File(getBasedir()));
+ mojo.setWorkingDirectory(new File(PlexusJUnit4TestCase.getBasedir()));
mojo.setConnectionType("connection");
mojo.execute();
}
+ @Test
public void testChangeLogWithParameters() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
ChangeLogMojo mojo = (ChangeLogMojo)
lookupMojo("changelog", getTestFile("src/test/resources/mojos/changelog/changelogWithParameters.xml"));
String connectionUrl = mojo.getConnectionUrl();
- connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir());
+ connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", PlexusJUnit4TestCase.getBasedir());
connectionUrl = StringUtils.replace(connectionUrl, "\\", "/");
mojo.setConnectionUrl(connectionUrl);
mojo.setWorkingDirectory(new File(getBasedir()));
@@ -87,6 +86,7 @@ public void testChangeLogWithParameters() throws Exception {
mojo.execute();
}
+ @Test
public void testChangeLogWithBadUserDateFormat() throws Exception {
ChangeLogMojo mojo = (ChangeLogMojo) lookupMojo(
"changelog", getTestFile("src/test/resources/mojos/changelog/changelogWithBadUserDateFormat.xml"));
@@ -107,11 +107,9 @@ public void testChangeLogWithBadUserDateFormat() throws Exception {
}
}
+ @Test
public void testChangeLogWithBadConnectionUrl() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
ChangeLogMojo mojo = (ChangeLogMojo) lookupMojo(
"changelog", getTestFile("src/test/resources/mojos/changelog/changelogWithBadConnectionUrl.xml"));
diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java
index a397e6b44..354d6eeed 100644
--- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java
+++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java
@@ -20,24 +20,31 @@
import java.io.File;
-import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
import org.apache.maven.scm.provider.svn.SvnScmTestUtils;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.apache.maven.scm.ScmTestCase.checkScmPresence;
+import static org.junit.Assert.assertNotEquals;
/**
* @author Emmanuel Venisse
*
*/
-public class CheckoutMojoTest extends AbstractMojoTestCase {
+@RunWith(JUnit4.class)
+public class CheckoutMojoTest extends AbstractJUnit4MojoTestCase {
File checkoutDir;
File repository;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
checkoutDir = getTestFile("target/checkout");
@@ -47,6 +54,7 @@ protected void setUp() throws Exception {
FileUtils.forceDelete(checkoutDir);
}
+ @Test
public void testSkipCheckoutWhenCheckoutDirectoryExistsAndSkip() throws Exception {
FileUtils.forceDelete(checkoutDir);
checkoutDir.mkdirs();
@@ -62,20 +70,15 @@ public void testSkipCheckoutWhenCheckoutDirectoryExistsAndSkip() throws Exceptio
assertEquals(0, checkoutDir.listFiles().length);
}
+ @Test
public void testSkipCheckoutWithConnectionUrl() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVNADMIN_COMMAND_LINE);
FileUtils.forceDelete(checkoutDir);
SvnScmTestUtils.initializeRepository(repository);
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
CheckoutMojo mojo = (CheckoutMojo)
lookupMojo("checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml"));
@@ -91,6 +94,7 @@ public void testSkipCheckoutWithConnectionUrl() throws Exception {
mojo.execute();
}
+ @Test
public void testSkipCheckoutWithoutConnectionUrl() throws Exception {
FileUtils.forceDelete(checkoutDir);
@@ -107,11 +111,9 @@ public void testSkipCheckoutWithoutConnectionUrl() throws Exception {
}
}
+ @Test
public void testUseExport() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
FileUtils.forceDelete(checkoutDir);
@@ -128,11 +130,9 @@ public void testUseExport() throws Exception {
assertFalse(new File(checkoutDir, ".svn").exists());
}
+ @Test
public void testExcludeInclude() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVNADMIN_COMMAND_LINE);
FileUtils.forceDelete(checkoutDir);
@@ -140,10 +140,7 @@ public void testExcludeInclude() throws Exception {
SvnScmTestUtils.initializeRepository(repository);
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
CheckoutMojo mojo = (CheckoutMojo) lookupMojo(
"checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithExcludesIncludes.xml"));
@@ -163,12 +160,23 @@ public void testExcludeInclude() throws Exception {
// assertTrue( new File( checkoutDir, "src/main/.svn" ).exists() );
}
+ @Test
public void testEncryptedPasswordFromSettings() throws Exception {
File pom = getTestFile("src/test/resources/mojos/checkout/checkoutEncryptedPasswordFromSettings.xml");
CheckoutMojo mojo = (CheckoutMojo) lookupMojo("checkout", pom);
ScmProviderRepositoryWithHost repo =
(ScmProviderRepositoryWithHost) mojo.getScmRepository().getProviderRepository();
+ assertNotEquals(
+ "Raw encrypted Password was returned instead of the decrypted plaintext version",
+ "{Ael0S2tnXv8H3X+gHKpZAvAA25D8+gmU2w2RrGaf5v8=}",
+ repo.getPassword());
+
+ assertNotEquals(
+ "Raw encrypted Passphrase was returned instead of the decrypted plaintext version",
+ "{7zK9P8hNVeUHbTsjiA/vnOs0zUXbND+9MBNPvdvl+x4=}",
+ repo.getPassphrase());
+
assertEquals("testuser", repo.getUser());
assertEquals("testpass", repo.getPassword());
assertEquals("testphrase", repo.getPassphrase());
diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java
index 6138a9db2..b284c3ff7 100644
--- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java
+++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java
@@ -20,20 +20,26 @@
import java.io.File;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.provider.svn.SvnScmTestUtils;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.apache.maven.scm.ScmTestCase.checkScmPresence;
/**
*
*/
-public class ExportMojoTest extends AbstractMojoTestCase {
+@RunWith(JUnit4.class)
+public class ExportMojoTest extends AbstractJUnit4MojoTestCase {
File exportDir;
File repository;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
exportDir = getTestFile("target/export");
@@ -43,18 +49,13 @@ protected void setUp() throws Exception {
FileUtils.forceDelete(exportDir);
}
+ @Test
public void testExport() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVNADMIN_COMMAND_LINE);
SvnScmTestUtils.initializeRepository(repository);
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
ExportMojo mojo = (ExportMojo) lookupMojo("export", getTestFile("src/test/resources/mojos/export/export.xml"));
@@ -66,6 +67,7 @@ public void testExport() throws Exception {
assertFalse(new File(exportDir, ".svn").exists());
}
+ @Test
public void testSkipExportIfExists() throws Exception {
exportDir.mkdirs();
@@ -79,20 +81,15 @@ public void testSkipExportIfExists() throws Exception {
assertEquals(0, exportDir.listFiles().length);
}
+ @Test
public void testExcludeInclude() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVNADMIN_COMMAND_LINE);
SvnScmTestUtils.initializeRepository(repository);
exportDir.mkdirs();
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
ExportMojo mojo = (ExportMojo)
lookupMojo("export", getTestFile("src/test/resources/mojos/export/exportWithExcludesIncludes.xml"));
diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java
index 12fa0945f..191800840 100644
--- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java
+++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java
@@ -20,20 +20,22 @@
import java.io.File;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.provider.svn.SvnScmTestUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.apache.maven.scm.ScmTestCase.checkScmPresence;
/**
* @author Emmanuel Venisse
*
*/
-public class StatusMojoTest extends AbstractMojoTestCase {
+@RunWith(JUnit4.class)
+public class StatusMojoTest extends AbstractJUnit4MojoTestCase {
+ @Test
public void testStatusMojo() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
StatusMojo mojo = (StatusMojo) lookupMojo("status", getTestFile("src/test/resources/mojos/status/status.xml"));
diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/TagMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/TagMojoTest.java
index b7a81f0cd..f2539db9d 100644
--- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/TagMojoTest.java
+++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/TagMojoTest.java
@@ -20,21 +20,27 @@
import java.io.File;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.provider.svn.SvnScmTestUtils;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.apache.maven.scm.ScmTestCase.checkScmPresence;
/**
* @author Emmanuel Venisse
*
*/
-public class TagMojoTest extends AbstractMojoTestCase {
+@RunWith(JUnit4.class)
+public class TagMojoTest extends AbstractJUnit4MojoTestCase {
File checkoutDir;
File repository;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
checkoutDir = getTestFile("target/checkout");
@@ -45,17 +51,11 @@ protected void setUp() throws Exception {
FileUtils.forceDelete(repository);
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp");
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVNADMIN_COMMAND_LINE);
SvnScmTestUtils.initializeRepository(repository);
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, "setUp");
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
CheckoutMojo checkoutMojo = (CheckoutMojo)
lookupMojo("checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml"));
@@ -75,11 +75,9 @@ private static void setupConnectionUrl(AbstractScmMojo mojo) {
mojo.setConnectionUrl(connectionUrl);
}
+ @Test
public void testTag() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
TagMojo mojo = (TagMojo) lookupMojo("tag", getTestFile("src/test/resources/mojos/tag/tag.xml"));
mojo.setWorkingDirectory(checkoutDir);
@@ -105,11 +103,9 @@ public void testTag() throws Exception {
assertTrue(new File(tagCheckoutDir, "pom.xml").exists());
}
+ @Test
public void testTagWithTimestamp() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
TagMojo mojo = (TagMojo) lookupMojo("tag", getTestFile("src/test/resources/mojos/tag/tagWithTimestamp.xml"));
mojo.setWorkingDirectory(checkoutDir);
diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UntagMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UntagMojoTest.java
index 7bf2df85d..ddae0c366 100644
--- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UntagMojoTest.java
+++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UntagMojoTest.java
@@ -20,29 +20,32 @@
import java.io.File;
-import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.provider.git.GitScmTestUtils;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
-public class UntagMojoTest extends AbstractMojoTestCase {
+import static org.apache.maven.scm.ScmTestCase.checkScmPresence;
+
+@RunWith(JUnit4.class)
+public class UntagMojoTest extends AbstractJUnit4MojoTestCase {
File checkoutDir;
File repository;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
checkoutDir = getTestFile("target/checkout");
repository = getTestFile("target/repository");
- if (!ScmTestCase.isSystemCmd(GitScmTestUtils.GIT_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(GitScmTestUtils.GIT_COMMAND_LINE, "setUp");
- return;
- }
+ checkScmPresence(GitScmTestUtils.GIT_COMMAND_LINE);
GitScmTestUtils.initRepo("src/test/resources/git", repository, checkoutDir);
@@ -63,11 +66,9 @@ protected void setUp() throws Exception {
GitScmTestUtils.setDefaulGitConfig(checkoutDir);
}
+ @Test
public void testUntag() throws Exception {
- if (!ScmTestCase.isSystemCmd(GitScmTestUtils.GIT_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(GitScmTestUtils.GIT_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(GitScmTestUtils.GIT_COMMAND_LINE);
TagMojo tagMojo = (TagMojo) lookupMojo("tag", getTestFile("src/test/resources/mojos/untag/tag.xml"));
tagMojo.setWorkingDirectory(checkoutDir);
diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UpdateMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UpdateMojoTest.java
index 478cb4672..6a30d8a8d 100644
--- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UpdateMojoTest.java
+++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/UpdateMojoTest.java
@@ -20,22 +20,28 @@
import java.io.File;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.provider.svn.SvnScmTestUtils;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.apache.maven.scm.ScmTestCase.checkScmPresence;
/**
* @author Emmanuel Venisse
*
*/
-public class UpdateMojoTest extends AbstractMojoTestCase {
+@RunWith(JUnit4.class)
+public class UpdateMojoTest extends AbstractJUnit4MojoTestCase {
File checkoutDir;
File repository;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
checkoutDir = getTestFile("target/checkout");
@@ -45,18 +51,13 @@ protected void setUp() throws Exception {
FileUtils.forceDelete(checkoutDir);
}
+ @Test
public void testSkipCheckoutWithConnectionUrl() throws Exception {
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVNADMIN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVNADMIN_COMMAND_LINE);
SvnScmTestUtils.initializeRepository(repository);
- if (!ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE)) {
- ScmTestCase.printSystemCmdUnavail(SvnScmTestUtils.SVN_COMMAND_LINE, getName());
- return;
- }
+ checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
CheckoutMojo checkoutMojo = (CheckoutMojo)
lookupMojo("checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml"));
diff --git a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java
index 9cd8b0e88..53cc347ad 100644
--- a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java
+++ b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java
@@ -19,25 +19,31 @@
package org.apache.maven.scm.plugin;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
* @author Emmanuel Venisse
*
*/
-public class ValidateMojoTest extends AbstractMojoTestCase {
+@RunWith(JUnit4.class)
+public class ValidateMojoTest extends AbstractJUnit4MojoTestCase {
+ @Test
public void testValidateWithoutScmUrl() throws Exception {
ValidateMojo mojo = (ValidateMojo)
lookupMojo("validate", getTestFile("src/test/resources/mojos/validate/validateWithoutScmUrl.xml"));
mojo.execute();
}
+ @Test
public void testValidateWithValidScmUrls() throws Exception {
ValidateMojo mojo = (ValidateMojo)
lookupMojo("validate", getTestFile("src/test/resources/mojos/validate/validateWithValidScmUrls.xml"));
mojo.execute();
}
+ @Test
public void testValidateWithInvalidScmUrls() throws Exception {
ValidateMojo mojo = (ValidateMojo)
lookupMojo("validate", getTestFile("src/test/resources/mojos/validate/validateWithInvalidScmUrls.xml"));
diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java
index 9ce819693..b04345747 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java
@@ -22,7 +22,7 @@
import java.io.FileWriter;
import java.io.IOException;
-import org.apache.maven.scm.PlexusJUnit4TestSupport;
+import org.apache.maven.scm.PlexusJUnit4TestCase;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.junit.Assert;
@@ -47,7 +47,7 @@ public static void initRepo(File repository, File workingDirectory, File asserti
public static void initRepo(String source, File repository, File workingDirectory) throws IOException {
// Copy the repository to target
- File src = PlexusJUnit4TestSupport.getTestFile(source);
+ File src = PlexusJUnit4TestCase.getTestFile(source);
FileUtils.deleteDirectory(repository);
diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkin/GitCheckInCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkin/GitCheckInCommandTckTest.java
index 53e612a15..009a877a1 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkin/GitCheckInCommandTckTest.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkin/GitCheckInCommandTckTest.java
@@ -21,7 +21,7 @@
import java.io.File;
import java.io.IOException;
-import org.apache.maven.scm.PlexusJUnit4TestSupport;
+import org.apache.maven.scm.PlexusJUnit4TestCase;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.command.checkin.CheckInScmResult;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
@@ -71,8 +71,8 @@ public void testUpToDatePush() throws Exception {
@Test
public void testRejectedNonFastForwardPush() throws Exception {
- File blockingRepo = PlexusJUnit4TestSupport.getTestFile("target/scm-test/blocking-repo");
- File rejectedRepo = PlexusJUnit4TestSupport.getTestFile("target/scm-test/rejected-repo");
+ File blockingRepo = PlexusJUnit4TestCase.getTestFile("target/scm-test/blocking-repo");
+ File rejectedRepo = PlexusJUnit4TestCase.getTestFile("target/scm-test/rejected-repo");
ScmRepository scmRepository = getScmManager().makeScmRepository(getScmUrl());
checkoutRepoInto(rejectedRepo, scmRepository);
diff --git a/maven-scm-test/pom.xml b/maven-scm-test/pom.xml
index 951ee7392..d4c7d91b0 100644
--- a/maven-scm-test/pom.xml
+++ b/maven-scm-test/pom.xml
@@ -74,6 +74,11 @@
junit
junit
+
+ org.apache.maven.plugin-testing
+ maven-plugin-testing-harness
+ 3.3.0
+
diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/PlexusJUnit4TestSupport.java b/maven-scm-test/src/main/java/org/apache/maven/scm/PlexusJUnit4TestCase.java
similarity index 98%
rename from maven-scm-test/src/main/java/org/apache/maven/scm/PlexusJUnit4TestSupport.java
rename to maven-scm-test/src/main/java/org/apache/maven/scm/PlexusJUnit4TestCase.java
index 0014cef2f..cb9af4b03 100644
--- a/maven-scm-test/src/main/java/org/apache/maven/scm/PlexusJUnit4TestSupport.java
+++ b/maven-scm-test/src/main/java/org/apache/maven/scm/PlexusJUnit4TestCase.java
@@ -45,7 +45,7 @@
*
* @author Robert Scholte
*/
-public abstract class PlexusJUnit4TestSupport {
+public class PlexusJUnit4TestCase {
private PlexusContainer container;
private static String basedir;
@@ -58,7 +58,7 @@ public void setUp() throws Exception {
basedir = getBasedir();
}
- protected String getName() {
+ public String getName() {
return testName.getMethodName();
}
@@ -118,7 +118,7 @@ protected void setupContainer() {
/**
* Allows test to define custom modules.
*/
- protected Module[] getCustomModules() {
+ public Module[] getCustomModules() {
return new Module[0];
}
diff --git a/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java b/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java
index abb8edcba..20e424ff3 100644
--- a/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java
+++ b/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java
@@ -25,12 +25,12 @@
import java.util.Date;
import java.util.TimeZone;
-import org.apache.commons.lang3.StringUtils;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.repository.ScmRepository;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer;
import org.codehaus.plexus.util.cli.Commandline;
@@ -52,7 +52,7 @@
* @author Jason van Zyl
*
*/
-public abstract class ScmTestCase extends PlexusJUnit4TestSupport {
+public abstract class ScmTestCase extends PlexusJUnit4TestCase {
protected static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone("GMT");
private static boolean debugExecute;
@@ -79,7 +79,7 @@ public void setUp() throws Exception {
}
@Override
- protected void customizeContainerConfiguration(final ContainerConfiguration configuration) {
+ public void customizeContainerConfiguration(final ContainerConfiguration configuration) {
configuration.setClassPathScanning(PlexusConstants.SCANNING_INDEX).setAutoWiring(true);
}
@@ -87,21 +87,21 @@ protected void customizeContainerConfiguration(final ContainerConfiguration conf
* @return default location of the test read/write repository
*/
protected File getRepositoryRoot() {
- return PlexusJUnit4TestSupport.getTestFile("target/scm-test/repository");
+ return PlexusJUnit4TestCase.getTestFile("target/scm-test/repository");
}
/**
* @return Location of the revisioned (read only) repository
*/
protected File getRepository() {
- return PlexusJUnit4TestSupport.getTestFile("/src/test/repository");
+ return PlexusJUnit4TestCase.getTestFile("/src/test/repository");
}
/**
* @return location of the working copy (always checkout)
*/
protected File getWorkingCopy() {
- return PlexusJUnit4TestSupport.getTestFile("target/scm-test/working-copy");
+ return PlexusJUnit4TestCase.getTestFile("target/scm-test/working-copy");
}
/**
@@ -117,14 +117,14 @@ protected File getWorkingDirectory() {
* @return default location for doing assertions on a working tree
*/
protected File getAssertionCopy() {
- return PlexusJUnit4TestSupport.getTestFile("target/scm-test/assertion-copy");
+ return PlexusJUnit4TestCase.getTestFile("target/scm-test/assertion-copy");
}
/**
* @return default location for doing update operations on a working tree
*/
protected File getUpdatingCopy() {
- return PlexusJUnit4TestSupport.getTestFile("target/scm-test/updating-copy");
+ return PlexusJUnit4TestCase.getTestFile("target/scm-test/updating-copy");
}
protected ScmManager getScmManager() throws Exception {
@@ -318,8 +318,4 @@ public static boolean isSystemCmd(String cmd) {
return false;
}
}
-
- public static void printSystemCmdUnavail(String cmd, String testName) {
- System.err.printf("'%s' is not a system command. Ignored %s.%n", cmd, testName);
- }
}