The following issues were found
android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
250 issues
Line: 229
new AbstractScheduledService() {
@Override
protected void startUp() throws Exception {
throw new Exception("Failed");
}
@Override
protected void runOneIteration() throws Exception {}
Reported by PMD.
Line: 515
secondBarrier.await();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
TestCustomScheduler scheduler = new TestCustomScheduler();
Cancellable future = scheduler.schedule(null, Executors.newScheduledThreadPool(10), task);
Reported by PMD.
Line: 563
if (state() != State.STARTING) {
inGetNextSchedule.await();
Thread.yield();
throw new RuntimeException("boom");
}
return new Schedule(0, TimeUnit.NANOSECONDS);
}
};
}
Reported by PMD.
Line: 51
* @author Luke Sandberg
*/
public class AbstractScheduledServiceTest extends TestCase {
volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
Reported by PMD.
Line: 53
public class AbstractScheduledServiceTest extends TestCase {
volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
Reported by PMD.
Line: 54
public class AbstractScheduledServiceTest extends TestCase {
volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
Reported by PMD.
Line: 54
public class AbstractScheduledServiceTest extends TestCase {
volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
Reported by PMD.
Line: 56
volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
final ScheduledExecutorService executor =
new ScheduledThreadPoolExecutor(10) {
Reported by PMD.
Line: 57
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
final ScheduledExecutorService executor =
new ScheduledThreadPoolExecutor(10) {
@Override
Reported by PMD.
Line: 58
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
final ScheduledExecutorService executor =
new ScheduledThreadPoolExecutor(10) {
@Override
public ScheduledFuture<?> scheduleWithFixedDelay(
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
250 issues
Line: 229
new AbstractScheduledService() {
@Override
protected void startUp() throws Exception {
throw new Exception("Failed");
}
@Override
protected void runOneIteration() throws Exception {}
Reported by PMD.
Line: 515
secondBarrier.await();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
TestCustomScheduler scheduler = new TestCustomScheduler();
Cancellable future = scheduler.schedule(null, Executors.newScheduledThreadPool(10), task);
Reported by PMD.
Line: 563
if (state() != State.STARTING) {
inGetNextSchedule.await();
Thread.yield();
throw new RuntimeException("boom");
}
return new Schedule(0, TimeUnit.NANOSECONDS);
}
};
}
Reported by PMD.
Line: 51
* @author Luke Sandberg
*/
public class AbstractScheduledServiceTest extends TestCase {
volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
Reported by PMD.
Line: 53
public class AbstractScheduledServiceTest extends TestCase {
volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
Reported by PMD.
Line: 54
public class AbstractScheduledServiceTest extends TestCase {
volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
Reported by PMD.
Line: 54
public class AbstractScheduledServiceTest extends TestCase {
volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
Reported by PMD.
Line: 56
volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
final ScheduledExecutorService executor =
new ScheduledThreadPoolExecutor(10) {
Reported by PMD.
Line: 57
volatile ScheduledFuture<?> future = null;
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
final ScheduledExecutorService executor =
new ScheduledThreadPoolExecutor(10) {
@Override
Reported by PMD.
Line: 58
volatile boolean atFixedRateCalled = false;
volatile boolean withFixedDelayCalled = false;
volatile boolean scheduleCalled = false;
final ScheduledExecutorService executor =
new ScheduledThreadPoolExecutor(10) {
@Override
public ScheduledFuture<?> scheduleWithFixedDelay(
Reported by PMD.
guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
248 issues
Line: 199
private static class ThrowsSomethingElse {
public static void christenPoodle(String name) {
throw new RuntimeException();
}
}
private interface InterfaceStaticMethodFailsToCheckNull {
static String create(String s) {
Reported by PMD.
Line: 360
THROW_A_NPE {
@Override
public void act() {
throw new NullPointerException();
}
},
THROW_OTHER {
@Override
public void act() {
Reported by PMD.
Line: 1453
}
static class DoesNotOverrideEquals {
public boolean equals(Object a, Object b) {
return true;
}
}
public void testEqualsMethod() {
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
Reported by PMD.
Line: 58
* @author Mick Killianey
*/
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {
/** Non-NPE RuntimeException. */
public static class FooException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
Reported by PMD.
Line: 58
* @author Mick Killianey
*/
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {
/** Non-NPE RuntimeException. */
public static class FooException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
Reported by PMD.
Line: 58
* @author Mick Killianey
*/
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {
/** Non-NPE RuntimeException. */
public static class FooException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
Reported by PMD.
Line: 58
* @author Mick Killianey
*/
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {
/** Non-NPE RuntimeException. */
public static class FooException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
Reported by PMD.
Line: 69
* Class for testing all permutations of static/non-static one-argument methods using
* methodParameter().
*/
@SuppressWarnings("unused") // used by reflection
public static class OneArg {
public static void staticOneArgCorrectlyThrowsNpe(String s) {
checkNotNull(s); // expect NPE here on null
}
Reported by PMD.
android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
246 issues
Line: 576
int behavior = random.nextInt(4);
if (behavior == 0) { // throw an exception
exceptionCount.incrementAndGet();
throw new RuntimeException("fake exception for test");
} else if (behavior == 1) { // return null
computeNullCount.incrementAndGet();
return null;
} else if (behavior == 2) { // slight delay before returning
Thread.sleep(5);
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.cache;
import static com.google.common.cache.TestingCacheLoaders.constantLoader;
import static com.google.common.cache.TestingCacheLoaders.identityLoader;
import static com.google.common.cache.TestingRemovalListeners.countingRemovalListener;
import static com.google.common.cache.TestingRemovalListeners.nullRemovalListener;
Reported by PMD.
Line: 51
/** Unit tests for CacheBuilder. */
@GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {
public void testNewBuilder() {
CacheLoader<Object, Integer> loader = constantLoader(1);
LoadingCache<String, Integer> cache =
Reported by PMD.
Line: 51
/** Unit tests for CacheBuilder. */
@GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {
public void testNewBuilder() {
CacheLoader<Object, Integer> loader = constantLoader(1);
LoadingCache<String, Integer> cache =
Reported by PMD.
Line: 51
/** Unit tests for CacheBuilder. */
@GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {
public void testNewBuilder() {
CacheLoader<Object, Integer> loader = constantLoader(1);
LoadingCache<String, Integer> cache =
Reported by PMD.
Line: 51
/** Unit tests for CacheBuilder. */
@GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {
public void testNewBuilder() {
CacheLoader<Object, Integer> loader = constantLoader(1);
LoadingCache<String, Integer> cache =
Reported by PMD.
Line: 53
@GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {
public void testNewBuilder() {
CacheLoader<Object, Integer> loader = constantLoader(1);
LoadingCache<String, Integer> cache =
CacheBuilder.newBuilder().removalListener(countingRemovalListener()).build(loader);
Reported by PMD.
Line: 53
@GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {
public void testNewBuilder() {
CacheLoader<Object, Integer> loader = constantLoader(1);
LoadingCache<String, Integer> cache =
CacheBuilder.newBuilder().removalListener(countingRemovalListener()).build(loader);
Reported by PMD.
Line: 59
LoadingCache<String, Integer> cache =
CacheBuilder.newBuilder().removalListener(countingRemovalListener()).build(loader);
assertEquals(Integer.valueOf(1), cache.getUnchecked("one"));
assertEquals(1, cache.size());
}
public void testInitialCapacity_negative() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
Reported by PMD.
Line: 59
LoadingCache<String, Integer> cache =
CacheBuilder.newBuilder().removalListener(countingRemovalListener()).build(loader);
assertEquals(Integer.valueOf(1), cache.getUnchecked("one"));
assertEquals(1, cache.size());
}
public void testInitialCapacity_negative() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
Reported by PMD.
android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
243 issues
Line: 41
* @author Louis Wasserman
*/
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TreeRangeMapTest.class);
suite.addTest(
MapTestSuiteBuilder.using(
Reported by PMD.
Line: 41
* @author Louis Wasserman
*/
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TreeRangeMapTest.class);
suite.addTest(
MapTestSuiteBuilder.using(
Reported by PMD.
Line: 41
* @author Louis Wasserman
*/
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TreeRangeMapTest.class);
suite.addTest(
MapTestSuiteBuilder.using(
Reported by PMD.
Line: 41
* @author Louis Wasserman
*/
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TreeRangeMapTest.class);
suite.addTest(
MapTestSuiteBuilder.using(
Reported by PMD.
Line: 42
*/
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TreeRangeMapTest.class);
suite.addTest(
MapTestSuiteBuilder.using(
new TestMapGenerator<Range<Integer>, String>() {
Reported by PMD.
Line: 42
*/
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TreeRangeMapTest.class);
suite.addTest(
MapTestSuiteBuilder.using(
new TestMapGenerator<Range<Integer>, String>() {
Reported by PMD.
Line: 42
*/
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TreeRangeMapTest.class);
suite.addTest(
MapTestSuiteBuilder.using(
new TestMapGenerator<Range<Integer>, String>() {
Reported by PMD.
Line: 42
*/
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TreeRangeMapTest.class);
suite.addTest(
MapTestSuiteBuilder.using(
new TestMapGenerator<Range<Integer>, String>() {
Reported by PMD.
Line: 51
@Override
public SampleElements<Entry<Range<Integer>, String>> samples() {
return new SampleElements<>(
mapEntry(Range.singleton(0), "banana"),
mapEntry(Range.closedOpen(3, 5), "frisbee"),
mapEntry(Range.atMost(-1), "fruitcake"),
mapEntry(Range.open(10, 15), "elephant"),
mapEntry(Range.closed(20, 22), "umbrella"));
}
Reported by PMD.
Line: 52
public SampleElements<Entry<Range<Integer>, String>> samples() {
return new SampleElements<>(
mapEntry(Range.singleton(0), "banana"),
mapEntry(Range.closedOpen(3, 5), "frisbee"),
mapEntry(Range.atMost(-1), "fruitcake"),
mapEntry(Range.open(10, 15), "elephant"),
mapEntry(Range.closed(20, 22), "umbrella"));
}
Reported by PMD.
guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java
243 issues
Line: 751
// keep trying
@SuppressWarnings("unused")
static GoodEquals create(int a, int b) {
throw new RuntimeException();
}
// Good!
static GoodEquals create(String a, int b) {
return new GoodEquals(a, b);
Reported by PMD.
Line: 1316
static class ConstructorThrows {
public ConstructorThrows() {
throw new RuntimeException();
}
}
static class FactoryMethodThrows {
private FactoryMethodThrows() {}
Reported by PMD.
Line: 1324
private FactoryMethodThrows() {}
public static FactoryMethodThrows create() {
throw new RuntimeException();
}
}
static class NotInstantiable {
private NotInstantiable() {}
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Functions;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Functions;
Reported by PMD.
Line: 48
*
* @author Ben Yu
*/
public class ClassSanityTesterTest extends TestCase {
private final ClassSanityTester tester = new ClassSanityTester();
public void testEqualsOnReturnValues_good() throws Exception {
tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
Reported by PMD.
Line: 48
*
* @author Ben Yu
*/
public class ClassSanityTesterTest extends TestCase {
private final ClassSanityTester tester = new ClassSanityTester();
public void testEqualsOnReturnValues_good() throws Exception {
tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
Reported by PMD.
Line: 48
*
* @author Ben Yu
*/
public class ClassSanityTesterTest extends TestCase {
private final ClassSanityTester tester = new ClassSanityTester();
public void testEqualsOnReturnValues_good() throws Exception {
tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
Reported by PMD.
Line: 50
*/
public class ClassSanityTesterTest extends TestCase {
private final ClassSanityTester tester = new ClassSanityTester();
public void testEqualsOnReturnValues_good() throws Exception {
tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
}
Reported by PMD.
Line: 52
private final ClassSanityTester tester = new ClassSanityTester();
public void testEqualsOnReturnValues_good() throws Exception {
tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
}
public static class GoodEqualsFactory {
public static Object good(
Reported by PMD.
android/guava-tests/test/com/google/common/primitives/ImmutableDoubleArrayTest.java
243 issues
Line: 45
/** @author Kevin Bourrillion */
@GwtCompatible(emulated = true)
public class ImmutableDoubleArrayTest extends TestCase {
// Test all creation paths very lazily: by assuming asList() works
public void testOf0() {
assertThat(ImmutableDoubleArray.of().asList()).isEmpty();
}
Reported by PMD.
Line: 45
/** @author Kevin Bourrillion */
@GwtCompatible(emulated = true)
public class ImmutableDoubleArrayTest extends TestCase {
// Test all creation paths very lazily: by assuming asList() works
public void testOf0() {
assertThat(ImmutableDoubleArray.of().asList()).isEmpty();
}
Reported by PMD.
Line: 48
public class ImmutableDoubleArrayTest extends TestCase {
// Test all creation paths very lazily: by assuming asList() works
public void testOf0() {
assertThat(ImmutableDoubleArray.of().asList()).isEmpty();
}
public void testOf1() {
assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
Reported by PMD.
Line: 49
// Test all creation paths very lazily: by assuming asList() works
public void testOf0() {
assertThat(ImmutableDoubleArray.of().asList()).isEmpty();
}
public void testOf1() {
assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
}
Reported by PMD.
Line: 49
// Test all creation paths very lazily: by assuming asList() works
public void testOf0() {
assertThat(ImmutableDoubleArray.of().asList()).isEmpty();
}
public void testOf1() {
assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
}
Reported by PMD.
Line: 52
assertThat(ImmutableDoubleArray.of().asList()).isEmpty();
}
public void testOf1() {
assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
}
public void testOf2() {
assertThat(ImmutableDoubleArray.of(0, 1).asList()).containsExactly(0.0, 1.0).inOrder();
Reported by PMD.
Line: 53
}
public void testOf1() {
assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
}
public void testOf2() {
assertThat(ImmutableDoubleArray.of(0, 1).asList()).containsExactly(0.0, 1.0).inOrder();
}
Reported by PMD.
Line: 53
}
public void testOf1() {
assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
}
public void testOf2() {
assertThat(ImmutableDoubleArray.of(0, 1).asList()).containsExactly(0.0, 1.0).inOrder();
}
Reported by PMD.
Line: 56
assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
}
public void testOf2() {
assertThat(ImmutableDoubleArray.of(0, 1).asList()).containsExactly(0.0, 1.0).inOrder();
}
public void testOf3() {
assertThat(ImmutableDoubleArray.of(0, 1, 3).asList()).containsExactly(0.0, 1.0, 3.0).inOrder();
Reported by PMD.
Line: 57
}
public void testOf2() {
assertThat(ImmutableDoubleArray.of(0, 1).asList()).containsExactly(0.0, 1.0).inOrder();
}
public void testOf3() {
assertThat(ImmutableDoubleArray.of(0, 1, 3).asList()).containsExactly(0.0, 1.0, 3.0).inOrder();
}
Reported by PMD.
android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
241 issues
Line: 198
private static class ThrowsSomethingElse {
public static void christenPoodle(String name) {
throw new RuntimeException();
}
}
public void testDontAcceptIae() {
NullPointerTester tester = new NullPointerTester();
Reported by PMD.
Line: 307
THROW_A_NPE {
@Override
public void act() {
throw new NullPointerException();
}
},
THROW_OTHER {
@Override
public void act() {
Reported by PMD.
Line: 1400
}
static class DoesNotOverrideEquals {
public boolean equals(Object a, Object b) {
return true;
}
}
public void testEqualsMethod() {
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
Reported by PMD.
Line: 58
* @author Mick Killianey
*/
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {
/** Non-NPE RuntimeException. */
public static class FooException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
Reported by PMD.
Line: 58
* @author Mick Killianey
*/
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {
/** Non-NPE RuntimeException. */
public static class FooException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
Reported by PMD.
Line: 58
* @author Mick Killianey
*/
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {
/** Non-NPE RuntimeException. */
public static class FooException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
Reported by PMD.
Line: 58
* @author Mick Killianey
*/
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {
/** Non-NPE RuntimeException. */
public static class FooException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
Reported by PMD.
Line: 69
* Class for testing all permutations of static/non-static one-argument methods using
* methodParameter().
*/
@SuppressWarnings("unused") // used by reflection
public static class OneArg {
public static void staticOneArgCorrectlyThrowsNpe(String s) {
checkNotNull(s); // expect NPE here on null
}
Reported by PMD.
android/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java
240 issues
Line: 746
// keep trying
@SuppressWarnings("unused")
static GoodEquals create(int a, int b) {
throw new RuntimeException();
}
// Good!
static GoodEquals create(String a, int b) {
return new GoodEquals(a, b);
Reported by PMD.
Line: 1303
static class ConstructorThrows {
public ConstructorThrows() {
throw new RuntimeException();
}
}
static class FactoryMethodThrows {
private FactoryMethodThrows() {}
Reported by PMD.
Line: 1311
private FactoryMethodThrows() {}
public static FactoryMethodThrows create() {
throw new RuntimeException();
}
}
static class NotInstantiable {
private NotInstantiable() {}
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Functions;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Functions;
Reported by PMD.
Line: 46
*
* @author Ben Yu
*/
public class ClassSanityTesterTest extends TestCase {
private final ClassSanityTester tester = new ClassSanityTester();
public void testEqualsOnReturnValues_good() throws Exception {
tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
Reported by PMD.
Line: 46
*
* @author Ben Yu
*/
public class ClassSanityTesterTest extends TestCase {
private final ClassSanityTester tester = new ClassSanityTester();
public void testEqualsOnReturnValues_good() throws Exception {
tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
Reported by PMD.
Line: 46
*
* @author Ben Yu
*/
public class ClassSanityTesterTest extends TestCase {
private final ClassSanityTester tester = new ClassSanityTester();
public void testEqualsOnReturnValues_good() throws Exception {
tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
Reported by PMD.
Line: 48
*/
public class ClassSanityTesterTest extends TestCase {
private final ClassSanityTester tester = new ClassSanityTester();
public void testEqualsOnReturnValues_good() throws Exception {
tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
}
Reported by PMD.
Line: 50
private final ClassSanityTester tester = new ClassSanityTester();
public void testEqualsOnReturnValues_good() throws Exception {
tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
}
public static class GoodEqualsFactory {
public static Object good(
Reported by PMD.
android/guava-tests/test/com/google/common/primitives/BooleansTest.java
239 issues
Line: 296
assertEquals(Booleans.asList(EMPTY), Collections.emptyList());
assertEquals(Booleans.asList(ARRAY_FALSE), Booleans.asList(ARRAY_FALSE));
assertFalse(Booleans.asList(ARRAY_FALSE).equals(ARRAY_FALSE));
assertFalse(Booleans.asList(ARRAY_FALSE).equals(null));
assertFalse(Booleans.asList(ARRAY_FALSE).equals(Booleans.asList(ARRAY_FALSE_TRUE)));
assertFalse(Booleans.asList(ARRAY_FALSE_FALSE).equals(Booleans.asList(ARRAY_FALSE_TRUE)));
assertEquals(1, Booleans.asList(ARRAY_FALSE_TRUE).lastIndexOf(true));
List<Boolean> reference = Booleans.asList(ARRAY_FALSE);
assertEquals(Booleans.asList(ARRAY_FALSE), reference);
Reported by PMD.
Line: 189
testReverse(new boolean[] {true, true, false, false}, new boolean[] {false, false, true, true});
}
private static void testReverse(boolean[] input, boolean[] expectedOutput) {
input = Arrays.copyOf(input, input.length);
Booleans.reverse(input);
assertTrue(Arrays.equals(expectedOutput, input));
}
Reported by PMD.
Line: 196
}
private static void testReverse(
boolean[] input, int fromIndex, int toIndex, boolean[] expectedOutput) {
input = Arrays.copyOf(input, input.length);
Booleans.reverse(input, fromIndex, toIndex);
assertTrue(Arrays.equals(expectedOutput, input));
}
Reported by PMD.
Line: 37
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class BooleansTest extends TestCase {
private static final boolean[] EMPTY = {};
private static final boolean[] ARRAY_FALSE = {false};
private static final boolean[] ARRAY_TRUE = {true};
private static final boolean[] ARRAY_FALSE_FALSE = {false, false};
private static final boolean[] ARRAY_FALSE_TRUE = {false, true};
Reported by PMD.
Line: 46
private static final boolean[] VALUES = {false, true};
public void testHashCode() {
assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
}
public void testTrueFirst() {
Reported by PMD.
Line: 46
private static final boolean[] VALUES = {false, true};
public void testHashCode() {
assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
}
public void testTrueFirst() {
Reported by PMD.
Line: 47
private static final boolean[] VALUES = {false, true};
public void testHashCode() {
assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
}
public void testTrueFirst() {
assertEquals(0, Booleans.trueFirst().compare(true, true));
Reported by PMD.
Line: 47
private static final boolean[] VALUES = {false, true};
public void testHashCode() {
assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
}
public void testTrueFirst() {
assertEquals(0, Booleans.trueFirst().compare(true, true));
Reported by PMD.
Line: 48
public void testHashCode() {
assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
}
public void testTrueFirst() {
assertEquals(0, Booleans.trueFirst().compare(true, true));
assertEquals(0, Booleans.trueFirst().compare(false, false));
Reported by PMD.
Line: 48
public void testHashCode() {
assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
}
public void testTrueFirst() {
assertEquals(0, Booleans.trueFirst().compare(true, true));
assertEquals(0, Booleans.trueFirst().compare(false, false));
Reported by PMD.