The following issues were found
guava-tests/test/com/google/common/collect/AbstractRangeSetTest.java
20 issues
Line: 30
*/
@GwtIncompatible // TreeRangeSet
public abstract class AbstractRangeSetTest extends TestCase {
public static void testInvariants(RangeSet<?> rangeSet) {
testInvariantsInternal(rangeSet);
testInvariantsInternal(rangeSet.complement());
}
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
Reported by PMD.
Line: 35
testInvariantsInternal(rangeSet.complement());
}
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
Reported by PMD.
Line: 36
}
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
Reported by PMD.
Line: 36
}
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
Reported by PMD.
Line: 37
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
Reported by PMD.
Line: 37
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
Reported by PMD.
Line: 38
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
// test that connected ranges are coalesced
Reported by PMD.
Line: 38
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
// test that connected ranges are coalesced
Reported by PMD.
Line: 38
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
// test that connected ranges are coalesced
Reported by PMD.
Line: 39
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
// test that connected ranges are coalesced
for (int i = 0; i + 1 < asRanges.size(); i++) {
Reported by PMD.
guava-tests/test/com/google/common/net/HostSpecifierTest.java
20 issues
Line: 38
public final class HostSpecifierTest extends TestCase {
private static final ImmutableList<String> GOOD_IPS =
ImmutableList.of("1.2.3.4", "2001:db8::1", "[2001:db8::1]");
private static final ImmutableList<String> BAD_IPS =
ImmutableList.of("1.2.3", "2001:db8::1::::::0", "[2001:db8::1", "[::]:80");
private static final ImmutableList<String> GOOD_DOMAINS =
Reported by PMD.
Line: 38
public final class HostSpecifierTest extends TestCase {
private static final ImmutableList<String> GOOD_IPS =
ImmutableList.of("1.2.3.4", "2001:db8::1", "[2001:db8::1]");
private static final ImmutableList<String> BAD_IPS =
ImmutableList.of("1.2.3", "2001:db8::1::::::0", "[2001:db8::1", "[::]:80");
private static final ImmutableList<String> GOOD_DOMAINS =
Reported by PMD.
Line: 44
ImmutableList.of("1.2.3", "2001:db8::1::::::0", "[2001:db8::1", "[::]:80");
private static final ImmutableList<String> GOOD_DOMAINS =
ImmutableList.of("com", "google.com", "foo.co.uk");
private static final ImmutableList<String> BAD_DOMAINS =
ImmutableList.of("foo.blah", "", "[google.com]");
public void testGoodIpAddresses() throws ParseException {
Reported by PMD.
Line: 49
private static final ImmutableList<String> BAD_DOMAINS =
ImmutableList.of("foo.blah", "", "[google.com]");
public void testGoodIpAddresses() throws ParseException {
for (String spec : GOOD_IPS) {
assertGood(spec);
}
}
Reported by PMD.
Line: 55
}
}
public void testBadIpAddresses() {
for (String spec : BAD_IPS) {
assertBad(spec);
}
}
Reported by PMD.
Line: 61
}
}
public void testGoodDomains() throws ParseException {
for (String spec : GOOD_DOMAINS) {
assertGood(spec);
}
}
Reported by PMD.
Line: 67
}
}
public void testBadDomains() {
for (String spec : BAD_DOMAINS) {
assertBad(spec);
}
}
Reported by PMD.
Line: 73
}
}
public void testEquality() {
new EqualsTester()
.addEqualityGroup(spec("1.2.3.4"), spec("1.2.3.4"))
.addEqualityGroup(spec("2001:db8::1"), spec("2001:db8::1"), spec("[2001:db8::1]"))
.addEqualityGroup(spec("2001:db8::2"))
.addEqualityGroup(spec("google.com"), spec("google.com"))
Reported by PMD.
Line: 73
}
}
public void testEquality() {
new EqualsTester()
.addEqualityGroup(spec("1.2.3.4"), spec("1.2.3.4"))
.addEqualityGroup(spec("2001:db8::1"), spec("2001:db8::1"), spec("[2001:db8::1]"))
.addEqualityGroup(spec("2001:db8::2"))
.addEqualityGroup(spec("google.com"), spec("google.com"))
Reported by PMD.
Line: 75
public void testEquality() {
new EqualsTester()
.addEqualityGroup(spec("1.2.3.4"), spec("1.2.3.4"))
.addEqualityGroup(spec("2001:db8::1"), spec("2001:db8::1"), spec("[2001:db8::1]"))
.addEqualityGroup(spec("2001:db8::2"))
.addEqualityGroup(spec("google.com"), spec("google.com"))
.addEqualityGroup(spec("www.google.com"))
.testEquals();
Reported by PMD.
guava-tests/test/com/google/common/net/UrlEscapersTest.java
20 issues
Line: 46
try {
e.escape((String) null);
fail("Escaping null string should throw exception");
} catch (NullPointerException x) {
// pass
}
// All URL escapers should leave 0-9, A-Z, a-z unescaped
assertUnescaped(e, 'a');
Reported by PMD.
Line: 46
try {
e.escape((String) null);
fail("Escaping null string should throw exception");
} catch (NullPointerException x) {
// pass
}
// All URL escapers should leave 0-9, A-Z, a-z unescaped
assertUnescaped(e, 'a');
Reported by PMD.
Line: 46
try {
e.escape((String) null);
fail("Escaping null string should throw exception");
} catch (NullPointerException x) {
// pass
}
// All URL escapers should leave 0-9, A-Z, a-z unescaped
assertUnescaped(e, 'a');
Reported by PMD.
Line: 73
assertUnicodeEscaping(e, "%F0%90%80%80", '\uD800', '\uDC00');
assertUnicodeEscaping(e, "%F4%8F%BF%BF", '\uDBFF', '\uDFFF');
assertEquals("", e.escape(""));
assertEquals("safestring", e.escape("safestring"));
assertEquals("embedded%00null", e.escape("embedded\0null"));
assertEquals("max%EF%BF%BFchar", e.escape("max\uffffchar"));
}
Reported by PMD.
Line: 74
assertUnicodeEscaping(e, "%F4%8F%BF%BF", '\uDBFF', '\uDFFF');
assertEquals("", e.escape(""));
assertEquals("safestring", e.escape("safestring"));
assertEquals("embedded%00null", e.escape("embedded\0null"));
assertEquals("max%EF%BF%BFchar", e.escape("max\uffffchar"));
}
// Helper to assert common expected behaviour of uri escapers.
Reported by PMD.
Line: 75
assertEquals("", e.escape(""));
assertEquals("safestring", e.escape("safestring"));
assertEquals("embedded%00null", e.escape("embedded\0null"));
assertEquals("max%EF%BF%BFchar", e.escape("max\uffffchar"));
}
// Helper to assert common expected behaviour of uri escapers.
static void assertBasicUrlEscaper(UnicodeEscaper e) {
Reported by PMD.
Line: 76
assertEquals("", e.escape(""));
assertEquals("safestring", e.escape("safestring"));
assertEquals("embedded%00null", e.escape("embedded\0null"));
assertEquals("max%EF%BF%BFchar", e.escape("max\uffffchar"));
}
// Helper to assert common expected behaviour of uri escapers.
static void assertBasicUrlEscaper(UnicodeEscaper e) {
assertBasicUrlEscaperExceptPercent(e);
Reported by PMD.
Line: 86
assertEscaping(e, "%25", '%');
}
public void testUrlFormParameterEscaper() {
UnicodeEscaper e = (UnicodeEscaper) urlFormParameterEscaper();
// Verify that these are the same escaper (as documented)
assertSame(e, urlFormParameterEscaper());
assertBasicUrlEscaper(e);
Reported by PMD.
Line: 86
assertEscaping(e, "%25", '%');
}
public void testUrlFormParameterEscaper() {
UnicodeEscaper e = (UnicodeEscaper) urlFormParameterEscaper();
// Verify that these are the same escaper (as documented)
assertSame(e, urlFormParameterEscaper());
assertBasicUrlEscaper(e);
Reported by PMD.
Line: 89
public void testUrlFormParameterEscaper() {
UnicodeEscaper e = (UnicodeEscaper) urlFormParameterEscaper();
// Verify that these are the same escaper (as documented)
assertSame(e, urlFormParameterEscaper());
assertBasicUrlEscaper(e);
/*
* Specified as safe by RFC 2396 but not by java.net.URLEncoder. These tests will start failing
* when the escaper is made compliant with RFC 2396, but that's a good thing (just change them
Reported by PMD.
android/guava-tests/test/com/google/common/collect/AbstractRangeSetTest.java
20 issues
Line: 30
*/
@GwtIncompatible // TreeRangeSet
public abstract class AbstractRangeSetTest extends TestCase {
public static void testInvariants(RangeSet<?> rangeSet) {
testInvariantsInternal(rangeSet);
testInvariantsInternal(rangeSet.complement());
}
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
Reported by PMD.
Line: 35
testInvariantsInternal(rangeSet.complement());
}
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
Reported by PMD.
Line: 36
}
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
Reported by PMD.
Line: 36
}
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
Reported by PMD.
Line: 37
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
Reported by PMD.
Line: 37
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
Reported by PMD.
Line: 38
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
// test that connected ranges are coalesced
Reported by PMD.
Line: 38
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
// test that connected ranges are coalesced
Reported by PMD.
Line: 38
private static <C extends Comparable> void testInvariantsInternal(RangeSet<C> rangeSet) {
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
// test that connected ranges are coalesced
Reported by PMD.
Line: 39
assertEquals(rangeSet.asRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(rangeSet.asDescendingSetOfRanges().isEmpty(), rangeSet.isEmpty());
assertEquals(!rangeSet.asRanges().iterator().hasNext(), rangeSet.isEmpty());
assertEquals(!rangeSet.asDescendingSetOfRanges().iterator().hasNext(), rangeSet.isEmpty());
List<Range<C>> asRanges = ImmutableList.copyOf(rangeSet.asRanges());
// test that connected ranges are coalesced
for (int i = 0; i + 1 < asRanges.size(); i++) {
Reported by PMD.
android/guava-testlib/test/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilderTest.java
20 issues
Line: 32
static boolean testWasRun;
@Override
protected void setUp() throws Exception {
super.setUp();
testWasRun = false;
}
Reported by PMD.
Line: 40
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public static final class MyAbstractTester extends AbstractTester<Void> {
public void testNothing() {
testWasRun = true;
}
}
private static final class MyTestSuiteBuilder
Reported by PMD.
Line: 40
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public static final class MyAbstractTester extends AbstractTester<Void> {
public void testNothing() {
testWasRun = true;
}
}
private static final class MyTestSuiteBuilder
Reported by PMD.
Line: 54
}
}
public void testLifecycle() {
final boolean setUp[] = {false};
Runnable setUpRunnable =
new Runnable() {
@Override
public void run() {
Reported by PMD.
Line: 54
}
}
public void testLifecycle() {
final boolean setUp[] = {false};
Runnable setUpRunnable =
new Runnable() {
@Override
public void run() {
Reported by PMD.
Line: 75
MyTestSuiteBuilder builder = new MyTestSuiteBuilder();
Test test =
builder
.usingGenerator("yam")
.named("yam")
.withFeatures(CollectionFeature.NONE)
.withSetUp(setUpRunnable)
.withTearDown(tearDownRunnable)
Reported by PMD.
Line: 75
MyTestSuiteBuilder builder = new MyTestSuiteBuilder();
Test test =
builder
.usingGenerator("yam")
.named("yam")
.withFeatures(CollectionFeature.NONE)
.withSetUp(setUpRunnable)
.withTearDown(tearDownRunnable)
Reported by PMD.
Line: 75
MyTestSuiteBuilder builder = new MyTestSuiteBuilder();
Test test =
builder
.usingGenerator("yam")
.named("yam")
.withFeatures(CollectionFeature.NONE)
.withSetUp(setUpRunnable)
.withTearDown(tearDownRunnable)
Reported by PMD.
Line: 75
MyTestSuiteBuilder builder = new MyTestSuiteBuilder();
Test test =
builder
.usingGenerator("yam")
.named("yam")
.withFeatures(CollectionFeature.NONE)
.withSetUp(setUpRunnable)
.withTearDown(tearDownRunnable)
Reported by PMD.
Line: 75
MyTestSuiteBuilder builder = new MyTestSuiteBuilder();
Test test =
builder
.usingGenerator("yam")
.named("yam")
.withFeatures(CollectionFeature.NONE)
.withSetUp(setUpRunnable)
.withTearDown(tearDownRunnable)
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/MultimapContainsEntryTester.java
20 issues
Line: 40
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapContainsEntryTester<K, V>
extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(absent = ZERO)
public void testContainsEntryYes() {
assertTrue(multimap().containsEntry(k0(), v0()));
}
public void testContainsEntryNo() {
Reported by PMD.
Line: 42
extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(absent = ZERO)
public void testContainsEntryYes() {
assertTrue(multimap().containsEntry(k0(), v0()));
}
public void testContainsEntryNo() {
assertFalse(multimap().containsEntry(k3(), v3()));
}
Reported by PMD.
Line: 45
assertTrue(multimap().containsEntry(k0(), v0()));
}
public void testContainsEntryNo() {
assertFalse(multimap().containsEntry(k3(), v3()));
}
public void testContainsEntryAgreesWithGet() {
for (K k : sampleKeys()) {
Reported by PMD.
Line: 46
}
public void testContainsEntryNo() {
assertFalse(multimap().containsEntry(k3(), v3()));
}
public void testContainsEntryAgreesWithGet() {
for (K k : sampleKeys()) {
for (V v : sampleValues()) {
Reported by PMD.
Line: 49
assertFalse(multimap().containsEntry(k3(), v3()));
}
public void testContainsEntryAgreesWithGet() {
for (K k : sampleKeys()) {
for (V v : sampleValues()) {
assertEquals(multimap().get(k).contains(v), multimap().containsEntry(k, v));
}
}
Reported by PMD.
Line: 52
public void testContainsEntryAgreesWithGet() {
for (K k : sampleKeys()) {
for (V v : sampleValues()) {
assertEquals(multimap().get(k).contains(v), multimap().containsEntry(k, v));
}
}
}
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 52
public void testContainsEntryAgreesWithGet() {
for (K k : sampleKeys()) {
for (V v : sampleValues()) {
assertEquals(multimap().get(k).contains(v), multimap().containsEntry(k, v));
}
}
}
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 52
public void testContainsEntryAgreesWithGet() {
for (K k : sampleKeys()) {
for (V v : sampleValues()) {
assertEquals(multimap().get(k).contains(v), multimap().containsEntry(k, v));
}
}
}
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 57
}
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require({ALLOWS_NULL_KEYS, ALLOWS_NULL_VALUES})
public void testContainsEntryNullYes() {
initMultimapWithNullKeyAndValue();
assertTrue(multimap().containsEntry(null, null));
}
Reported by PMD.
Line: 61
@MapFeature.Require({ALLOWS_NULL_KEYS, ALLOWS_NULL_VALUES})
public void testContainsEntryNullYes() {
initMultimapWithNullKeyAndValue();
assertTrue(multimap().containsEntry(null, null));
}
@MapFeature.Require({ALLOWS_NULL_KEY_QUERIES, ALLOWS_NULL_VALUE_QUERIES})
public void testContainsEntryNullNo() {
assertFalse(multimap().containsEntry(null, null));
Reported by PMD.
android/guava-tests/test/com/google/common/io/ByteSinkTest.java
19 issues
Line: 37
*/
public class ByteSinkTest extends IoTestCase {
private final byte[] bytes = newPreFilledByteArray(10000);
private TestByteSink sink;
@Override
protected void setUp() throws Exception {
Reported by PMD.
Line: 39
private final byte[] bytes = newPreFilledByteArray(10000);
private TestByteSink sink;
@Override
protected void setUp() throws Exception {
sink = new TestByteSink();
}
Reported by PMD.
Line: 41
private TestByteSink sink;
@Override
protected void setUp() throws Exception {
sink = new TestByteSink();
}
public void testOpenBufferedStream() throws IOException {
Reported by PMD.
Line: 46
sink = new TestByteSink();
}
public void testOpenBufferedStream() throws IOException {
OutputStream out = sink.openBufferedStream();
assertTrue(sink.wasStreamOpened());
assertFalse(sink.wasStreamClosed());
out.write(new byte[] {1, 2, 3, 4});
Reported by PMD.
Line: 46
sink = new TestByteSink();
}
public void testOpenBufferedStream() throws IOException {
OutputStream out = sink.openBufferedStream();
assertTrue(sink.wasStreamOpened());
assertFalse(sink.wasStreamClosed());
out.write(new byte[] {1, 2, 3, 4});
Reported by PMD.
Line: 47
}
public void testOpenBufferedStream() throws IOException {
OutputStream out = sink.openBufferedStream();
assertTrue(sink.wasStreamOpened());
assertFalse(sink.wasStreamClosed());
out.write(new byte[] {1, 2, 3, 4});
out.close();
Reported by PMD.
Line: 52
assertFalse(sink.wasStreamClosed());
out.write(new byte[] {1, 2, 3, 4});
out.close();
assertTrue(sink.wasStreamClosed());
assertArrayEquals(new byte[] {1, 2, 3, 4}, sink.getBytes());
}
Reported by PMD.
Line: 58
assertArrayEquals(new byte[] {1, 2, 3, 4}, sink.getBytes());
}
public void testWrite_bytes() throws IOException {
assertArrayEquals(new byte[0], sink.getBytes());
sink.write(bytes);
assertTrue(sink.wasStreamOpened() && sink.wasStreamClosed());
assertArrayEquals(bytes, sink.getBytes());
Reported by PMD.
Line: 58
assertArrayEquals(new byte[] {1, 2, 3, 4}, sink.getBytes());
}
public void testWrite_bytes() throws IOException {
assertArrayEquals(new byte[0], sink.getBytes());
sink.write(bytes);
assertTrue(sink.wasStreamOpened() && sink.wasStreamClosed());
assertArrayEquals(bytes, sink.getBytes());
Reported by PMD.
Line: 66
assertArrayEquals(bytes, sink.getBytes());
}
public void testWriteFrom_inputStream() throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
sink.writeFrom(in);
assertTrue(sink.wasStreamOpened() && sink.wasStreamClosed());
assertArrayEquals(bytes, sink.getBytes());
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddAllTester.java
19 issues
Line: 49
@SuppressWarnings("unchecked") // too many "unchecked generic array creations"
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionAddAllTester<E> extends AbstractCollectionTester<E> {
@CollectionFeature.Require(SUPPORTS_ADD)
public void testAddAll_supportedNothing() {
assertFalse("addAll(nothing) should return false", collection.addAll(emptyCollection()));
expectUnchanged();
}
Reported by PMD.
Line: 50
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionAddAllTester<E> extends AbstractCollectionTester<E> {
@CollectionFeature.Require(SUPPORTS_ADD)
public void testAddAll_supportedNothing() {
assertFalse("addAll(nothing) should return false", collection.addAll(emptyCollection()));
expectUnchanged();
}
Reported by PMD.
Line: 56
expectUnchanged();
}
@CollectionFeature.Require(absent = SUPPORTS_ADD)
public void testAddAll_unsupportedNothing() {
try {
assertFalse(
"addAll(nothing) should return false or throw", collection.addAll(emptyCollection()));
} catch (UnsupportedOperationException tolerated) {
Reported by PMD.
Line: 61
try {
assertFalse(
"addAll(nothing) should return false or throw", collection.addAll(emptyCollection()));
} catch (UnsupportedOperationException tolerated) {
}
expectUnchanged();
}
@CollectionFeature.Require(SUPPORTS_ADD)
Reported by PMD.
Line: 66
expectUnchanged();
}
@CollectionFeature.Require(SUPPORTS_ADD)
public void testAddAll_supportedNonePresent() {
assertTrue(
"addAll(nonePresent) should return true", collection.addAll(createDisjointCollection()));
expectAdded(e3(), e4());
}
Reported by PMD.
Line: 73
expectAdded(e3(), e4());
}
@CollectionFeature.Require(absent = SUPPORTS_ADD)
public void testAddAll_unsupportedNonePresent() {
try {
collection.addAll(createDisjointCollection());
fail("addAll(nonePresent) should throw");
} catch (UnsupportedOperationException expected) {
Reported by PMD.
Line: 84
expectMissing(e3(), e4());
}
@CollectionFeature.Require(SUPPORTS_ADD)
@CollectionSize.Require(absent = ZERO)
public void testAddAll_supportedSomePresent() {
assertTrue(
"addAll(somePresent) should return true",
collection.addAll(MinimalCollection.of(e3(), e0())));
Reported by PMD.
Line: 86
@CollectionFeature.Require(SUPPORTS_ADD)
@CollectionSize.Require(absent = ZERO)
public void testAddAll_supportedSomePresent() {
assertTrue(
"addAll(somePresent) should return true",
collection.addAll(MinimalCollection.of(e3(), e0())));
assertTrue("should contain " + e3(), collection.contains(e3()));
assertTrue("should contain " + e0(), collection.contains(e0()));
Reported by PMD.
Line: 94
assertTrue("should contain " + e0(), collection.contains(e0()));
}
@CollectionFeature.Require(absent = SUPPORTS_ADD)
@CollectionSize.Require(absent = ZERO)
public void testAddAll_unsupportedSomePresent() {
try {
collection.addAll(MinimalCollection.of(e3(), e0()));
fail("addAll(somePresent) should throw");
Reported by PMD.
Line: 105
expectUnchanged();
}
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
@CollectionSize.Require(absent = ZERO)
public void testAddAllConcurrentWithIteration() {
try {
Iterator<E> iterator = collection.iterator();
assertTrue(collection.addAll(MinimalCollection.of(e3(), e0())));
Reported by PMD.
android/guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java
19 issues
Line: 100
TooManyListenersException.class,
URISyntaxException.class);
@Param Validator validator;
@Param Result result;
@Param ExceptionType exceptionType;
/**
* The number of other exception types in the cache of known-good exceptions and the number of
* other {@code ClassValue} entries for the exception type to be tested. This lets us evaluate
Reported by PMD.
Line: 101
URISyntaxException.class);
@Param Validator validator;
@Param Result result;
@Param ExceptionType exceptionType;
/**
* The number of other exception types in the cache of known-good exceptions and the number of
* other {@code ClassValue} entries for the exception type to be tested. This lets us evaluate
* whether our solution scales to use with multiple exception types and to whether it is affected
Reported by PMD.
Line: 102
@Param Validator validator;
@Param Result result;
@Param ExceptionType exceptionType;
/**
* The number of other exception types in the cache of known-good exceptions and the number of
* other {@code ClassValue} entries for the exception type to be tested. This lets us evaluate
* whether our solution scales to use with multiple exception types and to whether it is affected
* by other {@code ClassValue} users. Some of the benchmarked implementations don't use one or
Reported by PMD.
Line: 111
* both of these mechanisms, so they will be unaffected.
*/
@Param({"0", "1", "12"})
int otherEntriesInDataStructure;
final List<ClassValue<?>> retainedReferencesToOtherClassValues = newArrayList();
@BeforeExperiment
void addOtherEntries() throws Exception {
Reported by PMD.
Line: 113
@Param({"0", "1", "12"})
int otherEntriesInDataStructure;
final List<ClassValue<?>> retainedReferencesToOtherClassValues = newArrayList();
@BeforeExperiment
void addOtherEntries() throws Exception {
GetCheckedTypeValidator validator = this.validator.validator;
Class<? extends Exception> exceptionType = this.exceptionType.exceptionType;
Reported by PMD.
Line: 116
final List<ClassValue<?>> retainedReferencesToOtherClassValues = newArrayList();
@BeforeExperiment
void addOtherEntries() throws Exception {
GetCheckedTypeValidator validator = this.validator.validator;
Class<? extends Exception> exceptionType = this.exceptionType.exceptionType;
for (Class<? extends Exception> exceptionClass :
OTHER_EXCEPTION_TYPES.asList().subList(0, otherEntriesInDataStructure)) {
Reported by PMD.
Line: 121
Class<? extends Exception> exceptionType = this.exceptionType.exceptionType;
for (Class<? extends Exception> exceptionClass :
OTHER_EXCEPTION_TYPES.asList().subList(0, otherEntriesInDataStructure)) {
getChecked(validator, immediateFuture(""), exceptionClass);
}
for (int i = 0; i < otherEntriesInDataStructure; i++) {
ClassValue<Boolean> classValue =
Reported by PMD.
Line: 127
for (int i = 0; i < otherEntriesInDataStructure; i++) {
ClassValue<Boolean> classValue =
new ClassValue<Boolean>() {
@Override
protected Boolean computeValue(Class<?> type) {
return true;
}
};
Reported by PMD.
Line: 146
Class<? extends Exception> exceptionType = this.exceptionType.exceptionType;
for (int i = 0; i < reps; ++i) {
try {
tmp += getChecked(validator, future, exceptionType).hashCode();
} catch (Exception e) {
tmp += e.hashCode();
}
}
return tmp;
Reported by PMD.
Line: 147
for (int i = 0; i < reps; ++i) {
try {
tmp += getChecked(validator, future, exceptionType).hashCode();
} catch (Exception e) {
tmp += e.hashCode();
}
}
return tmp;
}
Reported by PMD.
android/guava-tests/test/com/google/common/collect/ForwardingMultisetTest.java
19 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import com.google.common.base.Function;
import com.google.common.collect.Multiset.Entry;
import com.google.common.collect.testing.SetTestSuiteBuilder;
import com.google.common.collect.testing.TestStringSetGenerator;
Reported by PMD.
Line: 43
* @author Hayward Chan
* @author Louis Wasserman
*/
public class ForwardingMultisetTest extends TestCase {
static final class StandardImplForwardingMultiset<T> extends ForwardingMultiset<T> {
private final Multiset<T> backingCollection;
StandardImplForwardingMultiset(Multiset<T> backingMultiset) {
Reported by PMD.
Line: 43
* @author Hayward Chan
* @author Louis Wasserman
*/
public class ForwardingMultisetTest extends TestCase {
static final class StandardImplForwardingMultiset<T> extends ForwardingMultiset<T> {
private final Multiset<T> backingCollection;
StandardImplForwardingMultiset(Multiset<T> backingMultiset) {
Reported by PMD.
Line: 45
*/
public class ForwardingMultisetTest extends TestCase {
static final class StandardImplForwardingMultiset<T> extends ForwardingMultiset<T> {
private final Multiset<T> backingCollection;
StandardImplForwardingMultiset(Multiset<T> backingMultiset) {
this.backingCollection = backingMultiset;
}
Reported by PMD.
Line: 46
public class ForwardingMultisetTest extends TestCase {
static final class StandardImplForwardingMultiset<T> extends ForwardingMultiset<T> {
private final Multiset<T> backingCollection;
StandardImplForwardingMultiset(Multiset<T> backingMultiset) {
this.backingCollection = backingMultiset;
}
Reported by PMD.
Line: 158
}
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingMultisetTest.class);
suite.addTest(
MultisetTestSuiteBuilder.using(
Reported by PMD.
Line: 158
}
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingMultisetTest.class);
suite.addTest(
MultisetTestSuiteBuilder.using(
Reported by PMD.
Line: 158
}
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingMultisetTest.class);
suite.addTest(
MultisetTestSuiteBuilder.using(
Reported by PMD.
Line: 158
}
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingMultisetTest.class);
suite.addTest(
MultisetTestSuiteBuilder.using(
Reported by PMD.
Line: 199
* specifically authorized by the elementSet() or hashCode() docs.
*/
@Override
protected Set<String> create(String[] elements) {
final Multiset<String> inner =
LinkedHashMultiset.create(Arrays.asList(elements));
return new ForwardingMultiset<String>() {
@Override
protected Multiset<String> delegate() {
Reported by PMD.