Repository: groovy
Updated Branches:
  refs/heads/master bd9a237b1 -> cff3aed0c


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/cff3aed0
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/cff3aed0
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/cff3aed0

Branch: refs/heads/master
Commit: cff3aed0c2e1476fda8a04b18938cecf4f6d4dff
Parents: bd9a237
Author: Paul King <[email protected]>
Authored: Sun Aug 19 23:22:42 2018 +1000
Committer: Paul King <[email protected]>
Committed: Sun Aug 19 23:22:42 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/cff3aed0/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/cff3aed0/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/cff3aed0/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 {

Reply via email to