src.jsr166.Collection8Test Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-all Show documentation
Show all versions of android-all Show documentation
A library jar that provides APIs for Applications written for the Google Android Platform.
/*
* Written by Doug Lea and Martin Buchholz with assistance from
* members of JCP JSR-166 Expert Group and released to the public
* domain, as explained at
* http://creativecommons.org/publicdomain/zero/1.0/
*/
package jsr166;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
import junit.framework.Test;
/**
* Contains tests applicable to all jdk8+ Collection implementations.
* An extension of CollectionTest.
*/
// Android-changed: Made class abstract so it will be ignored by test runners.
public abstract class Collection8Test extends JSR166TestCase {
final CollectionImplementation impl;
/** Tests are parameterized by a Collection implementation. */
Collection8Test(CollectionImplementation impl, String methodName) {
super(methodName);
this.impl = impl;
}
public static Test testSuite(CollectionImplementation impl) {
return parameterizedTestSuite(Collection8Test.class,
CollectionImplementation.class,
impl);
}
/**
* stream().forEach returns elements in the collection
*/
public void testForEach() throws Throwable {
final Collection c = impl.emptyCollection();
final AtomicLong count = new AtomicLong(0L);
final Object x = impl.makeElement(1);
final Object y = impl.makeElement(2);
final ArrayList found = new ArrayList();
Consumer