The following issues were found
guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
230 issues
Line: 34
*
* @author Adam Winer
*/
public class CacheBuilderSpecTest extends TestCase {
public void testParse_empty() {
CacheBuilderSpec spec = parse("");
assertNull(spec.initialCapacity);
assertNull(spec.maximumSize);
assertNull(spec.maximumWeight);
Reported by PMD.
Line: 34
*
* @author Adam Winer
*/
public class CacheBuilderSpecTest extends TestCase {
public void testParse_empty() {
CacheBuilderSpec spec = parse("");
assertNull(spec.initialCapacity);
assertNull(spec.maximumSize);
assertNull(spec.maximumWeight);
Reported by PMD.
Line: 35
* @author Adam Winer
*/
public class CacheBuilderSpecTest extends TestCase {
public void testParse_empty() {
CacheBuilderSpec spec = parse("");
assertNull(spec.initialCapacity);
assertNull(spec.maximumSize);
assertNull(spec.maximumWeight);
assertNull(spec.concurrencyLevel);
Reported by PMD.
Line: 35
* @author Adam Winer
*/
public class CacheBuilderSpecTest extends TestCase {
public void testParse_empty() {
CacheBuilderSpec spec = parse("");
assertNull(spec.initialCapacity);
assertNull(spec.maximumSize);
assertNull(spec.maximumWeight);
assertNull(spec.concurrencyLevel);
Reported by PMD.
Line: 37
public class CacheBuilderSpecTest extends TestCase {
public void testParse_empty() {
CacheBuilderSpec spec = parse("");
assertNull(spec.initialCapacity);
assertNull(spec.maximumSize);
assertNull(spec.maximumWeight);
assertNull(spec.concurrencyLevel);
assertNull(spec.keyStrength);
assertNull(spec.valueStrength);
Reported by PMD.
Line: 38
public void testParse_empty() {
CacheBuilderSpec spec = parse("");
assertNull(spec.initialCapacity);
assertNull(spec.maximumSize);
assertNull(spec.maximumWeight);
assertNull(spec.concurrencyLevel);
assertNull(spec.keyStrength);
assertNull(spec.valueStrength);
assertNull(spec.writeExpirationTimeUnit);
Reported by PMD.
Line: 39
CacheBuilderSpec spec = parse("");
assertNull(spec.initialCapacity);
assertNull(spec.maximumSize);
assertNull(spec.maximumWeight);
assertNull(spec.concurrencyLevel);
assertNull(spec.keyStrength);
assertNull(spec.valueStrength);
assertNull(spec.writeExpirationTimeUnit);
assertNull(spec.accessExpirationTimeUnit);
Reported by PMD.
Line: 40
assertNull(spec.initialCapacity);
assertNull(spec.maximumSize);
assertNull(spec.maximumWeight);
assertNull(spec.concurrencyLevel);
assertNull(spec.keyStrength);
assertNull(spec.valueStrength);
assertNull(spec.writeExpirationTimeUnit);
assertNull(spec.accessExpirationTimeUnit);
assertCacheBuilderEquivalence(CacheBuilder.newBuilder(), CacheBuilder.from(spec));
Reported by PMD.
Line: 41
assertNull(spec.maximumSize);
assertNull(spec.maximumWeight);
assertNull(spec.concurrencyLevel);
assertNull(spec.keyStrength);
assertNull(spec.valueStrength);
assertNull(spec.writeExpirationTimeUnit);
assertNull(spec.accessExpirationTimeUnit);
assertCacheBuilderEquivalence(CacheBuilder.newBuilder(), CacheBuilder.from(spec));
}
Reported by PMD.
Line: 42
assertNull(spec.maximumWeight);
assertNull(spec.concurrencyLevel);
assertNull(spec.keyStrength);
assertNull(spec.valueStrength);
assertNull(spec.writeExpirationTimeUnit);
assertNull(spec.accessExpirationTimeUnit);
assertCacheBuilderEquivalence(CacheBuilder.newBuilder(), CacheBuilder.from(spec));
}
Reported by PMD.
android/guava-tests/test/com/google/common/primitives/ImmutableLongArrayTest.java
230 issues
Line: 45
/** @author Kevin Bourrillion */
@GwtCompatible(emulated = true)
public class ImmutableLongArrayTest extends TestCase {
// Test all creation paths very lazily: by assuming asList() works
public void testOf0() {
assertThat(ImmutableLongArray.of().asList()).isEmpty();
}
Reported by PMD.
Line: 48
public class ImmutableLongArrayTest extends TestCase {
// Test all creation paths very lazily: by assuming asList() works
public void testOf0() {
assertThat(ImmutableLongArray.of().asList()).isEmpty();
}
public void testOf1() {
assertThat(ImmutableLongArray.of(0).asList()).containsExactly(0L);
Reported by PMD.
Line: 49
// Test all creation paths very lazily: by assuming asList() works
public void testOf0() {
assertThat(ImmutableLongArray.of().asList()).isEmpty();
}
public void testOf1() {
assertThat(ImmutableLongArray.of(0).asList()).containsExactly(0L);
}
Reported by PMD.
Line: 49
// Test all creation paths very lazily: by assuming asList() works
public void testOf0() {
assertThat(ImmutableLongArray.of().asList()).isEmpty();
}
public void testOf1() {
assertThat(ImmutableLongArray.of(0).asList()).containsExactly(0L);
}
Reported by PMD.
Line: 52
assertThat(ImmutableLongArray.of().asList()).isEmpty();
}
public void testOf1() {
assertThat(ImmutableLongArray.of(0).asList()).containsExactly(0L);
}
public void testOf2() {
assertThat(ImmutableLongArray.of(0, 1).asList()).containsExactly(0L, 1L).inOrder();
Reported by PMD.
Line: 53
}
public void testOf1() {
assertThat(ImmutableLongArray.of(0).asList()).containsExactly(0L);
}
public void testOf2() {
assertThat(ImmutableLongArray.of(0, 1).asList()).containsExactly(0L, 1L).inOrder();
}
Reported by PMD.
Line: 53
}
public void testOf1() {
assertThat(ImmutableLongArray.of(0).asList()).containsExactly(0L);
}
public void testOf2() {
assertThat(ImmutableLongArray.of(0, 1).asList()).containsExactly(0L, 1L).inOrder();
}
Reported by PMD.
Line: 56
assertThat(ImmutableLongArray.of(0).asList()).containsExactly(0L);
}
public void testOf2() {
assertThat(ImmutableLongArray.of(0, 1).asList()).containsExactly(0L, 1L).inOrder();
}
public void testOf3() {
assertThat(ImmutableLongArray.of(0, 1, 3).asList()).containsExactly(0L, 1L, 3L).inOrder();
Reported by PMD.
Line: 57
}
public void testOf2() {
assertThat(ImmutableLongArray.of(0, 1).asList()).containsExactly(0L, 1L).inOrder();
}
public void testOf3() {
assertThat(ImmutableLongArray.of(0, 1, 3).asList()).containsExactly(0L, 1L, 3L).inOrder();
}
Reported by PMD.
Line: 57
}
public void testOf2() {
assertThat(ImmutableLongArray.of(0, 1).asList()).containsExactly(0L, 1L).inOrder();
}
public void testOf3() {
assertThat(ImmutableLongArray.of(0, 1, 3).asList()).containsExactly(0L, 1L, 3L).inOrder();
}
Reported by PMD.
guava/src/com/google/common/collect/Synchronized.java
230 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 76
* anyway, so we just need to get by without the annotations here until Kotlin better understands
* our other nullness annotations.
*/
final class Synchronized {
private Synchronized() {}
static class SynchronizedObject implements Serializable {
final Object delegate;
final Object mutex;
Reported by PMD.
Line: 76
* anyway, so we just need to get by without the annotations here until Kotlin better understands
* our other nullness annotations.
*/
final class Synchronized {
private Synchronized() {}
static class SynchronizedObject implements Serializable {
final Object delegate;
final Object mutex;
Reported by PMD.
Line: 80
private Synchronized() {}
static class SynchronizedObject implements Serializable {
final Object delegate;
final Object mutex;
SynchronizedObject(Object delegate, @CheckForNull Object mutex) {
this.delegate = checkNotNull(delegate);
this.mutex = (mutex == null) ? this : mutex;
Reported by PMD.
Line: 80
private Synchronized() {}
static class SynchronizedObject implements Serializable {
final Object delegate;
final Object mutex;
SynchronizedObject(Object delegate, @CheckForNull Object mutex) {
this.delegate = checkNotNull(delegate);
this.mutex = (mutex == null) ? this : mutex;
Reported by PMD.
Line: 81
static class SynchronizedObject implements Serializable {
final Object delegate;
final Object mutex;
SynchronizedObject(Object delegate, @CheckForNull Object mutex) {
this.delegate = checkNotNull(delegate);
this.mutex = (mutex == null) ? this : mutex;
}
Reported by PMD.
Line: 124
@VisibleForTesting
static class SynchronizedCollection<E extends @Nullable Object> extends SynchronizedObject
implements Collection<E> {
private SynchronizedCollection(Collection<E> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
}
@SuppressWarnings("unchecked")
Reported by PMD.
Line: 129
super(delegate, mutex);
}
@SuppressWarnings("unchecked")
@Override
Collection<E> delegate() {
return (Collection<E>) super.delegate();
}
Reported by PMD.
guava-tests/test/com/google/common/math/LongMathTest.java
229 issues
Line: 17
* limitations under the License.
*/
package com.google.common.math;
import static com.google.common.math.MathTesting.ALL_LONG_CANDIDATES;
import static com.google.common.math.MathTesting.ALL_ROUNDING_MODES;
import static com.google.common.math.MathTesting.ALL_SAFE_ROUNDING_MODES;
import static com.google.common.math.MathTesting.EXPONENTS;
Reported by PMD.
Line: 50
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
Reported by PMD.
Line: 50
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
Reported by PMD.
Line: 50
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
Reported by PMD.
Line: 51
*/
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
Reported by PMD.
Line: 52
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
public void testCeilingPowerOfTwo() {
Reported by PMD.
Line: 53
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
public void testCeilingPowerOfTwo() {
for (long x : POSITIVE_LONG_CANDIDATES) {
Reported by PMD.
Line: 54
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
public void testCeilingPowerOfTwo() {
for (long x : POSITIVE_LONG_CANDIDATES) {
BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));
Reported by PMD.
Line: 57
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
public void testCeilingPowerOfTwo() {
for (long x : POSITIVE_LONG_CANDIDATES) {
BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));
if (fitsInLong(expectedResult)) {
assertEquals(expectedResult.longValue(), LongMath.ceilingPowerOfTwo(x));
} else {
Reported by PMD.
Line: 61
for (long x : POSITIVE_LONG_CANDIDATES) {
BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));
if (fitsInLong(expectedResult)) {
assertEquals(expectedResult.longValue(), LongMath.ceilingPowerOfTwo(x));
} else {
try {
LongMath.ceilingPowerOfTwo(x);
fail("Expected ArithmeticException");
} catch (ArithmeticException expected) {
Reported by PMD.
android/guava-tests/test/com/google/common/math/LongMathTest.java
229 issues
Line: 17
* limitations under the License.
*/
package com.google.common.math;
import static com.google.common.math.MathTesting.ALL_LONG_CANDIDATES;
import static com.google.common.math.MathTesting.ALL_ROUNDING_MODES;
import static com.google.common.math.MathTesting.ALL_SAFE_ROUNDING_MODES;
import static com.google.common.math.MathTesting.EXPONENTS;
Reported by PMD.
Line: 50
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
Reported by PMD.
Line: 50
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
Reported by PMD.
Line: 50
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
Reported by PMD.
Line: 51
*/
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
Reported by PMD.
Line: 52
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
public void testCeilingPowerOfTwo() {
Reported by PMD.
Line: 53
public class LongMathTest extends TestCase {
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
public void testCeilingPowerOfTwo() {
for (long x : POSITIVE_LONG_CANDIDATES) {
Reported by PMD.
Line: 54
@SuppressWarnings("ConstantOverflow")
public void testMaxSignedPowerOfTwo() {
assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
public void testCeilingPowerOfTwo() {
for (long x : POSITIVE_LONG_CANDIDATES) {
BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));
Reported by PMD.
Line: 57
assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
}
public void testCeilingPowerOfTwo() {
for (long x : POSITIVE_LONG_CANDIDATES) {
BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));
if (fitsInLong(expectedResult)) {
assertEquals(expectedResult.longValue(), LongMath.ceilingPowerOfTwo(x));
} else {
Reported by PMD.
Line: 61
for (long x : POSITIVE_LONG_CANDIDATES) {
BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));
if (fitsInLong(expectedResult)) {
assertEquals(expectedResult.longValue(), LongMath.ceilingPowerOfTwo(x));
} else {
try {
LongMath.ceilingPowerOfTwo(x);
fail("Expected ArithmeticException");
} catch (ArithmeticException expected) {
Reported by PMD.
guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java
229 issues
Line: 17
* limitations under the License.
*/
package com.google.common.graph;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
import static org.junit.Assert.assertTrue;
Reported by PMD.
Line: 35
* Abstract base class for testing undirected {@link Network} implementations defined in this
* package.
*/
public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetworkTest {
private static final EndpointPair<Integer> ENDPOINTS_N1N2 = EndpointPair.ordered(N1, N2);
private static final EndpointPair<Integer> ENDPOINTS_N2N1 = EndpointPair.ordered(N2, N1);
@After
public void validateUndirectedEdges() {
Reported by PMD.
Line: 35
* Abstract base class for testing undirected {@link Network} implementations defined in this
* package.
*/
public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetworkTest {
private static final EndpointPair<Integer> ENDPOINTS_N1N2 = EndpointPair.ordered(N1, N2);
private static final EndpointPair<Integer> ENDPOINTS_N2N1 = EndpointPair.ordered(N2, N1);
@After
public void validateUndirectedEdges() {
Reported by PMD.
Line: 42
@After
public void validateUndirectedEdges() {
for (Integer node : network.nodes()) {
new EqualsTester()
.addEqualityGroup(
network.inEdges(node), network.outEdges(node), network.incidentEdges(node))
.testEquals();
new EqualsTester()
.addEqualityGroup(
Reported by PMD.
Line: 46
.addEqualityGroup(
network.inEdges(node), network.outEdges(node), network.incidentEdges(node))
.testEquals();
new EqualsTester()
.addEqualityGroup(
network.predecessors(node), network.successors(node), network.adjacentNodes(node))
.testEquals();
for (Integer adjacentNode : network.adjacentNodes(node)) {
Reported by PMD.
Line: 52
.testEquals();
for (Integer adjacentNode : network.adjacentNodes(node)) {
assertThat(network.edgesConnecting(node, adjacentNode))
.containsExactlyElementsIn(network.edgesConnecting(adjacentNode, node));
}
}
}
Reported by PMD.
Line: 67
fail(ERROR_MODIFIABLE_COLLECTION);
} catch (UnsupportedOperationException e) {
addNode(N1);
assertThat(network.nodes()).containsExactlyElementsIn(nodes);
}
}
@Override
@Test
Reported by PMD.
Line: 80
fail(ERROR_MODIFIABLE_COLLECTION);
} catch (UnsupportedOperationException e) {
addEdge(N1, N2, E12);
assertThat(network.edges()).containsExactlyElementsIn(edges);
}
}
@Override
@Test
Reported by PMD.
Line: 94
fail(ERROR_MODIFIABLE_COLLECTION);
} catch (UnsupportedOperationException e) {
addEdge(N1, N2, E12);
assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges);
}
}
@Override
@Test
Reported by PMD.
Line: 108
fail(ERROR_MODIFIABLE_COLLECTION);
} catch (UnsupportedOperationException e) {
addEdge(N1, N2, E12);
assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
}
}
@Override
public void adjacentEdges_checkReturnedSetMutability() {
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
228 issues
Line: 29
* Pat Fisher, Mike Judd.
*/
package com.google.common.util.concurrent;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.MoreExecutors.invokeAnyImpl;
Reported by PMD.
Line: 29
* Pat Fisher, Mike Judd.
*/
package com.google.common.util.concurrent;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.MoreExecutors.invokeAnyImpl;
Reported by PMD.
Line: 83
*
* @author Kyle Littlefield (klittle)
*/
public class MoreExecutorsTest extends JSR166TestCase {
private static final Runnable EMPTY_RUNNABLE =
new Runnable() {
@Override
public void run() {}
Reported by PMD.
Line: 83
*
* @author Kyle Littlefield (klittle)
*/
public class MoreExecutorsTest extends JSR166TestCase {
private static final Runnable EMPTY_RUNNABLE =
new Runnable() {
@Override
public void run() {}
Reported by PMD.
Line: 92
};
public void testDirectExecutorServiceServiceInThreadExecution() throws Exception {
final ListeningExecutorService executor = newDirectExecutorService();
final ThreadLocal<Integer> threadLocalCount =
new ThreadLocal<Integer>() {
@Override
protected Integer initialValue() {
Reported by PMD.
Line: 92
};
public void testDirectExecutorServiceServiceInThreadExecution() throws Exception {
final ListeningExecutorService executor = newDirectExecutorService();
final ThreadLocal<Integer> threadLocalCount =
new ThreadLocal<Integer>() {
@Override
protected Integer initialValue() {
Reported by PMD.
Line: 117
public void run() {
try {
Future<?> future = executor.submit(incrementTask);
assertTrue(future.isDone());
assertEquals(1, threadLocalCount.get().intValue());
} catch (Throwable t) {
throwableFromOtherThread.set(t);
}
}
Reported by PMD.
Line: 118
try {
Future<?> future = executor.submit(incrementTask);
assertTrue(future.isDone());
assertEquals(1, threadLocalCount.get().intValue());
} catch (Throwable t) {
throwableFromOtherThread.set(t);
}
}
});
Reported by PMD.
Line: 119
Future<?> future = executor.submit(incrementTask);
assertTrue(future.isDone());
assertEquals(1, threadLocalCount.get().intValue());
} catch (Throwable t) {
throwableFromOtherThread.set(t);
}
}
});
Reported by PMD.
Line: 127
otherThread.start();
ListenableFuture<?> future = executor.submit(incrementTask);
assertTrue(future.isDone());
assertListenerRunImmediately(future);
assertEquals(1, threadLocalCount.get().intValue());
otherThread.join(1000);
assertEquals(Thread.State.TERMINATED, otherThread.getState());
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
228 issues
Line: 29
* Pat Fisher, Mike Judd.
*/
package com.google.common.util.concurrent;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.MoreExecutors.invokeAnyImpl;
Reported by PMD.
Line: 29
* Pat Fisher, Mike Judd.
*/
package com.google.common.util.concurrent;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.MoreExecutors.invokeAnyImpl;
Reported by PMD.
Line: 83
*
* @author Kyle Littlefield (klittle)
*/
public class MoreExecutorsTest extends JSR166TestCase {
private static final Runnable EMPTY_RUNNABLE =
new Runnable() {
@Override
public void run() {}
Reported by PMD.
Line: 83
*
* @author Kyle Littlefield (klittle)
*/
public class MoreExecutorsTest extends JSR166TestCase {
private static final Runnable EMPTY_RUNNABLE =
new Runnable() {
@Override
public void run() {}
Reported by PMD.
Line: 92
};
public void testDirectExecutorServiceServiceInThreadExecution() throws Exception {
final ListeningExecutorService executor = newDirectExecutorService();
final ThreadLocal<Integer> threadLocalCount =
new ThreadLocal<Integer>() {
@Override
protected Integer initialValue() {
Reported by PMD.
Line: 92
};
public void testDirectExecutorServiceServiceInThreadExecution() throws Exception {
final ListeningExecutorService executor = newDirectExecutorService();
final ThreadLocal<Integer> threadLocalCount =
new ThreadLocal<Integer>() {
@Override
protected Integer initialValue() {
Reported by PMD.
Line: 117
public void run() {
try {
Future<?> future = executor.submit(incrementTask);
assertTrue(future.isDone());
assertEquals(1, threadLocalCount.get().intValue());
} catch (Throwable t) {
throwableFromOtherThread.set(t);
}
}
Reported by PMD.
Line: 118
try {
Future<?> future = executor.submit(incrementTask);
assertTrue(future.isDone());
assertEquals(1, threadLocalCount.get().intValue());
} catch (Throwable t) {
throwableFromOtherThread.set(t);
}
}
});
Reported by PMD.
Line: 119
Future<?> future = executor.submit(incrementTask);
assertTrue(future.isDone());
assertEquals(1, threadLocalCount.get().intValue());
} catch (Throwable t) {
throwableFromOtherThread.set(t);
}
}
});
Reported by PMD.
Line: 127
otherThread.start();
ListenableFuture<?> future = executor.submit(incrementTask);
assertTrue(future.isDone());
assertListenerRunImmediately(future);
assertEquals(1, threadLocalCount.get().intValue());
otherThread.join(1000);
assertEquals(Thread.State.TERMINATED, otherThread.getState());
Reported by PMD.
android/guava-tests/test/com/google/common/io/ByteStreamsTest.java
226 issues
Line: 62
File testFile = createTempFile();
byte[] dummyData = newPreFilledByteArray(chunkSize);
try (FileOutputStream fos = new FileOutputStream(testFile)) {
for (int i = 0; i < 500; i++) {
fos.write(dummyData);
}
}
try (ReadableByteChannel inChannel = new RandomAccessFile(testFile, "r").getChannel()) {
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.io;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Charsets;
import java.io.ByteArrayInputStream;
Reported by PMD.
Line: 42
*
* @author Chris Nokleberg
*/
public class ByteStreamsTest extends IoTestCase {
public void testCopyChannel() throws IOException {
byte[] expected = newPreFilledByteArray(100);
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
Reported by PMD.
Line: 42
*
* @author Chris Nokleberg
*/
public class ByteStreamsTest extends IoTestCase {
public void testCopyChannel() throws IOException {
byte[] expected = newPreFilledByteArray(100);
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
Reported by PMD.
Line: 44
*/
public class ByteStreamsTest extends IoTestCase {
public void testCopyChannel() throws IOException {
byte[] expected = newPreFilledByteArray(100);
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));
Reported by PMD.
Line: 47
public void testCopyChannel() throws IOException {
byte[] expected = newPreFilledByteArray(100);
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));
ByteStreams.copy(inChannel, outChannel);
assertThat(out.toByteArray()).isEqualTo(expected);
}
Reported by PMD.
Line: 51
ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));
ByteStreams.copy(inChannel, outChannel);
assertThat(out.toByteArray()).isEqualTo(expected);
}
public void testCopyFileChannel() throws IOException {
final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
Reported by PMD.
Line: 55
}
public void testCopyFileChannel() throws IOException {
final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
File testFile = createTempFile();
Reported by PMD.
Line: 58
public void testCopyFileChannel() throws IOException {
final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
File testFile = createTempFile();
byte[] dummyData = newPreFilledByteArray(chunkSize);
try (FileOutputStream fos = new FileOutputStream(testFile)) {
for (int i = 0; i < 500; i++) {
Reported by PMD.
Line: 72
}
byte[] actual = out.toByteArray();
for (int i = 0; i < 500 * chunkSize; i += chunkSize) {
assertThat(Arrays.copyOfRange(actual, i, i + chunkSize)).isEqualTo(dummyData);
}
}
public void testReadFully() throws IOException {
byte[] b = new byte[10];
Reported by PMD.
guava-tests/test/com/google/common/io/ByteStreamsTest.java
226 issues
Line: 62
File testFile = createTempFile();
byte[] dummyData = newPreFilledByteArray(chunkSize);
try (FileOutputStream fos = new FileOutputStream(testFile)) {
for (int i = 0; i < 500; i++) {
fos.write(dummyData);
}
}
try (ReadableByteChannel inChannel = new RandomAccessFile(testFile, "r").getChannel()) {
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.io;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Charsets;
import java.io.ByteArrayInputStream;
Reported by PMD.
Line: 42
*
* @author Chris Nokleberg
*/
public class ByteStreamsTest extends IoTestCase {
public void testCopyChannel() throws IOException {
byte[] expected = newPreFilledByteArray(100);
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
Reported by PMD.
Line: 42
*
* @author Chris Nokleberg
*/
public class ByteStreamsTest extends IoTestCase {
public void testCopyChannel() throws IOException {
byte[] expected = newPreFilledByteArray(100);
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
Reported by PMD.
Line: 44
*/
public class ByteStreamsTest extends IoTestCase {
public void testCopyChannel() throws IOException {
byte[] expected = newPreFilledByteArray(100);
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));
Reported by PMD.
Line: 47
public void testCopyChannel() throws IOException {
byte[] expected = newPreFilledByteArray(100);
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));
ByteStreams.copy(inChannel, outChannel);
assertThat(out.toByteArray()).isEqualTo(expected);
}
Reported by PMD.
Line: 51
ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));
ByteStreams.copy(inChannel, outChannel);
assertThat(out.toByteArray()).isEqualTo(expected);
}
public void testCopyFileChannel() throws IOException {
final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
Reported by PMD.
Line: 55
}
public void testCopyFileChannel() throws IOException {
final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
File testFile = createTempFile();
Reported by PMD.
Line: 58
public void testCopyFileChannel() throws IOException {
final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
ByteArrayOutputStream out = new ByteArrayOutputStream();
WritableByteChannel outChannel = Channels.newChannel(out);
File testFile = createTempFile();
byte[] dummyData = newPreFilledByteArray(chunkSize);
try (FileOutputStream fos = new FileOutputStream(testFile)) {
for (int i = 0; i < 500; i++) {
Reported by PMD.
Line: 72
}
byte[] actual = out.toByteArray();
for (int i = 0; i < 500 * chunkSize; i += chunkSize) {
assertThat(Arrays.copyOfRange(actual, i, i + chunkSize)).isEqualTo(dummyData);
}
}
public void testReadFully() throws IOException {
byte[] b = new byte[10];
Reported by PMD.