Package org.jboss.cache.transaction

Examples of org.jboss.cache.transaction.DummyTransactionManager


    {
        groupIncreaser++;
        TreeCache cache = createSyncReplicatedCache();
        TreeCache cache2 = createSyncReplicatedCache();

        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        assertNull(mgr.getTransaction());

        mgr.begin();

        assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

        SamplePojo pojo = new SamplePojo(21, "test");

        cache.put("/one/two", "key1", pojo);

        mgr.commit();

        // cache asserts
        assertNull(mgr.getTransaction());
        assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

        assertTrue(cache.exists(Fqn.fromString("/one/two")));
        assertNotNull(cache.get(Fqn.fromString("/")).getChild("one"));
View Full Code Here


    {
        groupIncreaser++;
        TreeCache cache = createSyncReplicatedCache();
        TreeCache cache2 = createSyncReplicatedCache();

        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        assertNull(mgr.getTransaction());

        mgr.begin();

        assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

        SamplePojo pojo = new SamplePojo(21, "test");

        cache.put("/one/two", "key1", pojo);

        mgr.commit();

        // cache asserts
        assertNull(mgr.getTransaction());
        assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

        assertTrue(cache.exists(Fqn.fromString("/one/two")));
        assertNotNull(cache.get(Fqn.fromString("/")).getChild("one"));
View Full Code Here

    {
        groupIncreaser++;
        TreeCache cache = createSyncReplicatedCache();
        TreeCache cache2 = createSyncReplicatedCache();

        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        assertNull(mgr.getTransaction());

        mgr.begin();
        Transaction tx = mgr.getTransaction();
        assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

        SamplePojo pojo = new SamplePojo(21, "test");

        cache.put("/one/two", "key1", pojo);

        mgr.suspend();

        assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());

        GlobalTransaction gtx = cache.getCurrentTransaction(tx);
        TransactionTable table = cache.getTransactionTable();
        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table
                .get(gtx);


        assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
        assertNull(mgr.getTransaction());

        mgr.begin();

        SamplePojo pojo2 = new SamplePojo(22, "test2");

        cache2.put("/one/two", "key1", pojo2);

        mgr.commit();

        assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());

        mgr.resume(tx);

        boolean fail = false;
        try
        {
            mgr.commit();
        }
        catch (Exception e)
        {
            fail = true;

        }

        assertEquals(true, fail);
        assertNull(mgr.getTransaction());
        assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

        assertEquals(0, entry.getTransactionWorkSpace().getNodes().size());
View Full Code Here

        SamplePojo pojo1 = new SamplePojo(21, "test-1");
        SamplePojo pojo2 = new SamplePojo(21, "test-2");

        TreeCache cache = createCacheWithListener();

        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        assertNull(mgr.getTransaction());

        // first put in a value
        mgr.begin();

        assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

        cache.put("/one/two", "key1", pojo1);

        mgr.commit();

        mgr.begin();
        Transaction tx = mgr.getTransaction();
        System.out.println("Current TX " + mgr.getTransaction());
        assertEquals(pojo1, cache.get("/one/two", "key1"));

        // start another
        mgr.suspend();

        mgr.begin();
        System.out.println("Current TX " + mgr.getTransaction());
        cache.put("/one/two", "key2", pojo2);

        // assert we can see this INSIDE the existing tx
        //assertEquals(pojo2, cache.get("/one/two", "key2"));

        mgr.commit();

        // assert we can see this outside the existing tx
        assertEquals(pojo2, cache.get("/one/two", "key2"));
        System.out.println("Current TX " + mgr.getTransaction());
        // resume the suspended one
        mgr.resume(tx);
        System.out.println("Current TX " + mgr.getTransaction());
        // assert we can't see the change from tx2 as we already touched the node
        assertEquals(null, cache.get("/one/two", "key2"));
        mgr.commit();
        destroyCache(cache);
    }
View Full Code Here

        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(interceptor);

