-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Michael Osipov <[email protected]> This closes #150
- Loading branch information
1 parent
cb1efe4
commit 95817d6
Showing
17 changed files
with
239 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/AbstractJUnit4MojoTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,16 +20,20 @@ | |
|
||
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 | ||
* | ||
* @author <a href="mailto:[email protected]">Arne Degenring</a> | ||
* | ||
*/ | ||
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, "", "")); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <a href="mailto:[email protected]">Emmanuel Venisse</a> | ||
* | ||
*/ | ||
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); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <a href="mailto:[email protected]">Emmanuel Venisse</a> | ||
* | ||
*/ | ||
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")); | ||
|
Oops, something went wrong.