You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/12/20 09:27:30 UTC

[maven-antrun-plugin] 21/26: Added integration tests

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to annotated tag maven-antrun-plugin-1.1
in repository https://gitbox.apache.org/repos/asf/maven-antrun-plugin.git

commit b529bdc42fbbe08871c4457ec2cb698bd37c44db
Author: Carlos Sanchez Gonzalez <ca...@apache.org>
AuthorDate: Sat Dec 31 18:13:48 2005 +0000

    Added integration tests
    
    git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-antrun-plugin@360383 13f79535-47bb-0310-9956-ffa450edef68
---
 src/it/test1/pom.xml                     |  2 +
 src/it/test2/pom.xml                     |  2 +
 src/it/test3/build.xml                   | 17 ++++++++
 src/it/{test2 => test3}/pom.xml          | 14 +++---
 src/it/test4/build.xml                   | 31 +++++++++++++
 src/it/test4/pom.xml                     | 74 ++++++++++++++++++++++++++++++++
 src/it/test5/build.xml                   | 31 +++++++++++++
 src/it/{test2 => test5}/pom.xml          | 31 ++++++-------
 src/it/test5/src/main/java/TestTask.java | 14 ++++++
 9 files changed, 196 insertions(+), 20 deletions(-)

diff --git a/src/it/test1/pom.xml b/src/it/test1/pom.xml
index 1fe94b1..d764e7a 100644
--- a/src/it/test1/pom.xml
+++ b/src/it/test1/pom.xml
@@ -7,6 +7,8 @@
   <groupId>org.apache.maven.plugins.antrun</groupId>
   <artifactId>test1</artifactId>
   <version>1.0-SNAPSHOT</version>
+  <name>Test for compile and plugin classpath references</name>
+  <description>Ensure that maven.compile.classpath and maven.plugin.classpath referencies are set</description>
  
   <dependencies>
   </dependencies>
diff --git a/src/it/test2/pom.xml b/src/it/test2/pom.xml
index 637ae7c..5e0ca7a 100644
--- a/src/it/test2/pom.xml
+++ b/src/it/test2/pom.xml
@@ -7,6 +7,8 @@
   <groupId>org.apache.maven.plugins.antrun</groupId>
   <artifactId>test2</artifactId>
   <version>1.0-SNAPSHOT</version>
+  <name>Test for MANTRUN-28</name>
+  <description>maven.test.classpath doesn't contain test scope dependancies</description>
 
   <dependencies>
     <dependency>
diff --git a/src/it/test3/build.xml b/src/it/test3/build.xml
new file mode 100644
index 0000000..b1d50ff
--- /dev/null
+++ b/src/it/test3/build.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<project name="test1">
+
+    <target name="test">
+
+        <echo>user.home = ${user.home}</echo>
+        <fail message="user.home is not set">
+          <condition>
+            <not>
+              <isset property="user.home"/>
+            </not>
+          </condition>
+        </fail>
+
+    </target>
+
+</project>
diff --git a/src/it/test2/pom.xml b/src/it/test3/pom.xml
similarity index 71%
copy from src/it/test2/pom.xml
copy to src/it/test3/pom.xml
index 637ae7c..ab7760c 100644
--- a/src/it/test2/pom.xml
+++ b/src/it/test3/pom.xml
@@ -5,8 +5,10 @@
   <modelVersion>4.0.0</modelVersion>
   
   <groupId>org.apache.maven.plugins.antrun</groupId>
-  <artifactId>test2</artifactId>
+  <artifactId>test3</artifactId>
   <version>1.0-SNAPSHOT</version>
+  <name>Test for MANTRUN-32</name>
+  <description>ant tasks don't use correct environment in antrun plugin</description>
 
   <dependencies>
     <dependency>
@@ -26,15 +28,17 @@
             <phase>test</phase>
             <configuration>
               <tasks>
-                <property name="test.classpath" refid="maven.test.classpath"/>
-                <echo>${test.classpath}</echo>
-                <fail message="Test classpath doesn't contain test scoped dependencies">
+                <echo>user.home = ${user.home}</echo>
+                <fail message="user.home is not set">
                   <condition>
                     <not>
-                      <contains string="${test.classpath}" substring="junit" casesensitive="no"/>
+                      <isset property="user.home"/>
                     </not>
                   </condition>
                 </fail>
+                <ant antfile="${basedir}/build.xml" inheritAll="true" inheritRefs="true">
+                  <target name="test"/>
+                </ant>
               </tasks>
             </configuration>
             <goals>
