Repository: ignite Updated Branches: refs/heads/ignite-1794 979d87225 -> be40f9377
http://git-wip-us.apache.org/repos/asf/ignite/blob/be40f937/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java b/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java deleted file mode 100644 index c4d6120..0000000 --- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java +++ /dev/null @@ -1,241 +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.hibernate; - -import java.io.Serializable; -import java.util.Map; -import javax.cache.Cache; -import javax.cache.configuration.Factory; -import javax.cache.integration.CacheLoaderException; -import javax.cache.integration.CacheWriterException; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import org.apache.ignite.cache.store.CacheStore; -import org.apache.ignite.cache.store.CacheStoreAdapter; -import org.apache.ignite.cache.store.CacheStoreSession; -import org.apache.ignite.cache.store.CacheStoreSessionListener; -import org.apache.ignite.cache.store.CacheStoreSessionListenerAbstractSelfTest; -import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener; -import org.apache.ignite.lang.IgniteBiInClosure; -import org.apache.ignite.resources.CacheStoreSessionResource; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.cfg.Configuration; - -/** - * Tests for {@link CacheJdbcStoreSessionListener}. - */ -public class CacheHibernateStoreSessionListenerSelfTest extends CacheStoreSessionListenerAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected Factory<? extends CacheStore<Integer, Integer>> storeFactory() { - return new Factory<CacheStore<Integer, Integer>>() { - @Override public CacheStore<Integer, Integer> create() { - return new Store(); - } - }; - } - - /** {@inheritDoc} */ - @Override protected Factory<CacheStoreSessionListener> sessionListenerFactory() { - return new Factory<CacheStoreSessionListener>() { - @Override public CacheStoreSessionListener create() { - CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener(); - - SessionFactory sesFactory = new Configuration(). - setProperty("hibernate.connection.url", URL). - addAnnotatedClass(Table1.class). - addAnnotatedClass(Table2.class). - buildSessionFactory(); - - lsnr.setSessionFactory(sesFactory); - - return lsnr; - } - }; - } - - /** - */ - private static class Store extends CacheStoreAdapter<Integer, Integer> { - /** */ - private static String SES_CONN_KEY = "ses_conn"; - - /** */ - @CacheStoreSessionResource - private CacheStoreSession ses; - - /** {@inheritDoc} */ - @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, Object... args) { - loadCacheCnt.incrementAndGet(); - - checkSession(); - } - - /** {@inheritDoc} */ - @Override public Integer load(Integer key) throws CacheLoaderException { - loadCnt.incrementAndGet(); - - checkSession(); - - return null; - } - - /** {@inheritDoc} */ - @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> entry) - throws CacheWriterException { - writeCnt.incrementAndGet(); - - checkSession(); - - if (write.get()) { - Session hibSes = ses.attachment(); - - switch (ses.cacheName()) { - case "cache1": - hibSes.save(new Table1(entry.getKey(), entry.getValue())); - - break; - - case "cache2": - if (fail.get()) - throw new CacheWriterException("Expected failure."); - - hibSes.save(new Table2(entry.getKey(), entry.getValue())); - - break; - - default: - throw new CacheWriterException("Wring cache: " + ses.cacheName()); - } - } - } - - /** {@inheritDoc} */ - @Override public void delete(Object key) throws CacheWriterException { - deleteCnt.incrementAndGet(); - - checkSession(); - } - - /** {@inheritDoc} */ - @Override public void sessionEnd(boolean commit) { - assertNull(ses.attachment()); - } - - /** - */ - private void checkSession() { - Session hibSes = ses.attachment(); - - assertNotNull(hibSes); - - assertTrue(hibSes.isOpen()); - - Transaction tx = hibSes.getTransaction(); - - assertNotNull(tx); - - if (ses.isWithinTransaction()) - assertTrue(tx.isActive()); - else - assertFalse(tx.isActive()); - - verifySameInstance(hibSes); - } - - /** - * @param hibSes Session. - */ - private void verifySameInstance(Session hibSes) { - Map<String, Session> props = ses.properties(); - - Session sesConn = props.get(SES_CONN_KEY); - - if (sesConn == null) - props.put(SES_CONN_KEY, hibSes); - else { - assertSame(hibSes, sesConn); - - reuseCnt.incrementAndGet(); - } - } - } - - /** - */ - @Entity - @Table(name = "Table1") - private static class Table1 implements Serializable { - /** */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private Integer id; - - /** */ - @Column(name = "key") - private int key; - - /** */ - @Column(name = "value") - private int value; - - /** - * @param key Key. - * @param value Value. - */ - private Table1(int key, int value) { - this.key = key; - this.value = value; - } - } - - /** - */ - @Entity - @Table(name = "Table2") - private static class Table2 implements Serializable { - /** */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private Integer id; - - /** */ - @Column(name = "key") - private int key; - - /** */ - @Column(name = "value") - private int value; - - /** - * @param key Key. - * @param value Value. - */ - private Table2(int key, int value) { - this.key = key; - this.value = value; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/be40f937/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml ---------------------------------------------------------------------- diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml b/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml deleted file mode 100644 index 3822b31..0000000 --- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?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. ---> - - -<!DOCTYPE hibernate-configuration PUBLIC - "-//Hibernate/Hibernate Configuration DTD 3.0//EN" - "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> - -<hibernate-configuration> - <session-factory> - <!-- Show SQL. --> - <property name="show_sql">true</property> - - <!-- Database connection settings (private in-memory database). --> - <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property> - - <!-- Only validate the database schema on startup in production mode. --> - <property name="hbm2ddl.auto">update</property> - - <!-- H2 dialect. --> - <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property> - - <!-- Mappings. --> - <mapping resource="org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml"/> - </session-factory> -</hibernate-configuration> http://git-wip-us.apache.org/repos/asf/ignite/blob/be40f937/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java ---------------------------------------------------------------------- diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java b/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java deleted file mode 100644 index 8af9886..0000000 --- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java +++ /dev/null @@ -1,22 +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 description. --> - * Contains internal tests or test related classes and interfaces. - */ -package org.apache.ignite.cache.store.hibernate; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/be40f937/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java ---------------------------------------------------------------------- diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java b/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java deleted file mode 100644 index d539511..0000000 --- a/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java +++ /dev/null @@ -1,37 +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.testsuites; - -import junit.framework.TestSuite; -import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.testframework.config.GridTestProperties; - -/** - * - */ -public class IgniteBinaryHibernate5TestSuite extends TestSuite { - /** - * @return Test suite. - * @throws Exception If failed. - */ - public static TestSuite suite() throws Exception { - GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName()); - - return IgniteHibernate5TestSuite.suite(); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/be40f937/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java ---------------------------------------------------------------------- diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java b/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java deleted file mode 100644 index 3d7c4ee..0000000 --- a/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java +++ /dev/null @@ -1,57 +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.testsuites; - -import junit.framework.TestSuite; -import org.apache.ignite.cache.hibernate.HibernateL2CacheConfigurationSelfTest; -import org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest; -import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalSelfTest; -import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalUseSyncSelfTest; -import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreNodeRestartTest; -import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreSelfTest; -import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest; -import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListenerSelfTest; - -/** - * Hibernate integration tests. - */ -public class IgniteHibernate5TestSuite extends TestSuite { - /** - * @return Test suite. - * @throws Exception Thrown in case of the failure. - */ - public static TestSuite suite() throws Exception { - TestSuite suite = new TestSuite("Hibernate5 Integration Test Suite"); - - // Hibernate L2 cache. - suite.addTestSuite(HibernateL2CacheSelfTest.class); - suite.addTestSuite(HibernateL2CacheTransactionalSelfTest.class); - suite.addTestSuite(HibernateL2CacheTransactionalUseSyncSelfTest.class); - suite.addTestSuite(HibernateL2CacheConfigurationSelfTest.class); - - suite.addTestSuite(CacheHibernateBlobStoreSelfTest.class); - - suite.addTestSuite(CacheHibernateBlobStoreNodeRestartTest.class); - - suite.addTestSuite(CacheHibernateStoreSessionListenerSelfTest.class); - - suite.addTestSuite(CacheHibernateStoreFactorySelfTest.class); - - return suite; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/be40f937/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 475299b..0911158 100644 --- a/pom.xml +++ b/pom.xml @@ -101,8 +101,9 @@ <module>examples</module> <module>modules/benchmarks</module> <module>modules/geospatial</module> - <module>modules/hibernate5</module> + <module>modules/hibernate-core</module> <module>modules/hibernate</module> + <module>modules/hibernate-5.1</module> <module>modules/ml</module> <module>modules/schedule</module> <module>modules/web-console/web-agent</module> @@ -193,7 +194,8 @@ <id>lgpl</id> <modules> <module>modules/hibernate</module> - <module>modules/hibernate5</module> + <module>modules/hibernate-core</module> + <module>modules/hibernate-5.1</module> <module>modules/geospatial</module> <module>modules/schedule</module> </modules>
