Commits

David Carr committed 4c901fe

tests: embed mongo for integration tests

- Added usage of the Maven failsafe plugin
- Changed the two tests that used MongoDB into integration tests
- Added usage of embed-mongo to allow using Mongo in integration tests in CI
- Moved the javadoc JAR, source JAR, and GPG steps into a release profile
- MongoDB server for integration tests now configurable via system property

Comments (0)

Files changed (7)

     <properties>
         <maven.min-version>2.2.1</maven.min-version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <mongodb.test.port>37017</mongodb.test.port>
     </properties>
     <parent>
         <groupId>org.sonatype.oss</groupId>
             </plugin>
             <plugin>
                 <artifactId>maven-enforcer-plugin</artifactId>
-                <version>1.0</version>
+                <version>1.1.1</version>
                 <executions>
                     <execution>
                         <id>enforce-maven</id>
                 </executions>
             </plugin>
             <plugin>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <version>2.12.3</version>
+                <configuration>
+                    <systemPropertyVariables>
+                        <mongodb.test.port>${mongodb.test.port}</mongodb.test.port>
+                    </systemPropertyVariables>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
                 <artifactId>maven-gpg-plugin</artifactId>
                 <version>1.4</version>
                 <configuration>
                     <useAgent>true</useAgent>
                 </configuration>
-                <executions>
-                    <execution>
-                        <id>sign-artifacts</id>
-                        <phase>verify</phase>
-                        <goals>
-                            <goal>sign</goal>
-                        </goals>
-                    </execution>
-                </executions>
             </plugin>
             <plugin>
                 <artifactId>maven-install-plugin</artifactId>
                         <link>http://api.mongodb.org/java/2.9.0/</link>
                     </links>
                 </configuration>
-                <executions>
-                    <execution>
-                        <id>attach-javadocs</id>
-                        <goals>
-                            <goal>jar</goal>
-                        </goals>
-                    </execution>
-                </executions>
             </plugin>
             <plugin>
                 <artifactId>maven-resources-plugin</artifactId>
             <plugin>
                 <artifactId>maven-source-plugin</artifactId>
                 <version>2.2</version>
-                <executions>
-                    <execution>
-                        <id>attach-sources</id>
-                        <goals>
-                            <goal>jar-no-fork</goal>
-                        </goals>
-                    </execution>
-                </executions>
             </plugin>
             <plugin>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <version>2.12.3</version>
             </plugin>
             <plugin>
+                <groupId>com.github.joelittlejohn.embedmongo</groupId>
+                <artifactId>embedmongo-maven-plugin</artifactId>
+                <version>0.1.3</version>
+                <executions>
+                    <execution>
+                        <id>mongodb-start</id>
+                        <goals>
+                            <goal>start</goal>
+                        </goals>
+                        <configuration>
+                            <port>${mongodb.test.port}</port>
+                            <version>2.2.0</version>
+                            <databaseDirectory>target/mongotest</databaseDirectory>
+                            <logging>none</logging>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>mongodb-stop</id>
+                        <goals>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>animal-sniffer-maven-plugin</artifactId>
                 <version>1.8</version>
             </plugin>
         </plugins>
     </build>
+    
+    <profiles>
+        <profile>
+            <id>release</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-gpg-plugin</artifactId>
+                        <configuration>
+                            <useAgent>true</useAgent>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>sign-artifacts</id>
+                                <phase>verify</phase>
+                                <goals>
+                                    <goal>sign</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-javadoc-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>attach-javadocs</id>
+                                <goals>
+                                    <goal>jar</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-source-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>attach-sources</id>
+                                <goals>
+                                    <goal>jar-no-fork</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>

src/test/java/org/bitbucket/davidm24/mongodb/aggregate/AggregateBuilderIT.java

