ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
Assert.assertNotNull(ref);
osgiHelper.waitForService(TransactionManager.class.getName(), null, 5000);
CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
TransactionManager tm = (TransactionManager) osgiHelper.getServiceObject(TransactionManager.class.getName(), null);
tm.begin();
Transaction t = tm.getTransaction();
try {
cs.doSomethingBad2();
Assert.fail("UnsupportedOperationException expected");
} catch (Exception e) {
Assert.assertTrue(e instanceof UnsupportedOperationException);
}
Transaction t2 = cs.getCurrentTransaction();
Assert.assertSame(t2, t);
Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
t.commit();
Assert.assertNull(cs.getLastRolledBack());
Assert.assertNotNull(cs.getLastCommitted());
Assert.assertEquals(1, cs.getNumberOfCommit());
Assert.assertEquals(0, cs.getNumberOfRollback());
Assert.assertSame(t, cs.getLastCommitted());
}