You are viewing a plain text version of this content. The canonical link for it is here.
Posted to easyant-commits@incubator.apache.org by jl...@apache.org on 2012/08/04 21:21:53 UTC

svn commit: r1369461 - in /incubator/easyant/plugins/trunk/source-jar/src: main/resources/ test/ test/antunit/ test/antunit/src/ test/antunit/src/main/ test/antunit/src/main/java/ test/antunit/src/main/java/org/ test/antunit/src/main/java/org/apache/ t...

Author: jlboudart
Date: Sat Aug  4 21:21:52 2012
New Revision: 1369461

URL: http://svn.apache.org/viewvc?rev=1369461&view=rev
Log:
Add source-jar test case

Added:
    incubator/easyant/plugins/trunk/source-jar/src/test/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/sample-module.ivy
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/source-jar-test.xml
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/main/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/main/java/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/main/java/org/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/main/java/org/apache/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/main/java/org/apache/easyant/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/main/java/org/apache/easyant/example/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/main/java/org/apache/easyant/example/Example.java
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/test/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/test/java/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/test/java/org/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/test/java/org/apache/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/test/java/org/apache/easyant/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/test/java/org/apache/easyant/example/
    incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/test/java/org/apache/easyant/example/Example2.java
Modified:
    incubator/easyant/plugins/trunk/source-jar/src/main/resources/source-jar.ant

Modified: incubator/easyant/plugins/trunk/source-jar/src/main/resources/source-jar.ant
URL: http://svn.apache.org/viewvc/incubator/easyant/plugins/trunk/source-jar/src/main/resources/source-jar.ant?rev=1369461&r1=1369460&r2=1369461&view=diff
==============================================================================
--- incubator/easyant/plugins/trunk/source-jar/src/main/resources/source-jar.ant (original)
+++ incubator/easyant/plugins/trunk/source-jar/src/main/resources/source-jar.ant Sat Aug  4 21:21:52 2012
@@ -17,19 +17,18 @@
 <project name="org.apache.easyant.plugins#source-jar" xmlns:ea="antlib:org.apache.easyant">
 
     <ea:core-version requiredrevision="[0.9,+]" />
+    <ea:import mrid="org.apache.easyant.plugins#abstract-package;0.9"/>
 
-    <target name="source-jar:init">
+    <target name="source-jar:init" depends="abstract-package:init">
         <ea:parameter property="target.artifacts.main.source.jar.name" default="${module.name}-sources.jar" description="main source artifact file name" />
 
         <ea:parameter property="target.artifacts.test.source.jar.name" default="${module.name}-test-sources.jar" description="test source artifact file name" />
-        <ea:parameter property="target.artifacts" required="true" description="destination directory for target artifacts"/>
 
+        <ea:parameter property="src.main.java" default="${basedir}/src/main/java" description="directory where main java files are stored" />
+        <ea:parameter property="src.test.java" default="${basedir}/src/test/java" description="directory where test java files are stored" />
 
-        <ea:parameter property="src.main.java" required="true" description="directory where main java files are stored" />
-        <ea:parameter property="src.test.java" required="true" description="directory where test java files are stored" />
-
-        <ea:parameter property="src.main.resources" required="true" description="directory where main resources files are stored" />
-        <ea:parameter property="src.test.resources" required="true" description="directory where test resources files are stored" />
+        <ea:parameter property="src.main.resources" default="${basedir}/src/main/resources" description="directory where main resources files are stored" />
+        <ea:parameter property="src.test.resources" default="${basedir}/src/test/resources" description="directory where test resources files are stored" />
         <ea:parameter property="src.publish.conf" default="source" description="default configuration for source artifacts" />
 
         <condition property="has.src.main">
@@ -55,7 +54,7 @@
             <fileset dir="${src.main.resources}" erroronmissingdir="false" />
             <fileset dir="${src.main.java}" erroronmissingdir="false" />
         </jar>
-        <ea:registerartifact type="source" ext="jar" classifier="sources" settingsRef="${project.ivy.instance}" conf="${src.publish.conf}"/>
+        <ea:registerartifact type="source" ext="jar" classifier="sources" settingsRef="${project.ivy.instance}" confs="${src.publish.conf}"/>
     </target>
 
     <!-- Test sources -->
@@ -66,7 +65,7 @@
             <fileset dir="${src.test.resources}" erroronmissingdir="false" />
             <fileset dir="${src.test.java}" erroronmissingdir="false" />
         </jar>
-        <ea:registerartifact type="test-source" ext="jar" classifier="test-sources" settingsRef="${project.ivy.instance}" conf="${src.publish.conf}"/>
+        <ea:registerartifact type="test-source" ext="jar" classifier="test-sources" settingsRef="${project.ivy.instance}" confs="${src.publish.conf}"/>
     </target>
 
 </project>

Added: incubator/easyant/plugins/trunk/source-jar/src/test/antunit/sample-module.ivy
URL: http://svn.apache.org/viewvc/incubator/easyant/plugins/trunk/source-jar/src/test/antunit/sample-module.ivy?rev=1369461&view=auto
==============================================================================
--- incubator/easyant/plugins/trunk/source-jar/src/test/antunit/sample-module.ivy (added)
+++ incubator/easyant/plugins/trunk/source-jar/src/test/antunit/sample-module.ivy Sat Aug  4 21:21:52 2012
@@ -0,0 +1,21 @@
+<?xml version="1.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.
+-->
+<ivy-module version="2.0" xmlns:ea="http://www.easyant.org"> 
+    <info organisation="org.apache.easyant" module="standard-java-app" revision="0.1" status="integration"/>
+
+</ivy-module>

