Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 568A118E3C for ; Wed, 17 Jun 2015 08:02:13 +0000 (UTC) Received: (qmail 54039 invoked by uid 500); 17 Jun 2015 08:02:13 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 54007 invoked by uid 500); 17 Jun 2015 08:02:13 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 53998 invoked by uid 99); 17 Jun 2015 08:02:13 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jun 2015 08:02:13 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id C93EECE618 for ; Wed, 17 Jun 2015 08:02:12 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.201 X-Spam-Level: * X-Spam-Status: No, score=1.201 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.58, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id aXcEA5pdSZb1 for ; Wed, 17 Jun 2015 08:02:04 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id 141BB2802B for ; Wed, 17 Jun 2015 08:02:01 +0000 (UTC) Received: (qmail 53020 invoked by uid 99); 17 Jun 2015 08:02:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jun 2015 08:02:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 75612E39B5; Wed, 17 Jun 2015 08:02:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.incubator.apache.org Date: Wed, 17 Jun 2015 08:02:09 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [10/27] incubator-ignite git commit: #ignite-960: Add tests. #ignite-960: Add tests. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/fef12fc2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/fef12fc2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/fef12fc2 Branch: refs/heads/ignite-gg-10411 Commit: fef12fc23a45d1bc4cade87460a76315c7dee6f0 Parents: c9dd891 Author: ivasilinets Authored: Tue Jun 2 12:57:34 2015 +0300 Committer: ivasilinets Committed: Tue Jun 2 12:57:34 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheProcessor.java | 3 +- .../store/jdbc/CacheJdbcBlobStoreFactory.java | 6 +- modules/spring/src/test/config/node.xml | 43 ++++++++++++++ modules/spring/src/test/config/store-cache1.xml | 62 ++++++++++++++++++++ .../jdbc/CacheJdbcBlobStoreFactorySelfTest.java | 51 ++++++++++++++-- 5 files changed, 154 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fef12fc2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java index 354172a..a220ae6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java @@ -1052,8 +1052,7 @@ public class GridCacheProcessor extends GridProcessorAdapter { { assert cfg != null; - if (cfg.getCacheStoreFactory() != null) - ctx.resource().injectGeneric(cfg.getCacheStoreFactory()); + prepare(cfg, cfg.getCacheStoreFactory(), false); CacheStore cfgStore = cfg.getCacheStoreFactory() != null ? cfg.getCacheStoreFactory().create() : null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fef12fc2/modules/spring/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactory.java ---------------------------------------------------------------------- diff --git a/modules/spring/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactory.java b/modules/spring/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactory.java index 743e5e8..9d572b6 100644 --- a/modules/spring/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactory.java +++ b/modules/spring/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactory.java @@ -63,7 +63,7 @@ import javax.sql.*; *
* For information about Spring framework visit www.springframework.org */ -public class CacheJdbcBlobStoreFactory implements Factory { +public class CacheJdbcBlobStoreFactory implements Factory> { /** Connection URL. */ private String connUrl = CacheJdbcBlobStore.DFLT_CONN_URL; @@ -100,8 +100,8 @@ public class CacheJdbcBlobStoreFactory implements Factory { private ApplicationContext appContext; /** {@inheritDoc} */ - @Override public CacheJdbcBlobStore create() { - CacheJdbcBlobStore store = new CacheJdbcBlobStore(); + @Override public CacheJdbcBlobStore create() { + CacheJdbcBlobStore store = new CacheJdbcBlobStore(); store.setInitSchema(initSchema); store.setConnectionUrl(connUrl); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fef12fc2/modules/spring/src/test/config/node.xml ---------------------------------------------------------------------- diff --git a/modules/spring/src/test/config/node.xml b/modules/spring/src/test/config/node.xml new file mode 100644 index 0000000..36d64cb --- /dev/null +++ b/modules/spring/src/test/config/node.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + 127.0.0.1:47500..47509 + + + + + + + + http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fef12fc2/modules/spring/src/test/config/store-cache1.xml ---------------------------------------------------------------------- diff --git a/modules/spring/src/test/config/store-cache1.xml b/modules/spring/src/test/config/store-cache1.xml new file mode 100644 index 0000000..9209e52 --- /dev/null +++ b/modules/spring/src/test/config/store-cache1.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 127.0.0.1:47500..47509 + + + + + + + + http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fef12fc2/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactorySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactorySelfTest.java b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactorySelfTest.java index bdfdcb9..eebd48d 100644 --- a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactorySelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactorySelfTest.java @@ -22,22 +22,61 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.junits.common.*; import org.h2.jdbcx.*; +import sun.jdbc.odbc.ee.*; /** * Test for Cache jdbc blob store factory. */ public class CacheJdbcBlobStoreFactorySelfTest extends GridCommonAbstractTest { + /** Cache name. */ + private static final String CACHE_NAME = "test"; + + /** + * @throws Exception If failed. + */ public void testXmlConfiguration() throws Exception { try (Ignite ignite = Ignition.start("modules/spring/src/test/config/store-cache.xml")) { - IgniteCache cache = ignite.cache("test"); + try(Ignite ignite1 = Ignition.start("modules/spring/src/test/config/store-cache1.xml")) { + checkStore(ignite.cache(CACHE_NAME), JdbcDataSource.class); + + checkStore(ignite1.cache(CACHE_NAME), ConnectionPoolDataSource.class); + } + } + } + + /** + * @throws Exception If failed. + */ + public void testCacheConfiguration() throws Exception { + try (Ignite ignite = Ignition.start("modules/spring/src/test/config/node.xml")) { + CacheConfiguration cfg = new CacheConfiguration<>(); + + CacheJdbcBlobStoreFactory factory = new CacheJdbcBlobStoreFactory(); - CacheJdbcBlobStore store = (CacheJdbcBlobStore) cache.getConfiguration(CacheConfiguration.class). - getCacheStoreFactory().create(); + factory.setUser("GridGain"); - assertEquals("GridGain", GridTestUtils.getFieldValue(store, CacheJdbcBlobStore.class, "user")); + factory.setDataSourceBean("simpleDataSource"); - assertEquals(JdbcDataSource.class, - GridTestUtils.getFieldValue(store, CacheJdbcBlobStore.class, "dataSrc").getClass()); + cfg.setCacheStoreFactory(factory); + + try(IgniteCache cache = ignite.getOrCreateCache(cfg)) { + checkStore(cache, JdbcDataSource.class); + } } } + + /** + * @param cache Ignite cache. + * @param dataSrcClass Data source class. + * @throws Exception If store parameters is not the same as in configuration xml. + */ + private void checkStore(IgniteCache cache, Class dataSrcClass) throws Exception { + CacheJdbcBlobStore store = (CacheJdbcBlobStore) cache.getConfiguration(CacheConfiguration.class). + getCacheStoreFactory().create(); + + assertEquals("GridGain", GridTestUtils.getFieldValue(store, CacheJdbcBlobStore.class, "user")); + + assertEquals(dataSrcClass, + GridTestUtils.getFieldValue(store, CacheJdbcBlobStore.class, "dataSrc").getClass()); + } }