//     first set up a node with a pojo
        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        mgr.begin();
        Transaction tx = mgr.getTransaction();

        // inject InvocationContext
        cache.getInvocationContext().setTransaction(tx);
        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));


        cache.remove("/one/two");
        mgr.commit();
        assertEquals(null, dummy.getCalled());
        TransactionTable table = cache.getTransactionTable();

        GlobalTransaction gtx = table.get(tx);
View Full Code Here

        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(interceptor);

//     first set up a node with a pojo
        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        mgr.begin();
        Transaction tx = mgr.getTransaction();

        // inject InvocationContext
        cache.getInvocationContext().setTransaction(tx);
        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));

        SamplePojo pojo = new SamplePojo(21, "test");
        Map temp = new HashMap();
        temp.put("key1", pojo);
        cache.put("/one/two", temp);

        cache.remove("/one/two");
        assertEquals(null, dummy.getCalled());
        TransactionTable table = cache.getTransactionTable();

        GlobalTransaction gtx = table.get(tx);

        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

        TransactionWorkspace workspace = entry.getTransactionWorkSpace();

        mgr.commit();

        //assert what should be the results of our call
        assertEquals(3, workspace.getNodes().size());

        assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
View Full Code Here

        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(interceptor);

//     first set up a node with a pojo
        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        mgr.begin();
        Transaction tx = mgr.getTransaction();

        // inject InvocationContext
        cache.getInvocationContext().setTransaction(tx);
        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));

        SamplePojo pojo = new SamplePojo(21, "test");
        Map temp = new HashMap();
        temp.put("key1", pojo);
        cache.put("/one/two", temp);

        cache.remove("/one");
        assertEquals(null, dummy.getCalled());
        TransactionTable table = cache.getTransactionTable();

        GlobalTransaction gtx = table.get(tx);

        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

        TransactionWorkspace workspace = entry.getTransactionWorkSpace();

        mgr.commit();

        //assert what should be the results of our call
        assertEquals(3, workspace.getNodes().size());

        assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
View Full Code Here

        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(interceptor);

//     first set up a node with a pojo
        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        mgr.begin();
        Transaction tx = mgr.getTransaction();

        // inject InvocationContext
        cache.getInvocationContext().setTransaction(tx);
        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));

        SamplePojo pojo = new SamplePojo(21, "test");
        Map temp = new HashMap();
        temp.put("key1", pojo);
        cache.put("/one/two", temp);

        // get the transaction stuff
        TransactionTable table = cache.getTransactionTable();
        GlobalTransaction gtx = table.get(tx);

        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

        TransactionWorkspace workspace = entry.getTransactionWorkSpace();

        workspace.getNode(Fqn.fromString("/one"));
        workspace.getNode(Fqn.fromString("/one/two"));


        cache.remove("/one");

        assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
        assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
        assertNotNull(workspace.getNode(Fqn.fromString("/one")));
        assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isDeleted());

        //will still have alink from one to two
        assertNotNull(workspace.getNode(Fqn.fromString("/one")).getChild("two"));
        assertEquals(null, workspace.getNode(Fqn.fromString("/")).getChild("one"));

        //now put /one/two back in
        cache.remove("/one");


        assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
        assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
        assertNotNull(workspace.getNode(Fqn.fromString("/one")));
        assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isDeleted());

        //will still have alink from one to two
        assertNotNull(workspace.getNode(Fqn.fromString("/one")).getChild("two"));
        assertEquals(null, workspace.getNode(Fqn.fromString("/")).getChild("one"));

        assertEquals(null, dummy.getCalled());


        mgr.commit();

        //assert what should be the results of our call
        assertEquals(3, workspace.getNodes().size());

View Full Code Here

        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(interceptor);

