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 2005/10/24 15:26:00 UTC

svn commit: r328059 - in /webservices/kandula/trunk/java/test/org/apache/kandula/integration: CreateCoordinationContextTest.java DummyResource.java KandulaDemoService.java KandulaDemoServiceStub.java meta-inf/ meta-inf/services.xml

Author: thilina
Date: Mon Oct 24 06:25:11 2005
New Revision: 328059

URL: http://svn.apache.org/viewcvs?rev=328059&view=rev
Log:
Improving the integration test to do a 2PC with a Dummy Kandula Resource

Added:
    webservices/kandula/trunk/java/test/org/apache/kandula/integration/DummyResource.java
    webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoService.java
    webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoServiceStub.java
    webservices/kandula/trunk/java/test/org/apache/kandula/integration/meta-inf/
    webservices/kandula/trunk/java/test/org/apache/kandula/integration/meta-inf/services.xml
Modified:
    webservices/kandula/trunk/java/test/org/apache/kandula/integration/CreateCoordinationContextTest.java

Modified: webservices/kandula/trunk/java/test/org/apache/kandula/integration/CreateCoordinationContextTest.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/test/org/apache/kandula/integration/CreateCoordinationContextTest.java?rev=328059&r1=328058&r2=328059&view=diff
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/CreateCoordinationContextTest.java (original)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/CreateCoordinationContextTest.java Mon Oct 24 06:25:11 2005
@@ -30,6 +30,7 @@
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.transport.http.SimpleHTTPServer;
 import org.apache.kandula.Constants;
+import org.apache.kandula.context.AbstractContext;
 import org.apache.kandula.initiator.TransactionManager;
 
 public class CreateCoordinationContextTest extends TestCase {
@@ -86,5 +87,11 @@
                         "http://localhost:8082/axis/services/ActivationCoordinator"));
 
         tm.begin();
+        KandulaDemoServiceStub stub = new KandulaDemoServiceStub("test-resources/client-repo",new EndpointReference(
+        "http://localhost:8082/axis/services/KandulaDemoService"));
+        stub.creditOperation();
+        tm.commit();
+        Thread.sleep(3000);
+        
     }
 }

Added: webservices/kandula/trunk/java/test/org/apache/kandula/integration/DummyResource.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/test/org/apache/kandula/integration/DummyResource.java?rev=328059&view=auto
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/DummyResource.java (added)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/DummyResource.java Mon Oct 24 06:25:11 2005
@@ -0,0 +1,56 @@
+/*
+ * 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;
+
+import org.apache.kandula.Constants;
+import org.apache.kandula.participant.KandulaResource;
+import org.apache.kandula.participant.Vote;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class DummyResource implements KandulaResource {
+
+    /**
+     * 
+     */
+    public DummyResource() {
+        super();
+        // TODO Auto-generated constructor stub
+    }
+
+
+    public void commit() {
+        System.out.println("Commited");
+
+    }
+
+    public void rollback() {
+        System.out.println("rollback");
+
+    }
+
+    public Vote prepare() {
+       return Vote.PREPARED;
+    }
+
+
+    public String getProtocol() {
+       return Constants.WS_AT_DURABLE2PC;
+    }
+
+}

Added: webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoService.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoService.java?rev=328059&view=auto
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoService.java (added)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoService.java Mon Oct 24 06:25:11 2005
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import org.apache.axis2.om.OMElement;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class KandulaDemoService {
+
+    /**
+     * 
+     */
+    public KandulaDemoService() {
+
+    }
+    public OMElement creditOperation(OMElement element)
+    {
+        return null;
+    }
+}

