The following issues were found
android/guava-testlib/src/com/google/common/collect/testing/google/UnmodifiableCollectionTests.java
31 issues
Line: 46
* @author Robert Konigsberg
*/
@GwtCompatible
public class UnmodifiableCollectionTests {
public static void assertMapEntryIsUnmodifiable(Entry<?, ?> entry) {
try {
entry.setValue(null);
fail("setValue on unmodifiable Map.Entry succeeded");
Reported by PMD.
Line: 46
* @author Robert Konigsberg
*/
@GwtCompatible
public class UnmodifiableCollectionTests {
public static void assertMapEntryIsUnmodifiable(Entry<?, ?> entry) {
try {
entry.setValue(null);
fail("setValue on unmodifiable Map.Entry succeeded");
Reported by PMD.
Line: 46
* @author Robert Konigsberg
*/
@GwtCompatible
public class UnmodifiableCollectionTests {
public static void assertMapEntryIsUnmodifiable(Entry<?, ?> entry) {
try {
entry.setValue(null);
fail("setValue on unmodifiable Map.Entry succeeded");
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 286
// Test asMap().entrySet()
assertSetIsUnmodifiable(
multimap.asMap().entrySet(), Maps.immutableEntry(sampleKey, sampleValueAsCollection));
// Test #values()
assertMultimapRemainsUnmodified(multimap, originalEntries);
if (!multimap.isEmpty()) {
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/testers/MapPutAllTester.java
31 issues
Line: 53
@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 MapPutAllTester<K, V> extends AbstractMapTester<K, V> {
private List<Entry<K, V>> containsNullKey;
private List<Entry<K, V>> containsNullValue;
@Override
public void setUp() throws Exception {
Reported by PMD.
Line: 54
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapPutAllTester<K, V> extends AbstractMapTester<K, V> {
private List<Entry<K, V>> containsNullKey;
private List<Entry<K, V>> containsNullValue;
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 55
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapPutAllTester<K, V> extends AbstractMapTester<K, V> {
private List<Entry<K, V>> containsNullKey;
private List<Entry<K, V>> containsNullValue;
@Override
public void setUp() throws Exception {
super.setUp();
containsNullKey = singletonList(entry(null, v3()));
Reported by PMD.
Line: 57
private List<Entry<K, V>> containsNullKey;
private List<Entry<K, V>> containsNullValue;
@Override
public void setUp() throws Exception {
super.setUp();
containsNullKey = singletonList(entry(null, v3()));
containsNullValue = singletonList(entry(k3(), null));
}
Reported by PMD.
Line: 64
containsNullValue = singletonList(entry(k3(), null));
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll_supportedNothing() {
getMap().putAll(emptyMap());
expectUnchanged();
}
Reported by PMD.
Line: 66
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll_supportedNothing() {
getMap().putAll(emptyMap());
expectUnchanged();
}
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutAll_unsupportedNothing() {
Reported by PMD.
Line: 70
expectUnchanged();
}
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutAll_unsupportedNothing() {
try {
getMap().putAll(emptyMap());
} catch (UnsupportedOperationException tolerated) {
}
Reported by PMD.
Line: 73
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutAll_unsupportedNothing() {
try {
getMap().putAll(emptyMap());
} catch (UnsupportedOperationException tolerated) {
}
expectUnchanged();
}
Reported by PMD.
Line: 74
public void testPutAll_unsupportedNothing() {
try {
getMap().putAll(emptyMap());
} catch (UnsupportedOperationException tolerated) {
}
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
Reported by PMD.
Line: 79
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll_supportedNonePresent() {
putAll(createDisjointCollection());
expectAdded(e3(), e4());
}
Reported by PMD.
android/guava/src/com/google/common/collect/AbstractBiMap.java
31 issues
Line: 59
/** Package-private constructor for creating a map-backed bimap. */
AbstractBiMap(Map<K, V> forward, Map<V, K> backward) {
setDelegates(forward, backward);
}
/** Private constructor for inverse bimap. */
private AbstractBiMap(Map<K, V> backward, AbstractBiMap<V, K> forward) {
delegate = backward;
Reported by PMD.
Line: 52
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
abstract class AbstractBiMap<K extends @Nullable Object, V extends @Nullable Object>
extends ForwardingMap<K, V> implements BiMap<K, V>, Serializable {
private transient Map<K, V> delegate;
@RetainedWith transient AbstractBiMap<V, K> inverse;
/** Package-private constructor for creating a map-backed bimap. */
Reported by PMD.
Line: 54
abstract class AbstractBiMap<K extends @Nullable Object, V extends @Nullable Object>
extends ForwardingMap<K, V> implements BiMap<K, V>, Serializable {
private transient Map<K, V> delegate;
@RetainedWith transient AbstractBiMap<V, K> inverse;
/** Package-private constructor for creating a map-backed bimap. */
AbstractBiMap(Map<K, V> forward, Map<V, K> backward) {
setDelegates(forward, backward);
Reported by PMD.
Line: 55
extends ForwardingMap<K, V> implements BiMap<K, V>, Serializable {
private transient Map<K, V> delegate;
@RetainedWith transient AbstractBiMap<V, K> inverse;
/** Package-private constructor for creating a map-backed bimap. */
AbstractBiMap(Map<K, V> forward, Map<V, K> backward) {
setDelegates(forward, backward);
}
Reported by PMD.
Line: 96
checkState(inverse == null);
checkArgument(forward.isEmpty());
checkArgument(backward.isEmpty());
checkArgument(forward != backward);
delegate = forward;
inverse = makeInverse(backward);
}
AbstractBiMap<V, K> makeInverse(Map<V, K> backward) {
Reported by PMD.
Line: 141
return value;
}
if (force) {
inverse().remove(value);
} else {
checkArgument(!containsValue(value), "value already present: %s", value);
}
V oldValue = delegate.put(key, value);
updateInverseMap(key, containedKey, oldValue, value);
Reported by PMD.
Line: 159
// The cast is safe because of the containedKey check.
removeFromInverseMap(uncheckedCastNullableTToT(oldValue));
}
inverse.delegate.put(newValue, key);
}
@CanIgnoreReturnValue
@Override
@CheckForNull
Reported by PMD.
Line: 179
}
private void removeFromInverseMap(@ParametricNullness V oldValue) {
inverse.delegate.remove(oldValue);
}
// Bulk Operations
@Override
Reported by PMD.
Line: 194
@Override
public void clear() {
delegate.clear();
inverse.delegate.clear();
}
// Views
@Override
Reported by PMD.
Line: 204
return inverse;
}
@CheckForNull private transient Set<K> keySet;
@Override
public Set<K> keySet() {
Set<K> result = keySet;
return (result == null) ? keySet = new KeySet() : result;
Reported by PMD.
android/guava-tests/test/com/google/common/xml/XmlEscapersTest.java
31 issues
Line: 33
* @author David Beaumont
*/
@GwtCompatible
public class XmlEscapersTest extends TestCase {
public void testXmlContentEscaper() throws Exception {
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
Reported by PMD.
Line: 33
* @author David Beaumont
*/
@GwtCompatible
public class XmlEscapersTest extends TestCase {
public void testXmlContentEscaper() throws Exception {
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
Reported by PMD.
Line: 35
@GwtCompatible
public class XmlEscapersTest extends TestCase {
public void testXmlContentEscaper() throws Exception {
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
Reported by PMD.
Line: 35
@GwtCompatible
public class XmlEscapersTest extends TestCase {
public void testXmlContentEscaper() throws Exception {
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
Reported by PMD.
Line: 39
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
Reported by PMD.
Line: 39
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
Reported by PMD.
Line: 40
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
assertBasicXmlEscaper(xmlAttributeEscaper, true, true);
Reported by PMD.
Line: 40
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
assertBasicXmlEscaper(xmlAttributeEscaper, true, true);
Reported by PMD.
Line: 43
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
assertBasicXmlEscaper(xmlAttributeEscaper, true, true);
// Test quotes are escaped.
assertEquals(""test"", xmlAttributeEscaper.escape("\"test\""));
assertEquals("'test'", xmlAttributeEscaper.escape("\'test'"));
Reported by PMD.
Line: 43
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
assertBasicXmlEscaper(xmlAttributeEscaper, true, true);
// Test quotes are escaped.
assertEquals(""test"", xmlAttributeEscaper.escape("\"test\""));
assertEquals("'test'", xmlAttributeEscaper.escape("\'test'"));
Reported by PMD.
android/guava-tests/test/com/google/common/net/PercentEscaperTest.java
31 issues
Line: 38
public class PercentEscaperTest extends TestCase {
/** Tests that the simple escaper treats 0-9, a-z and A-Z as safe */
public void testSimpleEscaper() {
UnicodeEscaper e = new PercentEscaper("", false);
for (char c = 0; c < 128; c++) {
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
assertUnescaped(e, c);
} else {
Reported by PMD.
Line: 38
public class PercentEscaperTest extends TestCase {
/** Tests that the simple escaper treats 0-9, a-z and A-Z as safe */
public void testSimpleEscaper() {
UnicodeEscaper e = new PercentEscaper("", false);
for (char c = 0; c < 128; c++) {
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
assertUnescaped(e, c);
} else {
Reported by PMD.
Line: 59
assertUnicodeEscaping(e, "%F4%8F%BF%BF", '\uDBFF', '\uDFFF');
// simple string tests
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: 60
// simple string tests
assertEquals("", e.escape(""));
assertEquals("safestring", e.escape("safestring"));
assertEquals("embedded%00null", e.escape("embedded\0null"));
assertEquals("max%EF%BF%BFchar", e.escape("max\uffffchar"));
}
/** Tests the various ways that the space character can be handled */
Reported by PMD.
Line: 61
// simple string tests
assertEquals("", e.escape(""));
assertEquals("safestring", e.escape("safestring"));
assertEquals("embedded%00null", e.escape("embedded\0null"));
assertEquals("max%EF%BF%BFchar", e.escape("max\uffffchar"));
}
/** Tests the various ways that the space character can be handled */
public void testPlusForSpace() {
Reported by PMD.
Line: 62
assertEquals("", e.escape(""));
assertEquals("safestring", e.escape("safestring"));
assertEquals("embedded%00null", e.escape("embedded\0null"));
assertEquals("max%EF%BF%BFchar", e.escape("max\uffffchar"));
}
/** Tests the various ways that the space character can be handled */
public void testPlusForSpace() {
UnicodeEscaper basicEscaper = new PercentEscaper("", false);
Reported by PMD.
Line: 66
}
/** Tests the various ways that the space character can be handled */
public void testPlusForSpace() {
UnicodeEscaper basicEscaper = new PercentEscaper("", false);
UnicodeEscaper plusForSpaceEscaper = new PercentEscaper("", true);
UnicodeEscaper spaceEscaper = new PercentEscaper(" ", false);
assertEquals("string%20with%20spaces", basicEscaper.escape("string with spaces"));
Reported by PMD.
Line: 66
}
/** Tests the various ways that the space character can be handled */
public void testPlusForSpace() {
UnicodeEscaper basicEscaper = new PercentEscaper("", false);
UnicodeEscaper plusForSpaceEscaper = new PercentEscaper("", true);
UnicodeEscaper spaceEscaper = new PercentEscaper(" ", false);
assertEquals("string%20with%20spaces", basicEscaper.escape("string with spaces"));
Reported by PMD.
Line: 71
UnicodeEscaper plusForSpaceEscaper = new PercentEscaper("", true);
UnicodeEscaper spaceEscaper = new PercentEscaper(" ", false);
assertEquals("string%20with%20spaces", basicEscaper.escape("string with spaces"));
assertEquals("string+with+spaces", plusForSpaceEscaper.escape("string with spaces"));
assertEquals("string with spaces", spaceEscaper.escape("string with spaces"));
}
/** Tests that if we add extra 'safe' characters they remain unescaped */
Reported by PMD.
Line: 71
UnicodeEscaper plusForSpaceEscaper = new PercentEscaper("", true);
UnicodeEscaper spaceEscaper = new PercentEscaper(" ", false);
assertEquals("string%20with%20spaces", basicEscaper.escape("string with spaces"));
assertEquals("string+with+spaces", plusForSpaceEscaper.escape("string with spaces"));
assertEquals("string with spaces", spaceEscaper.escape("string with spaces"));
}
/** Tests that if we add extra 'safe' characters they remain unescaped */
Reported by PMD.
android/guava/src/com/google/common/base/Splitter.java
31 issues
Line: 191
continue positions;
}
}
return p;
}
return -1;
}
@Override
Reported by PMD.
Line: 614
limit--;
}
return toSplit.subSequence(start, end).toString();
}
return endOfData();
}
}
}
Reported by PMD.
Line: 102
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
Reported by PMD.
Line: 103
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
Reported by PMD.
Line: 104
@ElementTypesAreNonnullByDefault
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
this(strategy, false, CharMatcher.none(), Integer.MAX_VALUE);
Reported by PMD.
Line: 104
@ElementTypesAreNonnullByDefault
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
this(strategy, false, CharMatcher.none(), Integer.MAX_VALUE);
Reported by PMD.
Line: 105
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
this(strategy, false, CharMatcher.none(), Integer.MAX_VALUE);
}
Reported by PMD.
Line: 106
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
this(strategy, false, CharMatcher.none(), Integer.MAX_VALUE);
}
Reported by PMD.
Line: 106
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
this(strategy, false, CharMatcher.none(), Integer.MAX_VALUE);
}
Reported by PMD.
Line: 172
*/
public static Splitter on(final String separator) {
checkArgument(separator.length() != 0, "The separator may not be the empty string.");
if (separator.length() == 1) {
return Splitter.on(separator.charAt(0));
}
return new Splitter(
new Strategy() {
@Override
Reported by PMD.
guava-tests/test/com/google/common/xml/XmlEscapersTest.java
31 issues
Line: 33
* @author David Beaumont
*/
@GwtCompatible
public class XmlEscapersTest extends TestCase {
public void testXmlContentEscaper() throws Exception {
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
Reported by PMD.
Line: 33
* @author David Beaumont
*/
@GwtCompatible
public class XmlEscapersTest extends TestCase {
public void testXmlContentEscaper() throws Exception {
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
Reported by PMD.
Line: 35
@GwtCompatible
public class XmlEscapersTest extends TestCase {
public void testXmlContentEscaper() throws Exception {
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
Reported by PMD.
Line: 35
@GwtCompatible
public class XmlEscapersTest extends TestCase {
public void testXmlContentEscaper() throws Exception {
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
Reported by PMD.
Line: 39
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
Reported by PMD.
Line: 39
CharEscaper xmlContentEscaper = (CharEscaper) XmlEscapers.xmlContentEscaper();
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
Reported by PMD.
Line: 40
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
assertBasicXmlEscaper(xmlAttributeEscaper, true, true);
Reported by PMD.
Line: 40
assertBasicXmlEscaper(xmlContentEscaper, false, false);
// Test quotes are not escaped.
assertEquals("\"test\"", xmlContentEscaper.escape("\"test\""));
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
assertBasicXmlEscaper(xmlAttributeEscaper, true, true);
Reported by PMD.
Line: 43
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
assertBasicXmlEscaper(xmlAttributeEscaper, true, true);
// Test quotes are escaped.
assertEquals(""test"", xmlAttributeEscaper.escape("\"test\""));
assertEquals("'test'", xmlAttributeEscaper.escape("\'test'"));
Reported by PMD.
Line: 43
assertEquals("'test'", xmlContentEscaper.escape("'test'"));
}
public void testXmlAttributeEscaper() throws Exception {
CharEscaper xmlAttributeEscaper = (CharEscaper) XmlEscapers.xmlAttributeEscaper();
assertBasicXmlEscaper(xmlAttributeEscaper, true, true);
// Test quotes are escaped.
assertEquals(""test"", xmlAttributeEscaper.escape("\"test\""));
assertEquals("'test'", xmlAttributeEscaper.escape("\'test'"));
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/UnmodifiableCollectionTests.java
31 issues
Line: 46
* @author Robert Konigsberg
*/
@GwtCompatible
public class UnmodifiableCollectionTests {
public static void assertMapEntryIsUnmodifiable(Entry<?, ?> entry) {
try {
entry.setValue(null);
fail("setValue on unmodifiable Map.Entry succeeded");
Reported by PMD.
Line: 46
* @author Robert Konigsberg
*/
@GwtCompatible
public class UnmodifiableCollectionTests {
public static void assertMapEntryIsUnmodifiable(Entry<?, ?> entry) {
try {
entry.setValue(null);
fail("setValue on unmodifiable Map.Entry succeeded");
Reported by PMD.
Line: 46
* @author Robert Konigsberg
*/
@GwtCompatible
public class UnmodifiableCollectionTests {
public static void assertMapEntryIsUnmodifiable(Entry<?, ?> entry) {
try {
entry.setValue(null);
fail("setValue on unmodifiable Map.Entry succeeded");
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 266
* @param sampleValue a key of the same type as that contained by {@code multimap}. {@code
* multimap} may or may not have {@code sampleValue} as a key.
*/
public static <K, V> void assertMultimapIsUnmodifiable(
Multimap<K, V> multimap, final K sampleKey, final V sampleValue) {
List<Entry<K, V>> originalEntries =
Collections.unmodifiableList(Lists.newArrayList(multimap.entries()));
assertMultimapRemainsUnmodified(multimap, originalEntries);
Reported by PMD.
Line: 286
// Test asMap().entrySet()
assertSetIsUnmodifiable(
multimap.asMap().entrySet(), Maps.immutableEntry(sampleKey, sampleValueAsCollection));
// Test #values()
assertMultimapRemainsUnmodified(multimap, originalEntries);
if (!multimap.isEmpty()) {
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/MapPutAllTester.java
31 issues
Line: 53
@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 MapPutAllTester<K, V> extends AbstractMapTester<K, V> {
private List<Entry<K, V>> containsNullKey;
private List<Entry<K, V>> containsNullValue;
@Override
public void setUp() throws Exception {
Reported by PMD.
Line: 54
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapPutAllTester<K, V> extends AbstractMapTester<K, V> {
private List<Entry<K, V>> containsNullKey;
private List<Entry<K, V>> containsNullValue;
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 55
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapPutAllTester<K, V> extends AbstractMapTester<K, V> {
private List<Entry<K, V>> containsNullKey;
private List<Entry<K, V>> containsNullValue;
@Override
public void setUp() throws Exception {
super.setUp();
containsNullKey = singletonList(entry(null, v3()));
Reported by PMD.
Line: 57
private List<Entry<K, V>> containsNullKey;
private List<Entry<K, V>> containsNullValue;
@Override
public void setUp() throws Exception {
super.setUp();
containsNullKey = singletonList(entry(null, v3()));
containsNullValue = singletonList(entry(k3(), null));
}
Reported by PMD.
Line: 64
containsNullValue = singletonList(entry(k3(), null));
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll_supportedNothing() {
getMap().putAll(emptyMap());
expectUnchanged();
}
Reported by PMD.
Line: 66
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll_supportedNothing() {
getMap().putAll(emptyMap());
expectUnchanged();
}
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutAll_unsupportedNothing() {
Reported by PMD.
Line: 70
expectUnchanged();
}
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutAll_unsupportedNothing() {
try {
getMap().putAll(emptyMap());
} catch (UnsupportedOperationException tolerated) {
}
Reported by PMD.
Line: 73
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutAll_unsupportedNothing() {
try {
getMap().putAll(emptyMap());
} catch (UnsupportedOperationException tolerated) {
}
expectUnchanged();
}
Reported by PMD.
Line: 74
public void testPutAll_unsupportedNothing() {
try {
getMap().putAll(emptyMap());
} catch (UnsupportedOperationException tolerated) {
}
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
Reported by PMD.
Line: 79
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll_supportedNonePresent() {
putAll(createDisjointCollection());
expectAdded(e3(), e4());
}
Reported by PMD.
guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java
31 issues
Line: 101
@Override
Map<String, String> wrap(final HashMap<String, String> map) {
if (map.containsKey(null)) {
throw new NullPointerException();
}
return new AbstractMap<String, String>() {
@Override
public Set<Entry<String, String>> entrySet() {
return map.entrySet();
Reported by PMD.
Line: 127
@Override
Map<String, String> wrap(final HashMap<String, String> map) {
if (map.containsValue(null)) {
throw new NullPointerException();
}
return new AbstractMap<String, String>() {
@Override
public Set<Entry<String, String>> entrySet() {
Reported by PMD.
Line: 55
*
* @author George van den Driessche
*/
public final class MapTestSuiteBuilderTests extends TestCase {
private MapTestSuiteBuilderTests() {}
public static Test suite() {
TestSuite suite = new TestSuite(MapTestSuiteBuilderTests.class.getSimpleName());
suite.addTest(testsForHashMapNullKeysForbidden());
Reported by PMD.
Line: 55
*
* @author George van den Driessche
*/
public final class MapTestSuiteBuilderTests extends TestCase {
private MapTestSuiteBuilderTests() {}
public static Test suite() {
TestSuite suite = new TestSuite(MapTestSuiteBuilderTests.class.getSimpleName());
suite.addTest(testsForHashMapNullKeysForbidden());
Reported by PMD.
Line: 55
*
* @author George van den Driessche
*/
public final class MapTestSuiteBuilderTests extends TestCase {
private MapTestSuiteBuilderTests() {}
public static Test suite() {
TestSuite suite = new TestSuite(MapTestSuiteBuilderTests.class.getSimpleName());
suite.addTest(testsForHashMapNullKeysForbidden());
Reported by PMD.
Line: 58
public final class MapTestSuiteBuilderTests extends TestCase {
private MapTestSuiteBuilderTests() {}
public static Test suite() {
TestSuite suite = new TestSuite(MapTestSuiteBuilderTests.class.getSimpleName());
suite.addTest(testsForHashMapNullKeysForbidden());
suite.addTest(testsForHashMapNullValuesForbidden());
suite.addTest(testsForSetUpTearDown());
return suite;
Reported by PMD.
Line: 76
return wrap(map);
}
abstract Map<String, String> wrap(HashMap<String, String> map);
}
private static TestSuite wrappedHashMapTests(
WrappedHashMapGenerator generator, String name, Feature<?>... features) {
List<Feature<?>> featuresList = Lists.newArrayList(features);
Reported by PMD.
Line: 87
MapFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionSize.ANY);
return MapTestSuiteBuilder.using(generator)
.named(name)
.withFeatures(featuresList)
.createTestSuite();
}
Reported by PMD.
Line: 87
MapFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionSize.ANY);
return MapTestSuiteBuilder.using(generator)
.named(name)
.withFeatures(featuresList)
.createTestSuite();
}
Reported by PMD.
Line: 87
MapFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionSize.ANY);
return MapTestSuiteBuilder.using(generator)
.named(name)
.withFeatures(featuresList)
.createTestSuite();
}
Reported by PMD.