You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gora.apache.org by le...@apache.org on 2014/06/04 18:37:03 UTC
[46/50] [abbrv] git commit: Add integration tests for MapReduce
feature
Add integration tests for MapReduce feature
* Fix gora-mongodb-mapping.xml for TokenDatum
* Add tests for TokenDatum and WordCount
Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/7eb27927
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/7eb27927
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/7eb27927
Branch: refs/heads/master
Commit: 7eb27927f2fdfdf2b6fb997f56297823f9920860
Parents: 0a2a72e
Author: Damien Raude-Morvan <da...@dictanova.com>
Authored: Sat May 24 23:56:06 2014 +0200
Committer: Damien Raude-Morvan <da...@dictanova.com>
Committed: Sat May 24 23:56:06 2014 +0200
----------------------------------------------------------------------
.../src/test/conf/gora-mongodb-mapping.xml | 4 +-
.../mongodb/mapreduce/GoraMongoMapredTest.java | 40 ++++++++++++++
.../mapreduce/TestMongoStoreCountQuery.java | 54 ++++++++++++++++++
.../mapreduce/TestMongoStoreWordCount.java | 58 ++++++++++++++++++++
4 files changed, 154 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/gora/blob/7eb27927/gora-mongodb/src/test/conf/gora-mongodb-mapping.xml
----------------------------------------------------------------------
diff --git a/gora-mongodb/src/test/conf/gora-mongodb-mapping.xml b/gora-mongodb/src/test/conf/gora-mongodb-mapping.xml
index d5c8229..1a0fbcb 100644
--- a/gora-mongodb/src/test/conf/gora-mongodb-mapping.xml
+++ b/gora-mongodb/src/test/conf/gora-mongodb-mapping.xml
@@ -35,8 +35,8 @@
<field name="metadata" docfield="metadata" type="document"/>
</class>
- <class name="org.apache.gora.examples.generated.TokenDatum" keyClass="java.lang.String" keyspace="TokenDatum">
- <field name="count" docfield="count" qualifier="int32"/>
+ <class name="org.apache.gora.examples.generated.TokenDatum" keyClass="java.lang.String" document="TokenDatum">
+ <field name="count" docfield="count" type="int32"/>
</class>
http://git-wip-us.apache.org/repos/asf/gora/blob/7eb27927/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/GoraMongoMapredTest.java
----------------------------------------------------------------------
diff --git a/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/GoraMongoMapredTest.java b/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/GoraMongoMapredTest.java
new file mode 100644
index 0000000..77cfc0d
--- /dev/null
+++ b/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/GoraMongoMapredTest.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.gora.mongodb.mapreduce;
+
+import org.apache.gora.GoraTestDriver;
+import org.apache.gora.mongodb.GoraMongodbTestDriver;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * Created by drazzib on 24/05/14.
+ */
+public class GoraMongoMapredTest {
+ protected static GoraTestDriver testDriver = new GoraMongodbTestDriver();
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ testDriver.setUpClass();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ testDriver.tearDownClass();
+ }
+}
http://git-wip-us.apache.org/repos/asf/gora/blob/7eb27927/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/TestMongoStoreCountQuery.java
----------------------------------------------------------------------
diff --git a/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/TestMongoStoreCountQuery.java b/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/TestMongoStoreCountQuery.java
new file mode 100644
index 0000000..7f1c9dc
--- /dev/null
+++ b/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/TestMongoStoreCountQuery.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.gora.mongodb.mapreduce;
+
+import org.apache.gora.examples.generated.Employee;
+import org.apache.gora.examples.generated.WebPage;
+import org.apache.gora.mapreduce.MapReduceTestUtils;
+import org.apache.gora.store.DataStore;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests related to {@link org.apache.gora.mongodb.store.MongoStore} using
+ * mapreduce.
+ */
+public class TestMongoStoreCountQuery extends GoraMongoMapredTest {
+
+ protected DataStore<String, Employee> employeeStore;
+ protected DataStore<String, WebPage> webPageStore;
+
+ @Before
+ public void setUp() throws Exception {
+ employeeStore = testDriver.createDataStore(String.class, Employee.class);
+ webPageStore = testDriver.createDataStore(String.class, WebPage.class);
+ testDriver.setUp();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ testDriver.tearDown();
+ }
+
+ @Test
+ public void testCountQuery() throws Exception {
+ MapReduceTestUtils.testCountQuery(webPageStore,
+ testDriver.getConfiguration());
+ }
+}
http://git-wip-us.apache.org/repos/asf/gora/blob/7eb27927/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/TestMongoStoreWordCount.java
----------------------------------------------------------------------
diff --git a/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/TestMongoStoreWordCount.java b/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/TestMongoStoreWordCount.java
new file mode 100644
index 0000000..d6a51a4
--- /dev/null
+++ b/gora-mongodb/src/test/java/org/apache/gora/mongodb/mapreduce/TestMongoStoreWordCount.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.gora.mongodb.mapreduce;
+
+import org.apache.gora.examples.generated.TokenDatum;
+import org.apache.gora.examples.generated.WebPage;
+import org.apache.gora.mapreduce.MapReduceTestUtils;
+import org.apache.gora.mongodb.store.MongoStore;
+import org.apache.gora.store.DataStoreFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests related to {@link org.apache.gora.mongodb.store.MongoStore} using
+ * mapreduce.
+ */
+public class TestMongoStoreWordCount extends GoraMongoMapredTest {
+
+ private MongoStore<String, WebPage> webPageStore;
+ private MongoStore<String, TokenDatum> tokenStore;
+
+ @Before
+ public void setUp() throws Exception {
+ webPageStore = DataStoreFactory.getDataStore(MongoStore.class,
+ String.class, WebPage.class, testDriver.getConfiguration());
+ tokenStore = DataStoreFactory.getDataStore(MongoStore.class, String.class,
+ TokenDatum.class, testDriver.getConfiguration());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ webPageStore.close();
+ tokenStore.close();
+ }
+
+ @Test
+ public void testWordCount() throws Exception {
+ MapReduceTestUtils.testWordCount(testDriver.getConfiguration(),
+ webPageStore, tokenStore);
+ }
+
+}