Added: webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoServiceStub.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoServiceStub.java?rev=328059&view=auto
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoServiceStub.java (added)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/KandulaDemoServiceStub.java Mon Oct 24 06:25:11 2005
@@ -0,0 +1,110 @@
+/*
+ * 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;
+
+import java.io.IOException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.AnyContentType;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.clientapi.MessageSender;
+import org.apache.axis2.description.InOnlyOperationDescription;
+import org.apache.axis2.description.OutInOperationDescription;
+import org.apache.axis2.description.ParameterImpl;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.receivers.AbstractMessageReceiver;
+import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
+import org.apache.kandula.Constants;
+import org.apache.kandula.utility.KandulaListener;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+
+public class KandulaDemoServiceStub extends
+        org.apache.axis2.clientapi.Stub {
+
+    public static final String AXIS2_HOME = ".";
+
+    protected static org.apache.axis2.description.OperationDescription[] operations;
+
+    static {
+
+        //creating the Service
+        _service = new org.apache.axis2.description.ServiceDescription(
+                new javax.xml.namespace.QName( "KandulaDemoService"));
+
+        //creating the operations
+        org.apache.axis2.description.OperationDescription operationDesc;
+        operations = new org.apache.axis2.description.OperationDescription[1];
+
+        operationDesc = new OutInOperationDescription();
+        operationDesc.setName(new javax.xml.namespace.QName("creditOperation"));
+        operations[0] = operationDesc;
+        _service.addOperation(operationDesc);
+
+    }
+
+    /**
+     * Constructor
+     */
+    public KandulaDemoServiceStub(String axis2Home,
+            EndpointReference targetEndpoint) throws java.lang.Exception {
+        this.toEPR = targetEndpoint;
+        //creating the configuration
+        _configurationContext = new org.apache.axis2.context.ConfigurationContextFactory()
+                .buildClientConfigurationContext(axis2Home);
+
+        _configurationContext.getAxisConfiguration().addService(_service);
+        _serviceContext = _service.getParent().getServiceGroupContext(
+                _configurationContext).getServiceContext(
+                _service.getName().getLocalPart());
+
+    }
+
+    public void creditOperation() throws IOException {
+
+        EndpointReference replyToEpr;
+
+        org.apache.axis2.context.MessageContext messageContext = getMessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                AddressingConstants.Submission.WSA_NAMESPACE);
+        org.apache.axis2.soap.SOAPEnvelope env = createSOAPEnvelope();
+        messageContext.setEnvelope(env);
+
+        MessageSender messageSender = new MessageSender(_serviceContext);
+        messageSender.setWsaAction("creditOperation");
+        messageSender.setTo(this.toEPR);
+        messageSender
+                .setSenderTransport(org.apache.axis2.Constants.TRANSPORT_HTTP);
+        messageSender.send(operations[0], messageContext);
+
+    }
+
+    private org.apache.axis2.soap.SOAPEnvelope createSOAPEnvelope() {
+        org.apache.axis2.soap.SOAPEnvelope env = super.createEnvelope();
+        org.apache.axis2.soap.SOAPFactory factory = OMAbstractFactory
+                .getSOAP12Factory();
+        return env;
+    }
+
+}
\ No newline at end of file

Added: webservices/kandula/trunk/java/test/org/apache/kandula/integration/meta-inf/services.xml
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/test/org/apache/kandula/integration/meta-inf/services.xml?rev=328059&view=auto
==============================================================================
--- webservices/kandula/trunk/java/test/org/apache/kandula/integration/meta-inf/services.xml (added)
+++ webservices/kandula/trunk/java/test/org/apache/kandula/integration/meta-inf/services.xml Mon Oct 24 06:25:11 2005
@@ -0,0 +1,10 @@
+<service name="KandulaDemoService">
+    <description>
+        Participant 2PC Coordination service.
+    </description>
+    <module ref="logging"/>
+   	<parameter name="ServiceClass" locked="xsd:false">org.apache.kandula.integration.KandulaDemoService</parameter>
+    <operation name="creditOperation">
+        <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+    </operation>
+</service>



---------------------------------------------------------------------
To unsubscribe, e-mail: kandula-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: kandula-dev-help@ws.apache.org