@Test
  public void testMultiInvoke() throws Exception {
    uba.begin();
    client.saveDataManualComplete();
    client.saveDataManualComplete(ServiceCommand.COMPLETE);
    uba.close();

    assertOrder(ConfirmCompleted.class, Close.class);
  }
 @Test(expected = TransactionRolledBackException.class)
 public void testCannotComplete() throws Exception {
   uba.begin();
   client.saveDataAutoComplete(ServiceCommand.CANNOT_COMPLETE);
   uba.close();
   assertOrder();
 }
 private void assertDataAvailable() {
   List<Class<? extends Annotation>> log = client.getEventLog().getDataUnavailableLog();
   if (!log.isEmpty()) {
     org.junit.Assert.fail(
         "One or more lifecycle methods could not access the managed data: " + log.toString());
   }
 }
  @Test
  public void testClientDrivenCompensate() throws Exception {
    uba.begin();
    client.saveDataAutoComplete();
    uba.cancel();

    assertOrder(ConfirmCompleted.class, Compensate.class);
  }
  @Test
  public void testAutoComplete() throws Exception {
    uba.begin();
    client.saveDataAutoComplete();
    uba.close();

    assertOrder(ConfirmCompleted.class, Close.class);
  }
 @Test
 public void testApplicationException() throws Exception {
   try {
     uba.begin();
     client.saveDataAutoComplete(ServiceCommand.THROW_APPLICATION_EXCEPTION);
     Assert.fail("Exception should have been thrown by now");
   } catch (SOAPFaultException e) {
     // todo: can we pass application exceptions over SOAP when using an EJB exposed as a JAX-WS
     // ws?
     System.out.println("Caught exception");
   } finally {
     uba.cancel();
   }
   assertOrder();
 }
 @After
 public void teardownTest() throws Exception {
   assertDataAvailable();
   client.clearEventLog();
   cancelIfActive(uba);
 }
 private void assertOrder(Class<? extends Annotation>... expectedOrder) {
   org.junit.Assert.assertEquals(Arrays.asList(expectedOrder), client.getEventLog().getEventLog());
 }