Search in sources :

Example 1 with CacheTransactionManagerCreation

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);
}
Also used : CacheTransactionManagerCreation(org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation) TransactionWriter(org.apache.geode.cache.TransactionWriter) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Test(org.junit.Test)

Example 2 with CacheTransactionManagerCreation

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);
}
Also used : CacheTransactionManagerCreation(org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Test(org.junit.Test)

Example 3 with CacheTransactionManagerCreation

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);
}
Also used : CacheTransactionManagerCreation(org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Test(org.junit.Test)

Example 4 with CacheTransactionManagerCreation

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()));
    }
}
Also used : TransactionListener(org.apache.geode.cache.TransactionListener) CacheTransactionManagerCreation(org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) Test(org.junit.Test)

Example 5 with CacheTransactionManagerCreation

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);
}
Also used : CacheTransactionManagerCreation(org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) ClientCache(org.apache.geode.cache.client.ClientCache) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) Test(org.junit.Test)

Aggregations

CacheTransactionManagerCreation (org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation)6 ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)6 Test (org.junit.Test)6 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)4 Cache (org.apache.geode.cache.Cache)2 CacheTransactionManager (org.apache.geode.cache.CacheTransactionManager)2 ClientCache (org.apache.geode.cache.client.ClientCache)2 TransactionListener (org.apache.geode.cache.TransactionListener)1 TransactionWriter (org.apache.geode.cache.TransactionWriter)1 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)1 IgnoredException (org.apache.geode.test.dunit.IgnoredException)1