Skip to content

Commit

Permalink
[GSCOLLECT-1547] Implement a JUnit Runner for interfaces containing c…
Browse files Browse the repository at this point in the history
…oncrete tests. Create a new test suite leveraging virtual extension methods.

git-svn-id: svn+ssh://gscollections.svn.services.gs.com/svnroot/gscollections-svn/trunk@798 d5c9223b-1aff-41ac-aadd-f810b4a99ac4
  • Loading branch information
motlin committed Jan 10, 2015
1 parent 91f427f commit 6116550
Show file tree
Hide file tree
Showing 145 changed files with 9,392 additions and 56 deletions.
4 changes: 2 additions & 2 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion .idea/inspectionProfiles/IDE.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion acceptance-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright 2014 Goldman Sachs.
~ Copyright 2015 Goldman Sachs.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -93,6 +93,11 @@
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<compilerArguments>
<J-Xmx2048m />
</compilerArguments>
<verbose>true</verbose>
</configuration>
</plugin>

Expand Down
4 changes: 2 additions & 2 deletions checkstyle-configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">

<!--
~ Copyright 2014 Goldman Sachs.
~ Copyright 2015 Goldman Sachs.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -228,7 +228,7 @@

<module name="AvoidStaticImport">
<property name="excludes"
value="org.junit.Assert.*,org.hamcrest.CoreMatchers.*,com.gs.collections.impl.test.Verify.*,com.gs.collections.impl.factory.Iterables.*" />
value="org.junit.Assert.*,org.hamcrest.CoreMatchers.*,org.hamcrest.Matchers.*,com.gs.collections.impl.test.Verify.*,com.gs.collections.impl.factory.Iterables.*,com.gs.collections.test.IterableTestCase.*" />
</module>

<module name="MissingDeprecated" />
Expand Down
5 changes: 4 additions & 1 deletion checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<!--
~ Copyright 2014 Goldman Sachs.
~ Copyright 2015 Goldman Sachs.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,6 +56,9 @@
<suppress checks="ConstantName" files="Multimaps.java" />

<suppress checks="MethodName" files="GsCollectionsCodeGenerator.java" />
<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/>

<suppress checks="MethodName" files="[\\/]unit-tests-java8[\\/]" />

<suppress checks="IllegalImport" files="ConcurrentHashMapUnsafe.java" />

Expand Down
5 changes: 2 additions & 3 deletions collections-testutils/gs-collections-testutils.iml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
<orderEntry type="module" module-name="gs-collections-api" />
<orderEntry type="module" module-name="gs-collections" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>

</module>
4 changes: 2 additions & 2 deletions collections-testutils/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright 2014 Goldman Sachs.
~ Copyright 2015 Goldman Sachs.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -106,7 +106,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<scope>compile</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.SortedSet;
import java.util.concurrent.Callable;

