Skip to content
Permalink
Browse files
Removed unused constructor and fixed intermittent unit test failure
  • Loading branch information
joe-chacko committed Oct 29, 2015
1 parent 2d5fd2d commit 52e1bdf2882b5e3378ceb9523b97f80c7bc32071
Showing 4 changed files with 14 additions and 26 deletions.
@@ -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>

This file was deleted.

@@ -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
@@ -5,28 +5,28 @@
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);
}

0 comments on commit 52e1bdf

Please sign in to comment.