+/**
+ *      Copyright (C) 2012 David M. Carr
+ *
+ *   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 org.bitbucket.davidm24.mongodb.aggregate;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.bson.types.ObjectId;
+import org.testng.annotations.Test;
+
+import com.mongodb.AggregationOutput;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+/**
+ * Tests for {@link AggregateBuilder}. Many of these test scenarios are pulled
+ * from the examples in the Aggregation Framework documentation.
+ * 
+ * @author David M. Carr
+ */
+public class AggregateBuilderIT extends AggregationTestCase {
+    @Test
+    public void articleTagToAuthorTest() {
+        String testName = "articleTagToAuthorTest";
+        DBCollection collection = getCollection(testName);
+        insertArticle1(collection);
+        AggregationOutput output = AggregateBuilder.aggregate(collection)
+                .project(newMap("author", 1, "tags", 1))
+                .unwind("$tags")
+                .group(GroupBuilder.start()
+                        .put("_id").to(new BasicDBObject("tags", "$tags"))
+                        .put("authors").addToSet("$author")
+                        .get()
+                )
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void projectIncludeTest() {
+        String testName = "projectIncludeTest";
+        DBCollection collection = getCollection(testName);
+        insertArticle1(collection);
+        AggregationOutput output = AggregateBuilder.aggregate(collection)
+                .project(newMap("title", 1, "author", 1))
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void projectExcludeIdTest() {
+        String testName = "projectExcludeIdTest";
+        DBCollection collection = getCollection(testName);
+        insertArticle1(collection);
+        AggregationOutput output = AggregateBuilder.aggregate(collection)
+                .project(newMap("_id", 0, "title", 1, "author", 1))
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void projectComputedTest() {
+        String testName = "projectComputedTest";
+        DBCollection collection = getCollection(testName);
+        insertArticle1(collection);
+        // TODO Add better support for expression operators
+        AggregationOutput output = AggregateBuilder
+                .aggregate(collection)
+                .project(
+                        newMap("title", 1,
+                                "doctoredPageViews",
+                                newMap("$add", newList("$pageViews", 10))
+                        ))
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void projectRenameTest() {
+        String testName = "projectRenameTest";
+        DBCollection collection = getCollection(testName);
+        insertArticle1(collection);
+        AggregationOutput output = AggregateBuilder
+                .aggregate(collection)
+                .project(
+                        newMap("title", 1, "page_views", "$pageViews", "bar",
+                                "$other.foo"))
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void projectSubdocumentTest() {
+        String testName = "projectSubdocumentTest";
+        DBCollection collection = getCollection(testName);
+        insertArticle1(collection);
+        // TODO Add better support for expression operators
+        AggregationOutput output = AggregateBuilder
+                .aggregate(collection)
+                .project(
+                        newMap("title",
+                                1,
+                                "stats",
+                                newMap(
+                                        "pv",
+                                        "$pageViews",
+                                        "foo",
+                                        "$other.foo",
+                                        "dpv",
+                                        newMap("$add",
+                                                newList("$pageViews", 10))
+                                )
+                        ))
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void matchFieldEqualityTest() {
+        String testName = "matchFieldEqualityTest";
+        DBCollection collection = getCollection(testName);
+        insertArticles(collection);
+        AggregationOutput output = AggregateBuilder.aggregate(collection)
+                .match("author", "dave")
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void matchQueryTest() {
+        String testName = "matchQueryTest";
+        DBCollection collection = getCollection(testName);
+        insertScoredTests(collection);
+        AggregationOutput output = AggregateBuilder
+                .aggregate(collection)
+                .match(QueryBuilder.start("score").greaterThan(50)
+                        .lessThanEquals(90).get())
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void limitTest() {
+        String testName = "limitTest";
+        DBCollection collection = getCollection(testName);
+        insertScoredTests(collection);
+        AggregationOutput output = AggregateBuilder.aggregate(collection)
+                .limit(4)
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void skipTest() {
+        String testName = "skipTest";
+        DBCollection collection = getCollection(testName);
+        insertScoredTests(collection);
+        AggregationOutput output = AggregateBuilder.aggregate(collection)
+                .skip(2)
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void unwindTest() {
+        String testName = "unwindTest";
+        DBCollection collection = getCollection(testName);
+        insertArticles(collection);
+        AggregationOutput output = AggregateBuilder.aggregate(collection)
+                .project(newMap("author", 1, "title", 1, "tags", 1))
+                .unwind("$tags")
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void groupWithSingleFieldIdTest() {
+        String testName = "groupWithSingleFieldIdTest";
+        DBCollection collection = getCollection(testName);
+        insertArticles(collection);
+        AggregationOutput output = AggregateBuilder.aggregate(collection)
+                .group(GroupBuilder.start()
+                        .put("_id").to("$author")
+                        .put("docsPerAuthor").sum(1)
+                        .put("viewsPerAuthor").sum("$pageViews")
+                        .get()
+                )
+                .sort(newMap("_id", 1)) // ensure the results are in a
+                                        // predictable order
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    // TODO: test group with aggregate id
+
+    @Test
+    public void sortTest() {
+        String testName = "sortTest";
+        DBCollection collection = getCollection(testName);
+        insertScoredTests(collection);
+        AggregationOutput output = AggregateBuilder.aggregate(collection)
+                .sort(newMap("score", -1))
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    private void insertArticles(DBCollection collection) {
+        insertArticle1(collection);
+        insertArticle2(collection);
+        insertArticle3(collection);
+    }
+
+    private void insertArticle1(DBCollection collection) {
+        DBObject testDoc = new BasicDBObject(newMap(
+                "_id", new ObjectId("504025b803647536296a9e5e"),
+                "title", "this is my title",
+                "author", "bob",
+                "posted", newDate("2012-05-13"),
+                "pageViews", 5,
+                "tags", newList("fun", "good", "fun"),
+                "comments", newList(
+                        newMap("author", "joe", "text", "this is cool"),
+                        newMap("author", "sam", "text", "this is bad")
+                ),
+                "other", newMap("foo", 5)
+                ));
+        collection.save(testDoc);
+    }
+
+    private void insertArticle2(DBCollection collection) {
+        DBObject testDoc = new BasicDBObject(newMap(
+                "_id", new ObjectId("5040260b03641261a772cc02"),
+                "title", "great article",
+                "author", "dave",
+                "posted", newDate("2012-05-17"),
+                "pageViews", 47,
+                "tags", newList("great")
+                ));
+        collection.save(testDoc);
+    }
+
+    private void insertArticle3(DBCollection collection) {
+        DBObject testDoc = new BasicDBObject(newMap(
+                "_id", new ObjectId("504029180364027e67d45700"),
+                "title", "today's ramblings",
+                "author", "bob",
+                "posted", newDate("2012-05-23"),
+                "pageViews", 3
+                ));
+        collection.save(testDoc);
+    }
+
+    private void insertScoredTests(DBCollection collection) {
+        Date date = newDate("2012-01-01");
+        int machine = 0;
+        List<DBObject> tests = new ArrayList<DBObject>();
+        for (int i = 50; i < 100; i += 8) {
+            tests.add(new BasicDBObject(newMap(
+                    "_id", new ObjectId(date, machine, i), "score", i)));
+        }
+        collection.insert(tests);
+    }
+}

src/test/java/org/bitbucket/davidm24/mongodb/aggregate/AggregateBuilderTest.java

-/**
- *      Copyright (C) 2012 David M. Carr
- *
- *   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 org.bitbucket.davidm24.mongodb.aggregate;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.bson.types.ObjectId;
-import org.testng.annotations.Test;
-
-import com.mongodb.AggregationOutput;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBCollection;
-import com.mongodb.DBObject;
-import com.mongodb.QueryBuilder;
-
-/**
- * Tests for {@link AggregateBuilder}. Many of these test scenarios are pulled
- * from the examples in the Aggregation Framework documentation.
- * 
- * @author David M. Carr
- */
-public class AggregateBuilderTest extends AggregationTestCase {
-    @Test
-    public void articleTagToAuthorTest() {
-        String testName = "articleTagToAuthorTest";
-        DBCollection collection = getCollection(testName);
-        insertArticle1(collection);
-        AggregationOutput output = AggregateBuilder.aggregate(collection)
-                .project(newMap("author", 1, "tags", 1))
-                .unwind("$tags")
-                .group(GroupBuilder.start()
-                        .put("_id").to(new BasicDBObject("tags", "$tags"))
-                        .put("authors").addToSet("$author")
-                        .get()
-                )
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void projectIncludeTest() {
-        String testName = "projectIncludeTest";
-        DBCollection collection = getCollection(testName);
-        insertArticle1(collection);
-        AggregationOutput output = AggregateBuilder.aggregate(collection)
-                .project(newMap("title", 1, "author", 1))
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void projectExcludeIdTest() {
-        String testName = "projectExcludeIdTest";
-        DBCollection collection = getCollection(testName);
-        insertArticle1(collection);
-        AggregationOutput output = AggregateBuilder.aggregate(collection)
-                .project(newMap("_id", 0, "title", 1, "author", 1))
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void projectComputedTest() {
-        String testName = "projectComputedTest";
-        DBCollection collection = getCollection(testName);
-        insertArticle1(collection);
-        // TODO Add better support for expression operators
-        AggregationOutput output = AggregateBuilder
-                .aggregate(collection)
-                .project(
-                        newMap("title", 1,
-                                "doctoredPageViews",
-                                newMap("$add", newList("$pageViews", 10))
-                        ))
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void projectRenameTest() {
-        String testName = "projectRenameTest";
-        DBCollection collection = getCollection(testName);
-        insertArticle1(collection);
-        AggregationOutput output = AggregateBuilder
-                .aggregate(collection)
-                .project(
-                        newMap("title", 1, "page_views", "$pageViews", "bar",
-                                "$other.foo"))
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void projectSubdocumentTest() {
-        String testName = "projectSubdocumentTest";
-        DBCollection collection = getCollection(testName);
-        insertArticle1(collection);
-        // TODO Add better support for expression operators
-        AggregationOutput output = AggregateBuilder
-                .aggregate(collection)
-                .project(
-                        newMap("title",
-                                1,
-                                "stats",
-                                newMap(
-                                        "pv",
-                                        "$pageViews",
-                                        "foo",
-                                        "$other.foo",
-                                        "dpv",
-                                        newMap("$add",
-                                                newList("$pageViews", 10))
-                                )
-                        ))
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void matchFieldEqualityTest() {
-        String testName = "matchFieldEqualityTest";
-        DBCollection collection = getCollection(testName);
-        insertArticles(collection);
-        AggregationOutput output = AggregateBuilder.aggregate(collection)
-                .match("author", "dave")
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void matchQueryTest() {
-        String testName = "matchQueryTest";
-        DBCollection collection = getCollection(testName);
-        insertScoredTests(collection);
-        AggregationOutput output = AggregateBuilder
-                .aggregate(collection)
-                .match(QueryBuilder.start("score").greaterThan(50)
-                        .lessThanEquals(90).get())
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void limitTest() {
-        String testName = "limitTest";
-        DBCollection collection = getCollection(testName);
-        insertScoredTests(collection);
-        AggregationOutput output = AggregateBuilder.aggregate(collection)
-                .limit(4)
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void skipTest() {
-        String testName = "skipTest";
-        DBCollection collection = getCollection(testName);
-        insertScoredTests(collection);
-        AggregationOutput output = AggregateBuilder.aggregate(collection)
-                .skip(2)
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void unwindTest() {
-        String testName = "unwindTest";
-        DBCollection collection = getCollection(testName);
-        insertArticles(collection);
-        AggregationOutput output = AggregateBuilder.aggregate(collection)
-                .project(newMap("author", 1, "title", 1, "tags", 1))
-                .unwind("$tags")
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void groupWithSingleFieldIdTest() {
-        String testName = "groupWithSingleFieldIdTest";
-        DBCollection collection = getCollection(testName);
-        insertArticles(collection);
-        AggregationOutput output = AggregateBuilder.aggregate(collection)
-                .group(GroupBuilder.start()
-                        .put("_id").to("$author")
-                        .put("docsPerAuthor").sum(1)
-                        .put("viewsPerAuthor").sum("$pageViews")
-                        .get()
-                )
-                .sort(newMap("_id", 1)) // ensure the results are in a
-                                        // predictable order
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    // TODO: test group with aggregate id
-
-    @Test
-    public void sortTest() {
-        String testName = "sortTest";
-        DBCollection collection = getCollection(testName);
-        insertScoredTests(collection);
-        AggregationOutput output = AggregateBuilder.aggregate(collection)
-                .sort(newMap("score", -1))
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    private void insertArticles(DBCollection collection) {
-        insertArticle1(collection);
-        insertArticle2(collection);
-        insertArticle3(collection);
-    }
-
-    private void insertArticle1(DBCollection collection) {
-        DBObject testDoc = new BasicDBObject(newMap(
-                "_id", new ObjectId("504025b803647536296a9e5e"),
-                "title", "this is my title",
-                "author", "bob",
-                "posted", newDate("2012-05-13"),
-                "pageViews", 5,
-                "tags", newList("fun", "good", "fun"),
-                "comments", newList(
-                        newMap("author", "joe", "text", "this is cool"),
-                        newMap("author", "sam", "text", "this is bad")
-                ),
-                "other", newMap("foo", 5)
-                ));
-        collection.save(testDoc);
-    }
-
-    private void insertArticle2(DBCollection collection) {
-        DBObject testDoc = new BasicDBObject(newMap(
-                "_id", new ObjectId("5040260b03641261a772cc02"),
-                "title", "great article",
-                "author", "dave",
-                "posted", newDate("2012-05-17"),
-                "pageViews", 47,
-                "tags", newList("great")
-                ));
-        collection.save(testDoc);
-    }
-
-    private void insertArticle3(DBCollection collection) {
-        DBObject testDoc = new BasicDBObject(newMap(
-                "_id", new ObjectId("504029180364027e67d45700"),
-                "title", "today's ramblings",
-                "author", "bob",
-                "posted", newDate("2012-05-23"),
-                "pageViews", 3
-                ));
-        collection.save(testDoc);
-    }
-
-    private void insertScoredTests(DBCollection collection) {
-        Date date = newDate("2012-01-01");
-        int machine = 0;
-        List<DBObject> tests = new ArrayList<DBObject>();
-        for (int i = 50; i < 100; i += 8) {
-            tests.add(new BasicDBObject(newMap(
-                    "_id", new ObjectId(date, machine, i), "score", i)));
-        }
-        collection.insert(tests);
-    }
-}

src/test/java/org/bitbucket/davidm24/mongodb/aggregate/AggregationTestCase.java

 import java.util.List;
 import java.util.Map;
 
+import org.testng.annotations.BeforeClass;
+
 import com.mongodb.AggregationOutput;
 import com.mongodb.DB;
 import com.mongodb.DBCollection;
 
     public AggregationTestCase() {
         super();
+    }
+    
+    @BeforeClass
+    public void connectToDatabase() {
         cleanupDB = getClass().getSimpleName();
         try {
-            cleanupMongo = new Mongo("127.0.0.1");
+            String host = System.getProperty("mongodb.test.host", "127.0.0.1");
+            int port = Integer.getInteger("mongodb.test.port", 27017);
+            cleanupMongo = new Mongo(host, port);
             cleanupMongo.dropDatabase(cleanupDB);
             _testDB = cleanupMongo.getDB(cleanupDB);
         } catch (MongoException ex) {

src/test/java/org/bitbucket/davidm24/mongodb/aggregate/DocumentationExamplesIT.java

+/**
+ *      Copyright (C) 2012 David M. Carr
+ *
+ *   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 org.bitbucket.davidm24.mongodb.aggregate;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.mongodb.AggregationOutput;
+import com.mongodb.DBCollection;
+import com.mongodb.QueryBuilder;
+
+/**
+ * Tests based on the examples in the MongoDB <a
+ * href="http://docs.mongodb.org/manual/tutorial/aggregation-examples/"
+ * >Aggregation Framework Examples</a> documentation.
+ * 
+ * @author David M. Carr
+ */
+public class DocumentationExamplesIT extends AggregationTestCase {
+    private DBCollection collection;
+
+    @BeforeClass
+    public void importData() {
+        collection = getCollection("zipcodes");
+        importData(collection, "zips.json");
+        assertEquals(29467, collection.count());
+    }
+
+    @Test
+    public void statesWithPopulationsOverTenMillionTest() {
+        String testName = "statesWithPopulationsOverTenMillionTest";
+        AggregationOutput output = AggregateBuilder.aggregate(collection)
+                .group(GroupBuilder.start()
+                        .put("_id").to("$state")
+                        .put("totalPop").sum("$pop")
+                        .get()
+                )
+                .match(QueryBuilder.start()
+                        .put("totalPop").greaterThanEquals(10 * 1000 * 1000)
+                        .get()
+                )
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void averageCityPopulationByStateTest() {
+        String testName = "averageCityPopulationByStateTest";
+        AggregationOutput output = AggregateBuilder
+                .aggregate(collection)
+                .group(GroupBuilder.start()
+                        .put("_id")
+                        .to(newMap("state", "$state", "city", "$city"))
+                        .put("pop").sum("$pop")
+                        .get()
+                )
+                .group(GroupBuilder.start()
+                        .put("_id").to("$_id.state")
+                        .put("avgCityPop").avg("$pop")
+                        .get()
+                )
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+
+    @Test
+    public void largestAndSmallestCitiesByStateTest() {
+        String testName = "largestAndSmallestCitiesByStateTest";
+        AggregationOutput output = AggregateBuilder
+                .aggregate(collection)
+                .group(GroupBuilder.start()
+                        .put("_id")
+                        .to(newMap("state", "$state", "city", "$city"))
+                        .put("pop").sum("$pop")
+                        .get()
+                )
+                .sort(newMap("sort", 1))
+                .group(GroupBuilder.start()
+                        .put("_id").to("$_id.state")
+                        .put("biggestCity").last("$_id.city")
+                        .put("biggestPop").last("$pop")
+                        .put("smallestCity").first("$_id.city")
+                        .put("smallestPop").first("$pop")
+                        .get()
+                )
+                .project(
+                        newMap(
+                                "_id",
+                                0,
+                                "state",
+                                "$_id",
+                                "biggestCity",
+                                newMap("name", "$biggestCity", "pop",
+                                        "$biggestPop"),
+                                "smallestCity",
+                                newMap("name", "$smallestCity", "pop",
+                                        "$smallestPop")
+                        ))
+                .run();
+        verifyAggregationOutputFromResources(testName, output);
+    }
+}

src/test/java/org/bitbucket/davidm24/mongodb/aggregate/DocumentationExamplesTest.java

-/**
- *      Copyright (C) 2012 David M. Carr
- *
- *   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 org.bitbucket.davidm24.mongodb.aggregate;
-
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.mongodb.AggregationOutput;
-import com.mongodb.DBCollection;
-import com.mongodb.QueryBuilder;
-
-/**
- * Tests based on the examples in the MongoDB <a
- * href="http://docs.mongodb.org/manual/tutorial/aggregation-examples/"
- * >Aggregation Framework Examples</a> documentation.
- * 
- * @author David M. Carr
- */
-public class DocumentationExamplesTest extends AggregationTestCase {
-    private DBCollection collection;
-
-    @BeforeClass
-    public void importData() {
-        collection = getCollection("zipcodes");
-        importData(collection, "zips.json");
-        assertEquals(29467, collection.count());
-    }
-
-    @Test
-    public void statesWithPopulationsOverTenMillionTest() {
-        String testName = "statesWithPopulationsOverTenMillionTest";
-        AggregationOutput output = AggregateBuilder.aggregate(collection)
-                .group(GroupBuilder.start()
-                        .put("_id").to("$state")
-                        .put("totalPop").sum("$pop")
-                        .get()
-                )
-                .match(QueryBuilder.start()
-                        .put("totalPop").greaterThanEquals(10 * 1000 * 1000)
-                        .get()
-                )
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void averageCityPopulationByStateTest() {
-        String testName = "averageCityPopulationByStateTest";
-        AggregationOutput output = AggregateBuilder
-                .aggregate(collection)
-                .group(GroupBuilder.start()
-                        .put("_id")
-                        .to(newMap("state", "$state", "city", "$city"))
-                        .put("pop").sum("$pop")
-                        .get()
-                )
-                .group(GroupBuilder.start()
-                        .put("_id").to("$_id.state")
-                        .put("avgCityPop").avg("$pop")
-                        .get()
-                )
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-
-    @Test
-    public void largestAndSmallestCitiesByStateTest() {
-        String testName = "largestAndSmallestCitiesByStateTest";
-        AggregationOutput output = AggregateBuilder
-                .aggregate(collection)
-                .group(GroupBuilder.start()
-                        .put("_id")
-                        .to(newMap("state", "$state", "city", "$city"))
-                        .put("pop").sum("$pop")
-                        .get()
-                )
-                .sort(newMap("sort", 1))
-                .group(GroupBuilder.start()
-                        .put("_id").to("$_id.state")
-                        .put("biggestCity").last("$_id.city")
-                        .put("biggestPop").last("$pop")
-                        .put("smallestCity").first("$_id.city")
-                        .put("smallestPop").first("$pop")
-                        .get()
-                )
-                .project(
-                        newMap(
-                                "_id",
-                                0,
-                                "state",
-                                "$_id",
-                                "biggestCity",
-                                newMap("name", "$biggestCity", "pop",
-                                        "$biggestPop"),
-                                "smallestCity",
-                                newMap("name", "$smallestCity", "pop",
-                                        "$smallestPop")
-                        ))
-                .run();
-        verifyAggregationOutputFromResources(testName, output);
-    }
-}

src/test/java/org/bitbucket/davidm24/mongodb/aggregate/GroupBuilderTest.java

 
 import org.testng.annotations.Test;
 
+import com.mongodb.util.TestCase;
+
 /**
  * Tests for {@link GroupBuilder}.
  * 
  * @author David M. Carr
  */
-public class GroupBuilderTest extends AggregationTestCase {
+public class GroupBuilderTest extends TestCase {
     @Test
     public void addToSetTest() {
         String expected = "{ \"targetField\" : { \"$addToSet\" : \"$operand\"}}";