The following issues were found
android/guava-tests/test/com/google/common/collect/SetOperationsTest.java
70 issues
Line: 40
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Reported by PMD.
Line: 40
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Reported by PMD.
Line: 40
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Reported by PMD.
Line: 41
*/
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
SetTestSuiteBuilder.using(
Reported by PMD.
Line: 42
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
SetTestSuiteBuilder.using(
new TestStringSetGenerator() {
Reported by PMD.
Line: 42
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
SetTestSuiteBuilder.using(
new TestStringSetGenerator() {
Reported by PMD.
Line: 42
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
SetTestSuiteBuilder.using(
new TestStringSetGenerator() {
Reported by PMD.
Line: 256
protected Set<String> create(String[] elements) {
Set<String> set = Sets.newHashSet(elements);
Set<String> other = Sets.newHashSet("wz", "xq");
set.addAll(other);
other.add("pq");
return Sets.difference(set, other);
}
})
.named("set - set")
Reported by PMD.
Line: 257
Set<String> set = Sets.newHashSet(elements);
Set<String> other = Sets.newHashSet("wz", "xq");
set.addAll(other);
other.add("pq");
return Sets.difference(set, other);
}
})
.named("set - set")
.withFeatures(
Reported by PMD.
Line: 299
}
public static class MoreTests extends TestCase {
Set<String> friends;
Set<String> enemies;
@Override
public void setUp() {
friends = Sets.newHashSet("Tom", "Joe", "Dave");
Reported by PMD.
android/guava-tests/test/com/google/common/base/Utf8Test.java
70 issues
Line: 321
* limit for numBytes
*/
@GwtIncompatible // java.nio.charset.Charset
private static void testBytes(int numBytes, long expectedCount, long start, long lim) {
byte[] bytes = new byte[numBytes];
if (lim == -1) {
lim = 1L << (numBytes * 8);
}
long countRoundTripped = 0;
Reported by PMD.
Line: 43
* @author Clément Roux
*/
@GwtCompatible(emulated = true)
public class Utf8Test extends TestCase {
private static final ImmutableList<String> ILL_FORMED_STRINGS;
static {
ImmutableList.Builder<String> builder = ImmutableList.builder();
Reported by PMD.
Line: 45
@GwtCompatible(emulated = true)
public class Utf8Test extends TestCase {
private static final ImmutableList<String> ILL_FORMED_STRINGS;
static {
ImmutableList.Builder<String> builder = ImmutableList.builder();
char[] surrogates = {
MAX_LOW_SURROGATE, MAX_HIGH_SURROGATE, MIN_LOW_SURROGATE, MIN_HIGH_SURROGATE,
Reported by PMD.
Line: 62
ILL_FORMED_STRINGS = builder.build();
}
public void testEncodedLength_validStrings() {
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Reported by PMD.
Line: 62
ILL_FORMED_STRINGS = builder.build();
}
public void testEncodedLength_validStrings() {
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Reported by PMD.
Line: 63
}
public void testEncodedLength_validStrings() {
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Utf8.encodedLength(
Reported by PMD.
Line: 64
public void testEncodedLength_validStrings() {
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Utf8.encodedLength(
"威廉·莎士比亞(William Shakespeare,"
Reported by PMD.
Line: 65
public void testEncodedLength_validStrings() {
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Utf8.encodedLength(
"威廉·莎士比亞(William Shakespeare,"
+ "1564年4月26號—1616年4月23號[1])係隻英國嗰演員、劇作家同詩人,"
Reported by PMD.
Line: 66
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Utf8.encodedLength(
"威廉·莎士比亞(William Shakespeare,"
+ "1564年4月26號—1616年4月23號[1])係隻英國嗰演員、劇作家同詩人,"
+ "有時間佢簡稱莎翁;中國清末民初哈拕翻譯做舌克斯毕、沙斯皮耳、筛斯比耳、"
Reported by PMD.
Line: 76
+ "狹斯丕爾。[2]莎士比亞編寫過好多作品,佢嗰劇作響西洋文學好有影響,"
+ "哈都拕人翻譯做好多話。"));
// A surrogate pair
assertEquals(4, Utf8.encodedLength(newString(MIN_HIGH_SURROGATE, MIN_LOW_SURROGATE)));
}
public void testEncodedLength_validStrings2() {
HashMap<Integer, Integer> utf8Lengths = new HashMap<>();
utf8Lengths.put(0x00, 1);
Reported by PMD.
guava-tests/test/com/google/common/collect/SetOperationsTest.java
70 issues
Line: 40
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Reported by PMD.
Line: 40
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Reported by PMD.
Line: 40
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Reported by PMD.
Line: 41
*/
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
SetTestSuiteBuilder.using(
Reported by PMD.
Line: 42
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
SetTestSuiteBuilder.using(
new TestStringSetGenerator() {
Reported by PMD.
Line: 42
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
SetTestSuiteBuilder.using(
new TestStringSetGenerator() {
Reported by PMD.
Line: 42
@GwtCompatible(emulated = true)
public class SetOperationsTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
SetTestSuiteBuilder.using(
new TestStringSetGenerator() {
Reported by PMD.
Line: 256
protected Set<String> create(String[] elements) {
Set<String> set = Sets.newHashSet(elements);
Set<String> other = Sets.newHashSet("wz", "xq");
set.addAll(other);
other.add("pq");
return Sets.difference(set, other);
}
})
.named("set - set")
Reported by PMD.
Line: 257
Set<String> set = Sets.newHashSet(elements);
Set<String> other = Sets.newHashSet("wz", "xq");
set.addAll(other);
other.add("pq");
return Sets.difference(set, other);
}
})
.named("set - set")
.withFeatures(
Reported by PMD.
Line: 299
}
public static class MoreTests extends TestCase {
Set<String> friends;
Set<String> enemies;
@Override
public void setUp() {
friends = Sets.newHashSet("Tom", "Joe", "Dave");
Reported by PMD.
guava-tests/test/com/google/common/base/Utf8Test.java
70 issues
Line: 321
* limit for numBytes
*/
@GwtIncompatible // java.nio.charset.Charset
private static void testBytes(int numBytes, long expectedCount, long start, long lim) {
byte[] bytes = new byte[numBytes];
if (lim == -1) {
lim = 1L << (numBytes * 8);
}
long countRoundTripped = 0;
Reported by PMD.
Line: 43
* @author Clément Roux
*/
@GwtCompatible(emulated = true)
public class Utf8Test extends TestCase {
private static final ImmutableList<String> ILL_FORMED_STRINGS;
static {
ImmutableList.Builder<String> builder = ImmutableList.builder();
Reported by PMD.
Line: 45
@GwtCompatible(emulated = true)
public class Utf8Test extends TestCase {
private static final ImmutableList<String> ILL_FORMED_STRINGS;
static {
ImmutableList.Builder<String> builder = ImmutableList.builder();
char[] surrogates = {
MAX_LOW_SURROGATE, MAX_HIGH_SURROGATE, MIN_LOW_SURROGATE, MIN_HIGH_SURROGATE,
Reported by PMD.
Line: 62
ILL_FORMED_STRINGS = builder.build();
}
public void testEncodedLength_validStrings() {
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Reported by PMD.
Line: 62
ILL_FORMED_STRINGS = builder.build();
}
public void testEncodedLength_validStrings() {
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Reported by PMD.
Line: 63
}
public void testEncodedLength_validStrings() {
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Utf8.encodedLength(
Reported by PMD.
Line: 64
public void testEncodedLength_validStrings() {
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Utf8.encodedLength(
"威廉·莎士比亞(William Shakespeare,"
Reported by PMD.
Line: 65
public void testEncodedLength_validStrings() {
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Utf8.encodedLength(
"威廉·莎士比亞(William Shakespeare,"
+ "1564年4月26號—1616年4月23號[1])係隻英國嗰演員、劇作家同詩人,"
Reported by PMD.
Line: 66
assertEquals(0, Utf8.encodedLength(""));
assertEquals(11, Utf8.encodedLength("Hello world"));
assertEquals(8, Utf8.encodedLength("Résumé"));
assertEquals(
461,
Utf8.encodedLength(
"威廉·莎士比亞(William Shakespeare,"
+ "1564年4月26號—1616年4月23號[1])係隻英國嗰演員、劇作家同詩人,"
+ "有時間佢簡稱莎翁;中國清末民初哈拕翻譯做舌克斯毕、沙斯皮耳、筛斯比耳、"
Reported by PMD.
Line: 76
+ "狹斯丕爾。[2]莎士比亞編寫過好多作品,佢嗰劇作響西洋文學好有影響,"
+ "哈都拕人翻譯做好多話。"));
// A surrogate pair
assertEquals(4, Utf8.encodedLength(newString(MIN_HIGH_SURROGATE, MIN_LOW_SURROGATE)));
}
public void testEncodedLength_validStrings2() {
HashMap<Integer, Integer> utf8Lengths = new HashMap<>();
utf8Lengths.put(0x00, 1);
Reported by PMD.
guava/src/com/google/common/io/ByteSource.java
69 issues
Line: 641
}
@Override
public ByteSource slice(long offset, long length) {
checkArgument(offset >= 0, "offset (%s) may not be negative", offset);
checkArgument(length >= 0, "length (%s) may not be negative", length);
offset = Math.min(offset, this.length);
length = Math.min(length, this.length - offset);
Reported by PMD.
Line: 641
}
@Override
public ByteSource slice(long offset, long length) {
checkArgument(offset >= 0, "offset (%s) may not be negative", offset);
checkArgument(length >= 0, "length (%s) may not be negative", length);
offset = Math.min(offset, this.length);
length = Math.min(length, this.length - offset);
Reported by PMD.
Line: 15
* the License.
*/
package com.google.common.io;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.io.ByteStreams.createBuffer;
import static com.google.common.io.ByteStreams.skipUpTo;
Reported by PMD.
Line: 78
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class ByteSource {
/** Constructor for use by subclasses. */
protected ByteSource() {}
/**
Reported by PMD.
Line: 153
*/
public boolean isEmpty() throws IOException {
Optional<Long> sizeIfKnown = sizeIfKnown();
if (sizeIfKnown.isPresent()) {
return sizeIfKnown.get() == 0L;
}
Closer closer = Closer.create();
try {
InputStream in = closer.register(openStream());
Reported by PMD.
Line: 158
}
Closer closer = Closer.create();
try {
InputStream in = closer.register(openStream());
return in.read() == -1;
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
Reported by PMD.
Line: 159
Closer closer = Closer.create();
try {
InputStream in = closer.register(openStream());
return in.read() == -1;
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
Reported by PMD.
Line: 160
try {
InputStream in = closer.register(openStream());
return in.read() == -1;
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
}
Reported by PMD.
Line: 207
*/
public long size() throws IOException {
Optional<Long> sizeIfKnown = sizeIfKnown();
if (sizeIfKnown.isPresent()) {
return sizeIfKnown.get();
}
Closer closer = Closer.create();
try {
Reported by PMD.
Line: 213
Closer closer = Closer.create();
try {
InputStream in = closer.register(openStream());
return countBySkipping(in);
} catch (IOException e) {
// skip may not be supported... at any rate, try reading
} finally {
closer.close();
Reported by PMD.
guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java
69 issues
Line: 192
.compute(
key,
(k, v) -> {
throw new RuntimeException();
});
});
fail("Should not get here");
} catch (RuntimeException ex) {
}
Reported by PMD.
Line: 34
/** Test Java8 map.compute in concurrent cache context. */
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
Reported by PMD.
Line: 34
/** Test Java8 map.compute in concurrent cache context. */
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
Reported by PMD.
Line: 35
/** Test Java8 map.compute in concurrent cache context. */
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
Reported by PMD.
Line: 35
/** Test Java8 map.compute in concurrent cache context. */
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
Reported by PMD.
Line: 36
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
IntStream.range(0, count).parallel().forEach(consumer);
Reported by PMD.
Line: 36
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
IntStream.range(0, count).parallel().forEach(consumer);
Reported by PMD.
Line: 37
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
IntStream.range(0, count).parallel().forEach(consumer);
}
Reported by PMD.
Line: 41
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
IntStream.range(0, count).parallel().forEach(consumer);
}
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 41
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
IntStream.range(0, count).parallel().forEach(consumer);
}
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
android/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java
69 issues
Line: 276
return generator.invoke(this, args);
} catch (InvocationTargetException e) {
throwIfUnchecked(e.getCause());
throw new RuntimeException(e.getCause());
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
Reported by PMD.
Line: 279
throw new RuntimeException(e.getCause());
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
private final class FreshInvocationHandler extends AbstractInvocationHandler {
private final int identity = generateInt();
Reported by PMD.
Line: 415
}
@Generates
short generateShort() {
return (short) generateInt();
}
@Generates
Short generateShortObject() {
Reported by PMD.
Line: 381
@Generates
Integer generateInteger() {
return new Integer(generateInt());
}
@Generates
long generateLong() {
return generateInt();
Reported by PMD.
Line: 391
@Generates
Long generateLongObject() {
return new Long(generateLong());
}
@Generates
float generateFloat() {
return generateInt();
Reported by PMD.
Line: 421
@Generates
Short generateShortObject() {
return new Short(generateShort());
}
@Generates
byte generateByte() {
return (byte) generateInt();
Reported by PMD.
Line: 431
@Generates
Byte generateByteObject() {
return new Byte(generateByte());
}
@Generates
char generateChar() {
return generateString().charAt(0);
Reported by PMD.
Line: 451
@Generates
Boolean generateBooleanObject() {
return new Boolean(generateBoolean());
}
@Generates
UnsignedInteger generateUnsignedInteger() {
return UnsignedInteger.fromIntBits(generateInt());
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
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.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
guava-testlib/src/com/google/common/testing/FreshValueGenerator.java
69 issues
Line: 278
return generator.invoke(this, args);
} catch (InvocationTargetException e) {
throwIfUnchecked(e.getCause());
throw new RuntimeException(e.getCause());
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
Reported by PMD.
Line: 281
throw new RuntimeException(e.getCause());
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
private final class FreshInvocationHandler extends AbstractInvocationHandler {
private final int identity = generateInt();
Reported by PMD.
Line: 417
}
@Generates
short generateShort() {
return (short) generateInt();
}
@Generates
Short generateShortObject() {
Reported by PMD.
Line: 383
@Generates
Integer generateInteger() {
return new Integer(generateInt());
}
@Generates
long generateLong() {
return generateInt();
Reported by PMD.
Line: 393
@Generates
Long generateLongObject() {
return new Long(generateLong());
}
@Generates
float generateFloat() {
return generateInt();
Reported by PMD.
Line: 423
@Generates
Short generateShortObject() {
return new Short(generateShort());
}
@Generates
byte generateByte() {
return (byte) generateInt();
Reported by PMD.
Line: 433
@Generates
Byte generateByteObject() {
return new Byte(generateByte());
}
@Generates
char generateChar() {
return generateString().charAt(0);
Reported by PMD.
Line: 453
@Generates
Boolean generateBooleanObject() {
return new Boolean(generateBoolean());
}
@Generates
UnsignedInteger generateUnsignedInteger() {
return UnsignedInteger.fromIntBits(generateInt());
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
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.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
guava-tests/test/com/google/common/io/CharStreamsTest.java
69 issues
Line: 36
*
* @author Chris Nokleberg
*/
public class CharStreamsTest extends IoTestCase {
private static final String TEXT = "The quick brown fox jumped over the lazy dog.";
public void testToString() throws IOException {
assertEquals(TEXT, CharStreams.toString(new StringReader(TEXT)));
Reported by PMD.
Line: 40
private static final String TEXT = "The quick brown fox jumped over the lazy dog.";
public void testToString() throws IOException {
assertEquals(TEXT, CharStreams.toString(new StringReader(TEXT)));
}
public void testReadLines() throws IOException {
List<String> lines = CharStreams.readLines(new StringReader("a\nb\nc"));
Reported by PMD.
Line: 44
assertEquals(TEXT, CharStreams.toString(new StringReader(TEXT)));
}
public void testReadLines() throws IOException {
List<String> lines = CharStreams.readLines(new StringReader("a\nb\nc"));
assertEquals(ImmutableList.of("a", "b", "c"), lines);
}
public void testReadLines_withLineProcessor() throws IOException {
Reported by PMD.
Line: 49
assertEquals(ImmutableList.of("a", "b", "c"), lines);
}
public void testReadLines_withLineProcessor() throws IOException {
String text = "a\nb\nc";
// Test a LineProcessor that always returns false.
Reader r = new StringReader(text);
LineProcessor<Integer> alwaysFalse =
Reported by PMD.
Line: 49
assertEquals(ImmutableList.of("a", "b", "c"), lines);
}
public void testReadLines_withLineProcessor() throws IOException {
String text = "a\nb\nc";
// Test a LineProcessor that always returns false.
Reader r = new StringReader(text);
LineProcessor<Integer> alwaysFalse =
Reported by PMD.
Line: 53
String text = "a\nb\nc";
// Test a LineProcessor that always returns false.
Reader r = new StringReader(text);
LineProcessor<Integer> alwaysFalse =
new LineProcessor<Integer>() {
int seen;
@Override
Reported by PMD.
Line: 72
assertEquals(
"processLine was called more than once",
1,
CharStreams.readLines(r, alwaysFalse).intValue());
// Test a LineProcessor that always returns true.
r = new StringReader(text);
LineProcessor<Integer> alwaysTrue =
new LineProcessor<Integer>() {
Reported by PMD.
Line: 94
assertEquals(
"processLine was not called for all the lines",
3,
CharStreams.readLines(r, alwaysTrue).intValue());
// Test a LineProcessor that is conditional.
r = new StringReader(text);
final StringBuilder sb = new StringBuilder();
LineProcessor<Integer> conditional =
Reported by PMD.
Line: 115
return seen;
}
};
assertEquals(2, CharStreams.readLines(r, conditional).intValue());
assertEquals("ab", sb.toString());
}
public void testSkipFully_EOF() throws IOException {
Reader reader = new StringReader("abcde");
Reported by PMD.
Line: 119
assertEquals("ab", sb.toString());
}
public void testSkipFully_EOF() throws IOException {
Reader reader = new StringReader("abcde");
try {
CharStreams.skipFully(reader, 6);
fail("expected EOFException");
} catch (EOFException expected) {
Reported by PMD.
android/guava-tests/test/com/google/common/cache/CacheRefreshTest.java
69 issues
Line: 30
* @author Charles Fry
*/
public class CacheRefreshTest extends TestCase {
public void testAutoRefresh() {
FakeTicker ticker = new FakeTicker();
IncrementingLoader loader = incrementingLoader();
LoadingCache<Integer, Integer> cache =
CacheBuilder.newBuilder()
.refreshAfterWrite(3, MILLISECONDS)
Reported by PMD.
Line: 30
* @author Charles Fry
*/
public class CacheRefreshTest extends TestCase {
public void testAutoRefresh() {
FakeTicker ticker = new FakeTicker();
IncrementingLoader loader = incrementingLoader();
LoadingCache<Integer, Integer> cache =
CacheBuilder.newBuilder()
.refreshAfterWrite(3, MILLISECONDS)
Reported by PMD.
Line: 43
int expectedLoads = 0;
int expectedReloads = 0;
for (int i = 0; i < 3; i++) {
assertEquals(Integer.valueOf(i), cache.getUnchecked(i));
expectedLoads++;
assertEquals(expectedLoads, loader.getLoadCount());
assertEquals(expectedReloads, loader.getReloadCount());
ticker.advance(1, MILLISECONDS);
}
Reported by PMD.
Line: 45
for (int i = 0; i < 3; i++) {
assertEquals(Integer.valueOf(i), cache.getUnchecked(i));
expectedLoads++;
assertEquals(expectedLoads, loader.getLoadCount());
assertEquals(expectedReloads, loader.getReloadCount());
ticker.advance(1, MILLISECONDS);
}
assertEquals(Integer.valueOf(0), cache.getUnchecked(0));
Reported by PMD.
Line: 46
assertEquals(Integer.valueOf(i), cache.getUnchecked(i));
expectedLoads++;
assertEquals(expectedLoads, loader.getLoadCount());
assertEquals(expectedReloads, loader.getReloadCount());
ticker.advance(1, MILLISECONDS);
}
assertEquals(Integer.valueOf(0), cache.getUnchecked(0));
assertEquals(Integer.valueOf(1), cache.getUnchecked(1));
Reported by PMD.
Line: 50
ticker.advance(1, MILLISECONDS);
}
assertEquals(Integer.valueOf(0), cache.getUnchecked(0));
assertEquals(Integer.valueOf(1), cache.getUnchecked(1));
assertEquals(Integer.valueOf(2), cache.getUnchecked(2));
assertEquals(expectedLoads, loader.getLoadCount());
assertEquals(expectedReloads, loader.getReloadCount());
Reported by PMD.
Line: 50
ticker.advance(1, MILLISECONDS);
}
assertEquals(Integer.valueOf(0), cache.getUnchecked(0));
assertEquals(Integer.valueOf(1), cache.getUnchecked(1));
assertEquals(Integer.valueOf(2), cache.getUnchecked(2));
assertEquals(expectedLoads, loader.getLoadCount());
assertEquals(expectedReloads, loader.getReloadCount());
Reported by PMD.
Line: 51
}
assertEquals(Integer.valueOf(0), cache.getUnchecked(0));
assertEquals(Integer.valueOf(1), cache.getUnchecked(1));
assertEquals(Integer.valueOf(2), cache.getUnchecked(2));
assertEquals(expectedLoads, loader.getLoadCount());
assertEquals(expectedReloads, loader.getReloadCount());
// refresh 0
Reported by PMD.
Line: 51
}
assertEquals(Integer.valueOf(0), cache.getUnchecked(0));
assertEquals(Integer.valueOf(1), cache.getUnchecked(1));
assertEquals(Integer.valueOf(2), cache.getUnchecked(2));
assertEquals(expectedLoads, loader.getLoadCount());
assertEquals(expectedReloads, loader.getReloadCount());
// refresh 0
Reported by PMD.
Line: 52
assertEquals(Integer.valueOf(0), cache.getUnchecked(0));
assertEquals(Integer.valueOf(1), cache.getUnchecked(1));
assertEquals(Integer.valueOf(2), cache.getUnchecked(2));
assertEquals(expectedLoads, loader.getLoadCount());
assertEquals(expectedReloads, loader.getReloadCount());
// refresh 0
ticker.advance(1, MILLISECONDS);
Reported by PMD.