Added: incubator/easyant/plugins/trunk/source-jar/src/test/antunit/source-jar-test.xml
URL: http://svn.apache.org/viewvc/incubator/easyant/plugins/trunk/source-jar/src/test/antunit/source-jar-test.xml?rev=1369461&view=auto
==============================================================================
--- incubator/easyant/plugins/trunk/source-jar/src/test/antunit/source-jar-test.xml (added)
+++ incubator/easyant/plugins/trunk/source-jar/src/test/antunit/source-jar-test.xml Sat Aug  4 21:21:52 2012
@@ -0,0 +1,69 @@
+<!--
+   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 name="org.apache.easyant.plugins;source-jar-test" 
+    xmlns:au="antlib:org.apache.ant.antunit" 
+    xmlns:ivy="antlib:org.apache.ivy.ant"
+    xmlns:ea="antlib:org.apache.easyant">
+    
+    <!-- Import your plugin --> 
+    <property name="target" value="target/test-antunit"/>
+    <!-- configure easyant in current project -->
+    <ea:configure-easyant-ivy-instance />
+    <!-- import our local plugin -->
+    <ea:import-test-module moduleIvy="../../../module.ivy" sourceDirectory="../../main/resources"/>
+
+    <!-- Defines a setUp / tearDown (before each test) that cleans the environnement --> 
+    <target name="clean" description="remove stale build artifacts before / after each test">
+        <delete dir="${basedir}" includeemptydirs="true">
+            <include name="**/target/**"/>
+            <include name="**/lib/**"/>
+        </delete>
+    </target>
+    
+    <target name="setUp" depends="clean">
+        <property name="project.ivy.instance" value="project.ivy.instance"/>
+        <ivy:settings id="project.ivy.instance"/>
+        <ivy:resolve file="sample-module.ivy" settingsRef="project.ivy.instance"/>
+    </target>
+    <target name="tearDown" depends="clean"/>
+    
+    <target name="test-source-jar:init" depends="source-jar:init">
+        <au:assertPropertyEquals name="target.artifacts.main.source.jar.name" value="${module.name}-sources.jar"/>
+        <au:assertPropertyEquals name="target.artifacts.test.source.jar.name" value="${module.name}-test-sources.jar"/>
+        <au:assertPropertyEquals name="src.main.java" value="${basedir}/src/main/java"/>
+        <au:assertPropertyEquals name="src.test.java" value="${basedir}/src/test/java"/>
+        <au:assertPropertyEquals name="src.main.resources" value="${basedir}/src/main/resources"/>
+        <au:assertPropertyEquals name="src.test.resources" value="${basedir}/src/test/resources"/>
+        <au:assertPropertyEquals name="src.publish.conf" value="source"/>
+        <au:assertPropertyEquals name="has.src.main" value="true"/>
+        <au:assertPropertyEquals name="has.src.test" value="true"/>
+    </target>
+
+    <target name="test-source-jar:main" depends="source-jar:main">
+        <au:assertFileExists file="${target.artifacts}"/>
+        <au:assertFileExists file="${target.artifacts}/${target.artifacts.main.source.jar.name}"/>
+    </target>
+
+    <target name="test-source-jar:test" depends="source-jar:test">
+        <au:assertFileExists file="${target.artifacts}"/>
+        <au:assertFileExists file="${target.artifacts}/${target.artifacts.test.source.jar.name}"/>
+
+
+    </target>
+
+
+</project>

Added: incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/main/java/org/apache/easyant/example/Example.java
URL: http://svn.apache.org/viewvc/incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/main/java/org/apache/easyant/example/Example.java?rev=1369461&view=auto
==============================================================================
--- incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/main/java/org/apache/easyant/example/Example.java (added)
+++ incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/main/java/org/apache/easyant/example/Example.java Sat Aug  4 21:21:52 2012
@@ -0,0 +1,36 @@
+/*
+ *  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.easyant.example;
+
+import java.io.IOException;
+import java.util.Properties;
+
+public class Example {
+    public static void main(String[] args) throws IOException {
+        System.out.println(new Example().sayHello("EasyAnt"));
+    }
+
+    /* 
+     * @param who Who says hello
+     */
+    public String sayHello(String who) throws IOException {
+        Properties props = new Properties();
+        props.load(Example.class.getResourceAsStream("/main.properties"));
+        return props.getProperty("example") + " " + who + "!";
+    }
+}

Added: incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/test/java/org/apache/easyant/example/Example2.java
URL: http://svn.apache.org/viewvc/incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/test/java/org/apache/easyant/example/Example2.java?rev=1369461&view=auto
==============================================================================
--- incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/test/java/org/apache/easyant/example/Example2.java (added)
+++ incubator/easyant/plugins/trunk/source-jar/src/test/antunit/src/test/java/org/apache/easyant/example/Example2.java Sat Aug  4 21:21:52 2012
@@ -0,0 +1,40 @@
+/*
+ *  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.easyant.example;
+
+import java.io.IOException;
+import java.util.Properties;
+
+public class Example2 {
+    public static void main(String[] args) throws IOException {
+        System.out.println(new Example().sayHello("EasyAnt"));
+    }
+
+    /* 
+     * @param who Who says hello
+     */
+    public String sayHello(String who) throws IOException {
+        Properties props = new Properties();
+        props.load(Example.class.getResourceAsStream("/main.properties"));
+        return props.getProperty("example") + " " + who + "!";
+    }
+    public String CheckstyleShouldComplainAboutMethodName() throws IOException {
+        return "CheckstyleShouldComplainAboutMethodName !";
+    }
+
+}