public static EmbeddedCacheManager fromStream(InputStream is) throws IOException { return fromStream(is, false); }
public static EmbeddedCacheManager fromStream(InputStream is, boolean keepJmxDomainName) throws IOException { return fromStream(is, keepJmxDomainName, true); }
public static EmbeddedCacheManager fromStream(InputStream is, boolean keepJmxDomainName, boolean defaultParsersOnly) throws IOException { return fromStream(is, keepJmxDomainName, defaultParsersOnly, true); }
public static EmbeddedCacheManager fromString(String config) throws IOException { return fromStream(new ByteArrayInputStream(config.getBytes())); }
@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 static EmbeddedCacheManager fromXml(String xmlFile, boolean keepJmxDomainName) throws IOException { InputStream is = FileLookupFactory.newInstance().lookupFileStrict( xmlFile, Thread.currentThread().getContextClassLoader()); return fromStream(is, keepJmxDomainName); }
public static EmbeddedCacheManager fromXml(String xmlFile, boolean keepJmxDomainName, boolean defaultParserOnly) throws IOException { InputStream is = FileLookupFactory.newInstance().lookupFileStrict( xmlFile, Thread.currentThread().getContextClassLoader()); return fromStream(is, keepJmxDomainName, defaultParserOnly, true); }
private void testInvalidConfiguration(String xmlConfiguration) throws IOException { EmbeddedCacheManager invalidCacheManager = null; try { log.infof("Creating cache manager with %s", xmlConfiguration); invalidCacheManager = TestCacheManagerFactory .fromStream(new ByteArrayInputStream(xmlConfiguration.getBytes())); } finally { if (invalidCacheManager != null) { invalidCacheManager.stop(); } } }
public static EmbeddedCacheManager fromXml(String xmlFile, boolean keepJmxDomainName, boolean defaultParserOnly, boolean start) throws IOException { InputStream is = FileLookupFactory.newInstance().lookupFileStrict( xmlFile, Thread.currentThread().getContextClassLoader()); return fromStream(is, keepJmxDomainName, defaultParserOnly, start); }
@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 testDeclarativeCustomMBeanServerLookupProperties() throws IOException { String cfg = "<infinispan>" + "<cache-container default-cache=\"default\">" + "<jmx mbean-server-lookup=\"" + TestLookup.class.getName() + "\">" + "<property name=\"key\">value</property>" + "</jmx>" + "<local-cache name=\"default\" statistics=\"true\"/>" + "</cache-container>" + "</infinispan>"; InputStream stream = new ByteArrayInputStream(cfg.getBytes()); CacheContainer cc = null; try { cc = TestCacheManagerFactory.fromStream(stream); cc.getCache(); assert "value".equals(TestLookup.p.get("key")); } finally { TestingUtil.killCacheManagers(cc); } }
@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 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 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 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()); } }); }
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()); } }); }
private StoreConfiguration buildCacheManagerWithCacheStore(final String config) throws IOException { InputStream is = new ByteArrayInputStream(config.getBytes()); cacheManager = TestCacheManagerFactory.fromStream(is); assert cacheManager.getDefaultCacheConfiguration().persistence().stores().size() == 1; return cacheManager.getDefaultCacheConfiguration().persistence().stores().get(0); } }
private CacheLoaderConfiguration buildCacheManagerWithCacheStore(final String config) throws IOException { InputStream is = new ByteArrayInputStream(config.getBytes()); cacheManager = TestCacheManagerFactory.fromStream(is); assert cacheManager.getDefaultCacheConfiguration().loaders().cacheLoaders().size() == 1; return cacheManager.getDefaultCacheConfiguration().loaders().cacheLoaders().get(0); } }
@Test public void testDefault() throws IOException { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<infinispan>" + "<cache-container name=\"1\" default-cache=\"default-cache\">" + "<local-cache name=\"default-cache\" />" + "</cache-container>" + "</infinispan>"; InputStream stream = new ByteArrayInputStream(xml.getBytes()); EmbeddedCacheManager cm = TestCacheManagerFactory.fromStream(stream); try { // Verify that the configuration is correct Assert.assertNull(cm.getDefaultCacheConfiguration().dataContainer().dataContainer()); Assert.assertEquals(cm.getCache().getAdvancedCache().getDataContainer().getClass(), DefaultDataContainer.class); } finally { TestingUtil.killCacheManagers(cm); } }