You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by jw...@apache.org on 2016/01/31 17:16:47 UTC

[1/3] groovy git commit: Remove Java 1.4 compatibility code (Integer.valueOf(int) was added in 1.5)

Repository: groovy
Updated Branches:
  refs/heads/master 67b774284 -> f7be98a08


Remove Java 1.4 compatibility code (Integer.valueOf(int) was added in 1.5)


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

Branch: refs/heads/master
Commit: 53ac431f807f629ad49bfb91a511ff95b42828ca
Parents: 67b7742
Author: John Wagenleitner <jw...@apache.org>
Authored: Sun Jan 31 07:08:10 2016 -0800
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sun Jan 31 07:08:10 2016 -0800

----------------------------------------------------------------------
 .../runtime/PerInstanceMetaClassTest.groovy     | 29 --------------------
 1 file changed, 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/53ac431f/src/test/org/codehaus/groovy/runtime/PerInstanceMetaClassTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/PerInstanceMetaClassTest.groovy b/src/test/org/codehaus/groovy/runtime/PerInstanceMetaClassTest.groovy
index 5488862..8ed2e02 100644
--- a/src/test/org/codehaus/groovy/runtime/PerInstanceMetaClassTest.groovy
+++ b/src/test/org/codehaus/groovy/runtime/PerInstanceMetaClassTest.groovy
@@ -20,35 +20,8 @@ package org.codehaus.groovy.runtime
 
 class PerInstanceMetaClassTest extends GroovyTestCase{
 
-    static Integer [] cache
-
-    static {
-        try {
-            Integer.valueOf(0)
-        }
-        catch (MissingMethodException e) {
-            cache = new Integer[-(-128) + 127 + 1]
-            for(int i = 0; i < cache.length; i++)
-              cache[i] = new Integer(i - 128);
-        }
-    }
-
     protected void setUp() {
         Integer.metaClass = null
-        setValueOfMethod()
-    }
-
-    private def setValueOfMethod() {
-        if (cache != null) {
-            Integer.metaClass.static.valueOf = {
-                Integer i ->
-                final int offset = 128;
-                if (i >= -128 && i <= 127) { // must cache
-                    return cache[i + offset];
-                }
-                return new Integer(i);
-            }
-        }
     }
 
     void testEMC () {
@@ -88,7 +61,6 @@ class PerInstanceMetaClassTest extends GroovyTestCase{
 
         x.metaClass = null
         Integer.metaClass = null
-        setValueOfMethod()
 
         assertEquals 28, x + 6
 
@@ -277,7 +249,6 @@ class PerInstanceMetaClassTest extends GroovyTestCase{
        ExpandoMetaClass.enableGlobally()
 
        Integer.metaClass = null
-       setValueOfMethod()
 
        def foo =  { x ->
            return x._100 


[3/3] groovy git commit: Remove sleep loop to improve test reliability and timeliness

Posted by jw...@apache.org.
Remove sleep loop to improve test reliability and timeliness


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

Branch: refs/heads/master
Commit: f7be98a084cf3d6b8a82cae05fa1ec32f7ed7029
Parents: efee13b
Author: John Wagenleitner <jw...@apache.org>
Authored: Sun Jan 31 07:57:41 2016 -0800
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sun Jan 31 07:57:41 2016 -0800

----------------------------------------------------------------------
 src/test/groovy/GroovyClosureMethodsTest.groovy | 15 ++++++++-------
 src/test/groovy/ThreadMethodsTest.groovy        | 19 +++++++++++--------
 2 files changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/f7be98a0/src/test/groovy/GroovyClosureMethodsTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/GroovyClosureMethodsTest.groovy b/src/test/groovy/GroovyClosureMethodsTest.groovy
index 43afac4..5b83305 100644
--- a/src/test/groovy/GroovyClosureMethodsTest.groovy
+++ b/src/test/groovy/GroovyClosureMethodsTest.groovy
@@ -18,6 +18,9 @@
  */
 package groovy
 
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+
 /**
  * Test case for the eachObject method on a file containing
  * zero, one or more objects (object stream).  Also test cases
@@ -161,15 +164,13 @@ class GroovyClosureMethodsTest extends GroovyTestCase {
     }
 
     void testRunAfter() {
-        boolean modifiedByRunAfter = false
+        CountDownLatch latch = new CountDownLatch(1)
         new Timer().runAfter(50) {
-            modifiedByRunAfter = true
-        }
-        assert modifiedByRunAfter == false
-        for(int i = 0; !modifiedByRunAfter && i < 10; i++) {
-           Thread.sleep 100
+            latch.countDown()
         }
-        assert modifiedByRunAfter
+        assert latch.getCount() == 1
+        latch.await(100L, TimeUnit.MILLISECONDS)
+        assert latch.getCount() == 0
     }
 
     void testSplitEachLine() {

http://git-wip-us.apache.org/repos/asf/groovy/blob/f7be98a0/src/test/groovy/ThreadMethodsTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/ThreadMethodsTest.groovy b/src/test/groovy/ThreadMethodsTest.groovy
index e433ccd..a19a6c5 100644
--- a/src/test/groovy/ThreadMethodsTest.groovy
+++ b/src/test/groovy/ThreadMethodsTest.groovy
@@ -18,18 +18,21 @@
  */
 package groovy
 
+import java.util.concurrent.CyclicBarrier
+import java.util.concurrent.TimeUnit
+
 class ThreadMethodsTest extends GroovyTestCase {
+    final CyclicBarrier barrier = new CyclicBarrier(2)
     void testThreadNaming() {
         def t = Thread.start("MyNamedThread") {
-            sleep 3000 // give ourselves time to find the thread
-        }
-        def threadFoundByName = false
-        30.times {
-            if (!threadFoundByName) {
-                sleep 100 // a little bit of time for t to start
-                threadFoundByName = Thread.allStackTraces.keySet().any { thread -> thread.name == 'MyNamedThread' }
-            }
+            barrier.await(3L, TimeUnit.SECONDS) // Signal Thread Start
+            barrier.await(3L, TimeUnit.SECONDS) // Wait for thread stop signal
         }
+
+        barrier.await(3L, TimeUnit.SECONDS) // Wait for thread start signal
+        boolean threadFoundByName = Thread.allStackTraces.keySet().any { thread -> thread.name == 'MyNamedThread' }
+        barrier.await(3L, TimeUnit.SECONDS) // Send thread stop signal
+        t.join(100L)
         assert threadFoundByName
     }
 }
\ No newline at end of file


[2/3] groovy git commit: Remove Java 1.5 runtime checks for java.lang.annotation.Annotation from tests

Posted by jw...@apache.org.
Remove Java 1.5 runtime checks for java.lang.annotation.Annotation from tests


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

Branch: refs/heads/master
Commit: efee13bd34862dbcbdebf79254043664861eb2df
Parents: 53ac431
Author: John Wagenleitner <jw...@apache.org>
Authored: Sun Jan 31 07:11:09 2016 -0800
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sun Jan 31 07:11:09 2016 -0800

----------------------------------------------------------------------
 .../org/codehaus/groovy/classgen/GenericsGenTest.groovy   |  8 --------
 .../org/codehaus/groovy/classgen/InterfaceTest.groovy     |  7 -------
 .../groovy/control/CompilerConfigurationTest.java         | 10 +---------
 3 files changed, 1 insertion(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/efee13bd/src/test/org/codehaus/groovy/classgen/GenericsGenTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/classgen/GenericsGenTest.groovy b/src/test/org/codehaus/groovy/classgen/GenericsGenTest.groovy
index e93271c..6d959a9 100644
--- a/src/test/org/codehaus/groovy/classgen/GenericsGenTest.groovy
+++ b/src/test/org/codehaus/groovy/classgen/GenericsGenTest.groovy
@@ -24,14 +24,6 @@ import org.codehaus.groovy.control.*
 class GenericsGenTest extends GroovyTestCase {
 
     void testCompile() {
-        try {
-            Class.forName("java.lang.annotation.Annotation");
-        }
-        catch (Exception ex) {
-            return
-        }
-
-
         File dir = createTempDir("groovy-src-", "-src")
         assertNotNull dir
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/efee13bd/src/test/org/codehaus/groovy/classgen/InterfaceTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/classgen/InterfaceTest.groovy b/src/test/org/codehaus/groovy/classgen/InterfaceTest.groovy
index 687b5e1..f267287 100644
--- a/src/test/org/codehaus/groovy/classgen/InterfaceTest.groovy
+++ b/src/test/org/codehaus/groovy/classgen/InterfaceTest.groovy
@@ -24,13 +24,6 @@ import org.codehaus.groovy.tools.FileSystemCompiler
 class InterfaceTest extends GroovyTestCase {
 
     void testCompile() {
-        try {
-            Class.forName("java.lang.annotation.Annotation");
-        }
-        catch (Exception ex) {
-            return
-        }
-
         File dir = createTempDir("groovy-src-", "-src")
         assertNotNull dir
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/efee13bd/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java b/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
index 636008a..7ec6742 100644
--- a/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
+++ b/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
@@ -76,15 +76,7 @@ public class CompilerConfigurationTest extends GroovyTestCase {
     }
 
     private static String getVMVersion() {
-        try {
-            Class.forName("java.lang.annotation.Annotation");
-            return CompilerConfiguration.POST_JDK5;
-        }
-        catch(Exception ex) {
-            // IGNORE
-        }
-
-        return CompilerConfiguration.PRE_JDK5;
+        return CompilerConfiguration.POST_JDK5;
     }
 
     public void testSetViaSystemProperties() {