You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by th...@apache.org on 2007/02/14 13:06:09 UTC
svn commit: r507498 [2/2] - in /webservices/kandula/trunk/java: ./ conf/
conf/ActivationCoordinator/META-INF/ conf/BACoordinator/
conf/BACoordinator/META-INF/ conf/BACoordinatorCompletionParticipant/
conf/BACoordinatorCompletionParticipant/META-INF/ co...
Modified: webservices/kandula/trunk/java/test/interop/testService.java
URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/test/interop/testService.java?view=diff&rev=507498&r1=507497&r2=507498
==============================================================================
--- webservices/kandula/trunk/java/test/interop/testService.java (original)
+++ webservices/kandula/trunk/java/test/interop/testService.java Wed Feb 14 04:06:06 2007
@@ -25,13 +25,15 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.engine.AxisError;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.kandula.Constants;
import org.apache.kandula.Status;
import org.apache.kandula.context.AbstractContext;
import org.apache.kandula.context.CoordinationContext;
-import org.apache.kandula.context.impl.ATParticipantContext;
+import org.apache.kandula.context.impl.ParticipantContext;
import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.KandulaGeneralException;
import org.apache.kandula.participant.KandulaResource;
import org.apache.kandula.participant.ParticipantUtility;
import org.apache.kandula.storage.Store;
@@ -42,164 +44,169 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class testService {
-
+
private MessageContext msgcts;
-
+
public testService() {
-
+
}
-
+
public void setOperationContext(OperationContext oc) throws AxisFault {
msgcts = oc.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
}
-
+
public OMElement Commit(OMElement element) {
return getResponseElement();
}
-
+
public OMElement Rollback(OMElement element) {
return getResponseElement();
}
-
+
public OMElement Phase2Rollback(OMElement element) throws AxisFault {
-
- String reqID = (String) msgcts
- .getProperty(AbstractContext.REQUESTER_ID);
- ATParticipantContext participantContext = (ATParticipantContext) StorageUtils
- .getContext(reqID);
- CoordinationContext coordinationContext = participantContext
- .getCoordinationContext();
-
- ATParticipantContext participantContext2 = new ATParticipantContext();
- participantContext2.setCoordinationContext(coordinationContext);
- KandulaResource resource1 = new Phase2RollbackTestVolatileResource();
- participantContext2.setResource(resource1);
- StorageUtils.putContext(participantContext2);
- MessageContext currentMessageContext = MessageContext.getCurrentMessageContext();
- ParticipantUtility.registerParticipant(participantContext2,currentMessageContext);
-
- ATParticipantContext participantContext1 = new ATParticipantContext();
- participantContext1.setCoordinationContext(coordinationContext);
- KandulaResource resource = new RollbackTestResource();
- participantContext1.setResource(resource);
- StorageUtils.putContext(participantContext1);
- ParticipantUtility.registerParticipant(participantContext1,currentMessageContext);
-
- return getResponseElement();
+ try {
+ String reqID = (String) msgcts.getProperty(AbstractContext.REQUESTER_ID);
+ ParticipantContext participantContext = (ParticipantContext) StorageUtils
+ .getContext(reqID);
+ CoordinationContext coordinationContext = participantContext.getCoordinationContext();
+
+ ParticipantContext participantContext2 = new ParticipantContext();
+ participantContext2.setCoordinationContext(coordinationContext);
+ KandulaResource resource1 = new Phase2RollbackTestVolatileResource();
+ participantContext2.setResource(resource1);
+ StorageUtils.putContext(participantContext2);
+ MessageContext currentMessageContext = MessageContext.getCurrentMessageContext();
+ ParticipantUtility.registerParticipant(participantContext2, currentMessageContext);
+
+ ParticipantContext participantContext1 = new ParticipantContext();
+ participantContext1.setCoordinationContext(coordinationContext);
+ KandulaResource resource = new RollbackTestResource();
+ participantContext1.setResource(resource);
+ StorageUtils.putContext(participantContext1);
+ ParticipantUtility.registerParticipant(participantContext1, currentMessageContext);
+
+ return getResponseElement();
+ } catch (KandulaGeneralException e) {
+ throw new AxisFault(e);
+ }
}
-
+
public OMElement Readonly(OMElement element) throws AxisFault {
-
- String reqID = (String) msgcts
- .getProperty(AbstractContext.REQUESTER_ID);
- ATParticipantContext participantContext = (ATParticipantContext) StorageUtils
- .getContext(reqID);
- CoordinationContext coordinationContext = participantContext
- .getCoordinationContext();
-
- ATParticipantContext participantContext2 = new ATParticipantContext();
- participantContext2.setCoordinationContext(coordinationContext);
- KandulaResource resource1 = new DurableReadOnlyResource();
- participantContext2.setResource(resource1);
- StorageUtils.putContext(participantContext2);
- MessageContext messageContext = MessageContext.getCurrentMessageContext();
- ParticipantUtility.registerParticipant(participantContext2,messageContext);
-
- ATParticipantContext participantContext1 = new ATParticipantContext();
- participantContext1.setCoordinationContext(coordinationContext);
- KandulaResource resource = new CommitTestResource();
- participantContext1.setResource(resource);
- StorageUtils.putContext(participantContext1);
- ParticipantUtility.registerParticipant(participantContext1,messageContext);
-
- return getResponseElement();
+ try {
+ String reqID = (String) msgcts.getProperty(AbstractContext.REQUESTER_ID);
+ ParticipantContext participantContext = (ParticipantContext) StorageUtils
+ .getContext(reqID);
+ CoordinationContext coordinationContext = participantContext.getCoordinationContext();
+
+ ParticipantContext participantContext2 = new ParticipantContext();
+ participantContext2.setCoordinationContext(coordinationContext);
+ KandulaResource resource1 = new DurableReadOnlyResource();
+ participantContext2.setResource(resource1);
+ StorageUtils.putContext(participantContext2);
+ MessageContext messageContext = MessageContext.getCurrentMessageContext();
+ ParticipantUtility.registerParticipant(participantContext2, messageContext);
+
+ ParticipantContext participantContext1 = new ParticipantContext();
+ participantContext1.setCoordinationContext(coordinationContext);
+ KandulaResource resource = new CommitTestResource();
+ participantContext1.setResource(resource);
+ StorageUtils.putContext(participantContext1);
+ ParticipantUtility.registerParticipant(participantContext1, messageContext);
+
+ return getResponseElement();
+ } catch (KandulaGeneralException e) {
+ throw new AxisFault(e);
+ }
}
-
+
public OMElement VolatileAndDurable(OMElement element) throws AxisFault {
-
- String reqID = (String) msgcts
- .getProperty(AbstractContext.REQUESTER_ID);
- ATParticipantContext participantContext = (ATParticipantContext) StorageUtils
- .getContext(reqID);
- final CoordinationContext coordinationContext = participantContext
- .getCoordinationContext();
-
- final ATParticipantContext participantContext2 = new ATParticipantContext();
- participantContext2.setCoordinationContext(coordinationContext);
- KandulaResource resource1 = new VolatileAndDurableTestVolatileResource();
- participantContext2.setResource(resource1);
- StorageUtils.putContext(participantContext2);
- final MessageContext messageContext = MessageContext.getCurrentMessageContext();
- ParticipantUtility.registerParticipant(participantContext2,messageContext);
- Thread thread = new Thread(new Runnable() {
- public void run() {
- try {
- ATParticipantContext participantContext1 = new ATParticipantContext();
- participantContext1
- .setCoordinationContext(coordinationContext);
- KandulaResource resource = new CommitTestResource();
- participantContext1.setResource(resource);
- StorageUtils.putContext(participantContext1);
-
- Map referenceParametersmap = participantContext2
- .getCoordinationEPR().getAllReferenceParameters();
- String id = ((OMElement) referenceParametersmap
- .get(Constants.TRANSACTION_ID_PARAMETER)).getText();
- AbstractContext transaction = (AbstractContext) StorageUtils
- .getContext(id);
- while (!(transaction.getStatus() == Status.CoordinatorStatus.STATUS_PREPARING_VOLATILE)) {
+ try {
+ String reqID = (String) msgcts
+ .getProperty(AbstractContext.REQUESTER_ID);
+ ParticipantContext participantContext = (ParticipantContext) StorageUtils
+ .getContext(reqID);
+ final CoordinationContext coordinationContext = participantContext
+ .getCoordinationContext();
+
+ final ParticipantContext participantContext2 = new ParticipantContext();
+ participantContext2.setCoordinationContext(coordinationContext);
+ KandulaResource resource1 = new VolatileAndDurableTestVolatileResource();
+ participantContext2.setResource(resource1);
+ StorageUtils.putContext(participantContext2);
+ final MessageContext messageContext = MessageContext.getCurrentMessageContext();
+ ParticipantUtility.registerParticipant(participantContext2,messageContext);
+ Thread thread = new Thread(new Runnable() {
+ public void run() {
+ try {
+ ParticipantContext participantContext1 = new ParticipantContext();
+ participantContext1
+ .setCoordinationContext(coordinationContext);
+ KandulaResource resource = new CommitTestResource();
+ participantContext1.setResource(resource);
+ StorageUtils.putContext(participantContext1);
+
+ Map referenceParametersmap = participantContext2
+ .getCoordinationEPR().getAllReferenceParameters();
+ String id = ((OMElement) referenceParametersmap
+ .get(Constants.TRANSACTION_ID_PARAMETER)).getText();
+ AbstractContext transaction = (AbstractContext) StorageUtils
+ .getContext(id);
+ while (!(transaction.getStatus() == Status.CoordinatorStatus.STATUS_PREPARING_VOLATILE)) {
+ }
+ ParticipantUtility.registerParticipant(participantContext1,messageContext);
+
+ } catch (AxisFault e) {
+ throw new AxisError(e.getMessage());
+ } catch (KandulaGeneralException e) {
+ throw new AxisError(e.getMessage());
}
- ParticipantUtility.registerParticipant(participantContext1,messageContext);
-
- } catch (AxisFault e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
- }
- });
- thread.start();
- return getResponseElement();
+ });
+ thread.start();
+ return getResponseElement();
+ } catch (KandulaGeneralException e) {
+ throw new AxisFault(e);
+ }
}
-
- public OMElement EarlyAborted(OMElement element) throws AxisFault {
-
- String reqID = (String) msgcts
- .getProperty(AbstractContext.REQUESTER_ID);
- ATParticipantContext participantContext = (ATParticipantContext) StorageUtils.getContext(reqID);
- CoordinationContext coordinationContext = participantContext
- .getCoordinationContext();
-
- ATParticipantContext participantContext2 = new ATParticipantContext();
- participantContext2.setCoordinationContext(coordinationContext);
- KandulaResource resource1 = new CommitTestResource();
- participantContext2.setResource(resource1);
- StorageUtils.putContext( participantContext2);
- MessageContext messageContext = MessageContext.getCurrentMessageContext();
- ParticipantUtility.registerParticipant(participantContext2,messageContext);
-
- ATParticipantContext participantContext1 = new ATParticipantContext();
- participantContext1.setCoordinationContext(coordinationContext);
- KandulaResource resource = new VolatileReadOnlyResource();
- participantContext1.setResource(resource);
- StorageUtils.putContext(participantContext1);
- ParticipantUtility.registerParticipant(participantContext1,messageContext);
-
- CoordinatorPortTypeRawXMLStub stub;
+ public OMElement EarlyAborted(OMElement element) throws AxisFault {
try {
- stub = new CoordinatorPortTypeRawXMLStub(participantContext1
- .getCoordinationEPR());
- stub.abortedOperation();
- } catch (AbstractKandulaException e) {
+ String reqID = (String) msgcts
+ .getProperty(AbstractContext.REQUESTER_ID);
+ ParticipantContext participantContext = (ParticipantContext) StorageUtils.getContext(reqID);
+ CoordinationContext coordinationContext = participantContext
+ .getCoordinationContext();
+
+ ParticipantContext participantContext2 = new ParticipantContext();
+ participantContext2.setCoordinationContext(coordinationContext);
+ KandulaResource resource1 = new CommitTestResource();
+ participantContext2.setResource(resource1);
+ StorageUtils.putContext( participantContext2);
+ MessageContext messageContext = MessageContext.getCurrentMessageContext();
+ ParticipantUtility.registerParticipant(participantContext2,messageContext);
+
+ ParticipantContext participantContext1 = new ParticipantContext();
+ participantContext1.setCoordinationContext(coordinationContext);
+ KandulaResource resource = new VolatileReadOnlyResource();
+ participantContext1.setResource(resource);
+ StorageUtils.putContext(participantContext1);
+ ParticipantUtility.registerParticipant(participantContext1,messageContext);
+
+ CoordinatorPortTypeRawXMLStub stub;
+ try {
+ stub = new CoordinatorPortTypeRawXMLStub(participantContext1
+ .getCoordinationEPR());
+ stub.abortedOperation();
+ } catch (AbstractKandulaException e) {
+ throw new AxisFault(e);
+ }
+ return getResponseElement();
+ } catch (KandulaGeneralException e) {
throw new AxisFault(e);
}
-
- return getResponseElement();
- }
- private OMElement getResponseElement()
- {
+ } private OMElement getResponseElement() {
SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
- OMNamespace namespace = factory.createOMNamespace("http://fabrikam123.com",null);
- OMElement testType = factory.createOMElement("Response",namespace);
+ OMNamespace namespace = factory.createOMNamespace("http://fabrikam123.com", null);
+ OMElement testType = factory.createOMElement("Response", namespace);
return testType;
}
}
Modified: webservices/kandula/trunk/java/test/org/apache/kandula/integration/CompletionCommitTest.java
URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/test/org/apache/kandula/integration/CompletionCommitTest.java?view=diff&rev=507498&r1=507497&r2=507498
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/CompletionCommitTest.java (original)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/CompletionCommitTest.java Wed Feb 14 04:06:06 2007
@@ -29,6 +29,8 @@
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.transport.http.SimpleHTTPServer;
import org.apache.kandula.initiator.TransactionManager;
+import org.apache.kandula.integration.xsd.CreditOperation;
+import org.apache.kandula.integration.xsd.DebitOperation;
public class CompletionCommitTest extends TestCase {
@@ -39,15 +41,16 @@
private SimpleHTTPServer server;
public CompletionCommitTest() throws Exception {
- super(CompletionCommitTest.class.getName());
- stub = new KandulaDemoServiceStub("target/initiator-repository", new EndpointReference(
- "http://localhost:8081/axis2/services/KandulaDemoService"));
+ this(CompletionCommitTest.class.getName());
}
public CompletionCommitTest(String testName) throws Exception {
super(testName);
- stub = new KandulaDemoServiceStub("target/initiator-repository", new EndpointReference(
- "http://localhost:8081/axis2/services/KandulaDemoService"));
+ ConfigurationContext configurationContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem("target/initiator-repository", "target/initiator-repository"
+ + "/axis2.xml");
+
+ stub = new KandulaDemoServiceStub(configurationContext, "http://localhost:8081/axis2/services/KandulaDemoService");
}
protected void setUp() throws Exception {
@@ -74,15 +77,23 @@
protected void tearDown() throws Exception {
server.stop();
}
+
+// public void testRegistration() throws Exception {
+// TransactionManager tm = new TransactionManager("target/initiator-repository",
+// "target/initiator-repository/axis2.xml");
+// tm.begin("http://localhost:8082/axis2/services/ActivationCoordinator");
+// tm.commit();
+// Thread.sleep(5000);
+// }
- public void testEchoXMLASync() throws Exception {
+ public void testCompletionCommit() throws Exception {
TransactionManager tm = new TransactionManager("target/initiator-repository",
"target/initiator-repository/axis2.xml");
tm.begin("http://localhost:8081/axis2/services/ActivationCoordinator");
- stub.creditOperation();
+ stub.creditOperation(new CreditOperation());
+ stub.debitOperation(new DebitOperation());
tm.commit();
Thread.sleep(5000);
-
}
// public void testEchoXMLSync() throws Exception {
Modified: webservices/kandula/trunk/java/test/org/apache/kandula/integration/DummyResource.java
URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/test/org/apache/kandula/integration/DummyResource.java?view=diff&rev=507498&r1=507497&r2=507498
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/DummyResource.java (original)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/DummyResource.java Wed Feb 14 04:06:06 2007
@@ -18,9 +18,10 @@
import org.apache.kandula.Constants;
import org.apache.kandula.participant.KandulaResource;
-import org.apache.kandula.participant.Vote;
+import org.apache.kandula.participant.at.KandulaAtomicResource;
+import org.apache.kandula.participant.at.Vote;
-public class DummyResource implements KandulaResource {
+public class DummyResource extends KandulaAtomicResource {
/**
*
Modified: webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoService.java
URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoService.java?view=diff&rev=507498&r1=507497&r2=507498
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoService.java (original)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoService.java Wed Feb 14 04:06:06 2007
@@ -17,6 +17,7 @@
package org.apache.kandula.integration;
import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
public class KandulaDemoService {
@@ -35,10 +36,20 @@
}
- public OMElement debitOperation(OMElement element) {
+ public OMElement debitOperation(OMElement element) throws AxisFault {
element.build();
element.detach();
-// System.out.println("done com");
+// MessageContext msgcts = MessageContext.getCurrentMessageContext();
+// String reqID = (String) msgcts.getProperty(AbstractContext.REQUESTER_ID);
+// ParticipantContext participantContext = (ParticipantContext) StorageUtils
+// .getContext(reqID);
+// KandulaBusinessActivityResource resource = (KandulaBusinessActivityResource)participantContext.getResource();
+// try {
+// resource.exit();
+// } catch (AbstractKandulaException e) {
+// throw new AxisFault(e);
+// }
+// throw new AxisFault("thilina");
return element;
}
Added: webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/BAParticipantRegistrationTest.java
URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/BAParticipantRegistrationTest.java?view=auto&rev=507498
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/BAParticipantRegistrationTest.java (added)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/BAParticipantRegistrationTest.java Wed Feb 14 04:06:06 2007
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kandula.integration.ba;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.kandula.Constants;
+import org.apache.kandula.ba.MixedBusinessActivity;
+import org.apache.kandula.integration.KandulaDemoServiceStub;
+import org.apache.kandula.integration.xsd.CreditOperation;
+import org.apache.kandula.integration.xsd.DebitOperation;
+
+public class BAParticipantRegistrationTest extends TestCase {
+
+ private String repository = "target/testing-repository";
+
+ private KandulaDemoServiceStub stub;
+
+ private SimpleHTTPServer server;
+
+ public BAParticipantRegistrationTest() throws Exception {
+ this(BAParticipantRegistrationTest.class.getName());
+ }
+
+ public BAParticipantRegistrationTest(String testName) throws Exception {
+ super(testName);
+ ConfigurationContext configurationContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem("target/initiator-repository",
+ "target/initiator-repository" + "/axis2.xml");
+
+ stub = new KandulaDemoServiceStub(configurationContext,
+ "http://localhost:8081/axis2/services/KandulaBADemoService");
+ }
+
+ protected void setUp() throws Exception {
+ File file = new File(repository);
+ File configFile = new File(repository + "/axis2.xml");
+ if (!file.exists()) {
+ throw new Exception("repository directory " + file.getAbsolutePath()
+ + " does not exists");
+ }
+ ConfigurationContext er = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(file.getAbsolutePath(), configFile
+ .getAbsolutePath());
+
+ server = new SimpleHTTPServer(er, 8081);
+
+ try {
+ server.start();
+ System.out.print("Server started on port " + 8081 + ".....");
+ } finally {
+
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ server.stop();
+ }
+
+ public void testRegistration() throws Exception {
+ MixedBusinessActivity businessActivity = null;
+ businessActivity = new MixedBusinessActivity(0);
+ stub._getServiceClient().getOptions().setProperty(
+ Constants.Configuration.TRANSACTION_CONTEXT, businessActivity.getContext());
+ stub._getServiceClient().getOptions().setProperty(
+ Constants.Configuration.PARTICIPANT_IDENTIFIER, "creditingBank");
+ stub.creditOperation(new CreditOperation());
+ try{
+ stub._getServiceClient().getOptions().setProperty(
+ Constants.Configuration.PARTICIPANT_IDENTIFIER, "debitingBank");
+ stub.debitOperation(new DebitOperation());
+ }catch (Exception e){
+
+ }
+ assertNotNull(businessActivity.getParticipant("debitingBank"));
+ assertNotNull(businessActivity.getParticipant("creditingBank"));
+// businessActivity.cancelParticipant("debitingBank");
+// Thread.sleep(1000);
+ businessActivity.setCallBack(new DemoServiceActivityMixedCallBack());
+ businessActivity.complete();
+ }
+/* public void testAtomicOutcome() throws Exception {
+ AtomicBusinessActivity businessActivity = null;
+ businessActivity = new AtomicBusinessActivity( 0);
+ stub._getServiceClient().getOptions().setProperty(
+ Constants.Configuration.TRANSACTION_CONTEXT, businessActivity.getContext());
+ stub._getServiceClient().getOptions().setProperty(
+ Constants.Configuration.PARTICIPANT_IDENTIFIER, "creditingBank");
+ stub.creditOperation(new CreditOperation());
+ try{
+ stub._getServiceClient().getOptions().setProperty(
+ Constants.Configuration.PARTICIPANT_IDENTIFIER, "debitingBank");
+ stub.debitOperation(new DebitOperation());
+ }catch (Exception e){
+
+ }
+ assertNotNull(businessActivity.getParticipant("debitingBank"));
+ assertNotNull(businessActivity.getParticipant("creditingBank"));
+// businessActivity.cancelParticipant("debitingBank");
+ Thread.sleep(1000);
+ businessActivity.setCallBack(new DemoServiceActivityCallBack());
+ businessActivity.complete();
+ }*/
+/* public void testCancelParticipant() throws Exception {
+ AtomicBusinessActivity businessActivity = null;
+ businessActivity = new AtomicBusinessActivity( 0);
+ stub._getServiceClient().getOptions().setProperty(
+ Constants.Configuration.TRANSACTION_CONTEXT, businessActivity.getContext());
+ stub._getServiceClient().getOptions().setProperty(
+ Constants.Configuration.PARTICIPANT_IDENTIFIER, "creditingBank");
+ stub.creditOperation(new CreditOperation());
+ try{
+ stub._getServiceClient().getOptions().setProperty(
+ Constants.Configuration.PARTICIPANT_IDENTIFIER, "debitingBank");
+ stub.debitOperation(new DebitOperation());
+ }catch (Exception e){
+
+ }
+ assertNotNull(businessActivity.getParticipant("debitingBank"));
+ assertNotNull(businessActivity.getParticipant("creditingBank"));
+ businessActivity.cancelParticipant("debitingBank");
+ assertNull(businessActivity.getParticipant("debitingBank"));
+ Thread.sleep(1000);
+ businessActivity.setCallBack(new DemoServiceActivityCallBack());
+ businessActivity.complete();
+ }*/
+}
\ No newline at end of file
Added: webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/BARegistrationTest.java
URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/BARegistrationTest.java?view=auto&rev=507498
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/BARegistrationTest.java (added)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/BARegistrationTest.java Wed Feb 14 04:06:06 2007
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kandula.integration.ba;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.kandula.Constants;
+import org.apache.kandula.ba.AtomicBusinessActivity;
+import org.apache.kandula.coordinator.Coordinator;
+
+public class BARegistrationTest extends TestCase {
+
+ private String repository = "target/testing-repository";
+
+ private SimpleHTTPServer server;
+
+ public BARegistrationTest() throws Exception {
+ super(BARegistrationTest.class.getName());
+ }
+
+ public BARegistrationTest(String testName) throws Exception {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ File file = new File(repository);
+ File configFile = new File(repository + "/axis2.xml");
+ if (!file.exists()) {
+ throw new Exception("repository directory "
+ + file.getAbsolutePath() + " does not exists");
+ }
+ ConfigurationContext er = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(file
+ .getAbsolutePath(), configFile.getAbsolutePath());
+
+ server = new SimpleHTTPServer(er, 8081);
+
+ try {
+ server.start();
+ System.out.print("Server started on port " + 8081 + ".....");
+ } finally {
+
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ server.stop();
+ }
+
+ public void testRegisteration() throws Exception {
+ AtomicBusinessActivity businessActivity = new AtomicBusinessActivity(1000);
+ Coordinator coordinator = new Coordinator();
+ EndpointReference epr= coordinator.registerParticipant(businessActivity.getContext(),Constants.WS_BA_CC,new EndpointReference("http://ws.apache.org/axis2"),null);
+ assertNotNull(epr);
+ }
+
+
+// public void testEchoXMLSync() throws Exception {
+// // TransactionManager tm = new TransactionManager(
+// // Constants.WS_AT,
+// // new EndpointReference(
+// // "http://localhost:8081/axis2/services/ActivationCoordinator"));
+// // tm.begin("target/initiator-repository",
+// // "target/initiator-repository/axis2.xml", false);
+// // try {
+// // stub.creditOperation();
+// // } catch (Exception e) {
+// // tm.rollback();
+// // }
+// // tm.commit();
+// }
+}
\ No newline at end of file
Added: webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DemoServiceActivityCallBack.java
URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DemoServiceActivityCallBack.java?view=auto&rev=507498
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DemoServiceActivityCallBack.java (added)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DemoServiceActivityCallBack.java Wed Feb 14 04:06:06 2007
@@ -0,0 +1,78 @@
+package org.apache.kandula.integration.ba;
+
+import org.apache.kandula.Status;
+import org.apache.kandula.ba.BusinessActivityCallBack;
+import org.apache.kandula.ba.MixedBusinessActivity;
+import org.apache.kandula.coordinator.ba.BAParticipantInformation;
+
+public class DemoServiceActivityCallBack extends BusinessActivityCallBack {
+
+ public DemoServiceActivityCallBack() {
+ super();
+ }
+
+ public void onComplete() {
+ try {
+ MixedBusinessActivity mixedBusinessActivity = (MixedBusinessActivity)businessActivity;
+ //choose just one airline
+ BAParticipantInformation emirates = mixedBusinessActivity.getParticipant("EmiratesAirlineBooking");
+ BAParticipantInformation srilankan = mixedBusinessActivity.getParticipant("SriLankanAirlineBooking");
+ BAParticipantInformation singapore = mixedBusinessActivity.getParticipant("SingaporeAirlineBooking");
+
+ if (srilankan!=null && (srilankan.getStatus()==Status.BACoordinatorStatus.STATUS_COMPLETED)){
+ mixedBusinessActivity.addParticipantToCloseList(srilankan);
+ mixedBusinessActivity.addParticipantToCompensateList(emirates);
+ mixedBusinessActivity.addParticipantToCompensateList(singapore);
+ }else if (emirates!=null && (emirates.getStatus()==Status.BACoordinatorStatus.STATUS_COMPLETED)){
+ mixedBusinessActivity.addParticipantToCloseList(emirates);
+ mixedBusinessActivity.addParticipantToCompensateList(srilankan);
+ mixedBusinessActivity.addParticipantToCompensateList(singapore);
+ }else if (singapore!=null && (singapore.getStatus()==Status.BACoordinatorStatus.STATUS_COMPLETED)){
+ mixedBusinessActivity.addParticipantToCloseList(singapore);
+ mixedBusinessActivity.addParticipantToCompensateList(emirates);
+ mixedBusinessActivity.addParticipantToCompensateList(srilankan);
+ }
+
+ BAParticipantInformation taj = mixedBusinessActivity.getParticipant("TajHotelBooking");
+ BAParticipantInformation hilton = mixedBusinessActivity.getParticipant("HiltonHotelBooking");
+
+ if (taj!=null && (taj.getStatus()==Status.BACoordinatorStatus.STATUS_COMPLETED)){
+ mixedBusinessActivity.addParticipantToCloseList(taj);
+ mixedBusinessActivity.addParticipantToCompensateList(hilton);
+ }else if (hilton!=null && (hilton.getStatus()==Status.BACoordinatorStatus.STATUS_COMPLETED)){
+ mixedBusinessActivity.addParticipantToCloseList(hilton);
+ mixedBusinessActivity.addParticipantToCompensateList(taj);
+ }
+
+ BAParticipantInformation hertz = mixedBusinessActivity.getParticipant("HertzCarBooking");
+ BAParticipantInformation malkey = mixedBusinessActivity.getParticipant("MalkeyCarBooking");
+ if (hertz!=null && (hertz.getStatus()==Status.BACoordinatorStatus.STATUS_COMPLETED)){
+ mixedBusinessActivity.addParticipantToCloseList(hertz);
+ mixedBusinessActivity.addParticipantToCompensateList(malkey);
+ }else if (malkey!=null && (malkey.getStatus()==Status.BACoordinatorStatus.STATUS_COMPLETED)){
+ mixedBusinessActivity.addParticipantToCloseList(malkey);
+ mixedBusinessActivity.addParticipantToCompensateList(hertz);
+ }
+
+ BAParticipantInformation map = mixedBusinessActivity.getParticipant("MapOrder");
+ if (map!=null && (map.getStatus()==Status.BACoordinatorStatus.STATUS_COMPLETED)){
+ mixedBusinessActivity.addParticipantToCloseList(map);
+ }else
+ {
+ mixedBusinessActivity.addParticipantToCompensateList(map);
+ }
+
+ mixedBusinessActivity.finalizeActivity();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+/* public void onComplete() {
+ try {
+ ((AtomicBusinessActivity)businessActivity).closeActivity();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }*/
+}
Added: webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DemoServiceActivityMixedCallBack.java
URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DemoServiceActivityMixedCallBack.java?view=auto&rev=507498
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DemoServiceActivityMixedCallBack.java (added)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DemoServiceActivityMixedCallBack.java Wed Feb 14 04:06:06 2007
@@ -0,0 +1,23 @@
+package org.apache.kandula.integration.ba;
+
+import org.apache.kandula.ba.BusinessActivityCallBack;
+import org.apache.kandula.ba.MixedBusinessActivity;
+
+public class DemoServiceActivityMixedCallBack extends BusinessActivityCallBack {
+
+ public DemoServiceActivityMixedCallBack() {
+ super();
+ }
+
+ public void onComplete() {
+ try {
+ MixedBusinessActivity mixedBusinessActivity = ((MixedBusinessActivity)businessActivity);
+ mixedBusinessActivity.addParticipantToCloseList("creditingBank");
+ mixedBusinessActivity.addParticipantToCompensateList("debitingBank");
+ mixedBusinessActivity.finalizeActivity();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
Added: webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DummyBAResource.java
URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DummyBAResource.java?view=auto&rev=507498
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DummyBAResource.java (added)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/ba/DummyBAResource.java Wed Feb 14 04:06:06 2007
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.kandula.integration.ba;
+
+import org.apache.kandula.Constants;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.participant.ba.KandulaBusinessActivityResource;
+
+public class DummyBAResource extends KandulaBusinessActivityResource {
+
+ /**
+ *
+ */
+ public DummyBAResource() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public String getProtocol() {
+ return Constants.WS_BA_CC;
+ }
+
+ public boolean compensate() {
+ System.out.println("Compensated");
+ return true;
+ }
+
+ public void complete() throws AbstractKandulaException{
+ System.out.println("Complete");
+ return;
+ }
+
+ public void close() {
+ System.out.println("Close");
+ }
+
+ public void cancel() {
+ System.out.println("Cancel");
+ }
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: kandula-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: kandula-dev-help@ws.apache.org