From 1eda58dbb393803901f4a748aab39f8a2c068fb0 Mon Sep 17 00:00:00 2001 From: anovikov Date: Mon, 9 Feb 2015 18:07:46 +0700 Subject: [PATCH 11/21] # ignite-205 Fixed incorrect path in test. --- .../cache/store/jdbc/CacheJdbcPojoStoreTest.java | 22 +++++++------ ...acheJdbcStoreAbstractMultithreadedSelfTest.java | 36 ++++++++++++---------- 2 files changed, 31 insertions(+), 27 deletions(-) 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 jdbc:h2:mem:jdbcCacheStore;DB_CLOSE_DELAY=-1). */ - 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); } } 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 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