Repository: incubator-ignite Updated Branches: refs/heads/ignite-32 7046d70e2 -> 38af46631
# IGNITE-32 WIP: Tests moved. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/38af4663 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/38af4663 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/38af4663 Branch: refs/heads/ignite-32 Commit: 38af46631ce6b93310fb89b39d28b1a3d54fc50e Parents: 7046d70 Author: AKuznetsov <[email protected]> Authored: Mon Jan 19 18:17:43 2015 +0700 Committer: AKuznetsov <[email protected]> Committed: Mon Jan 19 18:17:43 2015 +0700 ---------------------------------------------------------------------- modules/core/src/test/config/store/auto/all.xml | 186 +++++++++++++++++ .../auto/AbstractAutoCacheStoreSelfTest.java | 200 +++++++++++++++++++ .../store/auto/AutoCacheStoreSelfTest.java | 86 ++++++++ .../cache/store/auto/model/Organization.java | 154 ++++++++++++++ .../cache/store/auto/model/OrganizationKey.java | 97 +++++++++ .../ignite/cache/store/auto/model/Person.java | 154 ++++++++++++++ .../cache/store/auto/model/PersonKey.java | 97 +++++++++ modules/schema-load/pom.xml | 31 --- modules/schema-load/src/test/config/all.xml | 184 ----------------- .../java/org/apache/ignite/Organization.java | 137 ------------- .../java/org/apache/ignite/OrganizationKey.java | 80 -------- .../src/test/java/org/apache/ignite/Person.java | 137 ------------- .../test/java/org/apache/ignite/PersonKey.java | 80 -------- .../auto/AbstractAutoCacheStoreSelfTest.java | 195 ------------------ .../store/auto/AutoCacheStoreSelfTest.java | 46 ----- modules/schema-load/src/test/sql/sample.sql | 16 -- 16 files changed, 974 insertions(+), 906 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/core/src/test/config/store/auto/all.xml ---------------------------------------------------------------------- diff --git a/modules/core/src/test/config/store/auto/all.xml b/modules/core/src/test/config/store/auto/all.xml new file mode 100644 index 0000000..e260685 --- /dev/null +++ b/modules/core/src/test/config/store/auto/all.xml @@ -0,0 +1,186 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> + <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeMetadata"> + <property name="type" value="org.apache.ignite.cache.store.auto.model.Organization"/> + <property name="keyType" value="org.apache.ignite.cache.store.auto.model.OrganizationKey"/> + <property name="schema" value="PUBLIC"/> + <property name="tableName" value="ORGANIZATION"/> + <property name="keyDescriptors"> + <list> + <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> + <property name="javaName" value="id"/> + <property name="javaType" value="java.lang.Integer"/> + <property name="dbName" value="ID"/> + <property name="dbType" value="4"/> + </bean> + </list> + </property> + <property name="valueDescriptors"> + <list> + <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> + <property name="javaName" value="id"/> + <property name="javaType" value="java.lang.Integer"/> + <property name="dbName" value="ID"/> + <property name="dbType" value="4"/> + </bean> + <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> + <property name="javaName" value="name"/> + <property name="javaType" value="java.lang.String"/> + <property name="dbName" value="NAME"/> + <property name="dbType" value="12"/> + </bean> + <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> + <property name="javaName" value="city"/> + <property name="javaType" value="java.lang.String"/> + <property name="dbName" value="CITY"/> + <property name="dbType" value="12"/> + </bean> + </list> + </property> + <property name="queryFields"> + <map> + <entry key="id" value="java.lang.Integer"/> + <entry key="name" value="java.lang.String"/> + <entry key="city" value="java.lang.String"/> + </map> + </property> + <property name="ascendingFields"> + <map> + <entry key="id" value="java.lang.Integer"/> + <entry key="name" value="java.lang.String"/> + <entry key="city" value="java.lang.String"/> + </map> + </property> + <property name="groups"> + <map> + <entry key="primaryKeyD"> + <map> + <entry key="id"> + <bean class="org.apache.ignite.lang.IgniteBiTuple"> + <constructor-arg value="java.lang.Integer"/> + <constructor-arg value="false"/> + </bean> + </entry> + </map> + </entry> + <entry key="orgNameCityIdx"> + <map> + <entry key="name"> + <bean class="org.apache.ignite.lang.IgniteBiTuple"> + <constructor-arg value="java.lang.String"/> + <constructor-arg value="false"/> + </bean> + </entry> + <entry key="city"> + <bean class="org.apache.ignite.lang.IgniteBiTuple"> + <constructor-arg value="java.lang.String"/> + <constructor-arg value="false"/> + </bean> + </entry> + </map> + </entry> + <entry key="orgNameIdx"> + <map> + <entry key="name"> + <bean class="org.apache.ignite.lang.IgniteBiTuple"> + <constructor-arg value="java.lang.String"/> + <constructor-arg value="false"/> + </bean> + </entry> + </map> + </entry> + </map> + </property> + </bean> + <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeMetadata"> + <property name="type" value="org.apache.ignite.cache.store.auto.model.Person"/> + <property name="keyType" value="org.apache.ignite.cache.store.auto.model.PersonKey"/> + <property name="schema" value="PUBLIC"/> + <property name="tableName" value="PERSON"/> + <property name="keyDescriptors"> + <list> + <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> + <property name="javaName" value="id"/> + <property name="javaType" value="java.lang.Integer"/> + <property name="dbName" value="ID"/> + <property name="dbType" value="4"/> + </bean> + </list> + </property> + <property name="valueDescriptors"> + <list> + <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> + <property name="javaName" value="id"/> + <property name="javaType" value="java.lang.Integer"/> + <property name="dbName" value="ID"/> + <property name="dbType" value="4"/> + </bean> + <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> + <property name="javaName" value="orgId"/> + <property name="javaType" value="java.lang.Integer"/> + <property name="dbName" value="ORG_ID"/> + <property name="dbType" value="4"/> + </bean> + <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> + <property name="javaName" value="name"/> + <property name="javaType" value="java.lang.String"/> + <property name="dbName" value="NAME"/> + <property name="dbType" value="12"/> + </bean> + </list> + </property> + <property name="queryFields"> + <map> + <entry key="id" value="java.lang.Integer"/> + <entry key="orgId" value="java.lang.Integer"/> + <entry key="name" value="java.lang.String"/> + </map> + </property> + <property name="ascendingFields"> + <map> + <entry key="id" value="java.lang.Integer"/> + <entry key="name" value="java.lang.String"/> + </map> + </property> + <property name="descendingFields"> + <map> + <entry key="name" value="java.lang.String"/> + </map> + </property> + <property name="groups"> + <map> + <entry key="primaryKey8"> + <map> + <entry key="id"> + <bean class="org.apache.ignite.lang.IgniteBiTuple"> + <constructor-arg value="java.lang.Integer"/> + <constructor-arg value="false"/> + </bean> + </entry> + </map> + </entry> + <entry key="personNameIdx1"> + <map> + <entry key="name"> + <bean class="org.apache.ignite.lang.IgniteBiTuple"> + <constructor-arg value="java.lang.String"/> + <constructor-arg value="false"/> + </bean> + </entry> + </map> + </entry> + <entry key="personNameIdx2"> + <map> + <entry key="name"> + <bean class="org.apache.ignite.lang.IgniteBiTuple"> + <constructor-arg value="java.lang.String"/> + <constructor-arg value="true"/> + </bean> + </entry> + </map> + </entry> + </map> + </property> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/core/src/test/java/org/apache/ignite/cache/store/auto/AbstractAutoCacheStoreSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/auto/AbstractAutoCacheStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/AbstractAutoCacheStoreSelfTest.java new file mode 100644 index 0000000..514f05e --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/AbstractAutoCacheStoreSelfTest.java @@ -0,0 +1,200 @@ +/* + * 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.auto; + +import org.apache.ignite.*; +import org.apache.ignite.cache.store.auto.model.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.transactions.*; +import org.gridgain.grid.cache.store.auto.*; +import org.gridgain.grid.util.typedef.*; +import org.gridgain.grid.util.typedef.internal.*; +import org.gridgain.testframework.junits.cache.*; +import org.gridgain.testframework.junits.common.*; + +import java.sql.*; + +/** + * Base class for {@code AutoCacheStore} tests. + */ +abstract class AbstractAutoCacheStoreSelfTest extends GridCommonAbstractTest { + /** Organization count. */ + protected static final int ORGANIZATION_CNT = 1000; + + /** Person count. */ + protected static final int PERSON_CNT = 100000; + + /** */ + protected final AutoCacheStore<Object, Object> store; + + /** + * @throws Exception If failed. + */ + @SuppressWarnings({"AbstractMethodCallInConstructor", "OverriddenMethodCallDuringObjectConstruction"}) + protected AbstractAutoCacheStoreSelfTest() throws Exception { + super(false); + + store = store(); + + inject(store); + } + + /** + * @return Store. + */ + protected abstract AutoCacheStore<Object, Object> store() throws IgniteCheckedException; + + /** + * @param store Store. + * @throws Exception If failed. + */ + protected void inject(AutoCacheStore store) throws Exception { + getTestResources().inject(store); + } + + /** + * @throws Exception If failed. + */ + public void testLoadCache() throws Exception { + final T2<Integer, Integer> keys = new T2<>(0, 0); + + IgniteBiInClosure<Object, Object> c = new CI2<Object, Object>() { + @Override public void apply(Object k, Object v) { + assert keys.get1() != null; + assert keys.get2() != null; + + if (k instanceof OrganizationKey && v instanceof Organization) + keys.set1(keys.get1() + 1); + else if (k instanceof PersonKey && v instanceof Person) + keys.set2(keys.get2() + 1); + } + }; + + store.loadCache(c); + + assertEquals(new T2<>(ORGANIZATION_CNT, PERSON_CNT), keys); + } + + /** + * @throws Exception If failed. + */ + public void testStore() throws Exception { + // Create dummy transaction + IgniteTx tx = new GridAbstractCacheStoreSelfTest.DummyTx(); + + OrganizationKey k3 = new OrganizationKey(); + k3.setId(-3); + + OrganizationKey k4 = new OrganizationKey(); + k4.setId(-4); + + Organization v3 = new Organization(); + v3.setId(-3); + v3.setName("Test1"); + v3.setCity("Test2"); + + Organization v4 = new Organization(); + v4.setId(-4); + v4.setName("Test3"); + v4.setCity("Test4"); + + store.put(tx, k3, v3); + store.put(tx, k4, v4); + + store.txEnd(tx, true); + + assertEquals(v3, store.load(null, k3)); + assertEquals(v4, store.load(null, k4)); + + OrganizationKey k5 = new OrganizationKey(); + k5.setId(-5); + + assertNull(store.load(null, k5)); + + store.remove(tx, k3); + + assertNull(store.load(tx, k3)); + assertEquals(v4, store.load(tx, k4)); + + store.remove(tx, k4); + + assertNull(store.load(tx, k4)); + + store.putAll(tx, F.asMap(k3, v3, k4, v4)); + + assertEquals(v3, store.load(tx, k3)); + assertEquals(v4, store.load(tx, k4)); + + store.txEnd(tx, true); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + Class.forName("org.h2.Driver"); + Connection conn = DriverManager.getConnection("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", ""); + + 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))"); + + stmt.executeUpdate("CREATE INDEX Org_Name_IDX On Organization (name)"); + stmt.executeUpdate("CREATE INDEX Org_Name_City_IDX On Organization (name, city)"); + stmt.executeUpdate("CREATE INDEX Person_Name_IDX1 On Person (name)"); + stmt.executeUpdate("CREATE INDEX Person_Name_IDX2 On Person (name desc)"); + + conn.commit(); + + 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(); + + 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(stmt); + + U.closeQuiet(conn); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/core/src/test/java/org/apache/ignite/cache/store/auto/AutoCacheStoreSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/auto/AutoCacheStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/AutoCacheStoreSelfTest.java new file mode 100644 index 0000000..4ac5cb4 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/AutoCacheStoreSelfTest.java @@ -0,0 +1,86 @@ +/* + * 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.auto; + +import org.apache.ignite.*; +import org.gridgain.grid.cache.query.*; +import org.gridgain.grid.cache.store.auto.*; +import org.gridgain.grid.util.typedef.*; +import org.springframework.beans.*; +import org.springframework.beans.factory.xml.*; +import org.springframework.context.support.*; +import org.springframework.core.io.*; + +import java.io.*; +import java.net.*; +import java.util.*; + +/** + * Tests for {@code AutoCacheStore}. + */ +public class AutoCacheStoreSelfTest extends AbstractAutoCacheStoreSelfTest { + /** + * @throws Exception If failed. + */ + public AutoCacheStoreSelfTest() throws Exception { + } + + /** + * @return Store. + */ + @Override protected PojoCacheStore store() throws IgniteCheckedException { + PojoCacheStore store = new PojoCacheStore(); + + store.setConnUrl("jdbc:h2:mem:test"); + store.setUser("sa"); + store.setPassword(""); + + UrlResource metaUrl; + + try { + metaUrl = new UrlResource(new File("modules/core/src/test/config/store/auto/all.xml").toURI().toURL()); + } + catch (MalformedURLException e) { + throw new IgniteCheckedException("Failed to resolve metadata path [err=" + e.getMessage() + ']', e); + } + + try { + GenericApplicationContext springCtx = new GenericApplicationContext(); + + new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(metaUrl); + + springCtx.refresh(); + + Collection<GridCacheQueryTypeMetadata> typeMetadata = + springCtx.getBeansOfType(GridCacheQueryTypeMetadata.class).values(); + + store.setTypeMetadata(typeMetadata); + } + catch (BeansException e) { + if (X.hasCause(e, ClassNotFoundException.class)) + throw new IgniteCheckedException("Failed to instantiate Spring XML application context " + + "(make sure all classes used in Spring configuration are present at CLASSPATH) " + + "[springUrl=" + metaUrl + ']', e); + else + throw new IgniteCheckedException("Failed to instantiate Spring XML application context [springUrl=" + + metaUrl + ", err=" + e.getMessage() + ']', e); + } + + return store; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/Organization.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/Organization.java b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/Organization.java new file mode 100644 index 0000000..0762841 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/Organization.java @@ -0,0 +1,154 @@ +/* + * 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.auto.model; + +import java.io.*; + +/** + * Organization definition. + * + * Code generated by Apache Ignite Schema Load utility. + */ +public class Organization implements Serializable { + /** */ + private static final long serialVersionUID = 0L; + + /** Value for id. */ + private Integer id; + + /** Value for name. */ + private String name; + + /** Value for city. */ + private String city; + + /** + * Empty constructor. + */ + public Organization() { + // No-op. + } + + /** + * Full constructor. + */ + public Organization( + Integer id, + String name, + String city + ) { + this.id = id; + this.name = name; + this.city = city; + } + + /** + * Gets id. + * + * @return Value for id. + */ + public Integer getId() { + return id; + } + + /** + * Sets id. + * + * @param id New value for id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Gets name. + * + * @return Value for name. + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name New value for name. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Gets city. + * + * @return Value for city. + */ + public String getCity() { + return city; + } + + /** + * Sets city. + * + * @param city New value for city. + */ + public void setCity(String city) { + this.city = city; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof Organization)) + return false; + + Organization that = (Organization)o; + + if (id != null ? !id.equals(that.id) : that.id != null) + return false; + + if (name != null ? !name.equals(that.name) : that.name != null) + return false; + + if (city != null ? !city.equals(that.city) : that.city != null) + return false; + + return true; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + int res = id != null ? id.hashCode() : 0; + + res = 31 * res + (name != null ? name.hashCode() : 0); + res = 31 * res + (city != null ? city.hashCode() : 0); + + return res; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "Organization [" + + " id=" + id + + " name=" + name + + " city=" + city + + "]"; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/OrganizationKey.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/OrganizationKey.java b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/OrganizationKey.java new file mode 100644 index 0000000..92adc14 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/OrganizationKey.java @@ -0,0 +1,97 @@ +/* + * 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.auto.model; + +import java.io.*; + +/** + * OrganizationKey definition. + * + * Code generated by Apache Ignite Schema Load utility. + */ +public class OrganizationKey implements Serializable { + /** */ + private static final long serialVersionUID = 0L; + + /** Value for id. */ + private Integer id; + + /** + * Empty constructor. + */ + public OrganizationKey() { + // No-op. + } + + /** + * Full constructor. + */ + public OrganizationKey( + Integer id + ) { + this.id = id; + } + + /** + * Gets id. + * + * @return Value for id. + */ + public Integer getId() { + return id; + } + + /** + * Sets id. + * + * @param id New value for id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof OrganizationKey)) + return false; + + OrganizationKey that = (OrganizationKey)o; + + if (id != null ? !id.equals(that.id) : that.id != null) + return false; + + return true; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + int res = id != null ? id.hashCode() : 0; + + return res; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "OrganizationKey [" + + " id=" + id + + "]"; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/Person.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/Person.java b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/Person.java new file mode 100644 index 0000000..185d4e6 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/Person.java @@ -0,0 +1,154 @@ +/* + * 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.auto.model; + +import java.io.*; + +/** + * Person definition. + * + * Code generated by Apache Ignite Schema Load utility. + */ +public class Person implements Serializable { + /** */ + private static final long serialVersionUID = 0L; + + /** Value for id. */ + private Integer id; + + /** Value for orgId. */ + private Integer orgId; + + /** Value for name. */ + private String name; + + /** + * Empty constructor. + */ + public Person() { + // No-op. + } + + /** + * Full constructor. + */ + public Person( + Integer id, + Integer orgId, + String name + ) { + this.id = id; + this.orgId = orgId; + this.name = name; + } + + /** + * Gets id. + * + * @return Value for id. + */ + public Integer getId() { + return id; + } + + /** + * Sets id. + * + * @param id New value for id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Gets orgId. + * + * @return Value for orgId. + */ + public Integer getOrgId() { + return orgId; + } + + /** + * Sets orgId. + * + * @param orgId New value for orgId. + */ + public void setOrgId(Integer orgId) { + this.orgId = orgId; + } + + /** + * Gets name. + * + * @return Value for name. + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name New value for name. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof Person)) + return false; + + Person that = (Person)o; + + if (id != null ? !id.equals(that.id) : that.id != null) + return false; + + if (orgId != null ? !orgId.equals(that.orgId) : that.orgId != null) + return false; + + if (name != null ? !name.equals(that.name) : that.name != null) + return false; + + return true; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + int res = id != null ? id.hashCode() : 0; + + res = 31 * res + (orgId != null ? orgId.hashCode() : 0); + res = 31 * res + (name != null ? name.hashCode() : 0); + + return res; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "Person [" + + " id=" + id + + " orgId=" + orgId + + " name=" + name + + "]"; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/PersonKey.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/PersonKey.java b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/PersonKey.java new file mode 100644 index 0000000..d091f60 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/auto/model/PersonKey.java @@ -0,0 +1,97 @@ +/* + * 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.auto.model; + +import java.io.*; + +/** + * PersonKey definition. + * + * Code generated by Apache Ignite Schema Load utility. + */ +public class PersonKey implements Serializable { + /** */ + private static final long serialVersionUID = 0L; + + /** Value for id. */ + private Integer id; + + /** + * Empty constructor. + */ + public PersonKey() { + // No-op. + } + + /** + * Full constructor. + */ + public PersonKey( + Integer id + ) { + this.id = id; + } + + /** + * Gets id. + * + * @return Value for id. + */ + public Integer getId() { + return id; + } + + /** + * Sets id. + * + * @param id New value for id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof PersonKey)) + return false; + + PersonKey that = (PersonKey)o; + + if (id != null ? !id.equals(that.id) : that.id != null) + return false; + + return true; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + int res = id != null ? id.hashCode() : 0; + + return res; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "PersonKey [" + + " id=" + id + + "]"; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/schema-load/pom.xml ---------------------------------------------------------------------- diff --git a/modules/schema-load/pom.xml b/modules/schema-load/pom.xml index a3c6cd5..88eee8e 100644 --- a/modules/schema-load/pom.xml +++ b/modules/schema-load/pom.xml @@ -41,28 +41,6 @@ <artifactId>ignite-core</artifactId> <version>${ignite.version}</version> </dependency> - - <dependency> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-core</artifactId> - <version>${ignite.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-spring</artifactId> - <version>${ignite.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <version>1.3.175</version> - <scope>test</scope> - </dependency> </dependencies> <build> @@ -75,15 +53,6 @@ </resource> </resources> - <testResources> - <testResource> - <directory>src/test/java</directory> - <excludes> - <exclude>**/*.java</exclude> - </excludes> - </testResource> - </testResources> - <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/schema-load/src/test/config/all.xml ---------------------------------------------------------------------- diff --git a/modules/schema-load/src/test/config/all.xml b/modules/schema-load/src/test/config/all.xml deleted file mode 100644 index 14ebdc8..0000000 --- a/modules/schema-load/src/test/config/all.xml +++ /dev/null @@ -1,184 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> - <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeMetadata"> - <property name="type" value="org.apache.ignite.Organization"/> - <property name="keyType" value="org.apache.ignite.OrganizationKey"/> - <property name="schema" value="PUBLIC"/> - <property name="tableName" value="ORGANIZATION"/> - <property name="keyDescriptors"> - <list> - <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> - <property name="javaName" value="id"/> - <property name="javaType" value="java.lang.Integer"/> - <property name="dbName" value="ID"/> - <property name="dbType" value="4"/> - </bean> - </list> - </property> - <property name="valueDescriptors"> - <list> - <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> - <property name="javaName" value="id"/> - <property name="javaType" value="java.lang.Integer"/> - <property name="dbName" value="ID"/> - <property name="dbType" value="4"/> - </bean> - <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> - <property name="javaName" value="name"/> - <property name="javaType" value="java.lang.String"/> - <property name="dbName" value="NAME"/> - <property name="dbType" value="12"/> - </bean> - <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> - <property name="javaName" value="city"/> - <property name="javaType" value="java.lang.String"/> - <property name="dbName" value="CITY"/> - <property name="dbType" value="12"/> - </bean> - </list> - </property> - <property name="queryFields"> - <map> - <entry key="id" value="java.lang.Integer"/> - <entry key="name" value="java.lang.String"/> - <entry key="city" value="java.lang.String"/> - </map> - </property> - <property name="ascendingFields"> - <map> - <entry key="id" value="java.lang.Integer"/> - <entry key="name" value="java.lang.String"/> - <entry key="city" value="java.lang.String"/> - </map> - </property> - <property name="groups"> - <map> - <entry key="primaryKeyD"> - <map> - <entry key="id"> - <bean class="org.apache.ignite.lang.IgniteBiTuple"> - <constructor-arg value="java.lang.Integer"/> - <constructor-arg value="false"/> - </bean> - </entry> - </map> - </entry> - <entry key="orgNameCityIdx"> - <map> - <entry key="name"> - <bean class="org.apache.ignite.lang.IgniteBiTuple"> - <constructor-arg value="java.lang.String"/> - <constructor-arg value="false"/> - </bean> - </entry> - <entry key="city"> - <bean class="org.apache.ignite.lang.IgniteBiTuple"> - <constructor-arg value="java.lang.String"/> - <constructor-arg value="false"/> - </bean> - </entry> - </map> - </entry> - <entry key="orgNameIdx"> - <map> - <entry key="name"> - <bean class="org.apache.ignite.lang.IgniteBiTuple"> - <constructor-arg value="java.lang.String"/> - <constructor-arg value="false"/> - </bean> - </entry> - </map> - </entry> - </map> - </property> - </bean> - <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeMetadata"> - <property name="type" value="org.apache.ignite.Person"/> - <property name="keyType" value="org.apache.ignite.PersonKey"/> - <property name="schema" value="PUBLIC"/> - <property name="tableName" value="PERSON"/> - <property name="keyDescriptors"> - <list> - <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> - <property name="javaName" value="id"/> - <property name="javaType" value="java.lang.Integer"/> - <property name="dbName" value="ID"/> - <property name="dbType" value="4"/> - </bean> - </list> - </property> - <property name="valueDescriptors"> - <list> - <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> - <property name="javaName" value="id"/> - <property name="javaType" value="java.lang.Integer"/> - <property name="dbName" value="ID"/> - <property name="dbType" value="4"/> - </bean> - <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> - <property name="javaName" value="orgId"/> - <property name="javaType" value="java.lang.Integer"/> - <property name="dbName" value="ORG_ID"/> - <property name="dbType" value="4"/> - </bean> - <bean class="org.gridgain.grid.cache.query.GridCacheQueryTypeDescriptor"> - <property name="javaName" value="name"/> - <property name="javaType" value="java.lang.String"/> - <property name="dbName" value="NAME"/> - <property name="dbType" value="12"/> - </bean> - </list> - </property> - <property name="queryFields"> - <map> - <entry key="id" value="java.lang.Integer"/> - <entry key="orgId" value="java.lang.Integer"/> - <entry key="name" value="java.lang.String"/> - </map> - </property> - <property name="ascendingFields"> - <map> - <entry key="id" value="java.lang.Integer"/> - <entry key="name" value="java.lang.String"/> - </map> - </property> - <property name="descendingFields"> - <map> - <entry key="name" value="java.lang.String"/> - </map> - </property> - <property name="groups"> - <map> - <entry key="primaryKey8"> - <map> - <entry key="id"> - <bean class="org.apache.ignite.lang.IgniteBiTuple"> - <constructor-arg value="java.lang.Integer"/> - <constructor-arg value="false"/> - </bean> - </entry> - </map> - </entry> - <entry key="personNameIdx1"> - <map> - <entry key="name"> - <bean class="org.apache.ignite.lang.IgniteBiTuple"> - <constructor-arg value="java.lang.String"/> - <constructor-arg value="false"/> - </bean> - </entry> - </map> - </entry> - <entry key="personNameIdx2"> - <map> - <entry key="name"> - <bean class="org.apache.ignite.lang.IgniteBiTuple"> - <constructor-arg value="java.lang.String"/> - <constructor-arg value="true"/> - </bean> - </entry> - </map> - </entry> - </map> - </property> - </bean> -</beans> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/schema-load/src/test/java/org/apache/ignite/Organization.java ---------------------------------------------------------------------- diff --git a/modules/schema-load/src/test/java/org/apache/ignite/Organization.java b/modules/schema-load/src/test/java/org/apache/ignite/Organization.java deleted file mode 100644 index 8c163bb..0000000 --- a/modules/schema-load/src/test/java/org/apache/ignite/Organization.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.apache.ignite; - -import java.io.*; - -/** - * Organization definition. - * - * Code generated by Apache Ignite Schema Load utility. - */ -public class Organization implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** Value for id. */ - private Integer id; - - /** Value for name. */ - private String name; - - /** Value for city. */ - private String city; - - /** - * Empty constructor. - */ - public Organization() { - // No-op. - } - - /** - * Full constructor. - */ - public Organization( - Integer id, - String name, - String city - ) { - this.id = id; - this.name = name; - this.city = city; - } - - /** - * Gets id. - * - * @return Value for id. - */ - public Integer getId() { - return id; - } - - /** - * Sets id. - * - * @param id New value for id. - */ - public void setId(Integer id) { - this.id = id; - } - - /** - * Gets name. - * - * @return Value for name. - */ - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name New value for name. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Gets city. - * - * @return Value for city. - */ - public String getCity() { - return city; - } - - /** - * Sets city. - * - * @param city New value for city. - */ - public void setCity(String city) { - this.city = city; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (!(o instanceof Organization)) - return false; - - Organization that = (Organization)o; - - if (id != null ? !id.equals(that.id) : that.id != null) - return false; - - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - - if (city != null ? !city.equals(that.city) : that.city != null) - return false; - - return true; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - int res = id != null ? id.hashCode() : 0; - - res = 31 * res + (name != null ? name.hashCode() : 0); - res = 31 * res + (city != null ? city.hashCode() : 0); - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "Organization [" + - " id=" + id + - " name=" + name + - " city=" + city + - "]"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/schema-load/src/test/java/org/apache/ignite/OrganizationKey.java ---------------------------------------------------------------------- diff --git a/modules/schema-load/src/test/java/org/apache/ignite/OrganizationKey.java b/modules/schema-load/src/test/java/org/apache/ignite/OrganizationKey.java deleted file mode 100644 index 1535619..0000000 --- a/modules/schema-load/src/test/java/org/apache/ignite/OrganizationKey.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.apache.ignite; - -import java.io.*; - -/** - * OrganizationKey definition. - * - * Code generated by Apache Ignite Schema Load utility. - */ -public class OrganizationKey implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** Value for id. */ - private Integer id; - - /** - * Empty constructor. - */ - public OrganizationKey() { - // No-op. - } - - /** - * Full constructor. - */ - public OrganizationKey( - Integer id - ) { - this.id = id; - } - - /** - * Gets id. - * - * @return Value for id. - */ - public Integer getId() { - return id; - } - - /** - * Sets id. - * - * @param id New value for id. - */ - public void setId(Integer id) { - this.id = id; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (!(o instanceof OrganizationKey)) - return false; - - OrganizationKey that = (OrganizationKey)o; - - if (id != null ? !id.equals(that.id) : that.id != null) - return false; - - return true; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - int res = id != null ? id.hashCode() : 0; - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "OrganizationKey [" + - " id=" + id + - "]"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/schema-load/src/test/java/org/apache/ignite/Person.java ---------------------------------------------------------------------- diff --git a/modules/schema-load/src/test/java/org/apache/ignite/Person.java b/modules/schema-load/src/test/java/org/apache/ignite/Person.java deleted file mode 100644 index ef1f96f..0000000 --- a/modules/schema-load/src/test/java/org/apache/ignite/Person.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.apache.ignite; - -import java.io.*; - -/** - * Person definition. - * - * Code generated by Apache Ignite Schema Load utility. - */ -public class Person implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** Value for id. */ - private Integer id; - - /** Value for orgId. */ - private Integer orgId; - - /** Value for name. */ - private String name; - - /** - * Empty constructor. - */ - public Person() { - // No-op. - } - - /** - * Full constructor. - */ - public Person( - Integer id, - Integer orgId, - String name - ) { - this.id = id; - this.orgId = orgId; - this.name = name; - } - - /** - * Gets id. - * - * @return Value for id. - */ - public Integer getId() { - return id; - } - - /** - * Sets id. - * - * @param id New value for id. - */ - public void setId(Integer id) { - this.id = id; - } - - /** - * Gets orgId. - * - * @return Value for orgId. - */ - public Integer getOrgId() { - return orgId; - } - - /** - * Sets orgId. - * - * @param orgId New value for orgId. - */ - public void setOrgId(Integer orgId) { - this.orgId = orgId; - } - - /** - * Gets name. - * - * @return Value for name. - */ - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name New value for name. - */ - public void setName(String name) { - this.name = name; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (!(o instanceof Person)) - return false; - - Person that = (Person)o; - - if (id != null ? !id.equals(that.id) : that.id != null) - return false; - - if (orgId != null ? !orgId.equals(that.orgId) : that.orgId != null) - return false; - - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - - return true; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - int res = id != null ? id.hashCode() : 0; - - res = 31 * res + (orgId != null ? orgId.hashCode() : 0); - res = 31 * res + (name != null ? name.hashCode() : 0); - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "Person [" + - " id=" + id + - " orgId=" + orgId + - " name=" + name + - "]"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/schema-load/src/test/java/org/apache/ignite/PersonKey.java ---------------------------------------------------------------------- diff --git a/modules/schema-load/src/test/java/org/apache/ignite/PersonKey.java b/modules/schema-load/src/test/java/org/apache/ignite/PersonKey.java deleted file mode 100644 index 27caa80..0000000 --- a/modules/schema-load/src/test/java/org/apache/ignite/PersonKey.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.apache.ignite; - -import java.io.*; - -/** - * PersonKey definition. - * - * Code generated by Apache Ignite Schema Load utility. - */ -public class PersonKey implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** Value for id. */ - private Integer id; - - /** - * Empty constructor. - */ - public PersonKey() { - // No-op. - } - - /** - * Full constructor. - */ - public PersonKey( - Integer id - ) { - this.id = id; - } - - /** - * Gets id. - * - * @return Value for id. - */ - public Integer getId() { - return id; - } - - /** - * Sets id. - * - * @param id New value for id. - */ - public void setId(Integer id) { - this.id = id; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (!(o instanceof PersonKey)) - return false; - - PersonKey that = (PersonKey)o; - - if (id != null ? !id.equals(that.id) : that.id != null) - return false; - - return true; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - int res = id != null ? id.hashCode() : 0; - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "PersonKey [" + - " id=" + id + - "]"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AbstractAutoCacheStoreSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AbstractAutoCacheStoreSelfTest.java b/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AbstractAutoCacheStoreSelfTest.java deleted file mode 100644 index 8fcb67f..0000000 --- a/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AbstractAutoCacheStoreSelfTest.java +++ /dev/null @@ -1,195 +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.gridgain.grid.cache.store.auto; - -import org.apache.ignite.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.transactions.*; -import org.gridgain.grid.util.typedef.*; -import org.gridgain.grid.util.typedef.internal.*; -import org.gridgain.testframework.junits.cache.*; -import org.gridgain.testframework.junits.common.*; - -import java.sql.*; - -/** - * Base class for {@code AutoCacheStore} tests. - */ -abstract class AbstractAutoCacheStoreSelfTest extends GridCommonAbstractTest { - /** Organization count. */ - protected static final int ORGANIZATION_CNT = 1000; - - /** Person count. */ - protected static final int PERSON_CNT = 100000; - - /** */ - protected final AutoCacheStore store; - - /** - * @throws Exception If failed. - */ - @SuppressWarnings({"AbstractMethodCallInConstructor", "OverriddenMethodCallDuringObjectConstruction"}) - protected AbstractAutoCacheStoreSelfTest() throws Exception { - super(false); - - store = store(); - - inject(store); - } - - /** - * @return Store. - */ - protected abstract AutoCacheStore store(); - - /** - * @param store Store. - * @throws Exception If failed. - */ - protected void inject(AutoCacheStore store) throws Exception { - getTestResources().inject(store); - } - - /** - * @throws Exception If failed. - */ - public void testLoadCache() throws Exception { - final T2<Integer, Integer> keys = new T2<>(0, 0); - - IgniteBiInClosure<Object, Object> c = new CI2<Object, Object>() { - @Override public void apply(Object k, Object v) { - if (k instanceof OrganizationKey && v instanceof Organization) - keys.set1(keys.get1() + 1); - else if (k instanceof PersonKey && v instanceof Person) - keys.set2(keys.get2() + 1); - } - }; - - store.loadCache(c); - - assertEquals(new T2<>(ORGANIZATION_CNT, PERSON_CNT), keys); - } - - /** - * @throws Exception If failed. - */ - public void testStore() throws Exception { - // Create dummy transaction - IgniteTx tx = new GridAbstractCacheStoreSelfTest.DummyTx(); - - OrganizationKey k3 = new OrganizationKey(); - k3.setId(-3); - - OrganizationKey k4 = new OrganizationKey(); - k4.setId(-4); - - Organization v3 = new Organization(); - v3.setId(-3); - v3.setName("Test1"); - v3.setCity("Test2"); - - Organization v4 = new Organization(); - v4.setId(-4); - v4.setName("Test3"); - v4.setCity("Test4"); - - store.put(tx, k3, v3); - store.put(tx, k4, v4); - - store.txEnd(tx, true); - - assertEquals(v3, store.load(null, k3)); - assertEquals(v4, store.load(null, k4)); - - OrganizationKey k5 = new OrganizationKey(); - k5.setId(-5); - - assertNull(store.load(null, k5)); - - store.remove(tx, k3); - - assertNull(store.load(tx, k3)); - assertEquals(v4, store.load(tx, k4)); - - store.remove(tx, k4); - - assertNull(store.load(tx, k4)); - - store.putAll(tx, F.asMap(k3, v3, k4, v4)); - - assertEquals(v3, store.load(tx, k3)); - assertEquals(v4, store.load(tx, k4)); - - store.txEnd(tx, true); - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - super.beforeTest(); - - Class.forName("org.h2.Driver"); - Connection conn = DriverManager.getConnection("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", ""); - - 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))"); - - stmt.executeUpdate("CREATE INDEX Org_Name_IDX On Organization (name)"); - stmt.executeUpdate("CREATE INDEX Org_Name_City_IDX On Organization (name, city)"); - stmt.executeUpdate("CREATE INDEX Person_Name_IDX1 On Person (name)"); - stmt.executeUpdate("CREATE INDEX Person_Name_IDX2 On Person (name desc)"); - - conn.commit(); - - 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(); - - 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(stmt); - - U.closeQuiet(conn); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AutoCacheStoreSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AutoCacheStoreSelfTest.java b/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AutoCacheStoreSelfTest.java deleted file mode 100644 index 0689ce3..0000000 --- a/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AutoCacheStoreSelfTest.java +++ /dev/null @@ -1,46 +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.gridgain.grid.cache.store.auto; - -import org.gridgain.grid.util.typedef.*; - -/** - * Tests for {@code AutoCacheStore}. - */ -public class AutoCacheStoreSelfTest extends AbstractAutoCacheStoreSelfTest { - /** - * @throws Exception If failed. - */ - public AutoCacheStoreSelfTest() throws Exception { - } - - /** - * @return Store. - */ - @Override protected PojoCacheStore store() { - PojoCacheStore store = new PojoCacheStore(); - - store.setConnUrl("jdbc:h2:mem:test"); - store.setUser("sa"); - store.setPassword(""); - - store.setTypeMetadataPaths(F.asList("modules/schema-load/src/test/config/all.xml")); - - return store; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38af4663/modules/schema-load/src/test/sql/sample.sql ---------------------------------------------------------------------- diff --git a/modules/schema-load/src/test/sql/sample.sql b/modules/schema-load/src/test/sql/sample.sql deleted file mode 100644 index 9d06e21..0000000 --- a/modules/schema-load/src/test/sql/sample.sql +++ /dev/null @@ -1,16 +0,0 @@ --- Script to create sample H2 database. -CREATE TABLE IF NOT EXISTS Organization(id integer primary key, name varchar(50), city varchar(50)); -CREATE TABLE IF NOT EXISTS Person(id integer primary key, org_id integer, name varchar(50)); -CREATE TABLE IF NOT EXISTS Bonus(id integer primary key, name varchar(50)); -CREATE TABLE IF NOT EXISTS Person_Bonus(id integer primary key, pid integer, bid integer, bonus_date date, amount integer); - -CREATE INDEX IF NOT EXISTS Org_Name_IDX On Organization (name); -CREATE INDEX IF NOT EXISTS Org_Name_City_IDX On Organization (name, city); -CREATE INDEX IF NOT EXISTS Person_Name_IDX1 On Person (name); -CREATE INDEX IF NOT EXISTS Person_Name_IDX2 On Person (name desc); - -INSERT INTO Organization(id, name, city) VALUES (1, 'Test1', 'Test2'); -INSERT INTO Organization(id, name, city) VALUES (2, 'Test3', 'Test4'); - -INSERT INTO Person(id, org_id, name) VALUES (1, 1, 'Test5'); -INSERT INTO Person(id, org_id, name) VALUES (2, 2, 'Test6');
