The following issues were found
guava-tests/test/com/google/common/reflect/ClassPathTest.java
213 issues
Line: 579
Closer closer = Closer.create();
try {
FileOutputStream fileOut = closer.register(new FileOutputStream(jarFile));
JarOutputStream jarOut = closer.register(new JarOutputStream(fileOut));
for (String entry : entries) {
jarOut.putNextEntry(new ZipEntry(entry));
Resources.copy(ClassPathTest.class.getResource(entry), jarOut);
jarOut.closeEntry();
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.common.reflect;
import static com.google.common.base.Charsets.US_ASCII;
import static com.google.common.base.StandardSystemProperty.JAVA_CLASS_PATH;
import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR;
import static com.google.common.io.MoreFiles.deleteRecursively;
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.common.reflect;
import static com.google.common.base.Charsets.US_ASCII;
import static com.google.common.base.StandardSystemProperty.JAVA_CLASS_PATH;
import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR;
import static com.google.common.io.MoreFiles.deleteRecursively;
Reported by PMD.
Line: 60
import org.junit.Test;
/** Functional tests of {@link ClassPath}. */
public class ClassPathTest extends TestCase {
private static final Logger log = Logger.getLogger(ClassPathTest.class.getName());
private static final File FILE = new File(".");
public void testEquals() {
new EqualsTester()
Reported by PMD.
Line: 60
import org.junit.Test;
/** Functional tests of {@link ClassPath}. */
public class ClassPathTest extends TestCase {
private static final Logger log = Logger.getLogger(ClassPathTest.class.getName());
private static final File FILE = new File(".");
public void testEquals() {
new EqualsTester()
Reported by PMD.
Line: 64
private static final Logger log = Logger.getLogger(ClassPathTest.class.getName());
private static final File FILE = new File(".");
public void testEquals() {
new EqualsTester()
.addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
.addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
.addEqualityGroup(
new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()),
Reported by PMD.
Line: 64
private static final Logger log = Logger.getLogger(ClassPathTest.class.getName());
private static final File FILE = new File(".");
public void testEquals() {
new EqualsTester()
.addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
.addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
.addEqualityGroup(
new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()),
Reported by PMD.
Line: 67
public void testEquals() {
new EqualsTester()
.addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
.addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
.addEqualityGroup(
new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()),
new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()))
.addEqualityGroup(new ResourceInfo(FILE, "x.txt", getClass().getClassLoader()))
.testEquals();
Reported by PMD.
Line: 67
public void testEquals() {
new EqualsTester()
.addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
.addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
.addEqualityGroup(
new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()),
new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()))
.addEqualityGroup(new ResourceInfo(FILE, "x.txt", getClass().getClassLoader()))
.testEquals();
Reported by PMD.
Line: 69
.addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
.addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
.addEqualityGroup(
new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()),
new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()))
.addEqualityGroup(new ResourceInfo(FILE, "x.txt", getClass().getClassLoader()))
.testEquals();
}
Reported by PMD.
android/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java
212 issues
Line: 54
// TODO: Reduce duplication of ImmutableMapTest code
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(MapTests.class);
suite.addTestSuite(InverseMapTests.class);
Reported by PMD.
Line: 117
BiMap<K, V> bimap = (BiMap<K, V>) map;
for (Entry<K, V> entry : map.entrySet()) {
assertEquals(entry.getKey() + "=" + entry.getValue(), entry.toString());
assertEquals(entry.getKey(), bimap.inverse().get(entry.getValue()));
}
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
Reported by PMD.
Line: 118
for (Entry<K, V> entry : map.entrySet()) {
assertEquals(entry.getKey() + "=" + entry.getValue(), entry.toString());
assertEquals(entry.getKey(), bimap.inverse().get(entry.getValue()));
}
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
Reported by PMD.
Line: 118
for (Entry<K, V> entry : map.entrySet()) {
assertEquals(entry.getKey() + "=" + entry.getValue(), entry.toString());
assertEquals(entry.getKey(), bimap.inverse().get(entry.getValue()));
}
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
Reported by PMD.
Line: 121
assertEquals(entry.getKey(), bimap.inverse().get(entry.getValue()));
}
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());
assertEquals(Sets.newHashSet(map.entrySet()), map.entrySet());
Reported by PMD.
Line: 122
}
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());
assertEquals(Sets.newHashSet(map.entrySet()), map.entrySet());
assertEquals(Sets.newHashSet(map.keySet()), map.keySet());
Reported by PMD.
Line: 122
}
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());
assertEquals(Sets.newHashSet(map.entrySet()), map.entrySet());
assertEquals(Sets.newHashSet(map.keySet()), map.keySet());
Reported by PMD.
Line: 123
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());
assertEquals(Sets.newHashSet(map.entrySet()), map.entrySet());
assertEquals(Sets.newHashSet(map.keySet()), map.keySet());
}
Reported by PMD.
Line: 123
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());
assertEquals(Sets.newHashSet(map.entrySet()), map.entrySet());
assertEquals(Sets.newHashSet(map.keySet()), map.keySet());
}
Reported by PMD.
Line: 124
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());
assertEquals(Sets.newHashSet(map.entrySet()), map.entrySet());
assertEquals(Sets.newHashSet(map.keySet()), map.keySet());
}
}
Reported by PMD.
guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java
212 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.collect.testing.Helpers.mapEntry;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.annotations.GwtCompatible;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.collect.testing.Helpers.mapEntry;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.annotations.GwtCompatible;
Reported by PMD.
Line: 64
// TODO: Reduce duplication of ImmutableMapTest code
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(MapTests.class);
suite.addTestSuite(InverseMapTests.class);
Reported by PMD.
Line: 90
new TestStringBiMapGenerator() {
@Override
protected BiMap<String, String> create(Entry<String, String>[] entries) {
return ImmutableBiMap.<String, String>builder()
.putAll(Arrays.asList(entries))
.buildJdkBacked();
}
})
.named("ImmutableBiMap [JDK backed]")
Reported by PMD.
Line: 90
new TestStringBiMapGenerator() {
@Override
protected BiMap<String, String> create(Entry<String, String>[] entries) {
return ImmutableBiMap.<String, String>builder()
.putAll(Arrays.asList(entries))
.buildJdkBacked();
}
})
.named("ImmutableBiMap [JDK backed]")
Reported by PMD.
Line: 90
new TestStringBiMapGenerator() {
@Override
protected BiMap<String, String> create(Entry<String, String>[] entries) {
return ImmutableBiMap.<String, String>builder()
.putAll(Arrays.asList(entries))
.buildJdkBacked();
}
})
.named("ImmutableBiMap [JDK backed]")
Reported by PMD.
Line: 148
BiMap<K, V> bimap = (BiMap<K, V>) map;
for (Entry<K, V> entry : map.entrySet()) {
assertEquals(entry.getKey() + "=" + entry.getValue(), entry.toString());
assertEquals(entry.getKey(), bimap.inverse().get(entry.getValue()));
}
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
Reported by PMD.
Line: 149
for (Entry<K, V> entry : map.entrySet()) {
assertEquals(entry.getKey() + "=" + entry.getValue(), entry.toString());
assertEquals(entry.getKey(), bimap.inverse().get(entry.getValue()));
}
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
Reported by PMD.
Line: 149
for (Entry<K, V> entry : map.entrySet()) {
assertEquals(entry.getKey() + "=" + entry.getValue(), entry.toString());
assertEquals(entry.getKey(), bimap.inverse().get(entry.getValue()));
}
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
Reported by PMD.
Line: 152
assertEquals(entry.getKey(), bimap.inverse().get(entry.getValue()));
}
assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());
assertEquals(Sets.newHashSet(map.entrySet()), map.entrySet());
Reported by PMD.
guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java
211 issues
Line: 99
assertEquals(Object[].class, foo.getArrayClassB());
}
private abstract static class Bar<T> {}
private abstract static class Parameterized<O, T, P> {
ParameterizedType parameterizedType() {
return new ParameterizedType() {
@Override
Reported by PMD.
Line: 156
TypeToken.of(IntegerStringFunction.class).resolveType(predicateParameterType).getType());
}
private abstract static class StringIntegerFoo extends Foo<String, Integer> {}
public void testConstructor_typeArgsResolvedFromAncestorClass() {
assertEquals(String.class, new StringIntegerFoo() {}.getClassA());
assertEquals(Integer.class, new StringIntegerFoo() {}.getClassB());
}
Reported by PMD.
Line: 541
try {
return cls.getMethod(methodName).getGenericReturnType();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void testTwoStageResolution() {
class ForTwoStageResolution<A extends Number> {
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
Reported by PMD.
Line: 39
* @author Ben Yu
*/
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeTokenResolutionTest extends TestCase {
private static class Foo<A, B> {
Class<? super A> getClassA() {
return new TypeToken<A>(getClass()) {}.getRawType();
Reported by PMD.
Line: 64
}
}
public void testSimpleTypeToken() {
Foo<String, Integer> foo = new Foo<String, Integer>() {};
assertEquals(String.class, foo.getClassA());
assertEquals(Integer.class, foo.getClassB());
assertEquals(String[].class, foo.getArrayClassA());
assertEquals(Integer[].class, foo.getArrayClassB());
Reported by PMD.
Line: 64
}
}
public void testSimpleTypeToken() {
Foo<String, Integer> foo = new Foo<String, Integer>() {};
assertEquals(String.class, foo.getClassA());
assertEquals(Integer.class, foo.getClassB());
assertEquals(String[].class, foo.getArrayClassA());
assertEquals(Integer[].class, foo.getArrayClassB());
Reported by PMD.
Line: 66
public void testSimpleTypeToken() {
Foo<String, Integer> foo = new Foo<String, Integer>() {};
assertEquals(String.class, foo.getClassA());
assertEquals(Integer.class, foo.getClassB());
assertEquals(String[].class, foo.getArrayClassA());
assertEquals(Integer[].class, foo.getArrayClassB());
}
Reported by PMD.
Line: 67
public void testSimpleTypeToken() {
Foo<String, Integer> foo = new Foo<String, Integer>() {};
assertEquals(String.class, foo.getClassA());
assertEquals(Integer.class, foo.getClassB());
assertEquals(String[].class, foo.getArrayClassA());
assertEquals(Integer[].class, foo.getArrayClassB());
}
public void testCompositeTypeToken() {
Reported by PMD.
android/guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java
211 issues
Line: 99
assertEquals(Object[].class, foo.getArrayClassB());
}
private abstract static class Bar<T> {}
private abstract static class Parameterized<O, T, P> {
ParameterizedType parameterizedType() {
return new ParameterizedType() {
@Override
Reported by PMD.
Line: 156
TypeToken.of(IntegerStringFunction.class).resolveType(predicateParameterType).getType());
}
private abstract static class StringIntegerFoo extends Foo<String, Integer> {}
public void testConstructor_typeArgsResolvedFromAncestorClass() {
assertEquals(String.class, new StringIntegerFoo() {}.getClassA());
assertEquals(Integer.class, new StringIntegerFoo() {}.getClassB());
}
Reported by PMD.
Line: 541
try {
return cls.getMethod(methodName).getGenericReturnType();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void testTwoStageResolution() {
class ForTwoStageResolution<A extends Number> {
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
Reported by PMD.
Line: 39
* @author Ben Yu
*/
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeTokenResolutionTest extends TestCase {
private static class Foo<A, B> {
Class<? super A> getClassA() {
return new TypeToken<A>(getClass()) {}.getRawType();
Reported by PMD.
Line: 64
}
}
public void testSimpleTypeToken() {
Foo<String, Integer> foo = new Foo<String, Integer>() {};
assertEquals(String.class, foo.getClassA());
assertEquals(Integer.class, foo.getClassB());
assertEquals(String[].class, foo.getArrayClassA());
assertEquals(Integer[].class, foo.getArrayClassB());
Reported by PMD.
Line: 64
}
}
public void testSimpleTypeToken() {
Foo<String, Integer> foo = new Foo<String, Integer>() {};
assertEquals(String.class, foo.getClassA());
assertEquals(Integer.class, foo.getClassB());
assertEquals(String[].class, foo.getArrayClassA());
assertEquals(Integer[].class, foo.getArrayClassB());
Reported by PMD.
Line: 66
public void testSimpleTypeToken() {
Foo<String, Integer> foo = new Foo<String, Integer>() {};
assertEquals(String.class, foo.getClassA());
assertEquals(Integer.class, foo.getClassB());
assertEquals(String[].class, foo.getArrayClassA());
assertEquals(Integer[].class, foo.getArrayClassB());
}
Reported by PMD.
Line: 67
public void testSimpleTypeToken() {
Foo<String, Integer> foo = new Foo<String, Integer>() {};
assertEquals(String.class, foo.getClassA());
assertEquals(Integer.class, foo.getClassB());
assertEquals(String[].class, foo.getArrayClassA());
assertEquals(Integer[].class, foo.getArrayClassB());
}
public void testCompositeTypeToken() {
Reported by PMD.
android/guava/src/com/google/common/collect/Synchronized.java
210 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 68
* anyway, so we just need to get by without the annotations here until Kotlin better understands
* our other nullness annotations.
*/
final class Synchronized {
private Synchronized() {}
static class SynchronizedObject implements Serializable {
final Object delegate;
final Object mutex;
Reported by PMD.
Line: 68
* anyway, so we just need to get by without the annotations here until Kotlin better understands
* our other nullness annotations.
*/
final class Synchronized {
private Synchronized() {}
static class SynchronizedObject implements Serializable {
final Object delegate;
final Object mutex;
Reported by PMD.
Line: 72
private Synchronized() {}
static class SynchronizedObject implements Serializable {
final Object delegate;
final Object mutex;
SynchronizedObject(Object delegate, @CheckForNull Object mutex) {
this.delegate = checkNotNull(delegate);
this.mutex = (mutex == null) ? this : mutex;
Reported by PMD.
Line: 72
private Synchronized() {}
static class SynchronizedObject implements Serializable {
final Object delegate;
final Object mutex;
SynchronizedObject(Object delegate, @CheckForNull Object mutex) {
this.delegate = checkNotNull(delegate);
this.mutex = (mutex == null) ? this : mutex;
Reported by PMD.
Line: 73
static class SynchronizedObject implements Serializable {
final Object delegate;
final Object mutex;
SynchronizedObject(Object delegate, @CheckForNull Object mutex) {
this.delegate = checkNotNull(delegate);
this.mutex = (mutex == null) ? this : mutex;
}
Reported by PMD.
Line: 116
@VisibleForTesting
static class SynchronizedCollection<E extends @Nullable Object> extends SynchronizedObject
implements Collection<E> {
private SynchronizedCollection(Collection<E> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
}
@SuppressWarnings("unchecked")
Reported by PMD.
Line: 121
super(delegate, mutex);
}
@SuppressWarnings("unchecked")
@Override
Collection<E> delegate() {
return (Collection<E>) super.delegate();
}
Reported by PMD.
Line: 130
@Override
public boolean add(E e) {
synchronized (mutex) {
return delegate().add(e);
}
}
@Override
public boolean addAll(Collection<? extends E> c) {
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java
208 issues
Line: 511
"Should not acquire additional permit even after sleeping", rateLimiter.tryAcquire());
}
private long measureTotalTimeMillis(RateLimiter rateLimiter, int permits, Random random) {
long startTime = stopwatch.instant;
while (permits > 0) {
int nextPermitsToAcquire = Math.max(1, random.nextInt(permits));
permits -= nextPermitsToAcquire;
rateLimiter.acquire(nextPermitsToAcquire);
Reported by PMD.
Line: 46
*
* @author Dimitris Andreou
*/
public class RateLimiterTest extends TestCase {
private static final double EPSILON = 1e-8;
private final FakeStopwatch stopwatch = new FakeStopwatch();
public void testSimple() {
Reported by PMD.
Line: 49
public class RateLimiterTest extends TestCase {
private static final double EPSILON = 1e-8;
private final FakeStopwatch stopwatch = new FakeStopwatch();
public void testSimple() {
RateLimiter limiter = RateLimiter.create(5.0, stopwatch);
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
Reported by PMD.
Line: 51
private final FakeStopwatch stopwatch = new FakeStopwatch();
public void testSimple() {
RateLimiter limiter = RateLimiter.create(5.0, stopwatch);
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
Reported by PMD.
Line: 53
public void testSimple() {
RateLimiter limiter = RateLimiter.create(5.0, stopwatch);
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
}
Reported by PMD.
Line: 54
public void testSimple() {
RateLimiter limiter = RateLimiter.create(5.0, stopwatch);
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
}
public void testImmediateTryAcquire() {
Reported by PMD.
Line: 55
RateLimiter limiter = RateLimiter.create(5.0, stopwatch);
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
}
public void testImmediateTryAcquire() {
RateLimiter r = RateLimiter.create(1);
Reported by PMD.
Line: 56
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
}
public void testImmediateTryAcquire() {
RateLimiter r = RateLimiter.create(1);
assertTrue("Unable to acquire initial permit", r.tryAcquire());
Reported by PMD.
Line: 56
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
}
public void testImmediateTryAcquire() {
RateLimiter r = RateLimiter.create(1);
assertTrue("Unable to acquire initial permit", r.tryAcquire());
Reported by PMD.
Line: 59
assertEvents("R0.00", "R0.20", "R0.20");
}
public void testImmediateTryAcquire() {
RateLimiter r = RateLimiter.create(1);
assertTrue("Unable to acquire initial permit", r.tryAcquire());
assertFalse("Capable of acquiring secondary permit", r.tryAcquire());
}
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java
208 issues
Line: 511
"Should not acquire additional permit even after sleeping", rateLimiter.tryAcquire());
}
private long measureTotalTimeMillis(RateLimiter rateLimiter, int permits, Random random) {
long startTime = stopwatch.instant;
while (permits > 0) {
int nextPermitsToAcquire = Math.max(1, random.nextInt(permits));
permits -= nextPermitsToAcquire;
rateLimiter.acquire(nextPermitsToAcquire);
Reported by PMD.
Line: 46
*
* @author Dimitris Andreou
*/
public class RateLimiterTest extends TestCase {
private static final double EPSILON = 1e-8;
private final FakeStopwatch stopwatch = new FakeStopwatch();
public void testSimple() {
Reported by PMD.
Line: 49
public class RateLimiterTest extends TestCase {
private static final double EPSILON = 1e-8;
private final FakeStopwatch stopwatch = new FakeStopwatch();
public void testSimple() {
RateLimiter limiter = RateLimiter.create(5.0, stopwatch);
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
Reported by PMD.
Line: 51
private final FakeStopwatch stopwatch = new FakeStopwatch();
public void testSimple() {
RateLimiter limiter = RateLimiter.create(5.0, stopwatch);
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
Reported by PMD.
Line: 53
public void testSimple() {
RateLimiter limiter = RateLimiter.create(5.0, stopwatch);
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
}
Reported by PMD.
Line: 54
public void testSimple() {
RateLimiter limiter = RateLimiter.create(5.0, stopwatch);
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
}
public void testImmediateTryAcquire() {
Reported by PMD.
Line: 55
RateLimiter limiter = RateLimiter.create(5.0, stopwatch);
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
}
public void testImmediateTryAcquire() {
RateLimiter r = RateLimiter.create(1);
Reported by PMD.
Line: 56
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
}
public void testImmediateTryAcquire() {
RateLimiter r = RateLimiter.create(1);
assertTrue("Unable to acquire initial permit", r.tryAcquire());
Reported by PMD.
Line: 56
limiter.acquire(); // R0.00, since it's the first request
limiter.acquire(); // R0.20
limiter.acquire(); // R0.20
assertEvents("R0.00", "R0.20", "R0.20");
}
public void testImmediateTryAcquire() {
RateLimiter r = RateLimiter.create(1);
assertTrue("Unable to acquire initial permit", r.tryAcquire());
Reported by PMD.
Line: 59
assertEvents("R0.00", "R0.20", "R0.20");
}
public void testImmediateTryAcquire() {
RateLimiter r = RateLimiter.create(1);
assertTrue("Unable to acquire initial permit", r.tryAcquire());
assertFalse("Capable of acquiring secondary permit", r.tryAcquire());
}
Reported by PMD.
android/guava-tests/test/com/google/common/base/ThrowablesTest.java
207 issues
Line: 17
* limitations under the License.
*/
package com.google.common.base;
import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
import static com.google.common.base.Throwables.getStackTraceAsString;
import static com.google.common.base.Throwables.lazyStackTrace;
import static com.google.common.base.Throwables.lazyStackTraceIsLazy;
Reported by PMD.
Line: 43
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class ThrowablesTest extends TestCase {
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
Reported by PMD.
Line: 43
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class ThrowablesTest extends TestCase {
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
Reported by PMD.
Line: 43
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class ThrowablesTest extends TestCase {
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
Reported by PMD.
Line: 44
*/
@GwtCompatible(emulated = true)
public class ThrowablesTest extends TestCase {
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
}
Reported by PMD.
Line: 47
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
}
}
public void testThrowIfUnchecked_Error() {
Reported by PMD.
Line: 47
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
}
}
public void testThrowIfUnchecked_Error() {
Reported by PMD.
Line: 52
}
}
public void testThrowIfUnchecked_Error() {
try {
throwIfUnchecked(new SomeError());
fail();
} catch (SomeError expected) {
}
Reported by PMD.
Line: 55
public void testThrowIfUnchecked_Error() {
try {
throwIfUnchecked(new SomeError());
fail();
} catch (SomeError expected) {
}
}
@SuppressWarnings("ThrowIfUncheckedKnownChecked")
Reported by PMD.
Line: 55
public void testThrowIfUnchecked_Error() {
try {
throwIfUnchecked(new SomeError());
fail();
} catch (SomeError expected) {
}
}
@SuppressWarnings("ThrowIfUncheckedKnownChecked")
Reported by PMD.
guava-tests/test/com/google/common/base/ThrowablesTest.java
207 issues
Line: 17
* limitations under the License.
*/
package com.google.common.base;
import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
import static com.google.common.base.Throwables.getStackTraceAsString;
import static com.google.common.base.Throwables.lazyStackTrace;
import static com.google.common.base.Throwables.lazyStackTraceIsLazy;
Reported by PMD.
Line: 43
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class ThrowablesTest extends TestCase {
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
Reported by PMD.
Line: 43
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class ThrowablesTest extends TestCase {
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
Reported by PMD.
Line: 43
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class ThrowablesTest extends TestCase {
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
Reported by PMD.
Line: 44
*/
@GwtCompatible(emulated = true)
public class ThrowablesTest extends TestCase {
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
}
Reported by PMD.
Line: 47
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
}
}
public void testThrowIfUnchecked_Error() {
Reported by PMD.
Line: 47
public void testThrowIfUnchecked_Unchecked() {
try {
throwIfUnchecked(new SomeUncheckedException());
fail();
} catch (SomeUncheckedException expected) {
}
}
public void testThrowIfUnchecked_Error() {
Reported by PMD.
Line: 52
}
}
public void testThrowIfUnchecked_Error() {
try {
throwIfUnchecked(new SomeError());
fail();
} catch (SomeError expected) {
}
Reported by PMD.
Line: 55
public void testThrowIfUnchecked_Error() {
try {
throwIfUnchecked(new SomeError());
fail();
} catch (SomeError expected) {
}
}
@SuppressWarnings("ThrowIfUncheckedKnownChecked")
Reported by PMD.
Line: 55
public void testThrowIfUnchecked_Error() {
try {
throwIfUnchecked(new SomeError());
fail();
} catch (SomeError expected) {
}
}
@SuppressWarnings("ThrowIfUncheckedKnownChecked")
Reported by PMD.