diff --git a/android/guava-tests/test/com/google/common/collect/Collections2FilterArrayListTest.java b/android/guava-tests/test/com/google/common/collect/Collections2FilterArrayListTest.java new file mode 100644 index 000000000000..8a783ec6e823 --- /dev/null +++ b/android/guava-tests/test/com/google/common/collect/Collections2FilterArrayListTest.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import com.google.common.base.Predicate; +import com.google.common.collect.FilteredCollectionsTestUtil.AbstractFilteredCollectionTest; +import java.util.Collection; + +public final class Collections2FilterArrayListTest + extends AbstractFilteredCollectionTest> { + @Override + Collection createUnfiltered(Iterable contents) { + return Lists.newArrayList(contents); + } + + @Override + Collection filter(Collection elements, Predicate predicate) { + return Collections2.filter(elements, predicate); + } +} diff --git a/android/guava-tests/test/com/google/common/collect/FilteredCollectionsTest.java b/android/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java similarity index 82% rename from android/guava-tests/test/com/google/common/collect/FilteredCollectionsTest.java rename to android/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java index 3b05972eeeec..77e01dc5836a 100644 --- a/android/guava-tests/test/com/google/common/collect/FilteredCollectionsTest.java +++ b/android/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java @@ -28,15 +28,19 @@ import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedSet; -import java.util.TreeSet; import junit.framework.TestCase; /** - * Tests for filtered collection views. + * Class that contains nested abstract tests for filtered collection views, along with their + * implementation helpers. * * @author Louis Wasserman */ -public class FilteredCollectionsTest extends TestCase { +/* + * TODO(cpovirk): Should all the tests for filtered collections run under GWT, too? Currently, they + * don't. + */ +public final class FilteredCollectionsTestUtil { private static final Predicate EVEN = new Predicate() { @Override @@ -374,79 +378,5 @@ public void testNavigation() { } } - // implementation tests - - public static final class IterablesFilterArrayListTest - extends AbstractFilteredIterableTest> { - @Override - Iterable createUnfiltered(Iterable contents) { - return Lists.newArrayList(contents); - } - - @Override - Iterable filter(Iterable elements, Predicate predicate) { - return Iterables.filter(elements, predicate); - } - } - - public static final class Collections2FilterArrayListTest - extends AbstractFilteredCollectionTest> { - @Override - Collection createUnfiltered(Iterable contents) { - return Lists.newArrayList(contents); - } - - @Override - Collection filter(Collection elements, Predicate predicate) { - return Collections2.filter(elements, predicate); - } - } - - public static final class SetsFilterHashSetTest extends AbstractFilteredSetTest> { - @Override - Set createUnfiltered(Iterable contents) { - return Sets.newHashSet(contents); - } - - @Override - Set filter(Set elements, Predicate predicate) { - return Sets.filter(elements, predicate); - } - } - - public static final class SetsFilterSortedSetTest - extends AbstractFilteredSortedSetTest> { - @Override - SortedSet createUnfiltered(Iterable contents) { - final TreeSet result = Sets.newTreeSet(contents); - // we have to make the result not Navigable - return new ForwardingSortedSet() { - @Override - protected SortedSet delegate() { - return result; - } - }; - } - - @Override - SortedSet filter(SortedSet elements, Predicate predicate) { - return Sets.filter(elements, predicate); - } - } - - public static final class SetsFilterNavigableSetTest extends AbstractFilteredNavigableSetTest { - @Override - NavigableSet createUnfiltered(Iterable contents) { - return Sets.newTreeSet(contents); - } - - @Override - NavigableSet filter( - NavigableSet elements, Predicate predicate) { - return Sets.filter(elements, predicate); - } - } - - /** No-op test so that the class has at least one method, making Maven's test runner happy. */ - public void testNoop() {} + private FilteredCollectionsTestUtil() {} } diff --git a/android/guava-tests/test/com/google/common/collect/IterablesFilterArrayListTest.java b/android/guava-tests/test/com/google/common/collect/IterablesFilterArrayListTest.java new file mode 100644 index 000000000000..9cd2d90917c6 --- /dev/null +++ b/android/guava-tests/test/com/google/common/collect/IterablesFilterArrayListTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2012 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import com.google.common.base.Predicate; +import com.google.common.collect.FilteredCollectionsTestUtil.AbstractFilteredIterableTest; + +public final class IterablesFilterArrayListTest + extends AbstractFilteredIterableTest> { + @Override + Iterable createUnfiltered(Iterable contents) { + return Lists.newArrayList(contents); + } + + @Override + Iterable filter(Iterable elements, Predicate predicate) { + return Iterables.filter(elements, predicate); + } +} diff --git a/android/guava-tests/test/com/google/common/collect/SetsFilterHashSetTest.java b/android/guava-tests/test/com/google/common/collect/SetsFilterHashSetTest.java new file mode 100644 index 000000000000..a550f04875e5 --- /dev/null +++ b/android/guava-tests/test/com/google/common/collect/SetsFilterHashSetTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2012 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import com.google.common.base.Predicate; +import com.google.common.collect.FilteredCollectionsTestUtil.AbstractFilteredSetTest; +import java.util.Set; + +public final class SetsFilterHashSetTest extends AbstractFilteredSetTest> { + @Override + Set createUnfiltered(Iterable contents) { + return Sets.newHashSet(contents); + } + + @Override + Set filter(Set elements, Predicate predicate) { + return Sets.filter(elements, predicate); + } +} diff --git a/android/guava-tests/test/com/google/common/collect/SetsFilterNavigableSetTest.java b/android/guava-tests/test/com/google/common/collect/SetsFilterNavigableSetTest.java new file mode 100644 index 000000000000..350c091507ba --- /dev/null +++ b/android/guava-tests/test/com/google/common/collect/SetsFilterNavigableSetTest.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import com.google.common.base.Predicate; +import com.google.common.collect.FilteredCollectionsTestUtil.AbstractFilteredNavigableSetTest; +import java.util.NavigableSet; + +public final class SetsFilterNavigableSetTest extends AbstractFilteredNavigableSetTest { + @Override + NavigableSet createUnfiltered(Iterable contents) { + return Sets.newTreeSet(contents); + } + + @Override + NavigableSet filter( + NavigableSet elements, Predicate predicate) { + return Sets.filter(elements, predicate); + } +} diff --git a/android/guava-tests/test/com/google/common/collect/SetsFilterSortedSetTest.java b/android/guava-tests/test/com/google/common/collect/SetsFilterSortedSetTest.java new file mode 100644 index 000000000000..0529bead6ccd --- /dev/null +++ b/android/guava-tests/test/com/google/common/collect/SetsFilterSortedSetTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2012 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import com.google.common.base.Predicate; +import com.google.common.collect.FilteredCollectionsTestUtil.AbstractFilteredSortedSetTest; +import java.util.SortedSet; +import java.util.TreeSet; + +public final class SetsFilterSortedSetTest + extends AbstractFilteredSortedSetTest> { + @Override + SortedSet createUnfiltered(Iterable contents) { + final TreeSet result = Sets.newTreeSet(contents); + // we have to make the result not Navigable + return new ForwardingSortedSet() { + @Override + protected SortedSet delegate() { + return result; + } + }; + } + + @Override + SortedSet filter(SortedSet elements, Predicate predicate) { + return Sets.filter(elements, predicate); + } +} diff --git a/guava-tests/test/com/google/common/collect/Collections2FilterArrayListTest.java b/guava-tests/test/com/google/common/collect/Collections2FilterArrayListTest.java new file mode 100644 index 000000000000..8a783ec6e823 --- /dev/null +++ b/guava-tests/test/com/google/common/collect/Collections2FilterArrayListTest.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import com.google.common.base.Predicate; +import com.google.common.collect.FilteredCollectionsTestUtil.AbstractFilteredCollectionTest; +import java.util.Collection; + +public final class Collections2FilterArrayListTest + extends AbstractFilteredCollectionTest> { + @Override + Collection createUnfiltered(Iterable contents) { + return Lists.newArrayList(contents); + } + + @Override + Collection filter(Collection elements, Predicate predicate) { + return Collections2.filter(elements, predicate); + } +} diff --git a/guava-tests/test/com/google/common/collect/FilteredCollectionsTest.java b/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java similarity index 83% rename from guava-tests/test/com/google/common/collect/FilteredCollectionsTest.java rename to guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java index 85b4e214d3d5..95bfac5bcb16 100644 --- a/guava-tests/test/com/google/common/collect/FilteredCollectionsTest.java +++ b/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java @@ -29,15 +29,19 @@ import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedSet; -import java.util.TreeSet; import junit.framework.TestCase; /** - * Tests for filtered collection views. + * Class that contains nested abstract tests for filtered collection views, along with their + * implementation helpers. * * @author Louis Wasserman */ -public class FilteredCollectionsTest extends TestCase { +/* + * TODO(cpovirk): Should all the tests for filtered collections run under GWT, too? Currently, they + * don't. + */ +public final class FilteredCollectionsTestUtil { private static final Predicate EVEN = new Predicate() { @Override @@ -389,79 +393,5 @@ public void testNavigation() { } } - // implementation tests - - public static final class IterablesFilterArrayListTest - extends AbstractFilteredIterableTest> { - @Override - Iterable createUnfiltered(Iterable contents) { - return Lists.newArrayList(contents); - } - - @Override - Iterable filter(Iterable elements, Predicate predicate) { - return Iterables.filter(elements, predicate); - } - } - - public static final class Collections2FilterArrayListTest - extends AbstractFilteredCollectionTest> { - @Override - Collection createUnfiltered(Iterable contents) { - return Lists.newArrayList(contents); - } - - @Override - Collection filter(Collection elements, Predicate predicate) { - return Collections2.filter(elements, predicate); - } - } - - public static final class SetsFilterHashSetTest extends AbstractFilteredSetTest> { - @Override - Set createUnfiltered(Iterable contents) { - return Sets.newHashSet(contents); - } - - @Override - Set filter(Set elements, Predicate predicate) { - return Sets.filter(elements, predicate); - } - } - - public static final class SetsFilterSortedSetTest - extends AbstractFilteredSortedSetTest> { - @Override - SortedSet createUnfiltered(Iterable contents) { - final TreeSet result = Sets.newTreeSet(contents); - // we have to make the result not Navigable - return new ForwardingSortedSet() { - @Override - protected SortedSet delegate() { - return result; - } - }; - } - - @Override - SortedSet filter(SortedSet elements, Predicate predicate) { - return Sets.filter(elements, predicate); - } - } - - public static final class SetsFilterNavigableSetTest extends AbstractFilteredNavigableSetTest { - @Override - NavigableSet createUnfiltered(Iterable contents) { - return Sets.newTreeSet(contents); - } - - @Override - NavigableSet filter( - NavigableSet elements, Predicate predicate) { - return Sets.filter(elements, predicate); - } - } - - /** No-op test so that the class has at least one method, making Maven's test runner happy. */ - public void testNoop() {} + private FilteredCollectionsTestUtil() {} } diff --git a/guava-tests/test/com/google/common/collect/IterablesFilterArrayListTest.java b/guava-tests/test/com/google/common/collect/IterablesFilterArrayListTest.java new file mode 100644 index 000000000000..9cd2d90917c6 --- /dev/null +++ b/guava-tests/test/com/google/common/collect/IterablesFilterArrayListTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2012 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import com.google.common.base.Predicate; +import com.google.common.collect.FilteredCollectionsTestUtil.AbstractFilteredIterableTest; + +public final class IterablesFilterArrayListTest + extends AbstractFilteredIterableTest> { + @Override + Iterable createUnfiltered(Iterable contents) { + return Lists.newArrayList(contents); + } + + @Override + Iterable filter(Iterable elements, Predicate predicate) { + return Iterables.filter(elements, predicate); + } +} diff --git a/guava-tests/test/com/google/common/collect/SetsFilterHashSetTest.java b/guava-tests/test/com/google/common/collect/SetsFilterHashSetTest.java new file mode 100644 index 000000000000..a550f04875e5 --- /dev/null +++ b/guava-tests/test/com/google/common/collect/SetsFilterHashSetTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2012 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import com.google.common.base.Predicate; +import com.google.common.collect.FilteredCollectionsTestUtil.AbstractFilteredSetTest; +import java.util.Set; + +public final class SetsFilterHashSetTest extends AbstractFilteredSetTest> { + @Override + Set createUnfiltered(Iterable contents) { + return Sets.newHashSet(contents); + } + + @Override + Set filter(Set elements, Predicate predicate) { + return Sets.filter(elements, predicate); + } +} diff --git a/guava-tests/test/com/google/common/collect/SetsFilterNavigableSetTest.java b/guava-tests/test/com/google/common/collect/SetsFilterNavigableSetTest.java new file mode 100644 index 000000000000..350c091507ba --- /dev/null +++ b/guava-tests/test/com/google/common/collect/SetsFilterNavigableSetTest.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import com.google.common.base.Predicate; +import com.google.common.collect.FilteredCollectionsTestUtil.AbstractFilteredNavigableSetTest; +import java.util.NavigableSet; + +public final class SetsFilterNavigableSetTest extends AbstractFilteredNavigableSetTest { + @Override + NavigableSet createUnfiltered(Iterable contents) { + return Sets.newTreeSet(contents); + } + + @Override + NavigableSet filter( + NavigableSet elements, Predicate predicate) { + return Sets.filter(elements, predicate); + } +} diff --git a/guava-tests/test/com/google/common/collect/SetsFilterSortedSetTest.java b/guava-tests/test/com/google/common/collect/SetsFilterSortedSetTest.java new file mode 100644 index 000000000000..0529bead6ccd --- /dev/null +++ b/guava-tests/test/com/google/common/collect/SetsFilterSortedSetTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2012 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import com.google.common.base.Predicate; +import com.google.common.collect.FilteredCollectionsTestUtil.AbstractFilteredSortedSetTest; +import java.util.SortedSet; +import java.util.TreeSet; + +public final class SetsFilterSortedSetTest + extends AbstractFilteredSortedSetTest> { + @Override + SortedSet createUnfiltered(Iterable contents) { + final TreeSet result = Sets.newTreeSet(contents); + // we have to make the result not Navigable + return new ForwardingSortedSet() { + @Override + protected SortedSet delegate() { + return result; + } + }; + } + + @Override + SortedSet filter(SortedSet elements, Predicate predicate) { + return Sets.filter(elements, predicate); + } +}