#ignite-960: Change CacheJdbcBlobStoreFactorySelfTest:testCacheConfiguration. Start several nodes with different configuration + use TcpDiscoveryVmIpFinder.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5c4bb215 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5c4bb215 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5c4bb215 Branch: refs/heads/ignite-484-1 Commit: 5c4bb215b1713df40ac8ae28f97e7f0b3a1916fe Parents: fef12fc Author: ivasilinets <[email protected]> Authored: Tue Jun 2 13:18:30 2015 +0300 Committer: ivasilinets <[email protected]> Committed: Tue Jun 2 13:18:30 2015 +0300 ---------------------------------------------------------------------- modules/spring/src/test/config/node.xml | 2 +- modules/spring/src/test/config/node1.xml | 45 ++++++++++++++++++++ .../jdbc/CacheJdbcBlobStoreFactorySelfTest.java | 36 +++++++++++----- 3 files changed, 72 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c4bb215/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 index 36d64cb..6f467eb 100644 --- a/modules/spring/src/test/config/node.xml +++ b/modules/spring/src/test/config/node.xml @@ -29,7 +29,7 @@ <property name="discoverySpi"> <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> <property name="ipFinder"> - <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder"> + <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> <property name="addresses"> <list> <value>127.0.0.1:47500..47509</value> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c4bb215/modules/spring/src/test/config/node1.xml ---------------------------------------------------------------------- diff --git a/modules/spring/src/test/config/node1.xml b/modules/spring/src/test/config/node1.xml new file mode 100644 index 0000000..67bae12 --- /dev/null +++ b/modules/spring/src/test/config/node1.xml @@ -0,0 +1,45 @@ +<?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. +--> +<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 id="simpleDataSource" class="sun.jdbc.odbc.ee.ConnectionPoolDataSource"/> + + <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> + <property name="gridName" value="ignite1"/> + + <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. --> + <property name="discoverySpi"> + <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> + <property name="ipFinder"> + <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> + <property name="addresses"> + <list> + <value>127.0.0.1:47500..47509</value> + </list> + </property> + </bean> + </property> + </bean> + </property> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c4bb215/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 eebd48d..6289e34 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 @@ -31,6 +31,9 @@ public class CacheJdbcBlobStoreFactorySelfTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "test"; + /** User name. */ + private static final String USER_NAME = "GridGain"; + /** * @throws Exception If failed. */ @@ -49,20 +52,33 @@ public class CacheJdbcBlobStoreFactorySelfTest extends GridCommonAbstractTest { */ public void testCacheConfiguration() throws Exception { try (Ignite ignite = Ignition.start("modules/spring/src/test/config/node.xml")) { - CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>(); + try (Ignite ignite1 = Ignition.start("modules/spring/src/test/config/node1.xml")) { + try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cacheConfiguration())) { + try (IgniteCache<Integer, String> cache1 = ignite1.getOrCreateCache(cacheConfiguration())) { + checkStore(cache, JdbcDataSource.class); + + checkStore(cache1, ConnectionPoolDataSource.class); + } + } + } + } + } - CacheJdbcBlobStoreFactory<Integer, String> factory = new CacheJdbcBlobStoreFactory(); + /** + * @return Cache configuration with store. + */ + private CacheConfiguration<Integer, String> cacheConfiguration() { + CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>(); - factory.setUser("GridGain"); + CacheJdbcBlobStoreFactory<Integer, String> factory = new CacheJdbcBlobStoreFactory(); - factory.setDataSourceBean("simpleDataSource"); + factory.setUser(USER_NAME); - cfg.setCacheStoreFactory(factory); + factory.setDataSourceBean("simpleDataSource"); - try(IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) { - checkStore(cache, JdbcDataSource.class); - } - } + cfg.setCacheStoreFactory(factory); + + return cfg; } /** @@ -74,7 +90,7 @@ public class CacheJdbcBlobStoreFactorySelfTest extends GridCommonAbstractTest { CacheJdbcBlobStore store = (CacheJdbcBlobStore) cache.getConfiguration(CacheConfiguration.class). getCacheStoreFactory().create(); - assertEquals("GridGain", GridTestUtils.getFieldValue(store, CacheJdbcBlobStore.class, "user")); + assertEquals(USER_NAME, GridTestUtils.getFieldValue(store, CacheJdbcBlobStore.class, "user")); assertEquals(dataSrcClass, GridTestUtils.getFieldValue(store, CacheJdbcBlobStore.class, "dataSrc").getClass());
