use of org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation in project geode by apache.
the class CacheXml66DUnitTest method testTransactionWriter.
/**
* Tests that a region created with a named attributes set programmatically for delta propogation
* has the correct attributes.
*/
@Test
public void testTransactionWriter() throws Exception {
CacheCreation creation = new CacheCreation();
CacheTransactionManagerCreation ctmc = new CacheTransactionManagerCreation();
ctmc.setWriter(new TestTransactionWriter());
creation.addCacheTransactionManagerCreation(ctmc);
testXml(creation);
Cache c = getCache();
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
TransactionWriter tw = c.getCacheTransactionManager().getWriter();
assertTrue("tw should be TransactionWriter, but it is:" + tw, tw instanceof TestTransactionWriter);
}
use of org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation in project geode by apache.
the class CacheXml66DUnitTest method testCacheTransactionManager.
/**
* Tests transaction manager with no listener
*
* @since GemFire 4.0
*/
@Test
public void testCacheTransactionManager() throws Exception {
CacheCreation cache = new CacheCreation();
CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation();
cache.addCacheTransactionManagerCreation(txMgrCreation);
testXml(cache);
}
use of org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation in project geode by apache.
the class CacheXml66DUnitTest method testTransactionListener.
/**
* Tests a cache listener with no parameters
*
* @since GemFire 4.0
*/
@Test
public void testTransactionListener() throws Exception {
CacheCreation cache = new CacheCreation();
CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation();
txMgrCreation.setListener(new MyTestTransactionListener());
cache.addCacheTransactionManagerCreation(txMgrCreation);
testXml(cache);
}
use of org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation in project geode by apache.
the class CacheXml66DUnitTest method testMultipleTXListener.
/**
* Tests multiple transaction listeners
*
* @since GemFire 5.0
*/
@Test
public void testMultipleTXListener() throws Exception {
CacheCreation cache = new CacheCreation();
CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation();
TransactionListener l1 = new MyTestTransactionListener();
TransactionListener l2 = new MySecondTestTransactionListener();
txMgrCreation.addListener(l1);
txMgrCreation.addListener(l2);
cache.addCacheTransactionManagerCreation(txMgrCreation);
testXml(cache);
{
CacheTransactionManager tm = getCache().getCacheTransactionManager();
assertEquals(Arrays.asList(new TransactionListener[] { l1, l2 }), Arrays.asList(tm.getListeners()));
tm.removeListener(l2);
assertEquals(Arrays.asList(new TransactionListener[] { l1 }), Arrays.asList(tm.getListeners()));
tm.removeListener(l1);
assertEquals(Arrays.asList(new TransactionListener[] {}), Arrays.asList(tm.getListeners()));
tm.addListener(l1);
assertEquals(Arrays.asList(new TransactionListener[] { l1 }), Arrays.asList(tm.getListeners()));
tm.addListener(l1);
assertEquals(Arrays.asList(new TransactionListener[] { l1 }), Arrays.asList(tm.getListeners()));
tm.addListener(l2);
assertEquals(Arrays.asList(new TransactionListener[] { l1, l2 }), Arrays.asList(tm.getListeners()));
tm.removeListener(l1);
assertEquals(Arrays.asList(new TransactionListener[] { l2 }), Arrays.asList(tm.getListeners()));
tm.removeListener(l1);
assertEquals(Arrays.asList(new TransactionListener[] { l2 }), Arrays.asList(tm.getListeners()));
tm.initListeners(new TransactionListener[] { l1, l2 });
assertEquals(Arrays.asList(new TransactionListener[] { l1, l2 }), Arrays.asList(tm.getListeners()));
}
}
use of org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation in project geode by apache.
the class CacheXml66DUnitTest method testTXManagerOnClientCache.
@Test
public void testTXManagerOnClientCache() throws Exception {
ClientCacheCreation cc = new ClientCacheCreation();
// CacheCreation cc = new CacheCreation();
CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation();
txMgrCreation.addListener(new TestTXListener());
cc.addCacheTransactionManagerCreation(txMgrCreation);
testXml(cc);
Cache c = getCache();
assertTrue(c instanceof ClientCache);
c.loadCacheXml(generate(cc));
ClientCache clientC = (ClientCache) c;
CacheTransactionManager mgr = clientC.getCacheTransactionManager();
assertNotNull(mgr);
assertTrue(mgr.getListeners()[0] instanceof TestTXListener);
}
Aggregations