# ignite-205 Fixed incorrect path in test.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/1eda58db Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1eda58db Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1eda58db Branch: refs/heads/ignite-176 Commit: 1eda58dbb393803901f4a748aab39f8a2c068fb0 Parents: 37c699b Author: anovikov <anovi...@gridgain.com> Authored: Mon Feb 9 18:07:46 2015 +0700 Committer: anovikov <anovi...@gridgain.com> Committed: Mon Feb 9 18:07:46 2015 +0700 ---------------------------------------------------------------------- .../store/jdbc/CacheJdbcPojoStoreTest.java | 22 ++++++------ ...eJdbcStoreAbstractMultithreadedSelfTest.java | 36 +++++++++++--------- 2 files changed, 31 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1eda58db/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java index 0edc6f6..1b665f7 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java @@ -39,7 +39,6 @@ import org.springframework.core.io.*; import javax.cache.*; import javax.cache.integration.*; -import java.io.*; import java.net.*; import java.sql.*; import java.util.*; @@ -53,10 +52,10 @@ import static org.apache.ignite.testframework.junits.cache.GridAbstractCacheStor */ public class CacheJdbcPojoStoreTest extends GridCommonAbstractTest { /** Default connection URL (value is <tt>jdbc:h2:mem:jdbcCacheStore;DB_CLOSE_DELAY=-1</tt>). */ - protected static final String DFLT_CONN_URL = "jdbc:h2:mem:autoCacheStore;DB_CLOSE_DELAY=-1"; + private static final String DFLT_CONN_URL = "jdbc:h2:mem:autoCacheStore;DB_CLOSE_DELAY=-1"; /** Default config with mapping. */ - protected static final String DFLT_MAPPING_CONFIG = "modules/core/src/test/config/store/jdbc/Ignite.xml"; + private static final String DFLT_MAPPING_CONFIG = "modules/core/src/test/config/store/jdbc/Ignite.xml"; /** Organization count. */ protected static final int ORGANIZATION_CNT = 1000; @@ -114,19 +113,22 @@ public class CacheJdbcPojoStoreTest extends GridCommonAbstractTest { GridTestUtils.setFieldValue(store, CacheStore.class, "ses", ses); - UrlResource metaUrl; + URL cfgUrl; try { - metaUrl = new UrlResource(new File(DFLT_MAPPING_CONFIG).toURI().toURL()); + cfgUrl = new URL(DFLT_MAPPING_CONFIG); } - catch (MalformedURLException e) { - throw new IgniteCheckedException("Failed to resolve metadata path [err=" + e.getMessage() + ']', e); + catch (MalformedURLException ignore) { + cfgUrl = U.resolveIgniteUrl(DFLT_MAPPING_CONFIG); } + if (cfgUrl == null) + throw new Exception("Failed to resolve metadata path: " + DFLT_MAPPING_CONFIG); + try { GenericApplicationContext springCtx = new GenericApplicationContext(); - new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(metaUrl); + new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(cfgUrl)); springCtx.refresh(); @@ -153,10 +155,10 @@ public class CacheJdbcPojoStoreTest extends GridCommonAbstractTest { 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); + "[springUrl=" + cfgUrl + ']', e); else throw new IgniteCheckedException("Failed to instantiate Spring XML application context [springUrl=" + - metaUrl + ", err=" + e.getMessage() + ']', e); + cfgUrl + ", err=" + e.getMessage() + ']', e); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1eda58db/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java index b6a0ddf..780b3d3 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java @@ -36,7 +36,6 @@ import org.springframework.context.support.*; import org.springframework.core.io.*; import javax.cache.configuration.*; -import java.io.*; import java.net.*; import java.sql.*; import java.util.*; @@ -51,6 +50,9 @@ import static org.apache.ignite.testframework.GridTestUtils.*; */ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends CacheAbstractJdbcStore> extends GridCommonAbstractTest { + /** Default config with mapping. */ + private static final String DFLT_MAPPING_CONFIG = "modules/core/src/test/config/store/jdbc/Ignite.xml"; + /** Database connection URL. */ protected static final String DFLT_CONN_URL = "jdbc:h2:mem:autoCacheStore;DB_CLOSE_DELAY=-1"; @@ -120,19 +122,22 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach cc.setSwapEnabled(false); cc.setWriteBehindEnabled(false); - UrlResource metaUrl; + URL cfgUrl; try { - metaUrl = new UrlResource(new File("modules/core/src/test/config/store/jdbc/Ignite.xml").toURI().toURL()); + cfgUrl = new URL(DFLT_MAPPING_CONFIG); } - catch (MalformedURLException e) { - throw new IgniteCheckedException("Failed to resolve metadata path [err=" + e.getMessage() + ']', e); + catch (MalformedURLException ignore) { + cfgUrl = U.resolveIgniteUrl(DFLT_MAPPING_CONFIG); } + if (cfgUrl == null) + throw new Exception("Failed to resolve metadata path: " + DFLT_MAPPING_CONFIG); + try { GenericApplicationContext springCtx = new GenericApplicationContext(); - new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(metaUrl); + new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(cfgUrl)); springCtx.refresh(); @@ -144,10 +149,10 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach 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); + "[springUrl=" + cfgUrl + ']', e); else throw new IgniteCheckedException("Failed to instantiate Spring XML application context [springUrl=" + - metaUrl + ", err=" + e.getMessage() + ']', e); + cfgUrl + ", err=" + e.getMessage() + ']', e); } cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); @@ -163,12 +168,11 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach /** * @throws Exception If failed. */ - // TODO: IGNITE-205: Enabled when fixed. - public void _testMultithreadedPut() throws Exception { + public void testMultithreadedPut() throws Exception { IgniteInternalFuture<?> fut1 = runMultiThreadedAsync(new Callable<Object>() { private final Random rnd = new Random(); - @Override public Object call() throws Exception { + @Nullable @Override public Object call() throws Exception { for (int i = 0; i < TX_CNT; i++) { IgniteCache<Object, Object> cache = jcache(); @@ -187,7 +191,7 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach IgniteInternalFuture<?> fut2 = runMultiThreadedAsync(new Callable<Object>() { private final Random rnd = new Random(); - @Override public Object call() throws Exception { + @Nullable @Override public Object call() throws Exception { for (int i = 0; i < TX_CNT; i++) { IgniteCache<Object, Object> cache = jcache(); @@ -210,8 +214,7 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach /** * @throws Exception If failed. */ - // TODO: IGNITE-205: Enabled when fixed. - public void _testMultithreadedPutAll() throws Exception { + public void testMultithreadedPutAll() throws Exception { multithreaded(new Callable<Object>() { private final Random rnd = new Random(); @@ -243,12 +246,11 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach /** * @throws Exception If failed. */ - // TODO: IGNITE-205: Enabled when fixed. - public void _testMultithreadedExplicitTx() throws Exception { + public void testMultithreadedExplicitTx() throws Exception { runMultiThreaded(new Callable<Object>() { private final Random rnd = new Random(); - @Override public Object call() throws Exception { + @Nullable @Override public Object call() throws Exception { for (int i = 0; i < TX_CNT; i++) { IgniteCache<PersonKey, Person> cache = jcache();