import com.gs.collections.api.InternalIterable;
import com.gs.collections.api.PrimitiveIterable;
import com.gs.collections.api.bag.sorted.SortedBag;
import com.gs.collections.api.block.predicate.Predicate;
Expand All @@ -50,8 +51,10 @@
import com.gs.collections.api.set.MutableSet;
import com.gs.collections.impl.block.factory.Comparators;
import com.gs.collections.impl.block.factory.Predicates;
import com.gs.collections.impl.block.procedure.CollectionAddProcedure;
import com.gs.collections.impl.factory.Lists;
import com.gs.collections.impl.factory.Sets;
import com.gs.collections.impl.list.mutable.FastList;
import com.gs.collections.impl.map.mutable.UnifiedMap;
import com.gs.collections.impl.set.mutable.UnifiedSet;
import com.gs.collections.impl.tuple.ImmutableEntry;
Expand Down Expand Up @@ -1877,7 +1880,22 @@ public static void assertListsEqual(String listName, List<?> expectedList, List<
{
try
{
Verify.assertIterablesEqual(listName, expectedList, actualList);
if (expectedList == null && actualList == null)
{
return;
}
Assert.assertNotNull(expectedList);
Assert.assertNotNull(actualList);
Assert.assertEquals(listName + " size", expectedList.size(), actualList.size());
for (int index = 0; index < actualList.size(); index++)
{
Object eachExpected = expectedList.get(index);
Object eachActual = actualList.get(index);
if (!Comparators.nullSafeEquals(eachExpected, eachActual))
{
junit.framework.Assert.failNotEquals(listName + " first differed at element [" + index + "];", eachExpected, eachActual);
}
}
}
catch (AssertionError e)
{
Expand Down Expand Up @@ -1952,6 +1970,7 @@ public static void assertSortedSetsEqual(String setName, SortedSet<?> expectedSe
{
try
{
Assert.assertEquals(setName, expectedSet, actualSet);
Verify.assertIterablesEqual(setName, expectedSet, actualSet);
}
catch (AssertionError e)
Expand All @@ -1976,6 +1995,7 @@ public static void assertSortedBagsEqual(String bagName, SortedBag<?> expectedBa
{
try
{
Assert.assertEquals(bagName, expectedBag, actualBag);
Verify.assertIterablesEqual(bagName, expectedBag, actualBag);
}
catch (AssertionError e)
Expand All @@ -2000,6 +2020,7 @@ public static void assertSortedMapsEqual(String mapName, SortedMapIterable<?, ?>
{
try
{
Assert.assertEquals(mapName, expectedMap, actualMap);
Verify.assertIterablesEqual(mapName, expectedMap, actualMap);
}
catch (AssertionError e)
Expand Down Expand Up @@ -2032,33 +2053,40 @@ public static void assertIterablesEqual(String iterableName, Iterable<?> expecte

Verify.assertObjectNotNull(iterableName, actualIterable);

if (expectedIterable.equals(actualIterable))
if (expectedIterable instanceof InternalIterable<?> && actualIterable instanceof InternalIterable<?>)
{
return;
MutableList<Object> expectedList = FastList.newList();
MutableList<Object> actualList = FastList.newList();
((InternalIterable<?>) expectedIterable).forEach(CollectionAddProcedure.on(expectedList));
((InternalIterable<?>) actualIterable).forEach(CollectionAddProcedure.on(actualList));
Verify.assertListsEqual(iterableName, expectedList, actualList);
}
Iterator<?> expectedIterator = expectedIterable.iterator();
Iterator<?> actualIterator = actualIterable.iterator();
int index = 0;

while (expectedIterator.hasNext() && actualIterator.hasNext())
else
{
Object eachExpected = expectedIterator.next();
Object eachActual = actualIterator.next();
Iterator<?> expectedIterator = expectedIterable.iterator();
Iterator<?> actualIterator = actualIterable.iterator();
int index = 0;

if (!Comparators.nullSafeEquals(eachExpected, eachActual))
while (expectedIterator.hasNext() && actualIterator.hasNext())
{
//noinspection UseOfObsoleteAssert
junit.framework.Assert.failNotEquals(iterableName + " first differed at element [" + index + "];", eachExpected, eachActual);
Object eachExpected = expectedIterator.next();
Object eachActual = actualIterator.next();

if (!Comparators.nullSafeEquals(eachExpected, eachActual))
{
//noinspection UseOfObsoleteAssert
junit.framework.Assert.failNotEquals(iterableName + " first differed at element [" + index + "];", eachExpected, eachActual);
}
index++;
}
index++;
}

Assert.assertFalse("Actual " + iterableName + " had " + index + " elements but expected " + iterableName + " had more.", expectedIterator.hasNext());
Assert.assertFalse("Expected " + iterableName + " had " + index + " elements but actual " + iterableName + " had more.", actualIterator.hasNext());
Assert.assertFalse("Actual " + iterableName + " had " + index + " elements but expected " + iterableName + " had more.", expectedIterator.hasNext());
Assert.assertFalse("Expected " + iterableName + " had " + index + " elements but actual " + iterableName + " had more.", actualIterator.hasNext());
}
}
catch (AssertionError e)
{
throwMangledException(e);
Verify.throwMangledException(e);
}
}

Expand Down Expand Up @@ -3214,7 +3242,7 @@ public static void assertSerializedForm(String expectedBase64Form, Object actual
Assert.assertEquals(
"Serialization was broken.",
expectedBase64Form,
encodeObject(actualObject));
Verify.encodeObject(actualObject));
}
catch (AssertionError e)
{
Expand Down
4 changes: 2 additions & 2 deletions gs-collections-forkjoin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright 2014 Goldman Sachs.
~ Copyright 2015 Goldman Sachs.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -107,7 +107,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<scope>test</scope>
</dependency>

Expand Down
4 changes: 2 additions & 2 deletions jmh-scala-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright 2014 Goldman Sachs.
~ Copyright 2015 Goldman Sachs.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,7 +51,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<scope>compile</scope>
</dependency>

Expand Down
9 changes: 7 additions & 2 deletions jmh-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright 2014 Goldman Sachs.
~ Copyright 2015 Goldman Sachs.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -82,7 +82,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<scope>compile</scope>
</dependency>

Expand Down Expand Up @@ -110,6 +110,11 @@
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<compilerArguments>
<J-Xmx2048m />
</compilerArguments>
<verbose>true</verbose>
</configuration>
</plugin>

Expand Down
15 changes: 15 additions & 0 deletions junit-trait-runner/junit-trait-runner.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
Loading

0 comments on commit 6116550

Please sign in to comment.