diff --git a/src/it/test4/build.xml b/src/it/test4/build.xml
new file mode 100644
index 0000000..6c726fc
--- /dev/null
+++ b/src/it/test4/build.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<project name="test1">
+
+    <target name="test">
+
+        <property name="property1" value="value"/>
+        <property name="property2" value="${property1}"/>
+        <property name="property3" value="prefix ${property1}"/>
+        <echo>P1: ${property1}</echo>
+        <echo>P2: ${property2}</echo>
+        <echo>P3: ${property3}</echo>
+        <echo message="P1: ${property1}"/>
+        <echo message="P2: ${property2}"/>
+        <echo message="P3: ${property3}"/>
+        <echo message="${property1}"/>
+        <echo message="${property2}"/>
+        <echo message="${property3}"/>
+
+        <fail message="Some property contains null in build.xml">
+          <condition>
+            <or>
+              <contains string="${property1}" substring="null" casesensitive="no"/>
+              <contains string="${property2}" substring="null" casesensitive="no"/>
+              <contains string="${property3}" substring="null" casesensitive="no"/>
+            </or>
+          </condition>
+        </fail>
+
+    </target>
+
+</project>
diff --git a/src/it/test4/pom.xml b/src/it/test4/pom.xml
new file mode 100644
index 0000000..63d3b15
--- /dev/null
+++ b/src/it/test4/pom.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  
+  <groupId>org.apache.maven.plugins.antrun</groupId>
+  <artifactId>test4</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Test for MANTRUN-29</name>
+  <description>properties not resolved in attributes</description>
+
+  <dependencies>
+  </dependencies>
+  
+  <properties>
+    <mavenProperty>xyz</mavenProperty>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>test</phase>
+            <configuration>
+              <tasks>
+
+                <ant antfile="${basedir}/build.xml" inheritAll="true" inheritRefs="true">
+                  <target name="test"/>
+                </ant>
+
+                <echo/>
+                <echo>Embedded tasks:</echo>
+
+                <property name="property1" value="value"/>
+                <property name="property2" value="${property1}"/>
+                <property name="property3" value="prefix ${property1}"/>
+                <echo>P1: ${property1}</echo>
+                <echo>P2: ${property2}</echo>
+                <echo>P3: ${property3}</echo>
+                <echo>mavenProperty: ${mavenProperty}</echo>
+                <echo message="P1: ${property1}"/>
+                <echo message="P2: ${property2}"/>
+                <echo message="P3: ${property3}"/>
+                <echo message="mavenProperty: ${mavenProperty}"/>
+                <echo message="${property1}"/>
+                <echo message="${property2}"/>
+                <echo message="${property3}"/>
+                <echo message="${mavenProperty}"/>
+
+                <fail message="Some property contains null in embedded tasks">
+                  <condition>
+                    <or>
+                      <contains string="${property1}" substring="null" casesensitive="no"/>
+                      <contains string="${property2}" substring="null" casesensitive="no"/>
+                      <contains string="${property3}" substring="null" casesensitive="no"/>
+                      <contains string="${mavenProperty}" substring="null" casesensitive="no"/>
+                    </or>
+                  </condition>
+                </fail>
+              </tasks>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/src/it/test5/build.xml b/src/it/test5/build.xml
new file mode 100644
index 0000000..6c726fc
--- /dev/null
+++ b/src/it/test5/build.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<project name="test1">
+
+    <target name="test">
+
+        <property name="property1" value="value"/>
+        <property name="property2" value="${property1}"/>
+        <property name="property3" value="prefix ${property1}"/>
+        <echo>P1: ${property1}</echo>
+        <echo>P2: ${property2}</echo>
+        <echo>P3: ${property3}</echo>
+        <echo message="P1: ${property1}"/>
+        <echo message="P2: ${property2}"/>
+        <echo message="P3: ${property3}"/>
+        <echo message="${property1}"/>
+        <echo message="${property2}"/>
+        <echo message="${property3}"/>
+
+        <fail message="Some property contains null in build.xml">
+          <condition>
+            <or>
+              <contains string="${property1}" substring="null" casesensitive="no"/>
+              <contains string="${property2}" substring="null" casesensitive="no"/>
+              <contains string="${property3}" substring="null" casesensitive="no"/>
+            </or>
+          </condition>
+        </fail>
+
+    </target>
+
+</project>
diff --git a/src/it/test2/pom.xml b/src/it/test5/pom.xml
similarity index 59%
copy from src/it/test2/pom.xml
copy to src/it/test5/pom.xml
index 637ae7c..760211c 100644
--- a/src/it/test2/pom.xml
+++ b/src/it/test5/pom.xml
@@ -5,18 +5,19 @@
   <modelVersion>4.0.0</modelVersion>
   
   <groupId>org.apache.maven.plugins.antrun</groupId>
-  <artifactId>test2</artifactId>
+  <artifactId>test5</artifactId>
   <version>1.0-SNAPSHOT</version>
+  <name>Test for MANTRUN-34</name>
+  <description>StringIndexOutOfBoundsException in custom ant task referencing 'basedir'</description>
 
   <dependencies>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
+      <artifactId>ant</artifactId>
+      <groupId>ant</groupId>
+      <version>1.6.5</version>
     </dependency>
   </dependencies>
-
+  
   <build>
     <plugins>
       <plugin>
@@ -26,15 +27,15 @@
             <phase>test</phase>
             <configuration>
               <tasks>
-                <property name="test.classpath" refid="maven.test.classpath"/>
-                <echo>${test.classpath}</echo>
-                <fail message="Test classpath doesn't contain test scoped dependencies">
-                  <condition>
-                    <not>
-                      <contains string="${test.classpath}" substring="junit" casesensitive="no"/>
-                    </not>
-                  </condition>
-                </fail>
+
+                <echo message="basedir:${basedir}" />
+                <echo message="sourceDirectory:${project.build.sourceDirectory}" />
+
+                <taskdef name="test" classname="TestTask">
+                  <classpath refid="maven.compile.classpath"/>
+                </taskdef>
+                <test/>
+
               </tasks>
             </configuration>
             <goals>
diff --git a/src/it/test5/src/main/java/TestTask.java b/src/it/test5/src/main/java/TestTask.java
new file mode 100644
index 0000000..6b7adc4
--- /dev/null
+++ b/src/it/test5/src/main/java/TestTask.java
@@ -0,0 +1,14 @@
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+public class TestTask extends Task {
+
+    public void execute() throws BuildException {
+        Project p = this.getProject();
+        System.out.println("sourceDirectory:" + p.getProperty("project.build.sourceDirectory"));
+        System.out.println("project.cmdline:" + p.getProperty("project.cmdline"));
+        System.out.println("basedir:" + p.getProperty("basedir"));
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.