Package org.gridkit.coherence.txlite

Examples of org.gridkit.coherence.txlite.TxSession


  @Test
  public void testReadThenWrite() {
   
    TxManager txman = TxLite.getManager();
   
    TxSession rsession = txman.openReadOnlySession();
    TxSession wsession = txman.openReadWriteSession();
    NamedCache writeA = wsession.connect(cacheA);
    NamedCache rrA = rsession.connect(cacheA);
    NamedCache rcA = txman.toReadCommited(cacheA);

    Assert.assertThat(rrA.get("A"), IsNull.nullValue());
    Assert.assertThat(rcA.get("A"), IsNull.nullValue());
    Assert.assertThat(cacheA.get("A"), IsNull.nullValue());
    Assert.assertThat(writeA.get("A"), IsNull.nullValue());
   
    writeA.put("A", "A");
 
    Assert.assertThat(rrA.get("A"), IsNull.nullValue());
    Assert.assertThat(rcA.get("A"), IsNull.nullValue());
    Assert.assertThat((String)cacheA.get("A"), Is.is("A"));
    Assert.assertThat((String)writeA.get("A"), Is.is("A"));

    wsession.commit();
   
    Assert.assertThat(rrA.get("A"), IsNull.nullValue());
    Assert.assertThat((String)rcA.get("A"), Is.is("A"));

    rsession.commit();
View Full Code Here


  @Test
  public void testReadThenWrite() {
   
    TxManager txman = new TxManager(superviser);
   
    TxSession readSession = txman.openReadOnlySession();
    NamedCache readA = readSession.connect(cacheA);
    TxCacheWrapper dirtyA = new TxCacheWrapper(cacheA, new DirtyReadCacheAccessAdapter());
   
    TxSession writeSession = txman.openReadWriteSession();
    NamedCache writeA = writeSession.connect(cacheA);
   
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    Assert.assertThat(dirtyA.get("A"), IsNull.nullValue());
    Assert.assertThat(writeA.get("A"), IsNull.nullValue());
   
    writeA.put("A", "A");
   
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    Assert.assertThat((String)dirtyA.get("A"), Is.is("A"));
    Assert.assertThat((String)writeA.get("A"), Is.is("A"));
   
    writeSession.commit();
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    readSession.commit();
    Assert.assertThat((String)readA.get("A"), Is.is("A"));
  }
View Full Code Here

  @Test
  public void testReadThenWriteThenRollback() {
   
    TxManager txman = new TxManager(superviser);
   
    TxSession readSession = txman.openReadOnlySession();
    NamedCache readA = readSession.connect(cacheA);
    TxCacheWrapper dirtyA = new TxCacheWrapper(cacheA, new DirtyReadCacheAccessAdapter());
   
    TxSession writeSession = txman.openReadWriteSession();
    NamedCache writeA = writeSession.connect(cacheA);
   
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    Assert.assertThat(dirtyA.get("A"), IsNull.nullValue());
    Assert.assertThat(writeA.get("A"), IsNull.nullValue());
   
    writeA.put("A", "A");
   
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    Assert.assertThat((String)dirtyA.get("A"), Is.is("A"));
    Assert.assertThat((String)writeA.get("A"), Is.is("A"));
   
    writeSession.rollback();
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    readSession.commit();
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    Assert.assertThat(dirtyA.get("A"), IsNull.nullValue());
    Assert.assertThat(writeA.get("A"), IsNull.nullValue());
    writeSession.rollback();
  }
View Full Code Here

TOP

Related Classes of org.gridkit.coherence.txlite.TxSession

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.