/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { Connection conn = DriverManager.getConnection(DFLT_CONN_URL, "sa", ""); Statement stmt = conn.createStatement(); stmt.executeUpdate("DROP TABLE IF EXISTS Organization"); stmt.executeUpdate("DROP TABLE IF EXISTS Person"); stmt.executeUpdate("CREATE TABLE Organization (id integer PRIMARY KEY, name varchar(50), city varchar(50))"); stmt.executeUpdate("CREATE TABLE Person (id integer PRIMARY KEY, org_id integer, name varchar(50))"); conn.commit(); U.closeQuiet(stmt); U.closeQuiet(conn); startGrid(); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); }
/** * @return Cache configuration. * @throws Exception If failed. */ protected CacheConfiguration cacheConfiguration() throws Exception { CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); cc.setAtomicityMode(ATOMIC); cc.setWriteBehindEnabled(false); cc.setCacheStoreFactory(singletonFactory(store)); cc.setReadThrough(true); cc.setWriteThrough(true); cc.setLoadPreviousValue(true); return cc; }
multithreaded(new Callable<Object>() { private final Random rnd = new Random();
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); c.setCacheConfiguration(cacheConfiguration()); return c; }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { store = store(); URL cfgUrl; try { cfgUrl = new URL(DFLT_MAPPING_CONFIG); } 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(new UrlResource(cfgUrl)); springCtx.refresh(); Collection<JdbcType> types = new ArrayList<>(springCtx.getBeansOfType(JdbcType.class).values()); store.setTypes(types.toArray(new JdbcType[types.size()])); } catch (BeansException e) { 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=" + cfgUrl + ']', e); else throw new IgniteCheckedException("Failed to instantiate Spring XML application context [springUrl=" + cfgUrl + ", err=" + e.getMessage() + ']', e); } }