The following issues were found
guava-testlib/test/com/google/common/testing/TestLogHandlerTest.java
26 issues
Line: 31
*/
public class TestLogHandlerTest extends TestCase {
private TestLogHandler handler;
private TearDownStack stack = new TearDownStack();
@Override
protected void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 32
public class TestLogHandlerTest extends TestCase {
private TestLogHandler handler;
private TearDownStack stack = new TearDownStack();
@Override
protected void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 32
public class TestLogHandlerTest extends TestCase {
private TestLogHandler handler;
private TearDownStack stack = new TearDownStack();
@Override
protected void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 34
private TestLogHandler handler;
private TearDownStack stack = new TearDownStack();
@Override
protected void setUp() throws Exception {
super.setUp();
handler = new TestLogHandler();
Reported by PMD.
Line: 41
handler = new TestLogHandler();
// You could also apply it higher up the Logger hierarchy than this
ExampleClassUnderTest.logger.addHandler(handler);
ExampleClassUnderTest.logger.setUseParentHandlers(false); // optional
stack.addTearDown(
new TearDown() {
Reported by PMD.
Line: 43
// You could also apply it higher up the Logger hierarchy than this
ExampleClassUnderTest.logger.addHandler(handler);
ExampleClassUnderTest.logger.setUseParentHandlers(false); // optional
stack.addTearDown(
new TearDown() {
@Override
public void tearDown() throws Exception {
Reported by PMD.
Line: 47
stack.addTearDown(
new TearDown() {
@Override
public void tearDown() throws Exception {
ExampleClassUnderTest.logger.setUseParentHandlers(true);
ExampleClassUnderTest.logger.removeHandler(handler);
}
});
Reported by PMD.
Line: 49
new TearDown() {
@Override
public void tearDown() throws Exception {
ExampleClassUnderTest.logger.setUseParentHandlers(true);
ExampleClassUnderTest.logger.removeHandler(handler);
}
});
}
Reported by PMD.
Line: 50
@Override
public void tearDown() throws Exception {
ExampleClassUnderTest.logger.setUseParentHandlers(true);
ExampleClassUnderTest.logger.removeHandler(handler);
}
});
}
public void test() throws Exception {
Reported by PMD.
Line: 55
});
}
public void test() throws Exception {
assertTrue(handler.getStoredLogRecords().isEmpty());
ExampleClassUnderTest.foo();
LogRecord record = handler.getStoredLogRecords().get(0);
assertEquals(Level.INFO, record.getLevel());
assertEquals("message", record.getMessage());
Reported by PMD.
guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java
26 issues
Line: 46
// TODO(cpovirk): Figure out Android JUnit 4 support. Does it work with Gingerbread? @RunWith?
@RunWith(Parameterized.class)
public final class DefaultNetworkImplementationsTest {
private MutableNetwork<Integer, String> network;
private NetworkForTest<Integer, String> networkForTest;
private static final Integer N1 = 1;
private static final Integer N2 = 2;
private static final Integer NODE_NOT_IN_GRAPH = 1000;
private static final String E11 = "1-1";
Reported by PMD.
Line: 47
@RunWith(Parameterized.class)
public final class DefaultNetworkImplementationsTest {
private MutableNetwork<Integer, String> network;
private NetworkForTest<Integer, String> networkForTest;
private static final Integer N1 = 1;
private static final Integer N2 = 2;
private static final Integer NODE_NOT_IN_GRAPH = 1000;
private static final String E11 = "1-1";
private static final String E11_A = "1-1a";
Reported by PMD.
Line: 66
});
}
private final EdgeType edgeType;
public DefaultNetworkImplementationsTest(EdgeType edgeType) {
this.edgeType = edgeType;
}
Reported by PMD.
Line: 77
NetworkBuilder<Object, Object> builder =
(edgeType == EdgeType.DIRECTED) ? NetworkBuilder.directed() : NetworkBuilder.undirected();
network = builder.allowsSelfLoops(true).allowsParallelEdges(true).build();
networkForTest = NetworkForTest.from(network);
}
@Test
public void edgesConnecting_disconnectedNodes() {
Reported by PMD.
Line: 77
NetworkBuilder<Object, Object> builder =
(edgeType == EdgeType.DIRECTED) ? NetworkBuilder.directed() : NetworkBuilder.undirected();
network = builder.allowsSelfLoops(true).allowsParallelEdges(true).build();
networkForTest = NetworkForTest.from(network);
}
@Test
public void edgesConnecting_disconnectedNodes() {
Reported by PMD.
Line: 85
public void edgesConnecting_disconnectedNodes() {
network.addNode(N1);
network.addNode(N2);
assertThat(networkForTest.edgesConnecting(N1, N2)).isEmpty();
}
@Test
public void edgesConnecting_nodesNotInGraph() {
network.addNode(N1);
Reported by PMD.
Line: 89
}
@Test
public void edgesConnecting_nodesNotInGraph() {
network.addNode(N1);
network.addNode(N2);
try {
networkForTest.edgesConnecting(N1, NODE_NOT_IN_GRAPH);
fail(ERROR_NODE_NOT_IN_GRAPH);
Reported by PMD.
Line: 122
fail(ERROR_MODIFIABLE_COLLECTION);
} catch (UnsupportedOperationException e) {
network.addEdge(N1, N2, E12);
assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
}
}
@Test
public void edgesConnecting_oneEdge() {
Reported by PMD.
Line: 127
}
@Test
public void edgesConnecting_oneEdge() {
network.addEdge(N1, N2, E12);
assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactly(E12);
if (edgeType == EdgeType.DIRECTED) {
assertThat(networkForTest.edgesConnecting(N2, N1)).isEmpty();
} else {
Reported by PMD.
Line: 129
@Test
public void edgesConnecting_oneEdge() {
network.addEdge(N1, N2, E12);
assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactly(E12);
if (edgeType == EdgeType.DIRECTED) {
assertThat(networkForTest.edgesConnecting(N2, N1)).isEmpty();
} else {
assertThat(networkForTest.edgesConnecting(N2, N1)).containsExactly(E12);
}
Reported by PMD.
guava-testlib/src/com/google/common/testing/ArbitraryInstances.java
26 issues
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 176
*/
@Beta
@GwtIncompatible
public final class ArbitraryInstances {
private static final Ordering<Field> BY_FIELD_NAME =
new Ordering<Field>() {
@Override
public int compare(Field left, Field right) {
Reported by PMD.
Line: 176
*/
@Beta
@GwtIncompatible
public final class ArbitraryInstances {
private static final Ordering<Field> BY_FIELD_NAME =
new Ordering<Field>() {
@Override
public int compare(Field left, Field right) {
Reported by PMD.
Line: 182
new Ordering<Field>() {
@Override
public int compare(Field left, Field right) {
return left.getName().compareTo(right.getName());
}
};
/**
* Returns a new {@code MatchResult} that corresponds to a successful match. Apache Harmony (used
Reported by PMD.
Line: 192
* http://goo.gl/5VQFmC
*/
private static MatchResult newMatchResult() {
Matcher matcher = Pattern.compile(".").matcher("X");
matcher.find();
return matcher.toMatchResult();
}
private static final ClassToInstanceMap<Object> DEFAULTS =
Reported by PMD.
Line: 193
*/
private static MatchResult newMatchResult() {
Matcher matcher = Pattern.compile(".").matcher("X");
matcher.find();
return matcher.toMatchResult();
}
private static final ClassToInstanceMap<Object> DEFAULTS =
ImmutableClassToInstanceMap.builder()
Reported by PMD.
Line: 194
private static MatchResult newMatchResult() {
Matcher matcher = Pattern.compile(".").matcher("X");
matcher.find();
return matcher.toMatchResult();
}
private static final ClassToInstanceMap<Object> DEFAULTS =
ImmutableClassToInstanceMap.builder()
// primitives
Reported by PMD.
Line: 349
* Returns an arbitrary instance for {@code type}, or {@code null} if no arbitrary instance can be
* determined.
*/
public static <T> @Nullable T get(Class<T> type) {
T defaultValue = DEFAULTS.getInstance(type);
if (defaultValue != null) {
return defaultValue;
}
Class<? extends T> implementation = getImplementation(type);
Reported by PMD.
Line: 349
* Returns an arbitrary instance for {@code type}, or {@code null} if no arbitrary instance can be
* determined.
*/
public static <T> @Nullable T get(Class<T> type) {
T defaultValue = DEFAULTS.getInstance(type);
if (defaultValue != null) {
return defaultValue;
}
Class<? extends T> implementation = getImplementation(type);
Reported by PMD.
guava-tests/test/com/google/common/base/VerifyTest.java
26 issues
Line: 28
/** Unit test for {@link com.google.common.base.Verify}. */
@GwtCompatible(emulated = true)
public class VerifyTest extends TestCase {
public void testVerify_simple_success() {
verify(true);
}
public void testVerify_simple_failure() {
Reported by PMD.
Line: 29
/** Unit test for {@link com.google.common.base.Verify}. */
@GwtCompatible(emulated = true)
public class VerifyTest extends TestCase {
public void testVerify_simple_success() {
verify(true);
}
public void testVerify_simple_failure() {
try {
Reported by PMD.
Line: 33
verify(true);
}
public void testVerify_simple_failure() {
try {
verify(false);
fail();
} catch (VerifyException expected) {
}
Reported by PMD.
Line: 36
public void testVerify_simple_failure() {
try {
verify(false);
fail();
} catch (VerifyException expected) {
}
}
public void testVerify_simpleMessage_success() {
Reported by PMD.
Line: 36
public void testVerify_simple_failure() {
try {
verify(false);
fail();
} catch (VerifyException expected) {
}
}
public void testVerify_simpleMessage_success() {
Reported by PMD.
Line: 41
}
}
public void testVerify_simpleMessage_success() {
verify(true, "message");
}
public void testVerify_simpleMessage_failure() {
try {
Reported by PMD.
Line: 45
verify(true, "message");
}
public void testVerify_simpleMessage_failure() {
try {
verify(false, "message");
fail();
} catch (VerifyException expected) {
assertThat(expected).hasMessageThat().isEqualTo("message");
Reported by PMD.
Line: 48
public void testVerify_simpleMessage_failure() {
try {
verify(false, "message");
fail();
} catch (VerifyException expected) {
assertThat(expected).hasMessageThat().isEqualTo("message");
}
}
Reported by PMD.
Line: 50
verify(false, "message");
fail();
} catch (VerifyException expected) {
assertThat(expected).hasMessageThat().isEqualTo("message");
}
}
public void testVerify_complexMessage_success() {
verify(true, "%s", IGNORE_ME);
Reported by PMD.
Line: 50
verify(false, "message");
fail();
} catch (VerifyException expected) {
assertThat(expected).hasMessageThat().isEqualTo("message");
}
}
public void testVerify_complexMessage_success() {
verify(true, "%s", IGNORE_ME);
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/MapMergeTester.java
26 issues
Line: 45
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapMergeTester<K, V> extends AbstractMapTester<K, V> {
@MapFeature.Require(SUPPORTS_PUT)
public void testAbsent() {
assertEquals(
"Map.merge(absent, value, function) should return value",
v3(),
getMap()
Reported by PMD.
Line: 50
assertEquals(
"Map.merge(absent, value, function) should return value",
v3(),
getMap()
.merge(
k3(),
v3(),
(oldV, newV) -> {
throw new AssertionFailedError(
Reported by PMD.
Line: 61
expectAdded(e3());
}
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
public void testMappedToNull() {
initMapWithNullValue();
assertEquals(
"Map.merge(keyMappedToNull, value, function) should return value",
Reported by PMD.
Line: 68
assertEquals(
"Map.merge(keyMappedToNull, value, function) should return value",
v3(),
getMap()
.merge(
getKeyForNullValue(),
v3(),
(oldV, newV) -> {
throw new AssertionFailedError(
Reported by PMD.
Line: 79
expectReplacement(entry(getKeyForNullValue(), v3()));
}
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_KEYS})
public void testMergeAbsentNullKey() {
assertEquals(
"Map.merge(null, value, function) should return value",
v3(),
getMap()
Reported by PMD.
Line: 84
assertEquals(
"Map.merge(null, value, function) should return value",
v3(),
getMap()
.merge(
null,
v3(),
(oldV, newV) -> {
throw new AssertionFailedError(
Reported by PMD.
Line: 95
expectAdded(entry(null, v3()));
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testMergePresent() {
assertEquals(
"Map.merge(present, value, function) should return function result",
v4(),
Reported by PMD.
Line: 97
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testMergePresent() {
assertEquals(
"Map.merge(present, value, function) should return function result",
v4(),
getMap()
.merge(
Reported by PMD.
Line: 101
assertEquals(
"Map.merge(present, value, function) should return function result",
v4(),
getMap()
.merge(
k0(),
v3(),
(oldV, newV) -> {
assertEquals(v0(), oldV);
Reported by PMD.
Line: 113
expectReplacement(entry(k0(), v4()));
}
private static class ExpectedException extends RuntimeException {}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testMergeFunctionThrows() {
try {
Reported by PMD.
guava-tests/test/com/google/common/collect/CollectSpliteratorsTest.java
26 issues
Line: 33
/** Tests for {@code CollectSpliterators}. */
@GwtCompatible
public class CollectSpliteratorsTest extends TestCase {
public void testMap() {
SpliteratorTester.of(
() ->
CollectSpliterators.map(
Arrays.spliterator(new String[] {"a", "b", "c", "d", "e"}), Ascii::toUpperCase))
.expect("A", "B", "C", "D", "E");
Reported by PMD.
Line: 33
/** Tests for {@code CollectSpliterators}. */
@GwtCompatible
public class CollectSpliteratorsTest extends TestCase {
public void testMap() {
SpliteratorTester.of(
() ->
CollectSpliterators.map(
Arrays.spliterator(new String[] {"a", "b", "c", "d", "e"}), Ascii::toUpperCase))
.expect("A", "B", "C", "D", "E");
Reported by PMD.
Line: 34
@GwtCompatible
public class CollectSpliteratorsTest extends TestCase {
public void testMap() {
SpliteratorTester.of(
() ->
CollectSpliterators.map(
Arrays.spliterator(new String[] {"a", "b", "c", "d", "e"}), Ascii::toUpperCase))
.expect("A", "B", "C", "D", "E");
}
Reported by PMD.
Line: 41
.expect("A", "B", "C", "D", "E");
}
public void testFlatMap() {
SpliteratorTester.of(
() ->
CollectSpliterators.flatMap(
Arrays.spliterator(new String[] {"abc", "", "de", "f", "g", ""}),
(String str) -> Lists.charactersOf(str).spliterator(),
Reported by PMD.
Line: 41
.expect("A", "B", "C", "D", "E");
}
public void testFlatMap() {
SpliteratorTester.of(
() ->
CollectSpliterators.flatMap(
Arrays.spliterator(new String[] {"abc", "", "de", "f", "g", ""}),
(String str) -> Lists.charactersOf(str).spliterator(),
Reported by PMD.
Line: 42
}
public void testFlatMap() {
SpliteratorTester.of(
() ->
CollectSpliterators.flatMap(
Arrays.spliterator(new String[] {"abc", "", "de", "f", "g", ""}),
(String str) -> Lists.charactersOf(str).spliterator(),
Spliterator.SIZED | Spliterator.DISTINCT | Spliterator.NONNULL,
Reported by PMD.
Line: 52
.expect('a', 'b', 'c', 'd', 'e', 'f', 'g');
}
public void testFlatMap_nullStream() {
SpliteratorTester.of(
() ->
CollectSpliterators.flatMap(
Arrays.spliterator(new String[] {"abc", "", "de", "f", "g", ""}),
(String str) -> str.isEmpty() ? null : Lists.charactersOf(str).spliterator(),
Reported by PMD.
Line: 52
.expect('a', 'b', 'c', 'd', 'e', 'f', 'g');
}
public void testFlatMap_nullStream() {
SpliteratorTester.of(
() ->
CollectSpliterators.flatMap(
Arrays.spliterator(new String[] {"abc", "", "de", "f", "g", ""}),
(String str) -> str.isEmpty() ? null : Lists.charactersOf(str).spliterator(),
Reported by PMD.
Line: 53
}
public void testFlatMap_nullStream() {
SpliteratorTester.of(
() ->
CollectSpliterators.flatMap(
Arrays.spliterator(new String[] {"abc", "", "de", "f", "g", ""}),
(String str) -> str.isEmpty() ? null : Lists.charactersOf(str).spliterator(),
Spliterator.SIZED | Spliterator.DISTINCT | Spliterator.NONNULL,
Reported by PMD.
Line: 63
.expect('a', 'b', 'c', 'd', 'e', 'f', 'g');
}
public void testFlatMapToInt_nullStream() {
SpliteratorTester.ofInt(
() ->
CollectSpliterators.flatMapToInt(
Arrays.spliterator(new Integer[] {1, 0, 1, 2, 3}),
(Integer i) -> i == 0 ? null : IntStream.of(i).spliterator(),
Reported by PMD.
android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetBasherTest.java
26 issues
Line: 45
public class ConcurrentHashMultisetBasherTest extends TestCase {
public void testAddAndRemove_ConcurrentHashMap() throws Exception {
testAddAndRemove(new ConcurrentHashMap<String, AtomicInteger>());
}
public void testAddAndRemove_ConcurrentSkipListMap() throws Exception {
testAddAndRemove(new ConcurrentSkipListMap<String, AtomicInteger>());
Reported by PMD.
Line: 45
public class ConcurrentHashMultisetBasherTest extends TestCase {
public void testAddAndRemove_ConcurrentHashMap() throws Exception {
testAddAndRemove(new ConcurrentHashMap<String, AtomicInteger>());
}
public void testAddAndRemove_ConcurrentSkipListMap() throws Exception {
testAddAndRemove(new ConcurrentSkipListMap<String, AtomicInteger>());
Reported by PMD.
Line: 49
testAddAndRemove(new ConcurrentHashMap<String, AtomicInteger>());
}
public void testAddAndRemove_ConcurrentSkipListMap() throws Exception {
testAddAndRemove(new ConcurrentSkipListMap<String, AtomicInteger>());
}
public void testAddAndRemove_MapMakerMap() throws Exception {
MapMaker mapMaker = new MapMaker();
Reported by PMD.
Line: 49
testAddAndRemove(new ConcurrentHashMap<String, AtomicInteger>());
}
public void testAddAndRemove_ConcurrentSkipListMap() throws Exception {
testAddAndRemove(new ConcurrentSkipListMap<String, AtomicInteger>());
}
public void testAddAndRemove_MapMakerMap() throws Exception {
MapMaker mapMaker = new MapMaker();
Reported by PMD.
Line: 53
testAddAndRemove(new ConcurrentSkipListMap<String, AtomicInteger>());
}
public void testAddAndRemove_MapMakerMap() throws Exception {
MapMaker mapMaker = new MapMaker();
// force MapMaker to use its own MapMakerInternalMap
mapMaker.useCustomMap = true;
testAddAndRemove(mapMaker.<String, AtomicInteger>makeMap());
}
Reported by PMD.
Line: 53
testAddAndRemove(new ConcurrentSkipListMap<String, AtomicInteger>());
}
public void testAddAndRemove_MapMakerMap() throws Exception {
MapMaker mapMaker = new MapMaker();
// force MapMaker to use its own MapMakerInternalMap
mapMaker.useCustomMap = true;
testAddAndRemove(mapMaker.<String, AtomicInteger>makeMap());
}
Reported by PMD.
Line: 60
testAddAndRemove(mapMaker.<String, AtomicInteger>makeMap());
}
private void testAddAndRemove(ConcurrentMap<String, AtomicInteger> map)
throws ExecutionException, InterruptedException {
final ConcurrentHashMultiset<String> multiset = new ConcurrentHashMultiset<>(map);
int nThreads = 20;
int tasksPerThread = 10;
Reported by PMD.
Line: 72
try {
List<Future<int[]>> futures = Lists.newArrayListWithExpectedSize(nTasks);
for (int i = 0; i < nTasks; i++) {
futures.add(pool.submit(new MutateTask(multiset, keys)));
}
int[] deltas = new int[3];
for (Future<int[]> future : futures) {
int[] taskDeltas = future.get();
Reported by PMD.
Line: 99
// Since we have access to the backing map, verify that there are no zeroes in the map
for (AtomicInteger value : map.values()) {
assertTrue("map should not contain a zero", value.get() != 0);
}
}
private static class MutateTask implements Callable<int[]> {
private final ConcurrentHashMultiset<String> multiset;
Reported by PMD.
Line: 104
}
private static class MutateTask implements Callable<int[]> {
private final ConcurrentHashMultiset<String> multiset;
private final ImmutableList<String> keys;
private final Random random = new Random();
private MutateTask(ConcurrentHashMultiset<String> multiset, ImmutableList<String> keys) {
this.multiset = multiset;
Reported by PMD.
android/guava-tests/test/com/google/common/escape/ArrayBasedUnicodeEscaperTest.java
26 issues
Line: 36
'&', "<and>");
private static final char[] NO_CHARS = new char[0];
public void testReplacements() throws IOException {
// In reality this is not a very sensible escaper to have (if you are only
// escaping elements from a map you would use a ArrayBasedCharEscaper).
UnicodeEscaper escaper =
new ArrayBasedUnicodeEscaper(
SIMPLE_REPLACEMENTS, Character.MIN_VALUE, Character.MAX_CODE_POINT, null) {
Reported by PMD.
Line: 36
'&', "<and>");
private static final char[] NO_CHARS = new char[0];
public void testReplacements() throws IOException {
// In reality this is not a very sensible escaper to have (if you are only
// escaping elements from a map you would use a ArrayBasedCharEscaper).
UnicodeEscaper escaper =
new ArrayBasedUnicodeEscaper(
SIMPLE_REPLACEMENTS, Character.MIN_VALUE, Character.MAX_CODE_POINT, null) {
Reported by PMD.
Line: 48
}
};
EscaperAsserts.assertBasic(escaper);
assertEquals("<tab>Fish <and> Chips<newline>", escaper.escape("\tFish & Chips\n"));
// Verify that everything else is left unescaped.
String safeChars = "\0\u0100\uD800\uDC00\uFFFF";
assertEquals(safeChars, escaper.escape(safeChars));
Reported by PMD.
Line: 52
// Verify that everything else is left unescaped.
String safeChars = "\0\u0100\uD800\uDC00\uFFFF";
assertEquals(safeChars, escaper.escape(safeChars));
// Ensure that Unicode escapers behave correctly wrt badly formed input.
String badUnicode = "\uDC00\uD800";
try {
escaper.escape(badUnicode);
Reported by PMD.
Line: 58
String badUnicode = "\uDC00\uD800";
try {
escaper.escape(badUnicode);
fail("should fail for bad Unicode");
} catch (IllegalArgumentException e) {
// Pass
}
}
Reported by PMD.
Line: 59
try {
escaper.escape(badUnicode);
fail("should fail for bad Unicode");
} catch (IllegalArgumentException e) {
// Pass
}
}
public void testSafeRange() throws IOException {
Reported by PMD.
Line: 64
}
}
public void testSafeRange() throws IOException {
// Basic escaping of unsafe chars (wrap them in {,}'s)
UnicodeEscaper wrappingEscaper =
new ArrayBasedUnicodeEscaper(NO_REPLACEMENTS, 'A', 'Z', null) {
@Override
protected char[] escapeUnsafe(int c) {
Reported by PMD.
Line: 75
};
EscaperAsserts.assertBasic(wrappingEscaper);
// '[' and '@' lie either side of [A-Z].
assertEquals("{[}FOO{@}BAR{]}", wrappingEscaper.escape("[FOO@BAR]"));
}
public void testDeleteUnsafeChars() throws IOException {
UnicodeEscaper deletingEscaper =
new ArrayBasedUnicodeEscaper(NO_REPLACEMENTS, ' ', '~', null) {
Reported by PMD.
Line: 78
assertEquals("{[}FOO{@}BAR{]}", wrappingEscaper.escape("[FOO@BAR]"));
}
public void testDeleteUnsafeChars() throws IOException {
UnicodeEscaper deletingEscaper =
new ArrayBasedUnicodeEscaper(NO_REPLACEMENTS, ' ', '~', null) {
@Override
protected char[] escapeUnsafe(int c) {
return NO_CHARS;
Reported by PMD.
Line: 87
}
};
EscaperAsserts.assertBasic(deletingEscaper);
assertEquals(
"Everything outside the printable ASCII range is deleted.",
deletingEscaper.escape(
"\tEverything\0 outside the\uD800\uDC00 "
+ "printable ASCII \uFFFFrange is \u007Fdeleted.\n"));
}
Reported by PMD.
android/guava-tests/test/com/google/common/eventbus/DispatcherTest.java
26 issues
Line: 37
public class DispatcherTest extends TestCase {
private final EventBus bus = new EventBus();
private final IntegerSubscriber i1 = new IntegerSubscriber("i1");
private final IntegerSubscriber i2 = new IntegerSubscriber("i2");
private final IntegerSubscriber i3 = new IntegerSubscriber("i3");
private final ImmutableList<Subscriber> integerSubscribers =
Reported by PMD.
Line: 39
private final EventBus bus = new EventBus();
private final IntegerSubscriber i1 = new IntegerSubscriber("i1");
private final IntegerSubscriber i2 = new IntegerSubscriber("i2");
private final IntegerSubscriber i3 = new IntegerSubscriber("i3");
private final ImmutableList<Subscriber> integerSubscribers =
ImmutableList.of(
subscriber(bus, i1, "handleInteger", Integer.class),
Reported by PMD.
Line: 40
private final EventBus bus = new EventBus();
private final IntegerSubscriber i1 = new IntegerSubscriber("i1");
private final IntegerSubscriber i2 = new IntegerSubscriber("i2");
private final IntegerSubscriber i3 = new IntegerSubscriber("i3");
private final ImmutableList<Subscriber> integerSubscribers =
ImmutableList.of(
subscriber(bus, i1, "handleInteger", Integer.class),
subscriber(bus, i2, "handleInteger", Integer.class),
Reported by PMD.
Line: 41
private final IntegerSubscriber i1 = new IntegerSubscriber("i1");
private final IntegerSubscriber i2 = new IntegerSubscriber("i2");
private final IntegerSubscriber i3 = new IntegerSubscriber("i3");
private final ImmutableList<Subscriber> integerSubscribers =
ImmutableList.of(
subscriber(bus, i1, "handleInteger", Integer.class),
subscriber(bus, i2, "handleInteger", Integer.class),
subscriber(bus, i3, "handleInteger", Integer.class));
Reported by PMD.
Line: 42
private final IntegerSubscriber i1 = new IntegerSubscriber("i1");
private final IntegerSubscriber i2 = new IntegerSubscriber("i2");
private final IntegerSubscriber i3 = new IntegerSubscriber("i3");
private final ImmutableList<Subscriber> integerSubscribers =
ImmutableList.of(
subscriber(bus, i1, "handleInteger", Integer.class),
subscriber(bus, i2, "handleInteger", Integer.class),
subscriber(bus, i3, "handleInteger", Integer.class));
Reported by PMD.
Line: 48
subscriber(bus, i2, "handleInteger", Integer.class),
subscriber(bus, i3, "handleInteger", Integer.class));
private final StringSubscriber s1 = new StringSubscriber("s1");
private final StringSubscriber s2 = new StringSubscriber("s2");
private final ImmutableList<Subscriber> stringSubscribers =
ImmutableList.of(
subscriber(bus, s1, "handleString", String.class),
subscriber(bus, s2, "handleString", String.class));
Reported by PMD.
Line: 49
subscriber(bus, i3, "handleInteger", Integer.class));
private final StringSubscriber s1 = new StringSubscriber("s1");
private final StringSubscriber s2 = new StringSubscriber("s2");
private final ImmutableList<Subscriber> stringSubscribers =
ImmutableList.of(
subscriber(bus, s1, "handleString", String.class),
subscriber(bus, s2, "handleString", String.class));
Reported by PMD.
Line: 50
private final StringSubscriber s1 = new StringSubscriber("s1");
private final StringSubscriber s2 = new StringSubscriber("s2");
private final ImmutableList<Subscriber> stringSubscribers =
ImmutableList.of(
subscriber(bus, s1, "handleString", String.class),
subscriber(bus, s2, "handleString", String.class));
private final ConcurrentLinkedQueue<Object> dispatchedSubscribers =
Reported by PMD.
Line: 55
subscriber(bus, s1, "handleString", String.class),
subscriber(bus, s2, "handleString", String.class));
private final ConcurrentLinkedQueue<Object> dispatchedSubscribers =
Queues.newConcurrentLinkedQueue();
private Dispatcher dispatcher;
public void testPerThreadQueuedDispatcher() {
Reported by PMD.
Line: 58
private final ConcurrentLinkedQueue<Object> dispatchedSubscribers =
Queues.newConcurrentLinkedQueue();
private Dispatcher dispatcher;
public void testPerThreadQueuedDispatcher() {
dispatcher = Dispatcher.perThreadDispatchQueue();
dispatcher.dispatch(1, integerSubscribers.iterator());
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java
26 issues
Line: 229
try {
requirements = FeatureUtil.getTesterRequirements(method);
} catch (ConflictingRequirementsException e) {
throw new RuntimeException(e);
}
if (!features.containsAll(requirements.getPresentFeatures())) {
if (logger.isLoggable(FINER)) {
Set<Feature<?>> missingFeatures = Helpers.copyToSet(requirements.getPresentFeatures());
missingFeatures.removeAll(features);
Reported by PMD.
Line: 176
public TestSuite createTestSuite() {
checkCanCreate();
logger.fine(" Testing: " + name);
logger.fine("Features: " + formatFeatureSet(features));
FeatureUtil.addImpliedFeatures(features);
logger.fine("Expanded: " + formatFeatureSet(features));
Reported by PMD.
Line: 177
checkCanCreate();
logger.fine(" Testing: " + name);
logger.fine("Features: " + formatFeatureSet(features));
FeatureUtil.addImpliedFeatures(features);
logger.fine("Expanded: " + formatFeatureSet(features));
Reported by PMD.
Line: 181
FeatureUtil.addImpliedFeatures(features);
logger.fine("Expanded: " + formatFeatureSet(features));
// Class parameters must be raw.
List<Class<? extends AbstractTester>> testers = getTesters();
TestSuite suite = new TestSuite(name);
Reported by PMD.
Line: 55
* @author George van den Driessche
*/
@GwtIncompatible
public abstract class FeatureSpecificTestSuiteBuilder<
B extends FeatureSpecificTestSuiteBuilder<B, G>, G> {
@SuppressWarnings("unchecked")
protected B self() {
return (B) this;
}
Reported by PMD.
Line: 56
*/
@GwtIncompatible
public abstract class FeatureSpecificTestSuiteBuilder<
B extends FeatureSpecificTestSuiteBuilder<B, G>, G> {
@SuppressWarnings("unchecked")
protected B self() {
return (B) this;
}
Reported by PMD.
Line: 64
// Test Data
private G subjectGenerator;
// Gets run before every test.
private Runnable setUp;
// Gets run at the conclusion of every test.
private Runnable tearDown;
Reported by PMD.
Line: 66
private G subjectGenerator;
// Gets run before every test.
private Runnable setUp;
// Gets run at the conclusion of every test.
private Runnable tearDown;
protected B usingGenerator(G subjectGenerator) {
this.subjectGenerator = subjectGenerator;
Reported by PMD.
Line: 68
// Gets run before every test.
private Runnable setUp;
// Gets run at the conclusion of every test.
private Runnable tearDown;
protected B usingGenerator(G subjectGenerator) {
this.subjectGenerator = subjectGenerator;
return self();
}
Reported by PMD.
Line: 122
// Name
private String name;
/** Configures this builder produce a TestSuite with the given name. */
public B named(String name) {
if (name.contains("(")) {
throw new IllegalArgumentException(
Reported by PMD.