You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2018/08/19 13:29:52 UTC

[4/6] groovy git commit: groovy-ant: further refactoring

groovy-ant: further refactoring


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/90c3cdc4
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/90c3cdc4
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/90c3cdc4

Branch: refs/heads/GROOVY_2_5_X
Commit: 90c3cdc493b5d28cf36509e5c5ce1d3758740b03
Parents: 59d9638
Author: Paul King <pa...@asert.com.au>
Authored: Sun Aug 19 23:22:42 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Sun Aug 19 23:29:32 2018 +1000

----------------------------------------------------------------------
 .../groovy-ant/src/spec/doc/ant-builder.adoc    |  4 +--
 .../spec/test/builder/AntBuilderSpecTest.groovy | 34 ++++++++++++++------
 .../src/test/groovy/groovy/ant/AntTest.groovy   |  9 ------
 3 files changed, 26 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/90c3cdc4/subprojects/groovy-ant/src/spec/doc/ant-builder.adoc
----------------------------------------------------------------------
diff --git a/subprojects/groovy-ant/src/spec/doc/ant-builder.adoc b/subprojects/groovy-ant/src/spec/doc/ant-builder.adoc
index 9d7521c..13329d8 100644
--- a/subprojects/groovy-ant/src/spec/doc/ant-builder.adoc
+++ b/subprojects/groovy-ant/src/spec/doc/ant-builder.adoc
@@ -50,7 +50,7 @@ include::{rootProjectDir}/subprojects/groovy-ant/src/spec/test/builder/AntBuilde
 <1> creates an instance of `AntBuilder`
 <2> executes the `echo` task with the message in parameter
 
-Imagine that you need to create a ZIP file:
+Imagine that you need to create a ZIP file. It can be as simple as:
 
 [source,groovy]
 ----
@@ -73,7 +73,7 @@ Another example would be iterating over a list of files matching a specific patt
 include::{rootProjectDir}/subprojects/groovy-ant/src/spec/test/builder/AntBuilderSpecTest.groovy[tags=filescanner,indent=0]
 ----
 
-Or execute a JUnit test:
+Or executing a JUnit test:
 
 [source,groovy]
 ----

http://git-wip-us.apache.org/repos/asf/groovy/blob/90c3cdc4/subprojects/groovy-ant/src/spec/test/builder/AntBuilderSpecTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-ant/src/spec/test/builder/AntBuilderSpecTest.groovy b/subprojects/groovy-ant/src/spec/test/builder/AntBuilderSpecTest.groovy
index 710d0c2..40a6c55 100644
--- a/subprojects/groovy-ant/src/spec/test/builder/AntBuilderSpecTest.groovy
+++ b/subprojects/groovy-ant/src/spec/test/builder/AntBuilderSpecTest.groovy
@@ -52,11 +52,11 @@ class AntBuilderSpecTest extends AntTestCase {
         doInTmpDir {ant, baseDir ->
             baseDir.src {
                 test {
-                    groovy {
+                    some {
                         'test1.groovy'('assert 1+1==2')
                         'test2.groovy'('assert 1+1==2')
-                        util {
-                            'AntTest.groovy'('assert 1+1==2')
+                        pkg {
+                            'MyTest.groovy'('assert 1+1==2')
                         }
                     }
                 }
@@ -79,7 +79,7 @@ class AntBuilderSpecTest extends AntTestCase {
             }
 
             // now let's do some normal Groovy again
-            def file = new File(ant.project.baseDir,"target/AntTest/groovy/util/AntTest.groovy")
+            def file = new File(ant.project.baseDir,"target/AntTest/some/pkg/MyTest.groovy")
             assert file.exists()
             // end::copy_files[]
         }
@@ -89,11 +89,11 @@ class AntBuilderSpecTest extends AntTestCase {
         doInTmpDir {ant, baseDir ->
             baseDir.src {
                 test {
-                    groovy {
+                    some {
                         'test1.groovy'('assert 1+1==2')
                         'test2.groovy'('assert 1+1==2')
-                        util {
-                            'AntTest.groovy'('assert 1+1==2')
+                        pkg {
+                            'MyTest.groovy'('assert 1+1==2')
                         }
                     }
                 }
@@ -102,7 +102,7 @@ class AntBuilderSpecTest extends AntTestCase {
             // let's create a scanner of filesets
             def scanner = ant.fileScanner {
                 fileset(dir:"src/test") {
-                    include(name:"**/Ant*.groovy")
+                    include(name:"**/My*.groovy")
                 }
             }
 
@@ -121,10 +121,24 @@ class AntBuilderSpecTest extends AntTestCase {
 
     void testExecuteJUnit() {
         doInTmpDir {ant, baseDir ->
+            baseDir.some {
+                pkg {
+                    'MyTest.java'('''
+                        package some.pkg;
+                        import junit.framework.TestCase;
+                        public class MyTest extends TestCase {
+                            public void testAddition() {
+                                assertEquals(1+1, 2);
+                            }
+                        }
+                    ''')
+                }
+            }
+            ant.javac(srcdir:'.', includes:'**/*.java', fork:'true')
             // tag::run_junit[]
-            // let's create a scanner of filesets
             ant.junit {
-                test(name:'groovy.util.SomethingThatDoesNotExist')
+                classpath { pathelement(path: '.') }
+                test(name:'some.pkg.MyTest')
             }
             // end::run_junit[]
         }

http://git-wip-us.apache.org/repos/asf/groovy/blob/90c3cdc4/subprojects/groovy-ant/src/test/groovy/groovy/ant/AntTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-ant/src/test/groovy/groovy/ant/AntTest.groovy b/subprojects/groovy-ant/src/test/groovy/groovy/ant/AntTest.groovy
index 0df92ca..c81db9a 100644
--- a/subprojects/groovy-ant/src/test/groovy/groovy/ant/AntTest.groovy
+++ b/subprojects/groovy-ant/src/test/groovy/groovy/ant/AntTest.groovy
@@ -27,8 +27,6 @@ import org.junit.Assert
 
 /**
  * Tests for the <groovy> task.
- *
- * @author Marc Guillemot
  */
 class AntTest extends GroovyTestCase {
 
@@ -72,13 +70,6 @@ class AntTest extends GroovyTestCase {
         assert found
     }
 
-    void testJunitTask() {
-        def ant = new AntBuilder()
-        ant.junit {
-            test(name: 'groovy.ant.SomethingThatDoesNotExist')
-        }
-    }
-
     void testPathBuilding() {
         def ant = new AntBuilder()
         def value = ant.path {