You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sandesha-dev@ws.apache.org by ch...@apache.org on 2006/06/15 07:51:24 UTC
svn commit: r414476 [12/15] - in /webservices/sandesha/trunk: ./ c/ config/
interop/ java/ java/config/ java/interop/ java/interop/conf/
java/interop/src/ java/interop/src/org/ java/interop/src/org/apache/
java/interop/src/org/apache/sandesha2/ java/in...
Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceAcknowledgement.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceAcknowledgement.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceAcknowledgement.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceAcknowledgement.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,289 @@
+/*
+ * Copyright 1999-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.sandesha2.wsrm;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.util.SpecSpecificConstants;
+
+/**
+ * Adds the SequenceAcknowledgement header block.
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+
+public class SequenceAcknowledgement implements IOMRMPart {
+
+ private Identifier identifier;
+ private ArrayList acknowledgementRangeList;
+ private ArrayList nackList;
+ private SOAPFactory defaultFactory;
+ private String namespaceValue = null;
+ private boolean mustUnderstand = false;
+ private AckNone ackNone = null;
+ private AckFinal ackFinal = null;
+
+ public SequenceAcknowledgement(SOAPFactory factory,String namespaceValue) throws SandeshaException {
+ if (!isNamespaceSupported(namespaceValue))
+ throw new SandeshaException ("Unsupported namespace");
+
+ this.namespaceValue = namespaceValue;
+ this.defaultFactory = factory;
+ acknowledgementRangeList = new ArrayList();
+ nackList = new ArrayList();
+ }
+
+ public String getNamespaceValue() {
+ return namespaceValue;
+ }
+
+ public Object fromOMElement(OMElement element) throws OMException,SandeshaException {
+
+ if (element == null || !(element instanceof SOAPHeader))
+ throw new OMException("Cant get sequence acknowlegement from a non-header element");
+
+ SOAPHeader header = (SOAPHeader) element;
+ OMElement sequenceAckPart = header.getFirstChildWithName(new QName(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.SEQUENCE_ACK));
+
+ if (sequenceAckPart == null)
+ throw new OMException("The passed element does not contain a seqence ackknowledgement Part");
+
+ OMFactory factory = element.getOMFactory();
+ if (factory==null)
+ factory = defaultFactory;
+
+ identifier = new Identifier(defaultFactory,namespaceValue);
+ identifier.fromOMElement(sequenceAckPart);
+
+ Iterator ackRangeParts = sequenceAckPart.getChildrenWithName(new QName(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.ACK_RANGE));
+
+ while (ackRangeParts.hasNext()) {
+ OMElement ackRangePart = (OMElement) ackRangeParts.next();
+
+ AcknowledgementRange ackRange = new AcknowledgementRange(defaultFactory,namespaceValue);
+ ackRange.fromOMElement(ackRangePart);
+ acknowledgementRangeList.add(ackRange);
+ }
+
+ Iterator nackParts = sequenceAckPart.getChildrenWithName(new QName(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.NACK));
+
+ while (nackParts.hasNext()) {
+ OMElement nackPart = (OMElement) nackParts.next();
+ Nack nack = new Nack(defaultFactory,namespaceValue);
+ nack.fromOMElement(nackPart);
+ nackList.add(nack);
+ }
+
+ String rmSpecVersion = SpecSpecificConstants.getSpecVersionString (namespaceValue);
+
+ if (SpecSpecificConstants.isAckFinalAllowed(rmSpecVersion)) {
+ OMElement ackFinalPart = sequenceAckPart.getFirstChildWithName(new QName (namespaceValue,Sandesha2Constants.WSRM_COMMON.FINAL));
+ if (ackFinalPart!=null) {
+ ackFinal = new AckFinal (defaultFactory,namespaceValue);
+ ackFinal.fromOMElement(sequenceAckPart);
+ }
+ }
+
+ if (SpecSpecificConstants.isAckNoneAllowed(rmSpecVersion)) {
+ OMElement ackNonePart = sequenceAckPart.getFirstChildWithName(new QName (namespaceValue,Sandesha2Constants.WSRM_COMMON.NONE));
+ if (ackNonePart!=null) {
+ ackNone = new AckNone (defaultFactory,namespaceValue);
+ ackNone.fromOMElement(sequenceAckPart);
+ }
+ }
+
+ return this;
+ }
+
+ public OMElement toOMElement(OMElement header) throws OMException,SandeshaException {
+
+ if (header == null || !(header instanceof SOAPHeader))
+ throw new OMException();
+
+ OMFactory factory = header.getOMFactory();
+ if (factory==null)
+ factory = defaultFactory;
+
+ OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+
+ SOAPHeader SOAPHeader = (SOAPHeader) header;
+ SOAPHeaderBlock sequenceAcknowledgementHeaderBlock = SOAPHeader.addHeaderBlock(
+ Sandesha2Constants.WSRM_COMMON.SEQUENCE_ACK,rmNamespace);
+
+ if (sequenceAcknowledgementHeaderBlock == null)
+ throw new OMException("Cant set sequence acknowledgement since the element is null");
+
+ if (identifier == null)
+ throw new OMException(
+ "Cant set the sequence since Identifier is null");
+
+ sequenceAcknowledgementHeaderBlock.setMustUnderstand(isMustUnderstand());
+ identifier.toOMElement(sequenceAcknowledgementHeaderBlock);
+
+ Iterator ackRangeIt = acknowledgementRangeList.iterator();
+ while (ackRangeIt.hasNext()) {
+ AcknowledgementRange ackRange = (AcknowledgementRange) ackRangeIt
+ .next();
+ ackRange.toOMElement(sequenceAcknowledgementHeaderBlock);
+ }
+
+ Iterator nackIt = nackList.iterator();
+ while (nackIt.hasNext()) {
+ Nack nack = (Nack) nackIt.next();
+ nack.toOMElement(sequenceAcknowledgementHeaderBlock);
+ }
+
+ String rmSpecVersion = SpecSpecificConstants.getSpecVersionString(namespaceValue);
+
+ //setting a 'None' when nothing is there (for the correct RM version)
+ if (ackNone==null && acknowledgementRangeList.size()==0 && nackList.size()==0 && SpecSpecificConstants.isAckNoneAllowed(rmSpecVersion)) {
+ ackNone = new AckNone (factory,namespaceValue);
+ }
+
+ if (ackNone!=null) {
+ if (!SpecSpecificConstants.isAckNoneAllowed(rmSpecVersion)) {
+ throw new SandeshaException ("The given namespace does not allow the 'None' part to be added to the sequenceAcknowledgement element");
+ }
+
+ if (acknowledgementRangeList.size()>0) {
+ throw new SandeshaException ("The 'None' element cannot be present when there are acknowledgement range elements under the sequenceAcknowledgement");
+ }
+
+ if (nackList.size()>0) {
+ throw new SandeshaException ("The 'None' element cannot be present when there are Nack elements under the sequenceAcknowledgement");
+ }
+
+ ackNone.toOMElement(sequenceAcknowledgementHeaderBlock);
+ }
+
+ if (ackFinal!=null) {
+ if (!SpecSpecificConstants.isAckFinalAllowed(rmSpecVersion)) {
+ throw new SandeshaException ("The given namespace does not allow the 'Final' part to be added to the sequenceAcknowledgement element");
+ }
+
+ if (nackList.size()>0) {
+ throw new SandeshaException ("The 'Final' element cannot be present when there are Nack elements under the sequenceAcknowledgement");
+ }
+
+ ackFinal.toOMElement(sequenceAcknowledgementHeaderBlock);
+ }
+
+ SOAPHeader.addChild(sequenceAcknowledgementHeaderBlock);
+
+ return header;
+ }
+
+ public void setIdentifier(Identifier identifier) {
+ this.identifier = identifier;
+ }
+
+ public void setAckRanges(ArrayList acknowledgementRagngesList) {
+ acknowledgementRangeList = acknowledgementRagngesList;
+ }
+
+ public Nack addNackRangges(Nack nack) {
+ nackList.add(nack);
+ return nack;
+ }
+
+ public AcknowledgementRange addAcknowledgementRanges(
+ AcknowledgementRange ackRange) {
+ acknowledgementRangeList.add(ackRange);
+ return ackRange;
+ }
+
+ public Identifier getIdentifier() {
+ return identifier;
+ }
+
+ public List getAcknowledgementRanges() {
+ return acknowledgementRangeList;
+ }
+
+ public List getNackList() {
+ return nackList;
+ }
+
+ public void addChildElement(OMElement element) {
+ acknowledgementRangeList.add(element);
+ }
+
+ public void toSOAPEnvelope(SOAPEnvelope envelope) throws SandeshaException {
+ SOAPHeader header = envelope.getHeader();
+
+ //detach if already exist.
+ OMElement elem = header.getFirstChildWithName(new QName(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.SEQUENCE_ACK));
+ if (elem != null)
+ elem.detach();
+
+ toOMElement(header);
+ }
+
+ public boolean isMustUnderstand() {
+ return mustUnderstand;
+ }
+
+ public void setMustUnderstand(boolean mustUnderstand) {
+ this.mustUnderstand = mustUnderstand;
+ }
+
+ public boolean isNamespaceSupported (String namespaceName) {
+ if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+ return true;
+
+ if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+ return true;
+
+ return false;
+ }
+
+ public AckFinal getAckFinal() {
+ return ackFinal;
+ }
+
+ public void setAckFinal(AckFinal ackFinal) {
+ this.ackFinal = ackFinal;
+ }
+
+ public AckNone getAckNone() {
+ return ackNone;
+ }
+
+ public void setAckNone(AckNone ackNone) {
+ this.ackNone = ackNone;
+ }
+}
\ No newline at end of file
Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceFault.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceFault.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceFault.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceFault.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,119 @@
+/*
+ * Copyright 1999-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.sandesha2.wsrm;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * Adds the SequenceFault header block.
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+
+public class SequenceFault implements IOMRMElement {
+
+ private FaultCode faultCode;
+
+ private SOAPFactory defaultFactory;
+
+ private String namespaceValue = null;
+
+ public SequenceFault(SOAPFactory factory,String namespaceValue) throws SandeshaException {
+ if (!isNamespaceSupported(namespaceValue))
+ throw new SandeshaException ("Unsupported namespace");
+
+ this.defaultFactory = factory;
+ this.namespaceValue = namespaceValue;
+ }
+
+ public String getNamespaceValue() {
+ return namespaceValue;
+ }
+
+ public Object fromOMElement(OMElement body) throws OMException,SandeshaException {
+
+ if (body == null || !(body instanceof SOAPBody))
+ throw new OMException(
+ "Cant get Sequence Fault part from a non-header element");
+
+ OMElement sequenceFaultPart = body.getFirstChildWithName(new QName(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.SEQUENCE_FAULT));
+
+ if (sequenceFaultPart == null)
+ throw new OMException("The passed element does not contain a Sequence Fault element");
+
+ OMElement faultCodePart = sequenceFaultPart
+ .getFirstChildWithName(new QName(namespaceValue,Sandesha2Constants.WSRM_COMMON.FAULT_CODE));
+
+ if (faultCodePart != null) {
+ faultCode = new FaultCode(defaultFactory,namespaceValue);
+ faultCode.fromOMElement(sequenceFaultPart);
+ }
+
+ return this;
+ }
+
+ public OMElement toOMElement(OMElement body) throws OMException {
+
+ if (body == null || !(body instanceof SOAPBody))
+ throw new OMException("Cant get Sequence Fault part from a non-header element");
+
+ OMFactory factory = body.getOMFactory();
+ if (factory==null)
+ factory = defaultFactory;
+
+ OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+ OMElement sequenceFaultElement =factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.SEQUENCE_FAULT, rmNamespace);
+ if (faultCode != null)
+ faultCode.toOMElement(sequenceFaultElement);
+
+ body.addChild(sequenceFaultElement);
+
+ return body;
+ }
+
+ public void setFaultCode(FaultCode faultCode) {
+ this.faultCode = faultCode;
+ }
+
+ public FaultCode getFaultCode() {
+ return faultCode;
+ }
+
+ public boolean isNamespaceSupported (String namespaceName) {
+ if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+ return true;
+
+ if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+ return true;
+
+ return false;
+ }
+
+}
Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceOffer.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceOffer.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceOffer.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/SequenceOffer.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,119 @@
+/*
+ * Copyright 1999-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.sandesha2.wsrm;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+
+public class SequenceOffer implements IOMRMElement {
+
+ private Identifier identifier = null;
+
+ private Expires expires = null;
+
+ private OMFactory defaultFactory;
+
+ private String namespaceValue = null;
+
+ public SequenceOffer(OMFactory factory,String namespaceValue) throws SandeshaException {
+ if (!isNamespaceSupported(namespaceValue))
+ throw new SandeshaException ("Unsupported namespace");
+
+ this.defaultFactory = factory;
+ this.namespaceValue = namespaceValue;
+ }
+
+ public String getNamespaceValue() {
+ return namespaceValue;
+ }
+
+ public Object fromOMElement(OMElement createSequenceElement)
+ throws OMException,SandeshaException {
+
+ OMElement sequenceOfferPart = createSequenceElement
+ .getFirstChildWithName(new QName(namespaceValue,Sandesha2Constants.WSRM_COMMON.SEQUENCE_OFFER));
+ if (sequenceOfferPart == null)
+ throw new OMException("The passed element does not contain a SequenceOffer part");
+
+ identifier = new Identifier(defaultFactory,namespaceValue);
+ identifier.fromOMElement(sequenceOfferPart);
+
+ OMElement expiresPart = sequenceOfferPart
+ .getFirstChildWithName(new QName(namespaceValue,Sandesha2Constants.WSRM_COMMON.EXPIRES));
+ if (expiresPart != null) {
+ expires = new Expires(defaultFactory,namespaceValue);
+ expires.fromOMElement(sequenceOfferPart);
+ }
+
+ return this;
+ }
+
+ public OMElement toOMElement(OMElement createSequenceElement)
+ throws OMException {
+
+ if (identifier == null)
+ throw new OMException("Cant set sequnceOffer since identifier is null");
+
+ OMFactory factory = createSequenceElement.getOMFactory();
+ if (factory==null)
+ factory = defaultFactory;
+
+ OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+ OMElement sequenceOfferElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.SEQUENCE_OFFER, rmNamespace);
+
+ identifier.toOMElement(sequenceOfferElement);
+
+ if (expires != null) {
+ expires.toOMElement(sequenceOfferElement);
+ }
+
+ createSequenceElement.addChild(sequenceOfferElement);
+
+ return createSequenceElement;
+ }
+
+ public Identifier getIdentifer() {
+ return identifier;
+ }
+
+ public void setIdentifier(Identifier identifier) {
+ this.identifier = identifier;
+ }
+
+ public boolean isNamespaceSupported (String namespaceName) {
+ if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+ return true;
+
+ if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+ return true;
+
+ return false;
+ }
+
+}
\ No newline at end of file
Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/TerminateSequence.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/TerminateSequence.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/TerminateSequence.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/TerminateSequence.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,127 @@
+/*
+ * Copyright 1999-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.sandesha2.wsrm;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * Adds the Terminate Sequence body part.
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+
+public class TerminateSequence implements IOMRMPart {
+
+ private Identifier identifier;
+
+ private SOAPFactory defaultFactory;
+
+ private String namespaceValue = null;
+
+ public TerminateSequence(SOAPFactory factory, String namespaceValue) throws SandeshaException {
+ if (!isNamespaceSupported(namespaceValue))
+ throw new SandeshaException ("Unsupported namespace");
+
+ this.defaultFactory = factory;
+ this.namespaceValue = namespaceValue;
+ }
+
+ public String getNamespaceValue() {
+ return namespaceValue;
+ }
+
+ public Object fromOMElement(OMElement body) throws OMException,SandeshaException {
+
+ if (!(body instanceof SOAPBody))
+ throw new OMException("Cant add terminate sequence to a non body element");
+
+ OMElement terminateSeqPart = body.getFirstChildWithName(new QName(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE));
+
+ if (terminateSeqPart == null)
+ throw new OMException("passed element does not contain a terminate sequence part");
+
+ identifier = new Identifier(defaultFactory,namespaceValue);
+ identifier.fromOMElement(terminateSeqPart);
+
+ return this;
+ }
+
+ public OMElement toOMElement(OMElement body) throws OMException {
+
+ if (body == null || !(body instanceof SOAPBody))
+ throw new OMException("Cant add terminate sequence to a nonbody element");
+
+ if (identifier == null)
+ throw new OMException("Cant add terminate sequence since identifier is not set");
+
+ OMFactory factory= body.getOMFactory();
+ if (factory==null)
+ factory = defaultFactory;
+
+ OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+ OMElement terminateSequenceElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE, rmNamespace);
+
+ identifier.toOMElement(terminateSequenceElement);
+ body.addChild(terminateSequenceElement);
+
+ return body;
+ }
+
+ public Identifier getIdentifier() {
+ return identifier;
+ }
+
+ public void setIdentifier(Identifier identifier) {
+ this.identifier = identifier;
+ }
+
+ public void toSOAPEnvelope(SOAPEnvelope envelope) {
+ SOAPBody body = envelope.getBody();
+
+ //detach if already exist.
+ OMElement elem = body.getFirstChildWithName(new QName(namespaceValue,
+ Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE));
+ if (elem!=null)
+ elem.detach();
+
+ toOMElement(body);
+ }
+
+ public boolean isNamespaceSupported (String namespaceName) {
+ if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+ return true;
+
+ if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+ return true;
+
+ return false;
+ }
+}
\ No newline at end of file
Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/TerminateSequenceResponse.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/TerminateSequenceResponse.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/TerminateSequenceResponse.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/TerminateSequenceResponse.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,128 @@
+/*
+ * Copyright 1999-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.sandesha2.wsrm;
+
+import javax.xml.namespace.QName;
+
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+
+/**
+ * Adds the Terminate Sequence Response body part.
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class TerminateSequenceResponse implements IOMRMPart {
+
+ private Identifier identifier;
+
+ private SOAPFactory defaultFactory;
+
+ private String namespaceValue = null;
+
+
+ public TerminateSequenceResponse(SOAPFactory factory, String namespaceValue) throws SandeshaException {
+ if (!isNamespaceSupported(namespaceValue))
+ throw new SandeshaException ("Unsupported namespace");
+
+ this.defaultFactory = factory;
+ this.namespaceValue = namespaceValue;
+ }
+
+ public String getNamespaceValue() {
+ return namespaceValue;
+ }
+
+ public Object fromOMElement(OMElement body) throws OMException,SandeshaException {
+
+ if (!(body instanceof SOAPBody))
+ throw new OMException(
+ "Cant add terminate sequence response to a non body element");
+
+ OMElement terminateSeqResponsePart = body.getFirstChildWithName(new QName(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE_RESPONSE));
+
+ if (terminateSeqResponsePart == null)
+ throw new OMException(
+ "passed element does not contain a terminate sequence response part");
+
+ identifier = new Identifier(defaultFactory,namespaceValue);
+ identifier.fromOMElement(terminateSeqResponsePart);
+
+ return this;
+ }
+
+ public OMElement toOMElement(OMElement body) throws OMException {
+
+ if (body == null || !(body instanceof SOAPBody))
+ throw new OMException("Cant add terminate sequence response to a nonbody element");
+
+ if (identifier == null)
+ throw new OMException("Cant add terminate sequence response since identifier is not set");
+
+ OMFactory factory = body.getOMFactory();
+ if (factory==null)
+ factory = defaultFactory;
+
+ OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+ OMElement terminateSequenceResponseElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE_RESPONSE, rmNamespace);
+
+ identifier.toOMElement(terminateSequenceResponseElement);
+ body.addChild(terminateSequenceResponseElement);
+
+ return body;
+ }
+
+ public Identifier getIdentifier() {
+ return identifier;
+ }
+
+ public void setIdentifier(Identifier identifier) {
+ this.identifier = identifier;
+ }
+
+ public void toSOAPEnvelope(SOAPEnvelope envelope) {
+ SOAPBody body = envelope.getBody();
+
+ //detach if already exist.
+ OMElement elem = body.getFirstChildWithName(new QName(namespaceValue,
+ Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE_RESPONSE));
+ if (elem!=null)
+ elem.detach();
+
+ toOMElement(body);
+ }
+
+ public boolean isNamespaceSupported (String namespaceName) {
+ if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+ return true;
+
+ return false;
+ }
+
+
+}
Added: webservices/sandesha/trunk/java/test-resources/CreateSequence.xml
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test-resources/CreateSequence.xml?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test-resources/CreateSequence.xml (added)
+++ webservices/sandesha/trunk/java/test-resources/CreateSequence.xml Wed Jun 14 22:51:15 2006
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <soapenv:Header>
+ <wsa:MessageID soapenv:mustUnderstand="0">uuid:c3671020-15e0-11da-9b3a-f0439d4867bd</wsa:MessageID>
+ <wsa:To soapenv:mustUnderstand="0">http://localhost:8070/axis/services/TestService</wsa:To>
+ <wsa:Action soapenv:mustUnderstand="0">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</wsa:Action>
+ <wsa:From soapenv:mustUnderstand="0">
+ <wsa:Address>http://192.168.1.4:9090/axis/services/RMService</wsa:Address>
+ </wsa:From>
+ <wsa:ReplyTo soapenv:mustUnderstand="0">
+ <wsa:Address>http://127.0.0.1:9090/axis/services/RMService</wsa:Address>
+ </wsa:ReplyTo>
+ </soapenv:Header>
+ <soapenv:Body>
+ <wsrm:CreateSequence>
+ <wsrm:AcksTo>
+ <wsa:Address>http://127.0.0.1:9090/axis/services/RMService</wsa:Address>
+ </wsrm:AcksTo>
+ <wsrm:Offer>
+ <wsrm:Identifier>uuid:c3671020-15e0-11da-9b3b-f0439d4867bd</wsrm:Identifier>
+ </wsrm:Offer>
+ </wsrm:CreateSequence>
+ </soapenv:Body>
+ </soapenv:Envelope>
Added: webservices/sandesha/trunk/java/test-resources/CreateSequenceResponse.xml
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test-resources/CreateSequenceResponse.xml?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test-resources/CreateSequenceResponse.xml (added)
+++ webservices/sandesha/trunk/java/test-resources/CreateSequenceResponse.xml Wed Jun 14 22:51:15 2006
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <soapenv:Header>
+ <wsa:MessageID soapenv:mustUnderstand="1">uuid:88754b00-161a-11da-b6d6-8198de3c47c5</wsa:MessageID>
+ <wsa:To soapenv:mustUnderstand="1">http://127.0.0.1:9070/axis/services/RMService</wsa:To>
+ <wsa:Action soapenv:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</wsa:Action>
+ <wsa:From soapenv:mustUnderstand="1">
+ <wsa:Address>http://localhost:8070/axis/services/TestService</wsa:Address>
+ </wsa:From>
+ <wsa:RelatesTo RelationshipType="http://schemas.xmlsoap.org/ws/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:http="wsa">uuid:872e4c10-161a-11da-9ef7-bd9ad94438a3</wsa:RelatesTo>
+ </soapenv:Header>
+ <soapenv:Body>
+ <wsrm:CreateSequenceResponse>
+ <wsrm:Identifier>uuid:88754b00-161a-11da-b6d6-8198de3c47c5</wsrm:Identifier>
+ <wsrm:Accept>
+ <wsrm:AcksTo>
+ <wsa:Address>http://localhost:8070/axis/services/TestService</wsa:Address>
+ </wsrm:AcksTo>
+ </wsrm:Accept>
+ </wsrm:CreateSequenceResponse>
+ </soapenv:Body>
+ </soapenv:Envelope>
Added: webservices/sandesha/trunk/java/test-resources/Sequence.xml
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test-resources/Sequence.xml?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test-resources/Sequence.xml (added)
+++ webservices/sandesha/trunk/java/test-resources/Sequence.xml Wed Jun 14 22:51:15 2006
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <soapenv:Header>
+ <wsa:MessageID soapenv:mustUnderstand="1">uuid:8c00b020-1624-11da-a28e-b3b9c4e71445</wsa:MessageID>
+ <wsa:To soapenv:mustUnderstand="1">http://127.0.0.1:9070/axis/services/RMService</wsa:To>
+ <wsa:Action soapenv:mustUnderstand="1">urn:wsrm:echoStringResponse</wsa:Action>
+ <wsa:From soapenv:mustUnderstand="1">
+ <wsa:Address>http://localhost:8070/axis/services/TestService</wsa:Address>
+ </wsa:From>
+ <wsa:RelatesTo RelationshipType="wsa:Reply" soapenv:mustUnderstand="1">uuid:87a0b160-1624-11da-bed9-84d13db13902</wsa:RelatesTo>
+ <wsrm:Sequence soapenv:mustUnderstand="1">
+ <wsrm:Identifier>uuid:879da420-1624-11da-bed9-84d13db13902</wsrm:Identifier>
+ <wsrm:MessageNumber>1</wsrm:MessageNumber>
+ </wsrm:Sequence>
+ </soapenv:Header>
+ <soapenv:Body>
+ <ns1:echoStringResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://tempuri.org/">
+ <echoStringReturn xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">Sandesha Echo 1</echoStringReturn>
+ </ns1:echoStringResponse>
+ </soapenv:Body>
+ </soapenv:Envelope>
Added: webservices/sandesha/trunk/java/test-resources/SequenceAcknowledgement.xml
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test-resources/SequenceAcknowledgement.xml?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test-resources/SequenceAcknowledgement.xml (added)
+++ webservices/sandesha/trunk/java/test-resources/SequenceAcknowledgement.xml Wed Jun 14 22:51:15 2006
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <soapenv:Header>
+ <wsa:MessageID soapenv:mustUnderstand="1">uuid:8d8f8d80-1624-11da-a28e-b3b9c4e71445</wsa:MessageID>
+ <wsa:To soapenv:mustUnderstand="1">http://127.0.0.1:9070/axis/services/RMService</wsa:To>
+ <wsa:Action soapenv:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement</wsa:Action>
+ <wsa:From soapenv:mustUnderstand="1">
+ <wsa:Address>http://localhost:8070/axis/services/TestService</wsa:Address>
+ </wsa:From>
+ <wsrm:SequenceAcknowledgement soapenv:mustUnderstand="1">
+ <wsrm:AcknowledgementRange Upper="2" Lower="1"/>
+ <wsrm:AcknowledgementRange Upper="6" Lower="4"/>
+ <wsrm:AcknowledgementRange Upper="10" Lower="8"/>
+ <wsrm:Nack>3</wsrm:Nack>
+ <wsrm:Nack>7</wsrm:Nack>
+ <wsrm:Identifier>uuid:897ee740-1624-11da-a28e-b3b9c4e71445</wsrm:Identifier>
+ </wsrm:SequenceAcknowledgement>
+ </soapenv:Header>
+ <soapenv:Body/>
+ </soapenv:Envelope>
Added: webservices/sandesha/trunk/java/test-resources/TerminateSequence.xml
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test-resources/TerminateSequence.xml?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test-resources/TerminateSequence.xml (added)
+++ webservices/sandesha/trunk/java/test-resources/TerminateSequence.xml Wed Jun 14 22:51:15 2006
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <soapenv:Header>
+ <wsa:MessageID soapenv:mustUnderstand="1">uuid:64f5c3c0-1625-11da-a28e-b3b9c4e71445</wsa:MessageID>
+ <wsa:To soapenv:mustUnderstand="1">http://127.0.0.1:9070/axis/services/RMService</wsa:To>
+ <wsa:Action soapenv:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</wsa:Action>
+ <wsa:From soapenv:mustUnderstand="1">
+ <wsa:Address>http://localhost:8070/axis/services/TestService</wsa:Address>
+ </wsa:From>
+ </soapenv:Header>
+ <soapenv:Body>
+ <wsrm:TerminateSequence>
+ <wsrm:Identifier>uuid:59b0c910-1625-11da-bdfc-b09ed76a1f06</wsrm:Identifier>
+ </wsrm:TerminateSequence>
+ </soapenv:Body>
+ </soapenv:Envelope>
Added: webservices/sandesha/trunk/java/test-resources/sandesha2-test.properties
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test-resources/sandesha2-test.properties?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test-resources/sandesha2-test.properties (added)
+++ webservices/sandesha/trunk/java/test-resources/sandesha2-test.properties Wed Jun 14 22:51:15 2006
@@ -0,0 +1 @@
+test.server.port=8060
\ No newline at end of file
Added: webservices/sandesha/trunk/java/test-resources/sandesha2.properties
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test-resources/sandesha2.properties?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test-resources/sandesha2.properties (added)
+++ webservices/sandesha/trunk/java/test-resources/sandesha2.properties Wed Jun 14 22:51:15 2006
@@ -0,0 +1,15 @@
+#THIS IS A TEST RESOURCE - THE CORRECT PROPERTIES FILE CAN BE FOUND
+#IN THE 'conf' DIRECTORY.
+
+#RM Policy values for the server
+#-------------------------------
+RetransmissionInterval=20000
+AcknowledgementInterval=8000
+ExponentialBackoff=false
+InactivityTimeout=3
+InactivityTimeoutMeasure=hours
+
+
+#Storage Manager Class
+#----------------------
+InMemoryStorageManager=org.apache.sandesha2.storage.inmemory.InMemoryStorageManager1
\ No newline at end of file
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/MessageRetransmissionTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/MessageRetransmissionTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/MessageRetransmissionTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/MessageRetransmissionTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,160 @@
+/*
+ * 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.sandesha2;
+
+import java.io.File;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+/**
+ * @author chamikara
+ *
+ */
+public class MessageRetransmissionTest extends SandeshaTestCase {
+
+ SimpleHTTPServer httpServer = null;
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String ping = "ping";
+ private final String Text = "Text";
+
+ private Log log = LogFactory.getLog(getClass());
+
+ int serverPort = DEFAULT_SERVER_TEST_PORT;
+
+ public MessageRetransmissionTest () {
+ super ("MessageRetransmissionTest");
+ }
+
+ public void setUp () {
+ String serverPortStr = getTestProperty("test.server.port");
+ if (serverPortStr!=null) {
+
+ try {
+ serverPort = Integer.parseInt(serverPortStr);
+ } catch (NumberFormatException e) {
+ log.error(e);
+ }
+ }
+ }
+
+ private void startServer () throws AxisFault {
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+
+ httpServer = new SimpleHTTPServer (configContext,serverPort);
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testMessageRetransmission () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ Options clientOptions = new Options ();
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+// serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+ //starting the server after a wait
+ Thread.sleep(10000);
+
+ startServer();
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+
+ Thread.sleep(10000);
+
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ serviceClient.finalizeInvoke();
+ }
+
+ private OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/PorpertyLoaderTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/PorpertyLoaderTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/PorpertyLoaderTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/PorpertyLoaderTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,77 @@
+/*
+ * 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.sandesha2;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaPropertyBean;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class PorpertyLoaderTest extends TestCase {
+
+ SandeshaPropertyBean propertyBean = null;
+
+ public void setUp () {
+ String fileName = "./test-resources/sandesha2.properties";
+ File file= new File (fileName);
+ if (!file.exists()) {
+ fail("'test-resources/sandesha2.properties' not found");
+ }
+
+ try {
+ InputStream in = new FileInputStream (file);
+ propertyBean = PropertyManager.loadPropertiesFromPropertyFile(in);
+ in.close();
+ } catch (Exception e) {
+ fail (e.getMessage());
+ }
+
+ }
+
+ public void testRetransmissionInterval () {
+ long value = propertyBean.getRetransmissionInterval();
+ assertEquals(value,20000);
+ }
+
+ public void testExponentialBackOff () {
+ boolean value = propertyBean.isExponentialBackoff();
+ assertEquals(value,false);
+ }
+
+ public void testAcknowledgementInterval () {
+ long value = propertyBean.getAcknowledgementInaterval();
+ assertEquals(value,8000);
+ }
+
+ public void testInactivityTImeout () {
+ long value = propertyBean.getInactiveTimeoutInterval();
+ assertEquals(value,(60*60*3*1000));
+ }
+
+ public void testStorageManager () {
+ String storageMgr = propertyBean.getInMemoryStorageManagerClass();
+ assertEquals(storageMgr,"org.apache.sandesha2.storage.inmemory.InMemoryStorageManager1");
+ }
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaClientTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaClientTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaClientTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaClientTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,158 @@
+/*
+ * 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.sandesha2;
+
+import java.io.File;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class SandeshaClientTest extends SandeshaTestCase {
+
+ SimpleHTTPServer httpServer = null;
+ private Log log = LogFactory.getLog(getClass());
+ int serverPort = DEFAULT_SERVER_TEST_PORT;
+
+ public SandeshaClientTest () {
+ super ("SandeshaClientTest");
+ }
+
+ public void setUp () throws AxisFault {
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ String serverPortStr = getTestProperty("test.server.port");
+ if (serverPortStr!=null) {
+
+ try {
+ serverPort = Integer.parseInt(serverPortStr);
+ } catch (NumberFormatException e) {
+ log.error(e);
+ }
+ }
+
+ httpServer = new SimpleHTTPServer (configContext,serverPort);
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testCreateSequenceWithOffer () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ Options clientOptions = new Options ();
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = SandeshaUtil.getUUID();
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+ clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+ String offeredSequenceID = SandeshaUtil.getUUID();
+ clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,offeredSequenceID);
+
+ serviceClient.setOptions(clientOptions);
+ //serviceClient.
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+
+ serviceClient.setOptions(clientOptions);
+
+ SandeshaClient.createSequence(serviceClient,true);
+
+ Thread.sleep(15000);
+
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+
+ assertNotNull(sequenceReport.getSequenceID());
+
+ serviceClient.finalizeInvoke();
+ }
+
+// public void testCreateSequenceWithoutOffer () {
+//// SandeshaClient.createSequence(serviceClient,true);
+//
+//
+// }
+
+// public void testCreateSequenceWithSequenceKey () {
+//
+// }
+//
+// public void testTerminateSequence () {
+//
+// }
+//
+// public void testCloseSequence () {
+//
+// }
+//
+// public void testAckRequest () {
+//
+// }
+//
+// public void getSequenceIDTest () {
+//
+// }
+
+
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaReportsTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaReportsTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaReportsTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaReportsTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,393 @@
+/*
+ * 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.sandesha2;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SandeshaReport;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class SandeshaReportsTest extends SandeshaTestCase {
+
+ SimpleHTTPServer httpServer = null;
+ private final static String applicationNamespaceName = "http://tempuri.org/";
+ private final static String echoString = "echoString";
+ private final static String Text = "Text";
+ private final static String Sequence = "Sequence";
+ private final static String echoStringResponse = "echoStringResponse";
+ private final static String EchoStringReturn = "EchoStringReturn";
+ int serverPort = DEFAULT_SERVER_TEST_PORT;
+ private final String ping = "ping";
+
+ private Log log = LogFactory.getLog(getClass());
+
+ public SandeshaReportsTest () {
+ super ("SandeshaReportsTest");
+ }
+
+ public void setUp () throws AxisFault {
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ String serverPortStr = getTestProperty("test.server.port");
+ if (serverPortStr!=null) {
+
+ try {
+ serverPort = Integer.parseInt(serverPortStr);
+ } catch (NumberFormatException e) {
+ log.error(e);
+ }
+ }
+
+ httpServer = new SimpleHTTPServer (configContext,serverPort);
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testSequenceReports () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ Options clientOptions = new Options ();
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = SandeshaUtil.getUUID();
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+ clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+
+ serviceClient.setOptions(clientOptions);
+ //serviceClient.
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+
+ serviceClient.setOptions(clientOptions);
+
+ TestCallback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ TestCallback callback2 = new TestCallback ("Callback 2");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo2",sequenceKey),callback2);
+
+
+ Thread.sleep(45000);
+
+ //testing outgoing sequence reports
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ //testing incoming sequence reports
+ ArrayList incomingSequenceReports = SandeshaClient.getIncomingSequenceReports(configContext);
+ assertEquals(incomingSequenceReports.size(),1);
+ SequenceReport incomingSequenceReport = (SequenceReport) incomingSequenceReports.get(0);
+ assertEquals(incomingSequenceReport.getCompletedMessages().size(),2);
+ assertNotNull(incomingSequenceReport.getSequenceID());
+ assertEquals(incomingSequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_IN);
+ assertEquals(incomingSequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertNotNull(incomingSequenceReport.getInternalSequenceID());
+
+ assertEquals(incomingSequenceReport.getSequenceID(),incomingSequenceReport.getInternalSequenceID()); //for the incoming side, internalSequenceID==sequenceID
+
+ serviceClient.finalizeInvoke();
+ }
+
+ public void testRMReport () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ Options clientOptions = new Options ();
+// clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey1 = "sequence3";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey1);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ serviceClient.setOptions(clientOptions);
+
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+ String sequenceKey2 = "sequence4";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey2);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "false");
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+
+ try {
+ //waiting till the messages exchange finishes.
+ Thread.sleep(18000);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+
+
+ SandeshaReport rmReport = SandeshaClient.getSandeshaReport(configContext);
+
+ SequenceReport sequence1Report = null;
+ SequenceReport sequence2Report = null;
+
+ Iterator iterator = rmReport.getOutgoingSequenceList().iterator();
+ while (iterator.hasNext()) {
+ String sequenceID = (String) iterator.next();
+
+ String internalSequenceID = rmReport.getInternalSequenceIdOfOutSequence(sequenceID);
+
+ if (internalSequenceID.indexOf(sequenceKey1)>=0) {
+ sequence1Report = SandeshaClient.getOutgoingSequenceReport(to,sequenceKey1,configContext);
+ } else if (internalSequenceID.indexOf(sequenceKey2)>=0){
+ sequence2Report = SandeshaClient.getOutgoingSequenceReport(to,sequenceKey2,configContext);
+ }
+ }
+
+ assertNotNull(sequence1Report);
+ assertNotNull(sequence2Report);
+
+ assertEquals(sequence1Report.getCompletedMessages().size(),2);
+ assertEquals(sequence2Report.getCompletedMessages().size(),1);
+
+ assertEquals(sequence1Report.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequence2Report.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_ESTABLISHED);
+
+ serviceClient.finalizeInvoke();
+ }
+
+ private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement echoStringElement = fac.createOMElement(echoString, applicationNamespace);
+ OMElement textElem = fac.createOMElement(Text,applicationNamespace);
+ OMElement sequenceElem = fac.createOMElement(Sequence,applicationNamespace);
+
+ textElem.setText(text);
+ sequenceElem.setText(sequenceKey);
+ echoStringElement.addChild(textElem);
+ echoStringElement.addChild(sequenceElem);
+
+ return echoStringElement;
+ }
+
+ class TestCallback extends Callback {
+
+ String name = null;
+ boolean completed = false;
+ boolean errorRported = false;
+ String resultStr;
+
+ public boolean isCompleted() {
+ return completed;
+ }
+
+ public boolean isErrorRported() {
+ return errorRported;
+ }
+
+ public String getResult () {
+ return resultStr;
+ }
+
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public void onComplete(AsyncResult result) {
+
+ SOAPBody body = result.getResponseEnvelope().getBody();
+
+ OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse));
+ if (echoStringResponseElem==null) {
+ log.error("Error: SOAPBody does not have a 'echoStringResponse' child");
+ return;
+ }
+
+ OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+ if (echoStringReturnElem==null) {
+ log.error("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+ return;
+ }
+
+ String resultStr = echoStringReturnElem.getText();
+ this.resultStr = resultStr;
+ completed = true;
+ }
+
+ public void onError (Exception e) {
+ e.printStackTrace();
+ errorRported = true;
+ }
+ }
+
+ private OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+
+// public void testSequenceTermination () throws AxisFault,InterruptedException {
+//
+// String to = "http://127.0.0.1:8060/axis2/services/RMSampleService";
+// String transportTo = "http://127.0.0.1:8060/axis2/services/RMSampleService";
+//
+// String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+// String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml";
+//
+// ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+//
+// //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+// Options clientOptions = new Options ();
+// clientOptions.setProperty(Options.COPY_PROPERTIES,new Boolean (true));
+// clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+//
+// clientOptions.setTo(new EndpointReference (to));
+// clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+//
+// String sequenceKey1 = "sequence1";
+// clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey1);
+//
+// ServiceClient serviceClient = new ServiceClient (configContext,null);
+//
+// serviceClient.setOptions(clientOptions);
+//
+// serviceClient.fireAndForget(getPingOMBlock("ping11"));
+// serviceClient.fireAndForget(getPingOMBlock("ping12"));
+//
+// String sequenceKey2 = "sequence2";
+// clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey2);
+//
+// serviceClient.fireAndForget(getPingOMBlock("ping21"));
+//
+// SandeshaClient.terminateSequence(serviceClient,sequenceKey1);
+//
+// clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+// serviceClient.fireAndForget(getPingOMBlock("ping22"));
+// try {
+// //waiting till the messages exchange finishes.
+// Thread.sleep(10000);
+// } catch (InterruptedException e) {
+// throw new SandeshaException ("sleep interupted");
+// }
+//
+//
+// SandeshaReport rmReport = SandeshaClient.getSandeshaReport(configContext);
+//
+// SequenceReport sequence1Report = null;
+// SequenceReport sequence2Report = null;
+//
+// Iterator iterator = rmReport.getOutgoingSequenceList().iterator();
+// while (iterator.hasNext()) {
+// String sequenceID = (String) iterator.next();
+//
+// String internalSequenceID = rmReport.getInternalSequenceIdOfOutSequence(sequenceID);
+//
+// if (internalSequenceID.indexOf(sequenceKey1)>=0) {
+// sequence1Report = SandeshaClient.getOutgoingSequenceReport(to,sequenceKey1,configContext);
+// } else if (internalSequenceID.indexOf(sequenceKey2)>=0){
+// sequence2Report = SandeshaClient.getOutgoingSequenceReport(to,sequenceKey2,configContext);
+// }
+// }
+//
+// assertNotNull(sequence1Report);
+// assertNotNull(sequence2Report);
+//
+// assertEquals(sequence1Report.getCompletedMessages().size(),2);
+// assertEquals(sequence2Report.getCompletedMessages().size(),2);
+//
+// assertEquals(sequence1Report.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+// assertEquals(sequence2Report.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+// }
+
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaTestCase.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaTestCase.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaTestCase.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaTestCase.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,110 @@
+package org.apache.sandesha2;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Properties;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+/*
+ * 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.
+ */
+
+public class SandeshaTestCase extends TestCase {
+
+ String resourceDir = ""; //"test-resources";
+ Properties properties = null;
+ final String PROPERTY_FILE_NAME = "sandesha2-test.properties";
+ public final int DEFAULT_SERVER_TEST_PORT = 8060;
+
+ private Log log = LogFactory.getLog(getClass());
+
+ public SandeshaTestCase(String name) {
+ super(name);
+ File baseDir = new File("");
+ String testRource = baseDir.getAbsolutePath() + File.separator + "test-resources";
+ resourceDir = new File(testRource).getPath();
+
+ String propFileStr = resourceDir + File.separator + PROPERTY_FILE_NAME;
+ properties = new Properties ();
+
+ try {
+ FileInputStream propertyFile = new FileInputStream (new File(propFileStr));
+ properties.load(propertyFile);
+ } catch (FileNotFoundException e) {
+ log.error(e);
+ } catch (IOException e) {
+ log.error(e);
+ }
+ }
+
+ protected InputStreamReader getResource(String relativePath, String resourceName) {
+ String resourceFile = resourceDir + relativePath + File.separator + resourceName;
+ try {
+ FileReader reader = new FileReader(resourceFile);
+ return reader;
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException("cannot load the test-resource", e);
+ }
+ }
+
+ protected SOAPEnvelope getSOAPEnvelope() {
+ return OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+ }
+
+ protected SOAPEnvelope getSOAPEnvelope(String relativePath, String resourceName) {
+ try {
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
+ getResource(relativePath, resourceName));
+ OMXMLParserWrapper wrapper = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
+ OMAbstractFactory.getSOAP11Factory(), reader);
+ return (SOAPEnvelope) wrapper.getDocumentElement();
+
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected SOAPEnvelope getEmptySOAPEnvelope() {
+ return OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+ }
+
+ public String getTestProperty (String key) {
+ if (properties!=null)
+ return properties.getProperty(key);
+ else
+ return null;
+ }
+
+ public void testMethod () {
+
+ }
+
+
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaUtilTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaUtilTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaUtilTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SandeshaUtilTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,84 @@
+/*
+ * Copyright 1999-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.sandesha2;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.sandesha2.util.SOAPAbstractFactory;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.wsrm.AcknowledgementRange;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class SandeshaUtilTest extends TestCase {
+
+ public void testUUIDGen () {
+ String UUID1 = SandeshaUtil.getUUID();
+ String UUID2 = SandeshaUtil.getUUID();
+
+ assertTrue(UUID1!=null);
+ assertTrue(UUID2!=null);
+ assertTrue(!UUID1.equals(UUID2));
+
+ assertTrue(UUID1.startsWith("urn:uuid:"));
+ assertTrue(UUID2.startsWith("urn:uuid:"));
+ }
+
+ public void testGetAckRangeArrayList () throws SandeshaException {
+ SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(Sandesha2Constants.SOAPVersion.v1_1);
+ String msgNumberStr = "3,6,1,5,8,2";
+
+ ArrayList list = SandeshaUtil.getAckRangeArrayList(msgNumberStr,factory,Sandesha2Constants.SPEC_2005_02.NS_URI);
+ assertNotNull(list);
+ assertEquals(list.size(),3);
+
+ Iterator it = list.iterator();
+ AcknowledgementRange ackRange = null;
+
+ ackRange = (AcknowledgementRange) it.next();
+ assertNotNull(ackRange);
+ assertEquals(ackRange.getLowerValue(),1);
+ assertEquals(ackRange.getUpperValue(),3);
+
+ ackRange = null;
+ ackRange = (AcknowledgementRange) it.next();
+ assertNotNull(ackRange);
+ assertEquals(ackRange.getLowerValue(),5);
+ assertEquals(ackRange.getUpperValue(),6);
+
+ ackRange = null;
+ ackRange = (AcknowledgementRange) it.next();
+ assertNotNull(ackRange);
+ assertEquals(ackRange.getLowerValue(),8);
+ assertEquals(ackRange.getUpperValue(),8);
+
+ assertFalse(it.hasNext());
+ }
+
+
+
+
+
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SquenceOfferTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SquenceOfferTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SquenceOfferTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/SquenceOfferTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,229 @@
+/*
+ * 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.sandesha2;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SandeshaReport;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class SquenceOfferTest extends SandeshaTestCase {
+
+ SimpleHTTPServer httpServer = null;
+
+ private final static String applicationNamespaceName = "http://tempuri.org/";
+ private final static String echoString = "echoString";
+ private final static String Text = "Text";
+ private final static String Sequence = "Sequence";
+ private final static String echoStringResponse = "echoStringResponse";
+ private final static String EchoStringReturn = "EchoStringReturn";
+ int serverPort = DEFAULT_SERVER_TEST_PORT;
+ private Log log = LogFactory.getLog(getClass());
+
+ public SquenceOfferTest () {
+ super ("SquenceOfferTest");
+ }
+
+ public void setUp () throws AxisFault {
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ String serverPortStr = getTestProperty("test.server.port");
+ if (serverPortStr!=null) {
+
+ try {
+ serverPort = Integer.parseInt(serverPortStr);
+ } catch (NumberFormatException e) {
+ log.error(e);
+ }
+ }
+
+ httpServer = new SimpleHTTPServer (configContext,serverPort);
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testSequenceOffer () throws AxisFault, InterruptedException {
+
+ String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ Options clientOptions = new Options ();
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = SandeshaUtil.getUUID();
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+ clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+ String offeredSequenceID = SandeshaUtil.getUUID();
+ clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,offeredSequenceID);
+
+ serviceClient.setOptions(clientOptions);
+ //serviceClient.
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+
+ serviceClient.setOptions(clientOptions);
+
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ TestCallback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1",sequenceKey),callback1);
+
+ Thread.sleep(22000);
+
+ //assertions for the out sequence.
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ assertTrue(callback1.isComplete());
+ assertEquals(callback1.getResult(),"echo1");
+
+ //checking weather the incomingSequenceReport has the offered sequence ID
+ SandeshaReport rmReport = SandeshaClient.getSandeshaReport(configContext);
+ ArrayList incomingSeqList = rmReport.getIncomingSequenceList();
+ assertEquals(incomingSeqList.size(),1);
+ assertEquals(incomingSeqList.get(0),offeredSequenceID);
+
+ serviceClient.finalizeInvoke();
+ }
+
+ private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement echoStringElement = fac.createOMElement(echoString, applicationNamespace);
+ OMElement textElem = fac.createOMElement(Text,applicationNamespace);
+ OMElement sequenceElem = fac.createOMElement(Sequence,applicationNamespace);
+
+ textElem.setText(text);
+ sequenceElem.setText(sequenceKey);
+ echoStringElement.addChild(textElem);
+ echoStringElement.addChild(sequenceElem);
+
+ return echoStringElement;
+ }
+
+ class TestCallback extends Callback {
+
+ String name = null;
+ boolean completed = false;
+ boolean errorRported = false;
+ String resultStr;
+
+ public boolean isCompleted() {
+ return completed;
+ }
+
+ public boolean isErrorRported() {
+ return errorRported;
+ }
+
+ public String getResult () {
+ return resultStr;
+ }
+
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public void onComplete(AsyncResult result) {
+
+ SOAPBody body = result.getResponseEnvelope().getBody();
+
+ OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse));
+ if (echoStringResponseElem==null) {
+ log.error("Error: SOAPBody does not have a 'echoStringResponse' child");
+ return;
+ }
+
+ OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+ if (echoStringReturnElem==null) {
+ log.error("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+ return;
+ }
+
+ String resultStr = echoStringReturnElem.getText();
+ this.resultStr = resultStr;
+ completed = true;
+ }
+
+ public void onError (Exception e) {
+ e.printStackTrace();
+ errorRported = true;
+ }
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org