public void testExtendedParserModulesElement() throws IOException { String config = TestingUtil.wrapXMLWithSchema("8.2", "<cache-container name=\"container-extra-modules\" default-cache=\"extra-module\">" + " <local-cache name=\"extra-module\">\n" + " <modules>\n" + " <sample-element xmlns=\"urn:infinispan:config:mymodule\" sample-attribute=\"test-value\" />\n" + " </modules>\n" + " </local-cache>\n" + "</cache-container>" ); assertCacheConfiguration(config); }
@Test(expectedExceptions=CacheConfigurationException.class) public void testDuplicateCacheNames() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"duplicatename\">" + " <transport cluster=\"demoCluster\"/>\n" + " <distributed-cache name=\"duplicatename\">\n" + " </distributed-cache>\n" + " <distributed-cache name=\"duplicatename\">\n" + " </distributed-cache>\n" + "</cache-container>" ); InputStream is = new ByteArrayInputStream(config.getBytes()); TestCacheManagerFactory.fromStream(is); }
public void testExtendedParserBareExtension() throws IOException { String config = TestingUtil.wrapXMLWithSchema( "<cache-container name=\"container-extra-modules\" default-cache=\"extra-module\">" + " <local-cache name=\"extra-module\">\n" + " <sample-element xmlns=\"urn:infinispan:config:mymodule\" sample-attribute=\"test-value\" />\n" + " </local-cache>\n" + "</cache-container>" ); assertCacheConfiguration(config); }
@Test(expectedExceptions = CacheConfigurationException.class, expectedExceptionsMessageRegExp = "java.lang.IllegalStateException: WRONG SCOPE") public void testExtendedParserWrongScope() throws IOException { String config = TestingUtil.wrapXMLWithSchema( "<cache-container name=\"container-extra-modules\" default-cache=\"extra-module\">" + " <local-cache name=\"extra-module\">\n" + " </local-cache>\n" + " <sample-element xmlns=\"urn:infinispan:config:mymodule\" sample-attribute=\"test-value\" />\n" + "</cache-container>" ); parseToHolder(config); } }
public static String wrapXMLWithSchema(String xml) { return wrapXMLWithSchema(Version.getSchemaVersion(), xml); }
@Test(expectedExceptions = CacheConfigurationException.class, expectedExceptionsMessageRegExp = "ISPN000484:.*") public void testNoWildcardsInCacheName() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container>" + " <transport cluster=\"demoCluster\"/>\n" + " <replicated-cache name=\"wildcard*\">\n" + " </replicated-cache>\n" + "</cache-container>" ); InputStream is = new ByteArrayInputStream(config.getBytes()); withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.fromStream(is)) { @Override public void call() { fail("Should have failed earlier"); } }); }
public void testNamedCacheXMLClashingNames() { String xml = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + "\n" + " <local-cache name=\"default\">\n" + " <locking concurrencyLevel=\"100\" lockAcquisitionTimeout=\"1000\" />\n" + " </local-cache>\n" + "\n" + " <local-cache name=\"c1\">\n" + " <transaction transaction-manager-lookup=\"org.infinispan.transaction.lookup.GenericTransactionManagerLookup\"/>\n" + " </local-cache>\n" + "\n" + " <replicated-cache name=\"c1\" mode=\"SYNC\" remote-timeout=\"15000\">\n" + " </replicated-cache>\n" + "</cache-container>"); ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes()); try { cm = TestCacheManagerFactory.fromStream(bais); assert false : "Should fail"; } catch (Throwable expected) { } }
@Test(expectedExceptions = CacheConfigurationException.class, expectedExceptionsMessageRegExp = "ISPN000432:.*") public void testNoDefaultCacheDeclaration() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"non-existent\">" + " <transport cluster=\"demoCluster\"/>\n" + " <replicated-cache name=\"default\">\n" + " </replicated-cache>\n" + "</cache-container>" ); InputStream is = new ByteArrayInputStream(config.getBytes()); withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.fromStream(is)) { @Override public void call() { // Do nothing } }); }
public void testCustomTransport() throws IOException { String config = TestingUtil.wrapXMLWithSchema( "<jgroups transport=\"org.infinispan.configuration.XmlFileParsingTest$CustomTransport\"/>\n" + "<cache-container default-cache=\"default\">\n" + " <transport cluster=\"ispn-perf-test\"/>\n" + " <distributed-cache name=\"default\"/>\n" + "</cache-container>" ); InputStream is = new ByteArrayInputStream(config.getBytes()); withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.fromStream(is)) { @Override public void call() { Transport transport = cm.getTransport(); assertNotNull(transport); assertTrue(transport instanceof CustomTransport); } }); }
public void testNoNamedCaches() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + " <transport cluster=\"demoCluster\"/>\n" + " <replicated-cache name=\"default\">\n" + " </replicated-cache>\n" + "</cache-container>" ); InputStream is = new ByteArrayInputStream(config.getBytes()); withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.fromStream(is)) { @Override public void call() { GlobalConfiguration globalCfg = cm.getCacheManagerConfiguration(); assertTrue(globalCfg.transport().transport() instanceof JGroupsTransport); assertEquals("demoCluster", globalCfg.transport().clusterName()); Configuration cfg = cm.getDefaultCacheConfiguration(); assertEquals(CacheMode.REPL_SYNC, cfg.clustering().cacheMode()); } }); }
public void testNoSchemaWithStuff() throws IOException { String config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + " <local-cache name=\"default\">\n" + " <locking concurrency-level=\"10000\" isolation=\"REPEATABLE_READ\" />\n" + " </local-cache>\n" + "</cache-container>" ); InputStream is = new ByteArrayInputStream(config.getBytes()); withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.fromStream(is)) { @Override public void call() { Configuration cfg = cm.getDefaultCacheConfiguration(); assertEquals(10000, cfg.locking().concurrencyLevel()); assertEquals(IsolationLevel.REPEATABLE_READ, cfg.locking().isolationLevel()); } }); }
@Test(expectedExceptions = CacheConfigurationException.class, expectedExceptionsMessageRegExp = "ISPN000485:.*") public void testAmbiguousWildcards() throws IOException { String config = TestingUtil.wrapXMLWithSchema( "<cache-container>" + " <local-cache-configuration name=\"wildcache*\">\n" + " <expiration interval=\"10500\" lifespan=\"11\" max-idle=\"11\"/>\n" + " </local-cache-configuration>\n" + " <local-cache-configuration name=\"wild*\">\n" + " </local-cache-configuration>\n" + "</cache-container>" ); InputStream is = new ByteArrayInputStream(config.getBytes()); withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.fromStream(is)) { @Override public void call() { cm.getCacheConfiguration("wildcache1"); fail("Ambiguous name should have thrown exception"); } }); }
public void testWildcards() throws IOException { String config = TestingUtil.wrapXMLWithSchema( "<cache-container>" + " <local-cache-configuration name=\"wildcache*\">\n" + " <expiration interval=\"10500\" lifespan=\"11\" max-idle=\"11\"/>\n" + " </local-cache-configuration>\n" + "</cache-container>" ); InputStream is = new ByteArrayInputStream(config.getBytes()); withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.fromStream(is)) { @Override public void call() { Configuration wildcache1 = cm.getCacheConfiguration("wildcache1"); assertNotNull(wildcache1); assertEquals(10500, wildcache1.expiration().wakeUpInterval()); assertEquals(11, wildcache1.expiration().lifespan()); assertEquals(11, wildcache1.expiration().maxIdle()); } }); }
public void testNoDefaultCache() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container>" + " <transport cluster=\"demoCluster\"/>\n" + " <replicated-cache name=\"default\">\n" + " </replicated-cache>\n" + "</cache-container>" ); InputStream is = new ByteArrayInputStream(config.getBytes()); withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.fromStream(is)) { @Override public void call() { GlobalConfiguration globalCfg = cm.getCacheManagerConfiguration(); assertFalse(globalCfg.defaultCacheName().isPresent()); assertNull(cm.getDefaultCacheConfiguration()); assertEquals(CacheMode.REPL_SYNC, cm.getCacheConfiguration("default").clustering().cacheMode()); } }); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + " <local-cache name=\"default\">\n" + " <indexing index=\"LOCAL\">\n" + " <property name=\"default.directory_provider\">local-heap</property>\n" + " <property name=\"lucene_version\">LUCENE_CURRENT</property>\n" + " </indexing>\n" + " </local-cache>\n" + "</cache-container>" ); log.tracef("Using test configuration:\n%s", config); InputStream is = new ByteArrayInputStream(config.getBytes()); try { cacheManager = TestCacheManagerFactory.fromStream(is); } finally { is.close(); } cache = cacheManager.getCache(); return cacheManager; }
public void testCompatibility() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + " <local-cache name=\"default\">\n" + config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + " <local-cache name=\"default\">\n" + config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + " <local-cache name=\"default\">\n" +
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + " <local-cache name=\"default\">\n" + " <indexing index=\"NONE\" />\n" + " </local-cache>\n" + " <local-cache name=\"indexingenabled\">\n" + " <indexing index=\"LOCAL\" >\n" + " <property name=\"default.directory_provider\">local-heap</property>\n" + " <property name=\"lucene_version\">LUCENE_CURRENT</property>\n" + " </indexing>\n" + " </local-cache>\n" + "</cache-container>" ); log.tracef("Using test configuration:\n%s", config); InputStream is = new ByteArrayInputStream(config.getBytes()); final EmbeddedCacheManager cm; try { cm = TestCacheManagerFactory.fromStream(is); } finally { is.close(); } cache = cm.getCache(); return cm; }
public void testParsingEmptyElement() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + " <local-cache name=\"default\">\n" + " <persistence passivation=\"false\"> \n" + " <file-store shared=\"false\" preload=\"true\"/> \n" + " </persistence>\n" + " </local-cache>\n" + "</cache-container>"); ConfigurationBuilderHolder holder = new ParserRegistry().parse(config); List<StoreConfiguration> storeConfigs = holder.getDefaultConfigurationBuilder().build().persistence().stores(); assertEquals(1, storeConfigs.size()); SingleFileStoreConfiguration fileStoreConfig = (SingleFileStoreConfiguration) storeConfigs.get(0); assertEquals("Infinispan-SingleFileStore", fileStoreConfig.location()); assertEquals(-1, fileStoreConfig.maxEntries()); }
public void testRemoteCacheStore() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + " <local-cache name=\"default\">\n" + " <persistence>\n" + " <remote-store xmlns=\"urn:infinispan:config:store:remote:"+ Version.getSchemaVersion() + "\" >\n" + " <remote-server host=\"one\" />\n" + " <remote-server host=\"two\" />\n" + " <connection-pool max-active=\"10\" exhausted-action=\"CREATE_NEW\" />\n" + " <async-executor>\n" + " <property name=\"maxThreads\">4</property>" + " </async-executor>\n" + " <write-behind/>\n" + " </remote-store>\n" + " </persistence>\n" + " </local-cache>\n" + "</cache-container>" ); RemoteStoreConfiguration store = (RemoteStoreConfiguration) buildCacheManagerWithCacheStore(config); assert store.servers().size() == 2; assert store.connectionPool().exhaustedAction() == ExhaustedAction.CREATE_NEW; assert store.asyncExecutorFactory().properties().getIntProperty("maxThreads", 0) == 4; assert store.async().enabled(); }
public void testStringKeyedJdbcStore() throws Exception { String config = TestingUtil.wrapXMLWithSchema( " <cache-container default-cache=\"default\">\n" + " <local-cache name=\"default\">\n" +