//     first set up a node with a pojo
        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        mgr.begin();
        Transaction tx = mgr.getTransaction();

        // inject InvocationContext
        cache.getInvocationContext().setTransaction(tx);
        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));

        SamplePojo pojo = new SamplePojo(21, "test");
        Map temp = new HashMap();
        temp.put("key1", pojo);
        cache.put("/one/two", temp);

        // get the transaction stuff
        TransactionTable table = cache.getTransactionTable();
        GlobalTransaction gtx = table.get(tx);

        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

        TransactionWorkspace workspace = entry.getTransactionWorkSpace();

        TreeNode one = workspace.getNode(Fqn.fromString("/one"));
        TreeNode two = workspace.getNode(Fqn.fromString("/one/two"));


        cache.remove("/one");

        assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
        assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
        assertNotNull(workspace.getNode(Fqn.fromString("/one")));
        assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isDeleted());

        //will still have alink from one to two
        assertNotNull(workspace.getNode(Fqn.fromString("/one")).getChild("two"));
        assertEquals(null, workspace.getNode(Fqn.fromString("/")).getChild("one"));

        //now put /one/two back in
        cache.put("/one/two", temp);

        WorkspaceNode oneAfter = workspace.getNode(Fqn.fromString("/one"));
        WorkspaceNode twoAfter = workspace.getNode(Fqn.fromString("/one/two"));

        assertNotSame(one, oneAfter);
        assertEquals(false, oneAfter.isDeleted());
        assertNotSame(two, twoAfter);
        assertEquals(false, twoAfter.isDeleted());

        assertEquals(twoAfter.getNode(), workspace.getNode(Fqn.fromString("/one")).getChild("two"));
        assertEquals(oneAfter.getNode(), workspace.getNode(Fqn.fromString("/")).getChild("one"));

        assertEquals(null, dummy.getCalled());


        mgr.commit();

        //assert what should be the results of our call
        assertEquals(3, workspace.getNodes().size());

View Full Code Here

        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(interceptor);

//     first set up a node with a pojo
        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
        mgr.begin();
        Transaction tx = mgr.getTransaction();

        // inject InvocationContext
        cache.getInvocationContext().setTransaction(tx);
        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));

        SamplePojo pojo = new SamplePojo(21, "test");
        Map temp = new HashMap();
        temp.put("key1", pojo);
        cache.put("/one/two", temp);

        // get the transaction stuff
        TransactionTable table = cache.getTransactionTable();
        GlobalTransaction gtx = table.get(tx);

        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

        TransactionWorkspace workspace = entry.getTransactionWorkSpace();

        TreeNode one = workspace.getNode(Fqn.fromString("/one"));
        TreeNode two = workspace.getNode(Fqn.fromString("/one/two"));


        cache.remove("/one");

        assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
        assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
        assertNotNull(workspace.getNode(Fqn.fromString("/one")));
        assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isDeleted());

        //will still have alink from one to two
        assertNotNull(workspace.getNode(Fqn.fromString("/one")).getChild("two"));
        assertEquals(null, workspace.getNode(Fqn.fromString("/")).getChild("one"));

        //now put /one back in
        SamplePojo pojo2 = new SamplePojo(21, "test");
        cache.put("/one", "key1", pojo2);

        WorkspaceNode oneAfter = workspace.getNode(Fqn.fromString("/one"));
        WorkspaceNode twoAfter = workspace.getNode(Fqn.fromString("/one/two"));

        assertNotSame(one, oneAfter);
        assertEquals(false, oneAfter.isDeleted());
        assertEquals(two, twoAfter);
        assertEquals(true, twoAfter.isDeleted());

        assertNull(workspace.getNode(Fqn.fromString("/one")).getChild("two"));
        assertEquals(oneAfter.getNode(), workspace.getNode(Fqn.fromString("/")).getChild("one"));

        assertEquals(null, dummy.getCalled());


        mgr.commit();

        assertEquals(pojo2, workspace.getNode(Fqn.fromString("/one")).get("key1"));
        //assert what should be the results of our call
        assertEquals(3, workspace.getNodes().size());
View Full Code Here

TOP

Related Classes of org.jboss.cache.transaction.DummyTransactionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.