use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testPackUnpack.
@Test
public void testPackUnpack() throws Exception {
XAResourceRecord xares;
DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
Object[] params = new Object[1];
params[XAResourceRecord.XACONNECTION] = rc;
xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), params);
OutputObjectState os = new OutputObjectState();
assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
InputObjectState is = new InputObjectState(os);
assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), null);
os = new OutputObjectState();
assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
is = new InputObjectState(os);
assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
}
use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.
the class XAResourceRecordUnitTest method test.
@Test
public void test() throws Exception {
XAResourceRecord xares = new XAResourceRecord();
Object obj = new Object();
xares.setValue(obj);
assertTrue(xares.value() != obj);
DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
Object[] params = new Object[1];
params[XAResourceRecord.XACONNECTION] = rc;
xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), params);
assertTrue(xares.type() != null);
xares.merge(xares);
xares.replace(xares);
assertTrue(xares.toString() != null);
}
use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testReadonly.
@Test
public void testReadonly() throws Exception {
XAResourceRecord xares;
DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
Object[] params = new Object[1];
params[XAResourceRecord.XACONNECTION] = rc;
xares = new XAResourceRecord(new TransactionImple(0), new TestResource(true), new XidImple(new Uid()), params);
assertEquals(xares.topLevelCommit(), TwoPhaseOutcome.NOT_PREPARED);
assertEquals(xares.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
}
use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.
the class OnePhaseUnitTest method testPackUnpackError.
@Test
public void testPackUnpackError() throws Exception {
SampleOnePhaseResource res = new SampleOnePhaseResource();
XidImple xid = new XidImple(new Uid());
XAOnePhaseResource xares = new XAOnePhaseResource(res, xid, null);
OutputObjectState os = new OutputObjectState();
try {
xares.pack(os);
fail();
} catch (final IOException ex) {
}
}
use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.
the class OnePhaseUnitTest method testFailure.
@Test
public void testFailure() throws Exception {
SampleOnePhaseResource res = new SampleOnePhaseResource(ErrorType.heurmix);
XAOnePhaseResource xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
assertEquals(xares.commit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
res = new SampleOnePhaseResource(ErrorType.rmerr);
xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
assertEquals(xares.commit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
res = new SampleOnePhaseResource(ErrorType.nota);
xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
assertEquals(xares.commit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
res = new SampleOnePhaseResource(ErrorType.inval);
xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
assertEquals(xares.commit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
res = new SampleOnePhaseResource(ErrorType.proto);
xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
assertEquals(xares.commit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
}
Aggregations