geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject [07/51] [abbrv] geronimo-yoko git commit: Removed unused constructor and fixed intermittent unit test failure
Date Sun, 19 Feb 2017 01:49:24 GMT
Removed unused constructor and fixed intermittent unit test failure


Project: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/repo
Commit: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/commit/52e1bdf2
Tree: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/tree/52e1bdf2
Diff: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/diff/52e1bdf2

Branch: refs/heads/master
Commit: 52e1bdf2882b5e3378ceb9523b97f80c7bc32071
Parents: 2d5fd2d
Author: Joe Chacko <chackoj@uk.ibm.com>
Authored: Thu Oct 29 14:01:12 2015 +0000
Committer: Joe Chacko <chackoj@uk.ibm.com>
Committed: Thu Oct 29 14:01:12 2015 +0000

----------------------------------------------------------------------
 yoko-util/pom.xml                                 |  3 ++-
 .../yoko/util/concurrent/NoOpRunnableFactory.java | 10 ----------
 .../yoko/util/concurrent/WeakConcurrentFifo.java  |  9 +++------
 .../util/concurrent/WeakConcurrentFifoTest.java   | 18 +++++++++---------
 4 files changed, 14 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/52e1bdf2/yoko-util/pom.xml
----------------------------------------------------------------------
diff --git a/yoko-util/pom.xml b/yoko-util/pom.xml
index 2c6c625..22a7200 100644
--- a/yoko-util/pom.xml
+++ b/yoko-util/pom.xml
@@ -50,7 +50,7 @@
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
-            <version>1.9.0</version>
+            <version>1.10.19</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
@@ -72,6 +72,7 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
+                    <!-- <argLine>-verbose:class</argLine> -->
                     <includes>
                         <include>**/*Test.java</include>
                     </includes>

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/52e1bdf2/yoko-util/src/main/java/org/apache/yoko/util/concurrent/NoOpRunnableFactory.java
----------------------------------------------------------------------
diff --git a/yoko-util/src/main/java/org/apache/yoko/util/concurrent/NoOpRunnableFactory.java
b/yoko-util/src/main/java/org/apache/yoko/util/concurrent/NoOpRunnableFactory.java
deleted file mode 100644
index 6d71a32..0000000
--- a/yoko-util/src/main/java/org/apache/yoko/util/concurrent/NoOpRunnableFactory.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.apache.yoko.util.concurrent;
-
-import org.apache.yoko.util.Factory;
-import org.apache.yoko.util.KeyedFactory;
-
-public enum NoOpRunnableFactory implements Runnable, KeyedFactory<Object, Runnable>
{
-    INSTANCE;
-    public Runnable create(Object key) {return this;}
-    public void run() {}
-}

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/52e1bdf2/yoko-util/src/main/java/org/apache/yoko/util/concurrent/WeakConcurrentFifo.java
----------------------------------------------------------------------
diff --git a/yoko-util/src/main/java/org/apache/yoko/util/concurrent/WeakConcurrentFifo.java
b/yoko-util/src/main/java/org/apache/yoko/util/concurrent/WeakConcurrentFifo.java
index 3dd9592..2191a94 100644
--- a/yoko-util/src/main/java/org/apache/yoko/util/concurrent/WeakConcurrentFifo.java
+++ b/yoko-util/src/main/java/org/apache/yoko/util/concurrent/WeakConcurrentFifo.java
@@ -1,20 +1,17 @@
 package org.apache.yoko.util.concurrent;
 
 import org.apache.yoko.util.KeyedFactory;
-import org.apache.yoko.util.Sequential;
 
 import java.lang.ref.ReferenceQueue;
 
+import static java.util.Objects.requireNonNull;
+
 public class WeakConcurrentFifo<T> extends ConcurrentFifo<T> {
     private final ReferenceQueue<T> refQueue = new ReferenceQueue<>();
     private final KeyedFactory<? super T, Runnable> cleanupFactory;
 
-    WeakConcurrentFifo() {
-        this(NoOpRunnableFactory.INSTANCE);
-    }
-
     WeakConcurrentFifo(KeyedFactory<? super T, Runnable> cleanupFactory) {
-        this.cleanupFactory = cleanupFactory;
+        this.cleanupFactory = requireNonNull(cleanupFactory);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/52e1bdf2/yoko-util/src/test/java/org/apache/yoko/util/concurrent/WeakConcurrentFifoTest.java
----------------------------------------------------------------------
diff --git a/yoko-util/src/test/java/org/apache/yoko/util/concurrent/WeakConcurrentFifoTest.java
b/yoko-util/src/test/java/org/apache/yoko/util/concurrent/WeakConcurrentFifoTest.java
index 75a0727..f81f477 100644
--- a/yoko-util/src/test/java/org/apache/yoko/util/concurrent/WeakConcurrentFifoTest.java
+++ b/yoko-util/src/test/java/org/apache/yoko/util/concurrent/WeakConcurrentFifoTest.java
@@ -5,28 +5,28 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
+import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 
 import java.lang.ref.WeakReference;
 
 import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.*;
 
-@RunWith(MockitoJUnitRunner.class)
 public class WeakConcurrentFifoTest extends ConcurrentFifoTest {
-    private KeyedFactory<String, Runnable> factory =  new KeyedFactory<String, Runnable>()
{
-        public Runnable create(String key) {
-            return cleanup;
-        }
+    // must not use a mock here because it will hold onto all its arguments strongly
+    private final KeyedFactory<String, Runnable> factory =  new KeyedFactory<String,
Runnable>() {
+        public Runnable create(String key) {return cleanup;}
     };
 
-    @Mock
+    // must not use the @Mock annotation and Mockito's injection
+    // because it intermittently fails to count invocations correctly
     private Runnable cleanup;
 
-    @Override
     @Before
+    @Override
     public void setupFifo() {
+        cleanup = mock(Runnable.class);
         fifo = new WeakConcurrentFifo<>(factory);
     }
 


Mime
View raw message