Heading towards a test for detatchment mojo
Project: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/commit/5d4ab8c4 Tree: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/tree/5d4ab8c4 Diff: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/diff/5d4ab8c4 Branch: refs/heads/master Commit: 5d4ab8c4c3b024aae607d83f428be7cbb17568e5 Parents: bb99995 Author: Rob Tompkins <chtom...@apache.org> Authored: Sat Jan 6 20:50:57 2018 -0500 Committer: Rob Tompkins <chtom...@apache.org> Committed: Sat Jan 6 20:50:57 2018 -0500 ---------------------------------------------------------------------- .../CommonsDistributionDetatchmentMojoTest.java | 54 +++++++++++++++++++ .../mojos/CommonsSiteCompressionMojoTest.java | 16 +++--- .../release/plugin/stubs/MavenProjectStub.java | 20 ------- .../release/plugin/stubs/package-info.java | 17 ------ .../detatch-distributions.xml | 51 ++++++++++++++++++ .../target/mockAttachedFile.html | 24 +++++++++ .../target/mockAttachedTar.tar.gz | Bin 0 -> 327 bytes .../target/mockAttachedZip.zip | Bin 0 -> 1323 bytes 8 files changed, 137 insertions(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/5d4ab8c4/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetatchmentMojoTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetatchmentMojoTest.java b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetatchmentMojoTest.java new file mode 100644 index 0000000..7e7867d --- /dev/null +++ b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetatchmentMojoTest.java @@ -0,0 +1,54 @@ +/* + * 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.commons.release.plugin.mojos; + +import org.apache.maven.plugin.testing.MojoRule; +import org.junit.Rule; +import org.junit.Test; + +import java.io.File; + +import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertNotNull; + +/** + * Unit tests for {@link CommonsDistributionDetatchmentMojo}. + * + * @author chtompki + */ +public class CommonsDistributionDetatchmentMojoTest { + + @Rule + public MojoRule rule = new MojoRule() { + @Override + protected void before() throws Throwable { + } + + @Override + protected void after() { + } + }; + + private CommonsDistributionDetatchmentMojo mojo; + + @Test + public void testSuccess() throws Exception { + File testPom = new File("src/test/resources/mojos/detatch-distributions/detatch-distributions.xml"); + assertNotNull(testPom); + assertTrue(testPom.exists()); + } +} http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/5d4ab8c4/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java index 50313b3..7d8efe6 100644 --- a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java +++ b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java @@ -50,10 +50,10 @@ public class CommonsSiteCompressionMojoTest { @Test public void testCompressSiteSuccess() throws Exception { - File testFile = new File("src/test/resources/mojos/compress-site/compress-site.xml"); - assertNotNull(testFile); - assertTrue(testFile.exists()); - mojo = (CommonsSiteCompressionMojo) rule.lookupMojo("compress-site", testFile); + File testPom = new File("src/test/resources/mojos/compress-site/compress-site.xml"); + assertNotNull(testPom); + assertTrue(testPom.exists()); + mojo = (CommonsSiteCompressionMojo) rule.lookupMojo("compress-site", testPom); mojo.execute(); File siteZip = new File("target/commons-release-plugin/site.zip"); assertTrue(siteZip.exists()); @@ -61,10 +61,10 @@ public class CommonsSiteCompressionMojoTest { @Test public void testCompressSiteDirNonExistentFailure() throws Exception { - File testFile = new File("src/test/resources/mojos/compress-site/compress-site-failure.xml"); - assertNotNull(testFile); - assertTrue(testFile.exists()); - mojo = (CommonsSiteCompressionMojo) rule.lookupMojo("compress-site", testFile); + File testPom = new File("src/test/resources/mojos/compress-site/compress-site-failure.xml"); + assertNotNull(testPom); + assertTrue(testPom.exists()); + mojo = (CommonsSiteCompressionMojo) rule.lookupMojo("compress-site", testPom); try { mojo.execute(); } catch (MojoFailureException e) { http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/5d4ab8c4/src/test/java/org/apache/commons/release/plugin/stubs/MavenProjectStub.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/release/plugin/stubs/MavenProjectStub.java b/src/test/java/org/apache/commons/release/plugin/stubs/MavenProjectStub.java deleted file mode 100644 index 3a7e104..0000000 --- a/src/test/java/org/apache/commons/release/plugin/stubs/MavenProjectStub.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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.commons.release.plugin.stubs; - -public class MavenProjectStub { -} http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/5d4ab8c4/src/test/java/org/apache/commons/release/plugin/stubs/package-info.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/release/plugin/stubs/package-info.java b/src/test/java/org/apache/commons/release/plugin/stubs/package-info.java deleted file mode 100644 index 95d9137..0000000 --- a/src/test/java/org/apache/commons/release/plugin/stubs/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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.commons.release.plugin.stubs; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/5d4ab8c4/src/test/resources/mojos/detatch-distributions/detatch-distributions.xml ---------------------------------------------------------------------- diff --git a/src/test/resources/mojos/detatch-distributions/detatch-distributions.xml b/src/test/resources/mojos/detatch-distributions/detatch-distributions.xml new file mode 100644 index 0000000..c7e399b --- /dev/null +++ b/src/test/resources/mojos/detatch-distributions/detatch-distributions.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.commons.plugin.my.unit</groupId> + <artifactId>compress-site-test</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>jar</packaging> + <name>Test MyMojo</name> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.commons</groupId> + <artifactId>commons-release-plugin</artifactId> + <configuration> + <workingDirectory>target/commons-release-plugin</workingDirectory> + <siteDirectory>${basedir}/target/test-classes/mojos/compress-site/example-site</siteDirectory> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/5d4ab8c4/src/test/resources/mojos/detatch-distributions/target/mockAttachedFile.html ---------------------------------------------------------------------- diff --git a/src/test/resources/mojos/detatch-distributions/target/mockAttachedFile.html b/src/test/resources/mojos/detatch-distributions/target/mockAttachedFile.html new file mode 100644 index 0000000..c9a72dd --- /dev/null +++ b/src/test/resources/mojos/detatch-distributions/target/mockAttachedFile.html @@ -0,0 +1,24 @@ +<html> +<!-- + ~ 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. + --> +<header><title>Mock maven site</title></header> +<body> +mock body +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/5d4ab8c4/src/test/resources/mojos/detatch-distributions/target/mockAttachedTar.tar.gz ---------------------------------------------------------------------- diff --git a/src/test/resources/mojos/detatch-distributions/target/mockAttachedTar.tar.gz b/src/test/resources/mojos/detatch-distributions/target/mockAttachedTar.tar.gz new file mode 100644 index 0000000..dda7e6c Binary files /dev/null and b/src/test/resources/mojos/detatch-distributions/target/mockAttachedTar.tar.gz differ http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/5d4ab8c4/src/test/resources/mojos/detatch-distributions/target/mockAttachedZip.zip ---------------------------------------------------------------------- diff --git a/src/test/resources/mojos/detatch-distributions/target/mockAttachedZip.zip b/src/test/resources/mojos/detatch-distributions/target/mockAttachedZip.zip new file mode 100644 index 0000000..1f34188 Binary files /dev/null and b/src/test/resources/mojos/detatch-distributions/target/mockAttachedZip.zip differ