The following issues were found
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.
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.
guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java
19 issues
Line: 102
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: 103
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: 104
@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: 113
* 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: 115
@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: 118
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: 123
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: 129
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: 148
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: 149
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.
guava-tests/test/com/google/common/graph/MapCacheTest.java
19 issues
Line: 84
@Test
public void testRemoveEqualKeyWithDifferentReference() {
String fooReference1 = new String("foo");
String fooReference2 = new String("foo");
assertThat(fooReference1).isNotSameInstanceAs(fooReference2);
assertThat(mapCache.put(fooReference1, "bar")).isNull();
assertThat(mapCache.get(fooReference1)).isEqualTo("bar"); // ensure first reference is cached
Reported by PMD.
Line: 85
@Test
public void testRemoveEqualKeyWithDifferentReference() {
String fooReference1 = new String("foo");
String fooReference2 = new String("foo");
assertThat(fooReference1).isNotSameInstanceAs(fooReference2);
assertThat(mapCache.put(fooReference1, "bar")).isNull();
assertThat(mapCache.get(fooReference1)).isEqualTo("bar"); // ensure first reference is cached
assertThat(mapCache.remove(fooReference2)).isEqualTo("bar");
Reported by PMD.
Line: 38
// TODO(cpovirk): Figure out Android JUnit 4 support. Does it work with Gingerbread? @RunWith?
@RunWith(Parameterized.class)
public final class MapCacheTest {
private final MapIteratorCache<String, String> mapCache;
public MapCacheTest(MapIteratorCache<String, String> mapCache) {
this.mapCache = mapCache;
}
Reported by PMD.
Line: 46
@Parameters
public static Collection<Object[]> parameters() {
Comparator<String> nullsLast = Ordering.natural().nullsLast();
return Arrays.asList(
new Object[][] {
{new MapIteratorCache<String, String>(new HashMap<String, String>())},
{new MapIteratorCache<String, String>(new TreeMap<String, String>(nullsLast))},
Reported by PMD.
Line: 63
}
@Test
public void testKeySetIterator() {
mapCache.put("A", "A_value");
mapCache.put("B", "B_value");
mapCache.put("C", "C_value");
assertThat(mapCache.unmodifiableKeySet()).hasSize(3);
Reported by PMD.
Line: 68
mapCache.put("B", "B_value");
mapCache.put("C", "C_value");
assertThat(mapCache.unmodifiableKeySet()).hasSize(3);
for (String key : mapCache.unmodifiableKeySet()) {
assertThat(mapCache.get(key)).isEqualTo(key + "_value");
}
}
Reported by PMD.
Line: 70
assertThat(mapCache.unmodifiableKeySet()).hasSize(3);
for (String key : mapCache.unmodifiableKeySet()) {
assertThat(mapCache.get(key)).isEqualTo(key + "_value");
}
}
@Test
public void testPutNewValue() {
Reported by PMD.
Line: 75
}
@Test
public void testPutNewValue() {
assertThat(mapCache.put("key", "value")).isNull();
assertThat(mapCache.get("key")).isEqualTo("value"); // ensure key/value is cached
assertThat(mapCache.put("key", "new value")).isEqualTo("value");
assertThat(mapCache.get("key")).isEqualTo("new value");
}
Reported by PMD.
Line: 76
@Test
public void testPutNewValue() {
assertThat(mapCache.put("key", "value")).isNull();
assertThat(mapCache.get("key")).isEqualTo("value"); // ensure key/value is cached
assertThat(mapCache.put("key", "new value")).isEqualTo("value");
assertThat(mapCache.get("key")).isEqualTo("new value");
}
Reported by PMD.
Line: 76
@Test
public void testPutNewValue() {
assertThat(mapCache.put("key", "value")).isNull();
assertThat(mapCache.get("key")).isEqualTo("value"); // ensure key/value is cached
assertThat(mapCache.put("key", "new value")).isEqualTo("value");
assertThat(mapCache.get("key")).isEqualTo("new value");
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/CollectionRemoveTester.java
18 issues
Line: 45
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionRemoveTester<E> extends AbstractCollectionTester<E> {
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_present() {
int initialSize = collection.size();
assertTrue("remove(present) should return true", collection.remove(e0()));
assertEquals(
Reported by PMD.
Line: 47
public class CollectionRemoveTester<E> extends AbstractCollectionTester<E> {
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_present() {
int initialSize = collection.size();
assertTrue("remove(present) should return true", collection.remove(e0()));
assertEquals(
"remove(present) should decrease a collection's size by one.",
initialSize - 1,
Reported by PMD.
Line: 57
expectMissing(e0());
}
@CollectionFeature.Require({SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
@CollectionSize.Require(SEVERAL)
public void testRemovePresentConcurrentWithIteration() {
try {
Iterator<E> iterator = collection.iterator();
assertTrue(collection.remove(e0()));
Reported by PMD.
Line: 70
}
}
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemove_notPresent() {
assertFalse("remove(notPresent) should return false", collection.remove(e3()));
expectUnchanged();
}
Reported by PMD.
Line: 76
expectUnchanged();
}
@CollectionFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
public void testRemove_nullPresent() {
collection = getSubjectGenerator().create(createArrayWithNullElement());
int initialSize = collection.size();
Reported by PMD.
Line: 78
@CollectionFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
public void testRemove_nullPresent() {
collection = getSubjectGenerator().create(createArrayWithNullElement());
int initialSize = collection.size();
assertTrue("remove(null) should return true", collection.remove(null));
assertEquals(
Reported by PMD.
Line: 79
@CollectionFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
public void testRemove_nullPresent() {
collection = getSubjectGenerator().create(createArrayWithNullElement());
int initialSize = collection.size();
assertTrue("remove(null) should return true", collection.remove(null));
assertEquals(
"remove(present) should decrease a collection's size by one.",
Reported by PMD.
Line: 90
expectMissing((E) null);
}
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_unsupported() {
try {
collection.remove(e0());
fail("remove(present) should throw UnsupportedOperationException");
Reported by PMD.
Line: 102
assertTrue("remove(present) should not remove the element", collection.contains(e0()));
}
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testRemove_unsupportedNotPresent() {
try {
assertFalse(
"remove(notPresent) should return false or throw UnsupportedOperationException",
collection.remove(e3()));
Reported by PMD.
Line: 108
assertFalse(
"remove(notPresent) should return false or throw UnsupportedOperationException",
collection.remove(e3()));
} catch (UnsupportedOperationException tolerated) {
}
expectUnchanged();
expectMissing(e3());
}
Reported by PMD.
guava-testlib/test/com/google/common/testing/SerializableTesterTest.java
18 issues
Line: 29
* @author Nick Kralevich
*/
public class SerializableTesterTest extends TestCase {
public void testStringAssertions() {
String original = "hello world";
String copy = SerializableTester.reserializeAndAssert(original);
assertEquals(original, copy);
assertNotSame(original, copy);
}
Reported by PMD.
Line: 29
* @author Nick Kralevich
*/
public class SerializableTesterTest extends TestCase {
public void testStringAssertions() {
String original = "hello world";
String copy = SerializableTester.reserializeAndAssert(original);
assertEquals(original, copy);
assertNotSame(original, copy);
}
Reported by PMD.
Line: 32
public void testStringAssertions() {
String original = "hello world";
String copy = SerializableTester.reserializeAndAssert(original);
assertEquals(original, copy);
assertNotSame(original, copy);
}
public void testClassWhichDoesNotImplementEquals() {
ClassWhichDoesNotImplementEquals orig = new ClassWhichDoesNotImplementEquals();
Reported by PMD.
Line: 33
String original = "hello world";
String copy = SerializableTester.reserializeAndAssert(original);
assertEquals(original, copy);
assertNotSame(original, copy);
}
public void testClassWhichDoesNotImplementEquals() {
ClassWhichDoesNotImplementEquals orig = new ClassWhichDoesNotImplementEquals();
boolean errorNotThrown = false;
Reported by PMD.
Line: 36
assertNotSame(original, copy);
}
public void testClassWhichDoesNotImplementEquals() {
ClassWhichDoesNotImplementEquals orig = new ClassWhichDoesNotImplementEquals();
boolean errorNotThrown = false;
try {
SerializableTester.reserializeAndAssert(orig);
errorNotThrown = true;
Reported by PMD.
Line: 36
assertNotSame(original, copy);
}
public void testClassWhichDoesNotImplementEquals() {
ClassWhichDoesNotImplementEquals orig = new ClassWhichDoesNotImplementEquals();
boolean errorNotThrown = false;
try {
SerializableTester.reserializeAndAssert(orig);
errorNotThrown = true;
Reported by PMD.
Line: 46
// expected
assertContains("must be Object#equals to", error.getMessage());
}
assertFalse(errorNotThrown);
}
public void testClassWhichIsAlwaysEqualButHasDifferentHashcodes() {
ClassWhichIsAlwaysEqualButHasDifferentHashcodes orig =
new ClassWhichIsAlwaysEqualButHasDifferentHashcodes();
Reported by PMD.
Line: 49
assertFalse(errorNotThrown);
}
public void testClassWhichIsAlwaysEqualButHasDifferentHashcodes() {
ClassWhichIsAlwaysEqualButHasDifferentHashcodes orig =
new ClassWhichIsAlwaysEqualButHasDifferentHashcodes();
boolean errorNotThrown = false;
try {
SerializableTester.reserializeAndAssert(orig);
Reported by PMD.
Line: 49
assertFalse(errorNotThrown);
}
public void testClassWhichIsAlwaysEqualButHasDifferentHashcodes() {
ClassWhichIsAlwaysEqualButHasDifferentHashcodes orig =
new ClassWhichIsAlwaysEqualButHasDifferentHashcodes();
boolean errorNotThrown = false;
try {
SerializableTester.reserializeAndAssert(orig);
Reported by PMD.
Line: 60
// expected
assertContains("must be equal to the Object#hashCode", error.getMessage());
}
assertFalse(errorNotThrown);
}
public void testObjectWhichIsEqualButChangesClass() {
ObjectWhichIsEqualButChangesClass orig = new ObjectWhichIsEqualButChangesClass();
boolean errorNotThrown = false;
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/MapReplaceAllTester.java
18 issues
Line: 52
return new SampleElements<V>(v0(), v1(), v2(), v3(), v4());
}
@MapFeature.Require(SUPPORTS_PUT)
public void testReplaceAllRotate() {
getMap()
.replaceAll(
(K k, V v) -> {
int index = keys().asList().indexOf(k);
Reported by PMD.
Line: 54
@MapFeature.Require(SUPPORTS_PUT)
public void testReplaceAllRotate() {
getMap()
.replaceAll(
(K k, V v) -> {
int index = keys().asList().indexOf(k);
return values().asList().get(index + 1);
});
Reported by PMD.
Line: 62
});
List<Entry<K, V>> expectedEntries = new ArrayList<>();
for (Entry<K, V> entry : getSampleEntries()) {
int index = keys().asList().indexOf(entry.getKey());
expectedEntries.add(Helpers.mapEntry(entry.getKey(), values().asList().get(index + 1)));
}
expectContents(expectedEntries);
}
Reported by PMD.
Line: 62
});
List<Entry<K, V>> expectedEntries = new ArrayList<>();
for (Entry<K, V> entry : getSampleEntries()) {
int index = keys().asList().indexOf(entry.getKey());
expectedEntries.add(Helpers.mapEntry(entry.getKey(), values().asList().get(index + 1)));
}
expectContents(expectedEntries);
}
Reported by PMD.
Line: 63
List<Entry<K, V>> expectedEntries = new ArrayList<>();
for (Entry<K, V> entry : getSampleEntries()) {
int index = keys().asList().indexOf(entry.getKey());
expectedEntries.add(Helpers.mapEntry(entry.getKey(), values().asList().get(index + 1)));
}
expectContents(expectedEntries);
}
@MapFeature.Require(SUPPORTS_PUT)
Reported by PMD.
Line: 63
List<Entry<K, V>> expectedEntries = new ArrayList<>();
for (Entry<K, V> entry : getSampleEntries()) {
int index = keys().asList().indexOf(entry.getKey());
expectedEntries.add(Helpers.mapEntry(entry.getKey(), values().asList().get(index + 1)));
}
expectContents(expectedEntries);
}
@MapFeature.Require(SUPPORTS_PUT)
Reported by PMD.
Line: 68
expectContents(expectedEntries);
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionFeature.Require(KNOWN_ORDER)
public void testReplaceAllPreservesOrder() {
getMap()
.replaceAll(
(K k, V v) -> {
Reported by PMD.
Line: 71
@MapFeature.Require(SUPPORTS_PUT)
@CollectionFeature.Require(KNOWN_ORDER)
public void testReplaceAllPreservesOrder() {
getMap()
.replaceAll(
(K k, V v) -> {
int index = keys().asList().indexOf(k);
return values().asList().get(index + 1);
});
Reported by PMD.
Line: 79
});
List<Entry<K, V>> orderedEntries = getOrderedElements();
int index = 0;
for (K key : getMap().keySet()) {
assertEquals(orderedEntries.get(index).getKey(), key);
index++;
}
}
Reported by PMD.
Line: 80
List<Entry<K, V>> orderedEntries = getOrderedElements();
int index = 0;
for (K key : getMap().keySet()) {
assertEquals(orderedEntries.get(index).getKey(), key);
index++;
}
}
@MapFeature.Require(absent = SUPPORTS_PUT)
Reported by PMD.
guava-tests/test/com/google/common/io/CloseablesTest.java
18 issues
Line: 39
* @author Michael Lancaster
*/
public class CloseablesTest extends TestCase {
private Closeable mockCloseable;
public void testClose_closeableClean() throws IOException {
// make sure that no exception is thrown regardless of value of
// 'swallowException' when the mock does not throw an exception.
setupCloseable(false);
Reported by PMD.
Line: 41
public class CloseablesTest extends TestCase {
private Closeable mockCloseable;
public void testClose_closeableClean() throws IOException {
// make sure that no exception is thrown regardless of value of
// 'swallowException' when the mock does not throw an exception.
setupCloseable(false);
doClose(mockCloseable, false, false);
Reported by PMD.
Line: 41
public class CloseablesTest extends TestCase {
private Closeable mockCloseable;
public void testClose_closeableClean() throws IOException {
// make sure that no exception is thrown regardless of value of
// 'swallowException' when the mock does not throw an exception.
setupCloseable(false);
doClose(mockCloseable, false, false);
Reported by PMD.
Line: 51
doClose(mockCloseable, true, false);
}
public void testClose_closeableWithEatenException() throws IOException {
// make sure that no exception is thrown if 'swallowException' is true
// when the mock does throw an exception.
setupCloseable(true);
doClose(mockCloseable, true);
}
Reported by PMD.
Line: 51
doClose(mockCloseable, true, false);
}
public void testClose_closeableWithEatenException() throws IOException {
// make sure that no exception is thrown if 'swallowException' is true
// when the mock does throw an exception.
setupCloseable(true);
doClose(mockCloseable, true);
}
Reported by PMD.
Line: 58
doClose(mockCloseable, true);
}
public void testClose_closeableWithThrownException() throws IOException {
// make sure that the exception is thrown if 'swallowException' is false
// when the mock does throw an exception.
setupCloseable(true);
doClose(mockCloseable, false);
}
Reported by PMD.
Line: 58
doClose(mockCloseable, true);
}
public void testClose_closeableWithThrownException() throws IOException {
// make sure that the exception is thrown if 'swallowException' is false
// when the mock does throw an exception.
setupCloseable(true);
doClose(mockCloseable, false);
}
Reported by PMD.
Line: 65
doClose(mockCloseable, false);
}
public void testCloseQuietly_inputStreamWithEatenException() throws IOException {
TestInputStream in =
new TestInputStream(new ByteArrayInputStream(new byte[1]), TestOption.CLOSE_THROWS);
Closeables.closeQuietly(in);
assertTrue(in.closed());
}
Reported by PMD.
Line: 69
TestInputStream in =
new TestInputStream(new ByteArrayInputStream(new byte[1]), TestOption.CLOSE_THROWS);
Closeables.closeQuietly(in);
assertTrue(in.closed());
}
public void testCloseQuietly_readerWithEatenException() throws IOException {
TestReader in = new TestReader(TestOption.CLOSE_THROWS);
Closeables.closeQuietly(in);
Reported by PMD.
Line: 72
assertTrue(in.closed());
}
public void testCloseQuietly_readerWithEatenException() throws IOException {
TestReader in = new TestReader(TestOption.CLOSE_THROWS);
Closeables.closeQuietly(in);
assertTrue(in.closed());
}
Reported by PMD.
guava-tests/test/com/google/common/io/IoTestCase.java
18 issues
Line: 72
URL testFileUrl = IoTestCase.class.getResource("testdata/i18n.txt");
if (testFileUrl == null) {
throw new RuntimeException("unable to locate testdata directory");
}
if (testFileUrl.getProtocol().equals("file")) {
try {
File testFile = new File(testFileUrl.toURI());
Reported by PMD.
Line: 159
private static void copy(URL url, File file) throws IOException {
InputStream in = url.openStream();
try {
OutputStream out = new FileOutputStream(file);
try {
byte[] buf = new byte[4096];
for (int read = in.read(buf); read != -1; read = in.read(buf)) {
out.write(buf, 0, read);
}
Reported by PMD.
Line: 50
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
private File testDir;
private File tempDir;
private final Set<File> filesToDelete = Sets.newHashSet();
@Override
Reported by PMD.
Line: 51
+ "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
private File testDir;
private File tempDir;
private final Set<File> filesToDelete = Sets.newHashSet();
@Override
protected void tearDown() {
Reported by PMD.
Line: 53
private File testDir;
private File tempDir;
private final Set<File> filesToDelete = Sets.newHashSet();
@Override
protected void tearDown() {
for (File file : filesToDelete) {
if (file.exists()) {
Reported by PMD.
Line: 55
private final Set<File> filesToDelete = Sets.newHashSet();
@Override
protected void tearDown() {
for (File file : filesToDelete) {
if (file.exists()) {
delete(file);
}
Reported by PMD.
Line: 75
throw new RuntimeException("unable to locate testdata directory");
}
if (testFileUrl.getProtocol().equals("file")) {
try {
File testFile = new File(testFileUrl.toURI());
testDir = testFile.getParentFile(); // the testdata directory
} catch (Exception ignore) {
// probably URISyntaxException or IllegalArgumentException
Reported by PMD.
Line: 75
throw new RuntimeException("unable to locate testdata directory");
}
if (testFileUrl.getProtocol().equals("file")) {
try {
File testFile = new File(testFileUrl.toURI());
testDir = testFile.getParentFile(); // the testdata directory
} catch (Exception ignore) {
// probably URISyntaxException or IllegalArgumentException
Reported by PMD.
Line: 75
throw new RuntimeException("unable to locate testdata directory");
}
if (testFileUrl.getProtocol().equals("file")) {
try {
File testFile = new File(testFileUrl.toURI());
testDir = testFile.getParentFile(); // the testdata directory
} catch (Exception ignore) {
// probably URISyntaxException or IllegalArgumentException
Reported by PMD.
Line: 79
try {
File testFile = new File(testFileUrl.toURI());
testDir = testFile.getParentFile(); // the testdata directory
} catch (Exception ignore) {
// probably URISyntaxException or IllegalArgumentException
// fall back to copying URLs to files in the testDir == null block below
}
}
Reported by PMD.
android/guava/src/com/google/common/collect/TreeBasedTable.java
18 issues
Line: 190
this.lowerBound = lowerBound;
this.upperBound = upperBound;
checkArgument(
lowerBound == null || upperBound == null || compare(lowerBound, upperBound) <= 0);
}
@Override
public SortedSet<C> keySet() {
return new Maps.SortedKeySet<>(this);
Reported by PMD.
Line: 72
@GwtCompatible(serializable = true)
@ElementTypesAreNonnullByDefault
public class TreeBasedTable<R, C, V> extends StandardRowSortedTable<R, C, V> {
private final Comparator<? super C> columnComparator;
private static class Factory<C, V> implements Supplier<TreeMap<C, V>>, Serializable {
final Comparator<? super C> comparator;
Factory(Comparator<? super C> comparator) {
Reported by PMD.
Line: 72
@GwtCompatible(serializable = true)
@ElementTypesAreNonnullByDefault
public class TreeBasedTable<R, C, V> extends StandardRowSortedTable<R, C, V> {
private final Comparator<? super C> columnComparator;
private static class Factory<C, V> implements Supplier<TreeMap<C, V>>, Serializable {
final Comparator<? super C> comparator;
Factory(Comparator<? super C> comparator) {
Reported by PMD.
Line: 75
private final Comparator<? super C> columnComparator;
private static class Factory<C, V> implements Supplier<TreeMap<C, V>>, Serializable {
final Comparator<? super C> comparator;
Factory(Comparator<? super C> comparator) {
this.comparator = comparator;
}
Reported by PMD.
Line: 144
* requireNonNull is safe because the factories require non-null Comparators, which they pass on
* to the backing collections.
*/
return requireNonNull(rowKeySet().comparator());
}
/**
* Returns the comparator that orders the columns. With natural ordering, {@link
* Ordering#natural()} is returned.
Reported by PMD.
Line: 177
return new TreeRow(rowKey);
}
private class TreeRow extends Row implements SortedMap<C, V> {
@CheckForNull final C lowerBound;
@CheckForNull final C upperBound;
TreeRow(R rowKey) {
this(rowKey, null, null);
Reported by PMD.
Line: 178
}
private class TreeRow extends Row implements SortedMap<C, V> {
@CheckForNull final C lowerBound;
@CheckForNull final C upperBound;
TreeRow(R rowKey) {
this(rowKey, null, null);
}
Reported by PMD.
Line: 179
private class TreeRow extends Row implements SortedMap<C, V> {
@CheckForNull final C lowerBound;
@CheckForNull final C upperBound;
TreeRow(R rowKey) {
this(rowKey, null, null);
}
Reported by PMD.
Line: 207
// pretend we can compare anything
@SuppressWarnings("unchecked")
Comparator<Object> cmp = (Comparator<Object>) comparator();
return cmp.compare(a, b);
}
boolean rangeContains(@CheckForNull Object o) {
return o != null
&& (lowerBound == null || compare(lowerBound, o) <= 0)
Reported by PMD.
Line: 283
updateWholeRowField();
if (wholeRow != null && wholeRow.isEmpty()) {
backingMap.remove(rowKey);
wholeRow = null;
backingRowMap = null;
}
}
@Override
Reported by PMD.