Add initial test base for aerorospike module
Project: http://git-wip-us.apache.org/repos/asf/gora/repo Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/7c3390d0 Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/7c3390d0 Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/7c3390d0 Branch: refs/heads/master Commit: 7c3390d0a7cf72afe3ffb3e3748f993e85cce48b Parents: d68be8d Author: nishadi <ndime...@gmail.com> Authored: Fri Jun 23 19:37:05 2017 +0530 Committer: nishadi <ndime...@gmail.com> Committed: Fri Jun 23 19:37:05 2017 +0530 ---------------------------------------------------------------------- gora-aerospike/pom.xml | 9 +- .../src/test/conf/gora-aerospike-mapping.xml | 49 +++ gora-aerospike/src/test/conf/gora.properties | 17 + .../gora/aerospike/GoraAerospikeTestDriver.java | 74 +++++ .../org/apache/gora/aerospike/package-info.java | 17 + .../aerospike/store/TestAerospikeStore.java | 330 +++++++++++++++++++ .../gora/aerospike/store/package-info.java | 21 ++ pom.xml | 6 + 8 files changed, 522 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/gora/blob/7c3390d0/gora-aerospike/pom.xml ---------------------------------------------------------------------- diff --git a/gora-aerospike/pom.xml b/gora-aerospike/pom.xml index b15693e..828f45d 100644 --- a/gora-aerospike/pom.xml +++ b/gora-aerospike/pom.xml @@ -63,7 +63,7 @@ <sourceDirectory>src/main/java</sourceDirectory> <testResources> <testResource> - <directory>${project.basedir}/src/test/resources</directory> + <directory>${project.basedir}/src/test/conf</directory> <includes> <include>**/*</include> </includes> @@ -141,6 +141,13 @@ <artifactId>junit</artifactId> </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>testcontainers</artifactId> + <version>1.1.0</version> + <scope>test</scope> + </dependency> + </dependencies> </project> http://git-wip-us.apache.org/repos/asf/gora/blob/7c3390d0/gora-aerospike/src/test/conf/gora-aerospike-mapping.xml ---------------------------------------------------------------------- diff --git a/gora-aerospike/src/test/conf/gora-aerospike-mapping.xml b/gora-aerospike/src/test/conf/gora-aerospike-mapping.xml new file mode 100644 index 0000000..f3f6eee --- /dev/null +++ b/gora-aerospike/src/test/conf/gora-aerospike-mapping.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<gora-otd> + + <class name="org.apache.gora.examples.generated.Employee" keyClass="java.lang.String" + set="Employee" namespace = "test"> + <field name="name" bin="name"/> + <field name="dateOfBirth" bin="dateOfBirth"/> + <field name="ssn" bin="ssn"/> + <field name="salary" bin="salary"/> + <field name="boss" bin="boss"/> + <field name="webpage" bin="webpage"/> + </class> + + <class name="org.apache.gora.examples.generated.WebPage" keyClass="java.lang.String" + table="WebPage" namespace = "test"> + <field name="url" bin="url"/> + <field name="content" bin="content"/> + <field name="parsedContent" bin="parsedContent"/> + <field name="outlinks" bin="outlinks"/> + <field name="headers" bin="headers"/> + <field name="metadata" bin="metadata"/> + <field name="byteData" bin="byteData"/> + <field name="stringData" bin="stringData"/> + </class> + + + <class name="org.apache.gora.examples.generated.TokenDatum" keyClass="java.lang.String" namespace = "test"> + <field name="count" bin="count"/> + </class> + +</gora-otd> http://git-wip-us.apache.org/repos/asf/gora/blob/7c3390d0/gora-aerospike/src/test/conf/gora.properties ---------------------------------------------------------------------- diff --git a/gora-aerospike/src/test/conf/gora.properties b/gora-aerospike/src/test/conf/gora.properties new file mode 100644 index 0000000..c0230ec --- /dev/null +++ b/gora-aerospike/src/test/conf/gora.properties @@ -0,0 +1,17 @@ +# 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. + +gora.datastore.default=org.apache.gora.aerospike.store.AerospikeStore +gora.datastore.mapping.file=gora-aerospike-mapping.xml \ No newline at end of file http://git-wip-us.apache.org/repos/asf/gora/blob/7c3390d0/gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java ---------------------------------------------------------------------- diff --git a/gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java b/gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java new file mode 100644 index 0000000..1281d9b --- /dev/null +++ b/gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java @@ -0,0 +1,74 @@ +/* + * 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.aerospike; + +import org.apache.gora.GoraTestDriver; +import org.apache.gora.aerospike.store.AerospikeStore; +import org.apache.gora.persistency.Persistent; +import org.apache.gora.store.DataStore; +import org.apache.gora.store.DataStoreFactory; +import org.apache.gora.util.GoraException; +import org.testcontainers.containers.GenericContainer; + +import java.util.Properties; + +/** + * Helper class for third part tests using gora-aerospike backend. + * @see GoraTestDriver + */ +public class GoraAerospikeTestDriver extends GoraTestDriver { + + private GenericContainer aerospikeContainer; + private Properties properties = DataStoreFactory.createProps(); + + public GoraAerospikeTestDriver(GenericContainer aerospikeContainer) { + super(AerospikeStore.class); + this.aerospikeContainer = aerospikeContainer; + } + + @Override + public void setUpClass() throws Exception { + properties.setProperty("server.ip", "localhost"); + properties.setProperty("server.port", aerospikeContainer.getMappedPort(3000).toString()); + } + + @Override + public void tearDownClass() throws Exception { + } + + /** + * Instantiate a new {@link DataStore}. Uses 'null' schema. + * + * @param keyClass The key class. + * @param persistentClass The value class. + * @return A new store instance. + * @throws GoraException + */ + @Override + public <K, T extends Persistent> DataStore<K, T> createDataStore(Class<K> keyClass, Class<T> persistentClass) + throws GoraException { + + final DataStore<K, T> dataStore = DataStoreFactory + .createDataStore((Class<? extends DataStore<K, T>>) dataStoreClass, keyClass, persistentClass, conf, + properties); + dataStores.add(dataStore); + log.info("Datastore for {} was added.", persistentClass); + return dataStore; + } +} http://git-wip-us.apache.org/repos/asf/gora/blob/7c3390d0/gora-aerospike/src/test/java/org/apache/gora/aerospike/package-info.java ---------------------------------------------------------------------- diff --git a/gora-aerospike/src/test/java/org/apache/gora/aerospike/package-info.java b/gora-aerospike/src/test/java/org/apache/gora/aerospike/package-info.java new file mode 100644 index 0000000..9eb6fbf --- /dev/null +++ b/gora-aerospike/src/test/java/org/apache/gora/aerospike/package-info.java @@ -0,0 +1,17 @@ +/* + * 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.aerospike; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/gora/blob/7c3390d0/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/TestAerospikeStore.java ---------------------------------------------------------------------- diff --git a/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/TestAerospikeStore.java b/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/TestAerospikeStore.java new file mode 100644 index 0000000..e1af3cd --- /dev/null +++ b/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/TestAerospikeStore.java @@ -0,0 +1,330 @@ +/* + * 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.aerospike.store; + +import org.apache.gora.aerospike.GoraAerospikeTestDriver; +import org.apache.gora.examples.generated.Employee; +import org.apache.gora.examples.generated.WebPage; +import org.apache.gora.store.DataStoreFactory; +import org.apache.gora.store.DataStoreTestBase; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; +import org.testcontainers.containers.GenericContainer; + +import java.io.IOException; + +/** + * Test case for AerospikeStore. + */ +public class TestAerospikeStore extends DataStoreTestBase { + + private static final String DOCKER_CONTAINER_NAME = "aerospike:3.14.0"; + + @ClassRule + public static GenericContainer aerospikeContainer = new GenericContainer(DOCKER_CONTAINER_NAME); + + static { + setTestDriver(new GoraAerospikeTestDriver(aerospikeContainer)); + } + + @Override + public void setUp() throws Exception { + super.setUp(); + } + + @Override + public void tearDown() throws Exception { + super.tearDown(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testNewInstance() throws Exception { + // super.testNewInstance(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testCreateSchema() throws Exception { + // super.testCreateSchema(); + } + + @Override + public void assertSchemaExists(String schemaName) throws Exception { + super.assertSchemaExists(schemaName); + } + + @Test + @Ignore("To be implemented") + @Override + public void testAutoCreateSchema() throws Exception { + super.testAutoCreateSchema(); + } + + @Test + @Ignore("To be implemented") + @Override + public void assertAutoCreateSchema() throws Exception { + super.assertAutoCreateSchema(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testTruncateSchema() throws Exception { + super.testTruncateSchema(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testDeleteSchema() throws Exception { + super.testDeleteSchema(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testSchemaExists() throws Exception { + super.testSchemaExists(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testPut() throws Exception { + super.testPut(); + } + + @Override + public void assertPut(Employee employee) throws IOException { + super.assertPut(employee); + } + + @Test + @Ignore("To be implemented") + @Override + public void testPutNested() throws Exception { + super.testPutNested(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testPutArray() throws Exception { + super.testPutArray(); + } + + @Test + @Ignore("To be implemented") + @Override + public void assertPutArray() throws IOException { + super.assertPutArray(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testPutBytes() throws Exception { + super.testPutBytes(); + } + + @Override + public void assertPutBytes(byte[] contentBytes) throws IOException { + super.assertPutBytes(contentBytes); + } + + @Test + @Ignore("To be implemented") + @Override + public void testPutMap() throws Exception { + super.testPutMap(); + } + + @Test + @Ignore("To be implemented") + @Override + public void assertPutMap() throws IOException { + super.assertPutMap(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testPutMixedMaps() throws Exception { + super.testPutMixedMaps(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testUpdate() throws Exception { + super.testUpdate(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testEmptyUpdate() throws Exception { + super.testEmptyUpdate(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testGet() throws Exception { + super.testGet(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testGetRecursive() throws Exception { + super.testGetRecursive(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testGetDoubleRecursive() throws Exception { + super.testGetDoubleRecursive(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testGetNested() throws Exception { + super.testGetNested(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testGet3UnionField() throws Exception { + super.testGet3UnionField(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testGetWithFields() throws Exception { + super.testGetWithFields(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testGetWebPage() throws Exception { + super.testGetWebPage(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testGetWebPageDefaultFields() throws Exception { + super.testGetWebPageDefaultFields(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testGetNonExisting() throws Exception { + super.testGetNonExisting(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testQuery() throws Exception { + super.testQuery(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testQueryStartKey() throws Exception { + super.testQueryStartKey(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testQueryEndKey() throws Exception { + super.testQueryEndKey(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testQueryKeyRange() throws Exception { + super.testQueryKeyRange(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testQueryWebPageSingleKey() throws Exception { + super.testQueryWebPageSingleKey(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testQueryWebPageSingleKeyDefaultFields() throws Exception { + super.testQueryWebPageSingleKeyDefaultFields(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testQueryWebPageQueryEmptyResults() throws Exception { + super.testQueryWebPageQueryEmptyResults(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testDelete() throws Exception { + super.testDelete(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testDeleteByQuery() throws Exception { + super.testDeleteByQuery(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testDeleteByQueryFields() throws Exception { + super.testDeleteByQueryFields(); + } + + @Test + @Ignore("To be implemented") + @Override + public void testGetPartitions() throws Exception { + super.testGetPartitions(); + } +} http://git-wip-us.apache.org/repos/asf/gora/blob/7c3390d0/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/package-info.java ---------------------------------------------------------------------- diff --git a/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/package-info.java b/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/package-info.java new file mode 100644 index 0000000..69670f8 --- /dev/null +++ b/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/package-info.java @@ -0,0 +1,21 @@ +/* + * 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. + */ +/** + * This package contains all the unit tests for basic CRUD operations + * functionality of the Aerospike dataStore. + */ +package org.apache.gora.aerospike.store; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/gora/blob/7c3390d0/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index b81d7e6..2d05a71 100644 --- a/pom.xml +++ b/pom.xml @@ -939,6 +939,12 @@ <artifactId>gora-aerospike</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.apache.gora</groupId> + <artifactId>gora-aerospike</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + </dependency> <!-- End of Internal Depednecies --> <dependency>