You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/11/04 07:14:15 UTC
ignite git commit: IGNITE-1753 More tests.
Repository: ignite
Updated Branches:
refs/heads/ignite-1753-1282 7278e0367 -> 9fa6cad33
IGNITE-1753 More tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9fa6cad3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9fa6cad3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9fa6cad3
Branch: refs/heads/ignite-1753-1282
Commit: 9fa6cad336af5075cf00bf78be7f5ecc18ea1af4
Parents: 7278e03
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Wed Nov 4 13:14:15 2015 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Wed Nov 4 13:14:15 2015 +0700
----------------------------------------------------------------------
.../CacheJdbcPojoStoreAbstractSelfTest.java | 298 +++++++++++++++++++
...dbcPojoStoreOptimizedMarshallerSelfTest.java | 31 ++
...JdbcPojoStorePortableMarshallerSelfTest.java | 62 ++++
.../store/jdbc/CacheJdbcPojoStoreSelfTest.java | 77 -----
.../jdbc/CacheJdbcPortableStoreSelfTest.java | 73 -----
.../jdbc/CacheJdbcStoreAbstractSelfTest.java | 233 ---------------
.../ignite/testsuites/IgniteCacheTestSuite.java | 10 +-
7 files changed, 396 insertions(+), 388 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fa6cad3/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
new file mode 100644
index 0000000..7e6a823
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
@@ -0,0 +1,298 @@
+/*
+ * 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.ignite.cache.store.jdbc;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Types;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.store.jdbc.dialect.H2Dialect;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.ConnectorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.h2.jdbcx.JdbcConnectionPool;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+
+/**
+ * Class for {@code PojoCacheStore} tests.
+ */
+public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ protected static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** DB connection URL. */
+ protected static final String DFLT_CONN_URL = "jdbc:h2:mem:TestDatabase;DB_CLOSE_DELAY=-1";
+
+ /** Organization count. */
+ protected static final int ORGANIZATION_CNT = 1000;
+
+ /** Person count. */
+ protected static final int PERSON_CNT = 100000;
+
+ /** Flag indicating that tests should use primitive classes like java.lang.Integer for keys. */
+ protected static boolean builtinKeys = false;
+
+ /** Flag indicating that classes for keys available on class path or not. */
+ protected static boolean noKeyClasses = false;
+
+ /** Flag indicating that classes for values available on class path or not. */
+ protected static boolean noValClasses = false;
+
+ /**
+ * @return Connection to test in-memory H2 database.
+ * @throws SQLException
+ */
+ protected Connection getConnection() throws SQLException {
+ return DriverManager.getConnection(DFLT_CONN_URL, "sa", "");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ Connection conn = getConnection();
+
+ Statement stmt = conn.createStatement();
+
+ stmt.executeUpdate("DROP TABLE IF EXISTS Organization");
+ stmt.executeUpdate("DROP TABLE IF EXISTS Person");
+
+ stmt.executeUpdate("CREATE TABLE Organization (id integer PRIMARY KEY, name varchar(50), city varchar(50))");
+ stmt.executeUpdate("CREATE TABLE Person (id integer PRIMARY KEY, org_id integer, name varchar(50))");
+
+ conn.commit();
+
+ U.closeQuiet(stmt);
+
+ fillSampleDatabase(conn);
+
+ U.closeQuiet(conn);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ cfg.setCacheConfiguration(cacheConfiguration());
+
+ cfg.setMarshaller(marshaller());
+
+ ConnectorConfiguration connCfg = new ConnectorConfiguration();
+ cfg.setConnectorConfiguration(connCfg);
+
+ return cfg;
+ }
+
+ /**
+ * @return Marshaller to be used in test.
+ */
+ protected abstract Marshaller marshaller();
+
+ /**
+ * @return Store configuration.
+ */
+ protected CacheJdbcPojoStoreConfiguration storeConfiguration() {
+ CacheJdbcPojoStoreConfiguration storeCfg = new CacheJdbcPojoStoreConfiguration();
+
+ storeCfg.setDialect(new H2Dialect());
+
+ storeCfg.setTypes(storeTypes());
+
+ return storeCfg;
+ }
+
+ /**
+ * @return Types to be used in test.
+ */
+ protected JdbcType[] storeTypes() {
+ JdbcType[] storeTypes = new JdbcType[2];
+
+ storeTypes[0] = new JdbcType();
+ storeTypes[0].setDatabaseSchema("PUBLIC");
+ storeTypes[0].setDatabaseTable("ORGANIZATION");
+
+ if (builtinKeys) {
+ storeTypes[0].setKeyType("java.lang.Integer");
+ storeTypes[0].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"));
+ }
+ else {
+ storeTypes[0].setKeyType("org.apache.ignite.cache.store.jdbc.model.OrganizationKey" + (noKeyClasses ? "1" : ""));
+ storeTypes[0].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"));
+ }
+
+ storeTypes[0].setValueType("org.apache.ignite.cache.store.jdbc.model.Organization" + (noValClasses ? "1" : ""));
+ storeTypes[0].setValueFields(
+ new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"),
+ new JdbcTypeField(Types.VARCHAR, "NAME", String.class, "name"),
+ new JdbcTypeField(Types.VARCHAR, "CITY", String.class, "city"));
+
+ storeTypes[1] = new JdbcType();
+ storeTypes[1].setDatabaseSchema("PUBLIC");
+ storeTypes[1].setDatabaseTable("PERSON");
+
+ if (builtinKeys) {
+ storeTypes[1].setKeyType("java.lang.Long");
+ storeTypes[1].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Long.class, "id"));
+ }
+ else {
+ storeTypes[1].setKeyType("org.apache.ignite.cache.store.jdbc.model.PersonKey" + (noKeyClasses ? "1" : ""));
+ storeTypes[1].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"));
+ }
+
+ storeTypes[1].setValueType("org.apache.ignite.cache.store.jdbc.model.Person" + (noValClasses ? "1" : ""));
+ storeTypes[1].setValueFields(
+ new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"),
+ new JdbcTypeField(Types.INTEGER, "ORG_ID", Integer.class, "orgId"),
+ new JdbcTypeField(Types.VARCHAR, "NAME", String.class, "name"));
+
+ return storeTypes;
+ }
+
+ /**
+ * @return Cache configuration for test.
+ * @throws Exception In case when failed to create cache configuration.
+ */
+ protected CacheConfiguration cacheConfiguration() throws Exception {
+ CacheConfiguration cc = defaultCacheConfiguration();
+
+ cc.setCacheMode(PARTITIONED);
+ cc.setAtomicityMode(ATOMIC);
+ cc.setSwapEnabled(false);
+ cc.setWriteBehindEnabled(false);
+
+ CacheJdbcPojoStoreFactory<Object, Object> storeFactory = new CacheJdbcPojoStoreFactory<>();
+ storeFactory.setConfiguration(storeConfiguration());
+ storeFactory.setDataSource(JdbcConnectionPool.create(DFLT_CONN_URL, "sa", "")); // H2 DataSource
+
+ cc.setCacheStoreFactory(storeFactory);
+ cc.setReadThrough(true);
+ cc.setWriteThrough(true);
+ cc.setLoadPreviousValue(true);
+
+ return cc;
+ }
+
+ /**
+ * Fill in-memory database with sample data.
+ *
+ * @param conn Connection to database.
+ * @throws SQLException In case of filling database with sample data failed.
+ */
+ protected void fillSampleDatabase(Connection conn) throws SQLException {
+ info("Start to fill sample database...");
+
+ PreparedStatement orgStmt = conn.prepareStatement("INSERT INTO Organization(id, name, city) VALUES (?, ?, ?)");
+
+ for (int i = 0; i < ORGANIZATION_CNT; i++) {
+ orgStmt.setInt(1, i);
+ orgStmt.setString(2, "name" + i);
+ orgStmt.setString(3, "city" + i % 10);
+
+ orgStmt.addBatch();
+ }
+
+ orgStmt.executeBatch();
+
+ U.closeQuiet(orgStmt);
+
+ conn.commit();
+
+ PreparedStatement prnStmt = conn.prepareStatement("INSERT INTO Person(id, org_id, name) VALUES (?, ?, ?)");
+
+ for (int i = 0; i < PERSON_CNT; i++) {
+ prnStmt.setInt(1, i);
+ prnStmt.setInt(2, i % 100);
+ prnStmt.setString(3, "name" + i);
+
+ prnStmt.addBatch();
+ }
+
+ prnStmt.executeBatch();
+
+ conn.commit();
+
+ U.closeQuiet(prnStmt);
+
+ info("Sample database prepared.");
+ }
+
+ /**
+ * Start test grid with specified options.
+ *
+ * @param pk {@code True} if keys are built in java types.
+ * @param noKeyCls {@code True} if keys classes are not on class path.
+ * @param noValCls {@code True} if values classes are not on class path.
+ * @throws Exception
+ */
+ protected void startTestGrid(boolean pk, boolean noKeyCls, boolean noValCls) throws Exception {
+ builtinKeys = pk;
+ noKeyClasses = noKeyCls;
+ noValClasses = noValCls;
+
+ startGrid();
+ }
+
+ /**
+ * Check that data was loaded correctly.
+ */
+ protected void checkCacheContent() {
+ IgniteCache<Object, Object> c1 = grid().cache(null);
+
+ c1.loadCache(null);
+
+ assertEquals(ORGANIZATION_CNT + PERSON_CNT, c1.size());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLoadCache() throws Exception {
+ startTestGrid(false, false, false);
+
+ checkCacheContent();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLoadCachePrimitiveKeys() throws Exception {
+ startTestGrid(true, false, false);
+
+ checkCacheContent();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fa6cad3/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreOptimizedMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreOptimizedMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreOptimizedMarshallerSelfTest.java
new file mode 100644
index 0000000..f40f7d7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreOptimizedMarshallerSelfTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.ignite.cache.store.jdbc;
+
+import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+
+/**
+ * Class for {@code PojoCacheStore} tests.
+ */
+public class CacheJdbcPojoStoreOptimizedMarshallerSelfTest extends CacheJdbcPojoStoreAbstractSelfTest {
+ /** {@inheritDoc} */
+ @Override protected Marshaller marshaller(){
+ return new OptimizedMarshaller();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fa6cad3/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStorePortableMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStorePortableMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStorePortableMarshallerSelfTest.java
new file mode 100644
index 0000000..4953a42
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStorePortableMarshallerSelfTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.ignite.cache.store.jdbc;
+
+import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+
+/**
+ * Class for {@code PojoCacheStore} tests.
+ */
+public class CacheJdbcPojoStorePortableMarshallerSelfTest extends CacheJdbcPojoStoreAbstractSelfTest {
+ /** {@inheritDoc} */
+ @Override protected Marshaller marshaller(){
+ PortableMarshaller marshaller = new PortableMarshaller();
+
+ marshaller.setMetaDataEnabled(false);
+
+ return marshaller;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLoadCacheNoKeyClasses() throws Exception {
+ startTestGrid(false, true, false);
+
+ checkCacheContent();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLoadCacheNoValueClasses() throws Exception {
+ startTestGrid(false, false, true);
+
+ checkCacheContent();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLoadCacheNoKeyAndValueClasses() throws Exception {
+ startTestGrid(false, true, true);
+
+ checkCacheContent();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fa6cad3/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreSelfTest.java
deleted file mode 100644
index f32d864..0000000
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreSelfTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.ignite.cache.store.jdbc;
-
-import java.sql.Types;
-import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
-
-/**
- * Class for {@code PojoCacheStore} tests.
- */
-public class CacheJdbcPojoStoreSelfTest extends CacheJdbcStoreAbstractSelfTest {
- /** {@inheritDoc} */
- @Override protected Marshaller marshaller(){
- return new OptimizedMarshaller();
- }
-
- /** {@inheritDoc} */
- @Override protected JdbcType[] storeTypes() {
- JdbcType[] storeTypes = new JdbcType[2];
-
- storeTypes[0] = new JdbcType();
- storeTypes[0].setDatabaseSchema("PUBLIC");
- storeTypes[0].setDatabaseTable("ORGANIZATION");
-
- if (primitiveKeys) {
- storeTypes[0].setKeyType("java.lang.Integer");
- storeTypes[0].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"));
- }
- else {
- storeTypes[0].setKeyType("org.apache.ignite.cache.store.jdbc.model.OrganizationKey");
- storeTypes[0].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"));
- }
-
- storeTypes[0].setValueType("org.apache.ignite.cache.store.jdbc.model.Organization");
- storeTypes[0].setValueFields(
- new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"),
- new JdbcTypeField(Types.VARCHAR, "NAME", String.class, "name"),
- new JdbcTypeField(Types.VARCHAR, "CITY", String.class, "city"));
-
- storeTypes[1] = new JdbcType();
- storeTypes[1].setDatabaseSchema("PUBLIC");
- storeTypes[1].setDatabaseTable("PERSON");
-
- if (primitiveKeys) {
- storeTypes[1].setKeyType("java.lang.Long");
- storeTypes[1].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Long.class, "id"));
- }
- else {
- storeTypes[1].setKeyType("org.apache.ignite.cache.store.jdbc.model.PersonKey");
- storeTypes[1].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"));
- }
-
- storeTypes[1].setValueType("org.apache.ignite.cache.store.jdbc.model.Person");
- storeTypes[1].setValueFields(
- new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"),
- new JdbcTypeField(Types.INTEGER, "ORG_ID", Integer.class, "orgId"),
- new JdbcTypeField(Types.VARCHAR, "NAME", String.class, "name"));
-
- return storeTypes;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fa6cad3/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPortableStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPortableStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPortableStoreSelfTest.java
deleted file mode 100644
index 20a5fdf..0000000
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPortableStoreSelfTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.ignite.cache.store.jdbc;
-
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-
-/**
- * Class for {@code PojoCacheStore} tests.
- */
-public class CacheJdbcPortableStoreSelfTest extends CacheJdbcStoreAbstractSelfTest {
- /** {@inheritDoc} */
- @Override protected Marshaller marshaller(){
- PortableMarshaller marsh = new PortableMarshaller();
-
- Collection<String> clsNames = new ArrayList<>();
- clsNames.add("org.apache.ignite.cache.store.jdbc.model.OrganizationKey");
- clsNames.add("org.apache.ignite.cache.store.jdbc.model.Organization");
- clsNames.add("org.apache.ignite.cache.store.jdbc.model.PersonKey");
- clsNames.add("org.apache.ignite.cache.store.jdbc.model.Person");
-
- marsh.setClassNames(clsNames);
-
- return marsh;
- }
-
- /** {@inheritDoc} */
- @Override protected JdbcType[] storeTypes() {
- JdbcType[] storeTypes = new JdbcType[2];
-
- storeTypes[0] = new JdbcType();
- storeTypes[0].setDatabaseSchema("PUBLIC");
- storeTypes[0].setDatabaseTable("ORGANIZATION");
- storeTypes[0].setKeyType("org.apache.ignite.cache.store.jdbc.model.OrganizationKey");
- storeTypes[0].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"));
- storeTypes[0].setValueType("org.apache.ignite.cache.store.jdbc.model.Organization");
- storeTypes[0].setValueFields(
- new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"),
- new JdbcTypeField(Types.VARCHAR, "NAME", String.class, "name"),
- new JdbcTypeField(Types.VARCHAR, "CITY", String.class, "city"));
-
- storeTypes[1] = new JdbcType();
- storeTypes[1].setDatabaseSchema("PUBLIC");
- storeTypes[1].setDatabaseTable("PERSON");
- storeTypes[1].setKeyType("org.apache.ignite.cache.store.jdbc.model.PersonKey");
- storeTypes[1].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"));
- storeTypes[1].setValueType("org.apache.ignite.cache.store.jdbc.model.Person");
- storeTypes[1].setValueFields(
- new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"),
- new JdbcTypeField(Types.INTEGER, "ORG_ID", Integer.class, "orgId"),
- new JdbcTypeField(Types.VARCHAR, "NAME", String.class, "name"));
-
- return storeTypes;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fa6cad3/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractSelfTest.java
deleted file mode 100644
index 3f0e794..0000000
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractSelfTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * 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.ignite.cache.store.jdbc;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Statement;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.store.jdbc.dialect.H2Dialect;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.ConnectorConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.h2.jdbcx.JdbcConnectionPool;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-
-/**
- * Class for {@code PojoCacheStore} tests.
- */
-public abstract class CacheJdbcStoreAbstractSelfTest extends GridCommonAbstractTest {
- /** IP finder. */
- protected static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
- /** DB connection URL. */
- protected static final String DFLT_CONN_URL = "jdbc:h2:mem:TestDatabase;DB_CLOSE_DELAY=-1";
-
- /** Organization count. */
- protected static final int ORGANIZATION_CNT = 1000;
-
- /** Person count. */
- protected static final int PERSON_CNT = 100000;
-
- /** Flag indicating that tests should use primitive classes like java.lang.Integer for keys. */
- protected static boolean primitiveKeys = false;
-
- /**
- * @return Connection to test in-memory H2 database.
- * @throws SQLException
- */
- protected Connection getConnection() throws SQLException {
- return DriverManager.getConnection(DFLT_CONN_URL, "sa", "");
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- Connection conn = getConnection();
-
- Statement stmt = conn.createStatement();
-
- stmt.executeUpdate("DROP TABLE IF EXISTS Organization");
- stmt.executeUpdate("DROP TABLE IF EXISTS Person");
-
- stmt.executeUpdate("CREATE TABLE Organization (id integer PRIMARY KEY, name varchar(50), city varchar(50))");
- stmt.executeUpdate("CREATE TABLE Person (id integer PRIMARY KEY, org_id integer, name varchar(50))");
-
- conn.commit();
-
- U.closeQuiet(stmt);
-
- fillSampleDatabase(conn);
-
- U.closeQuiet(conn);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
- disco.setIpFinder(IP_FINDER);
-
- cfg.setDiscoverySpi(disco);
-
- cfg.setCacheConfiguration(cacheConfiguration());
-
- cfg.setMarshaller(marshaller());
-
- ConnectorConfiguration connCfg = new ConnectorConfiguration();
- cfg.setConnectorConfiguration(connCfg);
-
- return cfg;
- }
-
- /**
- * @return Marshaller to be used in test.
- */
- protected abstract Marshaller marshaller();
-
- /** */
- protected CacheJdbcPojoStoreConfiguration storeConfiguration() {
- CacheJdbcPojoStoreConfiguration storeCfg = new CacheJdbcPojoStoreConfiguration();
-
- storeCfg.setDialect(new H2Dialect());
-
- storeCfg.setTypes(storeTypes());
-
- return storeCfg;
- }
-
- /**
- * @return Types to be used in test.
- */
- protected abstract JdbcType[] storeTypes();
-
- /** */
- protected CacheConfiguration cacheConfiguration() throws Exception {
- CacheConfiguration cc = defaultCacheConfiguration();
-
- cc.setCacheMode(PARTITIONED);
- cc.setAtomicityMode(ATOMIC);
- cc.setSwapEnabled(false);
- cc.setWriteBehindEnabled(false);
-
- CacheJdbcPojoStoreFactory<Object, Object> storeFactory = new CacheJdbcPojoStoreFactory<>();
- storeFactory.setConfiguration(storeConfiguration());
- storeFactory.setDataSource(JdbcConnectionPool.create(DFLT_CONN_URL, "sa", "")); // H2 DataSource
-
- cc.setCacheStoreFactory(storeFactory);
- cc.setReadThrough(true);
- cc.setWriteThrough(true);
- cc.setLoadPreviousValue(true);
-
- return cc;
- }
-
- /**
- * Fill in-memory database with sample data.
- *
- * @param conn Connection to database.
- * @throws SQLException In case of filling database with sample data failed.
- */
- protected void fillSampleDatabase(Connection conn) throws SQLException {
- info("Start to fill sample database...");
-
- PreparedStatement orgStmt = conn.prepareStatement("INSERT INTO Organization(id, name, city) VALUES (?, ?, ?)");
-
- for (int i = 0; i < ORGANIZATION_CNT; i++) {
- orgStmt.setInt(1, i);
- orgStmt.setString(2, "name" + i);
- orgStmt.setString(3, "city" + i % 10);
-
- orgStmt.addBatch();
- }
-
- orgStmt.executeBatch();
-
- U.closeQuiet(orgStmt);
-
- conn.commit();
-
- PreparedStatement prnStmt = conn.prepareStatement("INSERT INTO Person(id, org_id, name) VALUES (?, ?, ?)");
-
- for (int i = 0; i < PERSON_CNT; i++) {
- prnStmt.setInt(1, i);
- prnStmt.setInt(2, i % 100);
- prnStmt.setString(3, "name" + i);
-
- prnStmt.addBatch();
- }
-
- prnStmt.executeBatch();
-
- conn.commit();
-
- U.closeQuiet(prnStmt);
-
- info("Sample database prepared.");
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testLoadCache() throws Exception {
- primitiveKeys = false;
-
- startGrid();
-
- info("Execute testLoadCache...");
-
- IgniteCache<Object, Object> c1 = grid().cache(null);
-
- c1.loadCache(null);
-
- assertEquals(ORGANIZATION_CNT + PERSON_CNT, c1.size());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testLoadCachePrimitiveKeys() throws Exception {
- primitiveKeys = true;
-
- startGrid();
-
- info("Execute testLoadCachePrimitiveKeys...");
-
- IgniteCache<Object, Object> c1 = grid().cache(null);
-
- c1.loadCache(null);
-
- assertEquals(ORGANIZATION_CNT + PERSON_CNT, c1.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fa6cad3/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 9214393..d287692 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -30,9 +30,9 @@ import org.apache.ignite.cache.store.GridCacheBalancingStoreSelfTest;
import org.apache.ignite.cache.store.GridCacheLoadOnlyStoreAdapterSelfTest;
import org.apache.ignite.cache.store.StoreResourceInjectionSelfTest;
import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreMultitreadedSelfTest;
-import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreSelfTest;
+import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreOptimizedMarshallerSelfTest;
import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreTest;
-import org.apache.ignite.cache.store.jdbc.CacheJdbcPortableStoreSelfTest;
+import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStorePortableMarshallerSelfTest;
import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreMultithreadedSelfTest;
import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreSelfTest;
import org.apache.ignite.internal.processors.cache.CacheAffinityCallSelfTest;
@@ -140,7 +140,7 @@ public class IgniteCacheTestSuite extends TestSuite {
}
/**
- * @param ignoredTests
+ * @param ignoredTests Tests to ignore.
* @return Test suite.
* @throws Exception Thrown in case of the failure.
*/
@@ -211,8 +211,8 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(GridCacheJdbcBlobStoreSelfTest.class);
suite.addTestSuite(GridCacheJdbcBlobStoreMultithreadedSelfTest.class);
suite.addTestSuite(CacheJdbcPojoStoreTest.class);
- suite.addTestSuite(CacheJdbcPojoStoreSelfTest.class);
- suite.addTestSuite(CacheJdbcPortableStoreSelfTest.class);
+ suite.addTestSuite(CacheJdbcPojoStoreOptimizedMarshallerSelfTest.class);
+ suite.addTestSuite(CacheJdbcPojoStorePortableMarshallerSelfTest.class);
suite.addTestSuite(CacheJdbcPojoStoreMultitreadedSelfTest.class);
suite.addTestSuite(GridCacheBalancingStoreSelfTest.class);
suite.addTestSuite(GridCacheAffinityApiSelfTest.class);