use of com.arjuna.mw.wst11.UserBusinessActivity in project wildfly by wildfly.
the class CompensatableTestCase method testActiveTransaction.
@Test
public void testActiveTransaction() throws Exception {
final String deploymentUrl = DEPLOYMENT_URL;
final CompensatableService compensatableService = CompensatableClient.newInstance(deploymentUrl);
final UserBusinessActivity userBusinessActivity = UserBusinessActivity.getUserBusinessActivity();
userBusinessActivity.begin();
final boolean isTransactionActive = compensatableService.isTransactionActive();
userBusinessActivity.close();
Assert.assertEquals(true, isTransactionActive);
}
use of com.arjuna.mw.wst11.UserBusinessActivity in project quickstart by wildfly.
the class ClientIT method testSuccess.
/**
* Test the simple scenario where an item is added to the set within a Business Activity which is closed successfully.
*
* @throws Exception if something goes wrong.
*/
@Test
public void testSuccess() throws Exception {
System.out.println("\n\nStarting 'testSuccess'. This test invokes a WS twice within a BA. The BA is later closes, which causes these WS calls to complete successfully.");
System.out.println("[CLIENT] Creating a new Business Activity");
UserBusinessActivity uba = UserBusinessActivityFactory.userBusinessActivity();
try {
String value1 = "1";
String value2 = "2";
System.out.println("[CLIENT] Beginning Business Activity (All calls to Web services that support WS-BA wil be included in this activity)");
uba.begin();
System.out.println("[CLIENT] invoking addValueToSet(1) on WS");
client.addValueToSet(value1);
System.out.println("[CLIENT] invoking addValueToSet(2) on WS");
client.addValueToSet(value2);
System.out.println("[CLIENT] Closing Business Activity (This will cause the BA to complete successfully)");
uba.close();
Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value1));
Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value2));
} finally {
cancelIfActive(uba);
client.clear();
}
}
use of com.arjuna.mw.wst11.UserBusinessActivity in project quickstarts by jboss-switchyard.
the class AirportService method order.
/**
* Order flight ticket defined by fltid for a user identified by name.
* @param name username
* @param fltid flight identifier
*/
@WebMethod
public void order(@WebParam(name = "name") String name, @WebParam(name = "fltid") String fltid) {
log.info("AirportService:order");
UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
if (uba != null) {
log.info("Transaction ID = " + uba.toString());
if (uba.toString().compareTo("Unknown") == 0) {
log.info("JBoss AS is badly configured. (Enable XTS)");
return;
}
// Create order participant (fly ticket)
OrderParticipant op = new OrderParticipant(uba.toString(), fltid);
try {
// Enlist order participant to the transaction
BusinessActivityManager.getBusinessActivityManager().enlistForBusinessAgreementWithCoordinatorCompletion(op, "org.switchyard.quickstarts.bpel.xts.wsba.ws:AirportService:" + name + ":" + fltid);
} catch (Exception e) {
log.log(Level.SEVERE, e.getMessage());
e.printStackTrace();
}
}
}
use of com.arjuna.mw.wst11.UserBusinessActivity in project quickstart by wildfly.
the class ClientIT method testCancel.
/**
* Tests the scenario where an item is added to the set with in a business activity that is later cancelled. The test checks
* that the item is in the set after invoking addValueToSet on the Web service. After cancelling the Business Activity, the
* work should be compensated and thus the item should no longer be in the set.
*
* @throws Exception if something goes wrong
*/
@Test
public void testCancel() throws Exception {
System.out.println("\n\nStarting 'testCancel'. This test invokes a WS twice within a BA. The BA is later cancelled, which causes these WS calls to be compensated.");
System.out.println("[CLIENT] Creating a new Business Activity");
UserBusinessActivity uba = UserBusinessActivityFactory.userBusinessActivity();
try {
String value1 = "1";
String value2 = "2";
System.out.println("[CLIENT] Beginning Business Activity (All calls to Web services that support WS-BA will be included in this activity)");
uba.begin();
System.out.println("[CLIENT] invoking addValueToSet(1) on WS");
client.addValueToSet(value1);
System.out.println("[CLIENT] invoking addValueToSet(2) on WS");
client.addValueToSet(value2);
Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value1));
Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value2));
System.out.println("[CLIENT] Cancelling Business Activity (This will cause the work to be compensated)");
uba.cancel();
Assert.assertTrue("Expected value to not be in the set, but it was", !client.isInSet(value1));
Assert.assertTrue("Expected value to not be in the set, but it was", !client.isInSet(value2));
} finally {
cancelIfActive(uba);
client.clear();
}
}
use of com.arjuna.mw.wst11.UserBusinessActivity in project quickstart by wildfly.
the class ClientIT method testSuccess.
/**
* Test the simple scenario where an item is added to the set within a Business Activity which is closed successfully.
*
* @throws Exception if something goes wrong.
*/
@Test
public void testSuccess() throws Exception {
System.out.println("\n\nStarting 'testSuccess'. This test invokes a WS within a BA. The BA is later closed, which causes the WS call to complete successfully.");
System.out.println("[CLIENT] Creating a new Business Activity");
UserBusinessActivity uba = UserBusinessActivityFactory.userBusinessActivity();
try {
String value = "1";
System.out.println("[CLIENT] Beginning Business Activity (All calls to Web services that support WS-BA wil be included in this activity)");
uba.begin();
System.out.println("[CLIENT] invoking addValueToSet(1) on WS");
client.addValueToSet(value);
System.out.println("[CLIENT] Closing Business Activity (This will cause the BA to complete successfully)");
uba.close();
Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value));
} finally {
cancelIfActive(uba);
client.clear();
}
}
Aggregations