The following issues were found
guava-tests/test/com/google/common/base/FinalizableReferenceQueueClassLoaderUnloadingTest.java
63 issues
Line: 188
@Override
public WeakReference<Object> call() {
WeakReference<Object> wr =
new FinalizableWeakReference<Object>(new Integer(23), frq) {
@Override
public void finalizeReferent() {
finalized.release();
}
};
Reported by PMD.
Line: 86
}
}
private WeakReference<ClassLoader> useFrqInSeparateLoader() throws Exception {
final ClassLoader myLoader = getClass().getClassLoader();
URLClassLoader sepLoader = new URLClassLoader(getClassPathUrls(), myLoader.getParent());
// sepLoader is the loader that we will use to load the parallel FinalizableReferenceQueue (FRQ)
// and friends, and that we will eventually expect to see garbage-collected. The assumption
// is that the ClassLoader of this test is a URLClassLoader, and that it loads FRQ itself
Reported by PMD.
Line: 87
}
private WeakReference<ClassLoader> useFrqInSeparateLoader() throws Exception {
final ClassLoader myLoader = getClass().getClassLoader();
URLClassLoader sepLoader = new URLClassLoader(getClassPathUrls(), myLoader.getParent());
// sepLoader is the loader that we will use to load the parallel FinalizableReferenceQueue (FRQ)
// and friends, and that we will eventually expect to see garbage-collected. The assumption
// is that the ClassLoader of this test is a URLClassLoader, and that it loads FRQ itself
// rather than delegating to a parent ClassLoader. If this assumption is violated the test will
Reported by PMD.
Line: 87
}
private WeakReference<ClassLoader> useFrqInSeparateLoader() throws Exception {
final ClassLoader myLoader = getClass().getClassLoader();
URLClassLoader sepLoader = new URLClassLoader(getClassPathUrls(), myLoader.getParent());
// sepLoader is the loader that we will use to load the parallel FinalizableReferenceQueue (FRQ)
// and friends, and that we will eventually expect to see garbage-collected. The assumption
// is that the ClassLoader of this test is a URLClassLoader, and that it loads FRQ itself
// rather than delegating to a parent ClassLoader. If this assumption is violated the test will
Reported by PMD.
Line: 88
private WeakReference<ClassLoader> useFrqInSeparateLoader() throws Exception {
final ClassLoader myLoader = getClass().getClassLoader();
URLClassLoader sepLoader = new URLClassLoader(getClassPathUrls(), myLoader.getParent());
// sepLoader is the loader that we will use to load the parallel FinalizableReferenceQueue (FRQ)
// and friends, and that we will eventually expect to see garbage-collected. The assumption
// is that the ClassLoader of this test is a URLClassLoader, and that it loads FRQ itself
// rather than delegating to a parent ClassLoader. If this assumption is violated the test will
// fail and will need to be rewritten.
Reported by PMD.
Line: 96
// fail and will need to be rewritten.
Class<?> frqC = FinalizableReferenceQueue.class;
Class<?> sepFrqC = sepLoader.loadClass(frqC.getName());
assertNotSame(frqC, sepFrqC);
// Check the assumptions above.
// FRQ tries to load the Finalizer class (for the reference-collecting thread) in a few ways.
// If the class is accessible to the system ClassLoader (ClassLoader.getSystemClassLoader())
Reported by PMD.
Line: 97
Class<?> frqC = FinalizableReferenceQueue.class;
Class<?> sepFrqC = sepLoader.loadClass(frqC.getName());
assertNotSame(frqC, sepFrqC);
// Check the assumptions above.
// FRQ tries to load the Finalizer class (for the reference-collecting thread) in a few ways.
// If the class is accessible to the system ClassLoader (ClassLoader.getSystemClassLoader())
// then FRQ does not bother to load Finalizer.class through a separate ClassLoader. That happens
Reported by PMD.
Line: 108
// and each test creates its own one of those, so there is no test interference here.
Class<?> sepFrqSystemLoaderC =
sepLoader.loadClass(FinalizableReferenceQueue.SystemLoader.class.getName());
Field disabled = sepFrqSystemLoaderC.getDeclaredField("disabled");
disabled.setAccessible(true);
disabled.set(null, true);
// Now make a parallel FRQ and an associated FinalizableWeakReference to an object, in order to
// exercise some classes from the parallel ClassLoader.
Reported by PMD.
Line: 109
Class<?> sepFrqSystemLoaderC =
sepLoader.loadClass(FinalizableReferenceQueue.SystemLoader.class.getName());
Field disabled = sepFrqSystemLoaderC.getDeclaredField("disabled");
disabled.setAccessible(true);
disabled.set(null, true);
// Now make a parallel FRQ and an associated FinalizableWeakReference to an object, in order to
// exercise some classes from the parallel ClassLoader.
AtomicReference<Object> sepFrqA =
Reported by PMD.
Line: 110
sepLoader.loadClass(FinalizableReferenceQueue.SystemLoader.class.getName());
Field disabled = sepFrqSystemLoaderC.getDeclaredField("disabled");
disabled.setAccessible(true);
disabled.set(null, true);
// Now make a parallel FRQ and an associated FinalizableWeakReference to an object, in order to
// exercise some classes from the parallel ClassLoader.
AtomicReference<Object> sepFrqA =
new AtomicReference<Object>(sepFrqC.getDeclaredConstructor().newInstance());
Reported by PMD.
android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueClassLoaderUnloadingTest.java
63 issues
Line: 188
@Override
public WeakReference<Object> call() {
WeakReference<Object> wr =
new FinalizableWeakReference<Object>(new Integer(23), frq) {
@Override
public void finalizeReferent() {
finalized.release();
}
};
Reported by PMD.
Line: 86
}
}
private WeakReference<ClassLoader> useFrqInSeparateLoader() throws Exception {
final ClassLoader myLoader = getClass().getClassLoader();
URLClassLoader sepLoader = new URLClassLoader(getClassPathUrls(), myLoader.getParent());
// sepLoader is the loader that we will use to load the parallel FinalizableReferenceQueue (FRQ)
// and friends, and that we will eventually expect to see garbage-collected. The assumption
// is that the ClassLoader of this test is a URLClassLoader, and that it loads FRQ itself
Reported by PMD.
Line: 87
}
private WeakReference<ClassLoader> useFrqInSeparateLoader() throws Exception {
final ClassLoader myLoader = getClass().getClassLoader();
URLClassLoader sepLoader = new URLClassLoader(getClassPathUrls(), myLoader.getParent());
// sepLoader is the loader that we will use to load the parallel FinalizableReferenceQueue (FRQ)
// and friends, and that we will eventually expect to see garbage-collected. The assumption
// is that the ClassLoader of this test is a URLClassLoader, and that it loads FRQ itself
// rather than delegating to a parent ClassLoader. If this assumption is violated the test will
Reported by PMD.
Line: 87
}
private WeakReference<ClassLoader> useFrqInSeparateLoader() throws Exception {
final ClassLoader myLoader = getClass().getClassLoader();
URLClassLoader sepLoader = new URLClassLoader(getClassPathUrls(), myLoader.getParent());
// sepLoader is the loader that we will use to load the parallel FinalizableReferenceQueue (FRQ)
// and friends, and that we will eventually expect to see garbage-collected. The assumption
// is that the ClassLoader of this test is a URLClassLoader, and that it loads FRQ itself
// rather than delegating to a parent ClassLoader. If this assumption is violated the test will
Reported by PMD.
Line: 88
private WeakReference<ClassLoader> useFrqInSeparateLoader() throws Exception {
final ClassLoader myLoader = getClass().getClassLoader();
URLClassLoader sepLoader = new URLClassLoader(getClassPathUrls(), myLoader.getParent());
// sepLoader is the loader that we will use to load the parallel FinalizableReferenceQueue (FRQ)
// and friends, and that we will eventually expect to see garbage-collected. The assumption
// is that the ClassLoader of this test is a URLClassLoader, and that it loads FRQ itself
// rather than delegating to a parent ClassLoader. If this assumption is violated the test will
// fail and will need to be rewritten.
Reported by PMD.
Line: 96
// fail and will need to be rewritten.
Class<?> frqC = FinalizableReferenceQueue.class;
Class<?> sepFrqC = sepLoader.loadClass(frqC.getName());
assertNotSame(frqC, sepFrqC);
// Check the assumptions above.
// FRQ tries to load the Finalizer class (for the reference-collecting thread) in a few ways.
// If the class is accessible to the system ClassLoader (ClassLoader.getSystemClassLoader())
Reported by PMD.
Line: 97
Class<?> frqC = FinalizableReferenceQueue.class;
Class<?> sepFrqC = sepLoader.loadClass(frqC.getName());
assertNotSame(frqC, sepFrqC);
// Check the assumptions above.
// FRQ tries to load the Finalizer class (for the reference-collecting thread) in a few ways.
// If the class is accessible to the system ClassLoader (ClassLoader.getSystemClassLoader())
// then FRQ does not bother to load Finalizer.class through a separate ClassLoader. That happens
Reported by PMD.
Line: 108
// and each test creates its own one of those, so there is no test interference here.
Class<?> sepFrqSystemLoaderC =
sepLoader.loadClass(FinalizableReferenceQueue.SystemLoader.class.getName());
Field disabled = sepFrqSystemLoaderC.getDeclaredField("disabled");
disabled.setAccessible(true);
disabled.set(null, true);
// Now make a parallel FRQ and an associated FinalizableWeakReference to an object, in order to
// exercise some classes from the parallel ClassLoader.
Reported by PMD.
Line: 109
Class<?> sepFrqSystemLoaderC =
sepLoader.loadClass(FinalizableReferenceQueue.SystemLoader.class.getName());
Field disabled = sepFrqSystemLoaderC.getDeclaredField("disabled");
disabled.setAccessible(true);
disabled.set(null, true);
// Now make a parallel FRQ and an associated FinalizableWeakReference to an object, in order to
// exercise some classes from the parallel ClassLoader.
AtomicReference<Object> sepFrqA =
Reported by PMD.
Line: 110
sepLoader.loadClass(FinalizableReferenceQueue.SystemLoader.class.getName());
Field disabled = sepFrqSystemLoaderC.getDeclaredField("disabled");
disabled.setAccessible(true);
disabled.set(null, true);
// Now make a parallel FRQ and an associated FinalizableWeakReference to an object, in order to
// exercise some classes from the parallel ClassLoader.
AtomicReference<Object> sepFrqA =
new AtomicReference<Object>(sepFrqC.getDeclaredConstructor().newInstance());
Reported by PMD.
android/guava-tests/test/com/google/common/graph/StandardImmutableGraphAdditionalTest.java
63 issues
Line: 33
public class StandardImmutableGraphAdditionalTest {
@Test
public void immutableGraph() {
MutableGraph<String> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode("A");
ImmutableGraph<String> immutableGraph = ImmutableGraph.copyOf(mutableGraph);
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
Reported by PMD.
Line: 34
@Test
public void immutableGraph() {
MutableGraph<String> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode("A");
ImmutableGraph<String> immutableGraph = ImmutableGraph.copyOf(mutableGraph);
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
assertThat(immutableGraph).isEqualTo(mutableGraph);
Reported by PMD.
Line: 35
@Test
public void immutableGraph() {
MutableGraph<String> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode("A");
ImmutableGraph<String> immutableGraph = ImmutableGraph.copyOf(mutableGraph);
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
assertThat(immutableGraph).isEqualTo(mutableGraph);
Reported by PMD.
Line: 38
mutableGraph.addNode("A");
ImmutableGraph<String> immutableGraph = ImmutableGraph.copyOf(mutableGraph);
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
assertThat(immutableGraph).isEqualTo(mutableGraph);
mutableGraph.addNode("B");
assertThat(immutableGraph).isNotEqualTo(mutableGraph);
}
Reported by PMD.
Line: 39
ImmutableGraph<String> immutableGraph = ImmutableGraph.copyOf(mutableGraph);
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
assertThat(immutableGraph).isEqualTo(mutableGraph);
mutableGraph.addNode("B");
assertThat(immutableGraph).isNotEqualTo(mutableGraph);
}
Reported by PMD.
Line: 41
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
assertThat(immutableGraph).isEqualTo(mutableGraph);
mutableGraph.addNode("B");
assertThat(immutableGraph).isNotEqualTo(mutableGraph);
}
@Test
public void copyOfImmutableGraph_optimized() {
Reported by PMD.
Line: 42
assertThat(immutableGraph).isEqualTo(mutableGraph);
mutableGraph.addNode("B");
assertThat(immutableGraph).isNotEqualTo(mutableGraph);
}
@Test
public void copyOfImmutableGraph_optimized() {
Graph<String> graph1 = ImmutableGraph.copyOf(GraphBuilder.directed().<String>build());
Reported by PMD.
Line: 47
@Test
public void copyOfImmutableGraph_optimized() {
Graph<String> graph1 = ImmutableGraph.copyOf(GraphBuilder.directed().<String>build());
Graph<String> graph2 = ImmutableGraph.copyOf(graph1);
assertThat(graph2).isSameInstanceAs(graph1);
}
Reported by PMD.
Line: 50
Graph<String> graph1 = ImmutableGraph.copyOf(GraphBuilder.directed().<String>build());
Graph<String> graph2 = ImmutableGraph.copyOf(graph1);
assertThat(graph2).isSameInstanceAs(graph1);
}
@Test
public void immutableGraphBuilder_appliesGraphBuilderConfig() {
ImmutableGraph<String> emptyGraph =
Reported by PMD.
Line: 54
}
@Test
public void immutableGraphBuilder_appliesGraphBuilderConfig() {
ImmutableGraph<String> emptyGraph =
GraphBuilder.directed()
.allowsSelfLoops(true)
.nodeOrder(ElementOrder.<String>natural())
.immutable()
Reported by PMD.
guava-tests/test/com/google/common/graph/StandardImmutableGraphAdditionalTest.java
63 issues
Line: 33
public class StandardImmutableGraphAdditionalTest {
@Test
public void immutableGraph() {
MutableGraph<String> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode("A");
ImmutableGraph<String> immutableGraph = ImmutableGraph.copyOf(mutableGraph);
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
Reported by PMD.
Line: 34
@Test
public void immutableGraph() {
MutableGraph<String> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode("A");
ImmutableGraph<String> immutableGraph = ImmutableGraph.copyOf(mutableGraph);
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
assertThat(immutableGraph).isEqualTo(mutableGraph);
Reported by PMD.
Line: 35
@Test
public void immutableGraph() {
MutableGraph<String> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode("A");
ImmutableGraph<String> immutableGraph = ImmutableGraph.copyOf(mutableGraph);
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
assertThat(immutableGraph).isEqualTo(mutableGraph);
Reported by PMD.
Line: 38
mutableGraph.addNode("A");
ImmutableGraph<String> immutableGraph = ImmutableGraph.copyOf(mutableGraph);
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
assertThat(immutableGraph).isEqualTo(mutableGraph);
mutableGraph.addNode("B");
assertThat(immutableGraph).isNotEqualTo(mutableGraph);
}
Reported by PMD.
Line: 39
ImmutableGraph<String> immutableGraph = ImmutableGraph.copyOf(mutableGraph);
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
assertThat(immutableGraph).isEqualTo(mutableGraph);
mutableGraph.addNode("B");
assertThat(immutableGraph).isNotEqualTo(mutableGraph);
}
Reported by PMD.
Line: 41
assertThat(immutableGraph).isNotInstanceOf(MutableValueGraph.class);
assertThat(immutableGraph).isEqualTo(mutableGraph);
mutableGraph.addNode("B");
assertThat(immutableGraph).isNotEqualTo(mutableGraph);
}
@Test
public void copyOfImmutableGraph_optimized() {
Reported by PMD.
Line: 42
assertThat(immutableGraph).isEqualTo(mutableGraph);
mutableGraph.addNode("B");
assertThat(immutableGraph).isNotEqualTo(mutableGraph);
}
@Test
public void copyOfImmutableGraph_optimized() {
Graph<String> graph1 = ImmutableGraph.copyOf(GraphBuilder.directed().<String>build());
Reported by PMD.
Line: 47
@Test
public void copyOfImmutableGraph_optimized() {
Graph<String> graph1 = ImmutableGraph.copyOf(GraphBuilder.directed().<String>build());
Graph<String> graph2 = ImmutableGraph.copyOf(graph1);
assertThat(graph2).isSameInstanceAs(graph1);
}
Reported by PMD.
Line: 50
Graph<String> graph1 = ImmutableGraph.copyOf(GraphBuilder.directed().<String>build());
Graph<String> graph2 = ImmutableGraph.copyOf(graph1);
assertThat(graph2).isSameInstanceAs(graph1);
}
@Test
public void immutableGraphBuilder_appliesGraphBuilderConfig() {
ImmutableGraph<String> emptyGraph =
Reported by PMD.
Line: 54
}
@Test
public void immutableGraphBuilder_appliesGraphBuilderConfig() {
ImmutableGraph<String> emptyGraph =
GraphBuilder.directed()
.allowsSelfLoops(true)
.nodeOrder(ElementOrder.<String>natural())
.immutable()
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java
62 issues
Line: 68
try {
MILLISECONDS.sleep(DELAY_MS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
};
private static final Runnable BAD_RUNNABLE =
new Runnable() {
Reported by PMD.
Line: 79
try {
MILLISECONDS.sleep(DELAY_MS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
throw new SampleRuntimeException();
}
};
Reported by PMD.
Line: 38
* @author Jens Nyman
*/
public class SimpleTimeLimiterTest extends TestCase {
private static final long DELAY_MS = 50;
private static final long ENOUGH_MS = 10000;
private static final long NOT_ENOUGH_MS = 5;
Reported by PMD.
Line: 85
}
};
private TimeLimiter service;
private static final ExecutorService executor = Executors.newFixedThreadPool(1);
@Override
protected void setUp() throws Exception {
Reported by PMD.
Line: 89
private static final ExecutorService executor = Executors.newFixedThreadPool(1);
@Override
protected void setUp() throws Exception {
super.setUp();
service = SimpleTimeLimiter.create(executor);
}
Reported by PMD.
Line: 95
service = SimpleTimeLimiter.create(executor);
}
public void testNewProxy_goodMethodWithEnoughTime() throws Exception {
SampleImpl target = new SampleImpl(DELAY_MS);
Sample proxy = service.newProxy(target, Sample.class, ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
String result = proxy.sleepThenReturnInput("x");
Reported by PMD.
Line: 95
service = SimpleTimeLimiter.create(executor);
}
public void testNewProxy_goodMethodWithEnoughTime() throws Exception {
SampleImpl target = new SampleImpl(DELAY_MS);
Sample proxy = service.newProxy(target, Sample.class, ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
String result = proxy.sleepThenReturnInput("x");
Reported by PMD.
Line: 100
Sample proxy = service.newProxy(target, Sample.class, ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
String result = proxy.sleepThenReturnInput("x");
assertThat(result).isEqualTo("x");
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
assertThat(target.finished).isTrue();
}
Reported by PMD.
Line: 102
String result = proxy.sleepThenReturnInput("x");
assertThat(result).isEqualTo("x");
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
assertThat(target.finished).isTrue();
}
public void testNewProxy_goodMethodWithNotEnoughTime() throws Exception {
Reported by PMD.
Line: 103
String result = proxy.sleepThenReturnInput("x");
assertThat(result).isEqualTo("x");
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
assertThat(target.finished).isTrue();
}
public void testNewProxy_goodMethodWithNotEnoughTime() throws Exception {
SampleImpl target = new SampleImpl(9999);
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MultimapTestSuiteBuilder.java
62 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect.testing.google;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.testing.Helpers.mapEntry;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect.testing.google;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.testing.Helpers.mapEntry;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 68
@GwtIncompatible
public class MultimapTestSuiteBuilder<K, V, M extends Multimap<K, V>>
extends PerCollectionSizeTestSuiteBuilder<
MultimapTestSuiteBuilder<K, V, M>, TestMultimapGenerator<K, V, M>, M, Entry<K, V>> {
public static <K, V, M extends Multimap<K, V>> MultimapTestSuiteBuilder<K, V, M> using(
TestMultimapGenerator<K, V, M> generator) {
return new MultimapTestSuiteBuilder<K, V, M>().usingGenerator(generator);
}
Reported by PMD.
Line: 112
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) {
derivedSuites.add(
MultimapTestSuiteBuilder.using(
new ReserializedMultimapGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeReserializedMultimapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " reserialized")
Reported by PMD.
Line: 133
.withTearDown(parentBuilder.getTearDown())
.createTestSuite());
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
Reported by PMD.
Line: 134
.createTestSuite());
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
return derivedSuites;
Reported by PMD.
Line: 135
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
return derivedSuites;
}
Reported by PMD.
Line: 136
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
return derivedSuites;
}
Reported by PMD.
Line: 137
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
return derivedSuites;
}
TestSuite computeValuesTestSuite(
Reported by PMD.
Line: 212
static Set<Feature<?>> computeDerivedCollectionFeatures(Set<Feature<?>> multimapFeatures) {
Set<Feature<?>> derivedFeatures = Helpers.copyToSet(multimapFeatures);
if (!derivedFeatures.remove(CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS)) {
derivedFeatures.remove(CollectionFeature.SERIALIZABLE);
}
if (derivedFeatures.remove(MapFeature.SUPPORTS_REMOVE)) {
derivedFeatures.add(CollectionFeature.SUPPORTS_REMOVE);
}
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java
62 issues
Line: 68
try {
MILLISECONDS.sleep(DELAY_MS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
};
private static final Runnable BAD_RUNNABLE =
new Runnable() {
Reported by PMD.
Line: 79
try {
MILLISECONDS.sleep(DELAY_MS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
throw new SampleRuntimeException();
}
};
Reported by PMD.
Line: 38
* @author Jens Nyman
*/
public class SimpleTimeLimiterTest extends TestCase {
private static final long DELAY_MS = 50;
private static final long ENOUGH_MS = 10000;
private static final long NOT_ENOUGH_MS = 5;
Reported by PMD.
Line: 85
}
};
private TimeLimiter service;
private static final ExecutorService executor = Executors.newFixedThreadPool(1);
@Override
protected void setUp() throws Exception {
Reported by PMD.
Line: 89
private static final ExecutorService executor = Executors.newFixedThreadPool(1);
@Override
protected void setUp() throws Exception {
super.setUp();
service = SimpleTimeLimiter.create(executor);
}
Reported by PMD.
Line: 95
service = SimpleTimeLimiter.create(executor);
}
public void testNewProxy_goodMethodWithEnoughTime() throws Exception {
SampleImpl target = new SampleImpl(DELAY_MS);
Sample proxy = service.newProxy(target, Sample.class, ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
String result = proxy.sleepThenReturnInput("x");
Reported by PMD.
Line: 95
service = SimpleTimeLimiter.create(executor);
}
public void testNewProxy_goodMethodWithEnoughTime() throws Exception {
SampleImpl target = new SampleImpl(DELAY_MS);
Sample proxy = service.newProxy(target, Sample.class, ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
String result = proxy.sleepThenReturnInput("x");
Reported by PMD.
Line: 100
Sample proxy = service.newProxy(target, Sample.class, ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
String result = proxy.sleepThenReturnInput("x");
assertThat(result).isEqualTo("x");
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
assertThat(target.finished).isTrue();
}
Reported by PMD.
Line: 102
String result = proxy.sleepThenReturnInput("x");
assertThat(result).isEqualTo("x");
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
assertThat(target.finished).isTrue();
}
public void testNewProxy_goodMethodWithNotEnoughTime() throws Exception {
Reported by PMD.
Line: 103
String result = proxy.sleepThenReturnInput("x");
assertThat(result).isEqualTo("x");
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
assertThat(target.finished).isTrue();
}
public void testNewProxy_goodMethodWithNotEnoughTime() throws Exception {
SampleImpl target = new SampleImpl(9999);
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/MultimapTestSuiteBuilder.java
62 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect.testing.google;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.testing.Helpers.mapEntry;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect.testing.google;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.testing.Helpers.mapEntry;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 68
@GwtIncompatible
public class MultimapTestSuiteBuilder<K, V, M extends Multimap<K, V>>
extends PerCollectionSizeTestSuiteBuilder<
MultimapTestSuiteBuilder<K, V, M>, TestMultimapGenerator<K, V, M>, M, Entry<K, V>> {
public static <K, V, M extends Multimap<K, V>> MultimapTestSuiteBuilder<K, V, M> using(
TestMultimapGenerator<K, V, M> generator) {
return new MultimapTestSuiteBuilder<K, V, M>().usingGenerator(generator);
}
Reported by PMD.
Line: 111
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) {
derivedSuites.add(
MultimapTestSuiteBuilder.using(
new ReserializedMultimapGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeReserializedMultimapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " reserialized")
Reported by PMD.
Line: 132
.withTearDown(parentBuilder.getTearDown())
.createTestSuite());
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
Reported by PMD.
Line: 133
.createTestSuite());
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
return derivedSuites;
Reported by PMD.
Line: 134
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
return derivedSuites;
}
Reported by PMD.
Line: 135
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
return derivedSuites;
}
Reported by PMD.
Line: 136
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
return derivedSuites;
}
TestSuite computeValuesTestSuite(
Reported by PMD.
Line: 211
static Set<Feature<?>> computeDerivedCollectionFeatures(Set<Feature<?>> multimapFeatures) {
Set<Feature<?>> derivedFeatures = Helpers.copyToSet(multimapFeatures);
if (!derivedFeatures.remove(CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS)) {
derivedFeatures.remove(CollectionFeature.SERIALIZABLE);
}
if (derivedFeatures.remove(MapFeature.SUPPORTS_REMOVE)) {
derivedFeatures.add(CollectionFeature.SUPPORTS_REMOVE);
}
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/JdkFutureAdaptersTest.java
62 issues
Line: 202
* value is set in addition to the call we'll make after then.
*/
allowGetToComplete.await(1, SECONDS);
throw new RuntimeException("expected, should be caught");
}
@Override
public V get(long timeout, TimeUnit unit) {
throw new AssertionFailedError();
Reported by PMD.
Line: 46
public class JdkFutureAdaptersTest extends TestCase {
private static final String DATA1 = "data";
public void testListenInPoolThreadReturnsSameFuture() throws Exception {
ListenableFuture<String> listenableFuture = immediateFuture(DATA1);
assertSame(listenableFuture, listenInPoolThread(listenableFuture));
}
private static class SingleCallListener implements Runnable {
Reported by PMD.
Line: 48
public void testListenInPoolThreadReturnsSameFuture() throws Exception {
ListenableFuture<String> listenableFuture = immediateFuture(DATA1);
assertSame(listenableFuture, listenInPoolThread(listenableFuture));
}
private static class SingleCallListener implements Runnable {
private boolean expectCall = false;
Reported by PMD.
Line: 53
private static class SingleCallListener implements Runnable {
private boolean expectCall = false;
private final CountDownLatch calledCountDown = new CountDownLatch(1);
@Override
public void run() {
assertTrue("Listener called before it was expected", expectCall);
Reported by PMD.
Line: 53
private static class SingleCallListener implements Runnable {
private boolean expectCall = false;
private final CountDownLatch calledCountDown = new CountDownLatch(1);
@Override
public void run() {
assertTrue("Listener called before it was expected", expectCall);
Reported by PMD.
Line: 53
private static class SingleCallListener implements Runnable {
private boolean expectCall = false;
private final CountDownLatch calledCountDown = new CountDownLatch(1);
@Override
public void run() {
assertTrue("Listener called before it was expected", expectCall);
Reported by PMD.
Line: 54
private static class SingleCallListener implements Runnable {
private boolean expectCall = false;
private final CountDownLatch calledCountDown = new CountDownLatch(1);
@Override
public void run() {
assertTrue("Listener called before it was expected", expectCall);
assertFalse("Listener called more than once", wasCalled());
Reported by PMD.
Line: 78
}
}
public void testListenInPoolThreadIgnoresExecutorWhenDelegateIsDone() throws Exception {
NonListenableSettableFuture<String> abstractFuture = NonListenableSettableFuture.create();
abstractFuture.set(DATA1);
ExecutorSpy spy = new ExecutorSpy(directExecutor());
ListenableFuture<String> listenableFuture = listenInPoolThread(abstractFuture, spy);
Reported by PMD.
Line: 78
}
}
public void testListenInPoolThreadIgnoresExecutorWhenDelegateIsDone() throws Exception {
NonListenableSettableFuture<String> abstractFuture = NonListenableSettableFuture.create();
abstractFuture.set(DATA1);
ExecutorSpy spy = new ExecutorSpy(directExecutor());
ListenableFuture<String> listenableFuture = listenInPoolThread(abstractFuture, spy);
Reported by PMD.
Line: 80
public void testListenInPoolThreadIgnoresExecutorWhenDelegateIsDone() throws Exception {
NonListenableSettableFuture<String> abstractFuture = NonListenableSettableFuture.create();
abstractFuture.set(DATA1);
ExecutorSpy spy = new ExecutorSpy(directExecutor());
ListenableFuture<String> listenableFuture = listenInPoolThread(abstractFuture, spy);
SingleCallListener singleCallListener = new SingleCallListener();
singleCallListener.expectCall();
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/JdkFutureAdaptersTest.java
62 issues
Line: 202
* value is set in addition to the call we'll make after then.
*/
allowGetToComplete.await(1, SECONDS);
throw new RuntimeException("expected, should be caught");
}
@Override
public V get(long timeout, TimeUnit unit) {
throw new AssertionFailedError();
Reported by PMD.
Line: 46
public class JdkFutureAdaptersTest extends TestCase {
private static final String DATA1 = "data";
public void testListenInPoolThreadReturnsSameFuture() throws Exception {
ListenableFuture<String> listenableFuture = immediateFuture(DATA1);
assertSame(listenableFuture, listenInPoolThread(listenableFuture));
}
private static class SingleCallListener implements Runnable {
Reported by PMD.
Line: 48
public void testListenInPoolThreadReturnsSameFuture() throws Exception {
ListenableFuture<String> listenableFuture = immediateFuture(DATA1);
assertSame(listenableFuture, listenInPoolThread(listenableFuture));
}
private static class SingleCallListener implements Runnable {
private boolean expectCall = false;
Reported by PMD.
Line: 53
private static class SingleCallListener implements Runnable {
private boolean expectCall = false;
private final CountDownLatch calledCountDown = new CountDownLatch(1);
@Override
public void run() {
assertTrue("Listener called before it was expected", expectCall);
Reported by PMD.
Line: 53
private static class SingleCallListener implements Runnable {
private boolean expectCall = false;
private final CountDownLatch calledCountDown = new CountDownLatch(1);
@Override
public void run() {
assertTrue("Listener called before it was expected", expectCall);
Reported by PMD.
Line: 53
private static class SingleCallListener implements Runnable {
private boolean expectCall = false;
private final CountDownLatch calledCountDown = new CountDownLatch(1);
@Override
public void run() {
assertTrue("Listener called before it was expected", expectCall);
Reported by PMD.
Line: 54
private static class SingleCallListener implements Runnable {
private boolean expectCall = false;
private final CountDownLatch calledCountDown = new CountDownLatch(1);
@Override
public void run() {
assertTrue("Listener called before it was expected", expectCall);
assertFalse("Listener called more than once", wasCalled());
Reported by PMD.
Line: 78
}
}
public void testListenInPoolThreadIgnoresExecutorWhenDelegateIsDone() throws Exception {
NonListenableSettableFuture<String> abstractFuture = NonListenableSettableFuture.create();
abstractFuture.set(DATA1);
ExecutorSpy spy = new ExecutorSpy(directExecutor());
ListenableFuture<String> listenableFuture = listenInPoolThread(abstractFuture, spy);
Reported by PMD.
Line: 78
}
}
public void testListenInPoolThreadIgnoresExecutorWhenDelegateIsDone() throws Exception {
NonListenableSettableFuture<String> abstractFuture = NonListenableSettableFuture.create();
abstractFuture.set(DATA1);
ExecutorSpy spy = new ExecutorSpy(directExecutor());
ListenableFuture<String> listenableFuture = listenInPoolThread(abstractFuture, spy);
Reported by PMD.
Line: 80
public void testListenInPoolThreadIgnoresExecutorWhenDelegateIsDone() throws Exception {
NonListenableSettableFuture<String> abstractFuture = NonListenableSettableFuture.create();
abstractFuture.set(DATA1);
ExecutorSpy spy = new ExecutorSpy(directExecutor());
ListenableFuture<String> listenableFuture = listenInPoolThread(abstractFuture, spy);
SingleCallListener singleCallListener = new SingleCallListener();
singleCallListener.expectCall();
Reported by PMD.