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 2007/04/23 11:55:16 UTC
svn commit: r531400 [17/18] - in /webservices/sandesha/trunk/java/modules:
client/ core/ core/src/ core/src/main/ core/src/main/java/
core/src/main/java/org/ core/src/main/java/org/apache/
core/src/main/java/org/apache/sandesha2/ core/src/main/java/org...
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/security/UnitTestSecurityManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/security/UnitTestSecurityManager.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/security/UnitTestSecurityManager.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/security/UnitTestSecurityManager.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.security;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisModule;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+public class UnitTestSecurityManager extends SecurityManager {
+ private static Log log = LogFactory.getLog(UnitTestSecurityManager.class);
+
+ private static HashMap tokens = new HashMap();
+ private static int id = 0;
+ private static String secNamespace = Sandesha2Constants.SPEC_2005_02.SEC_NS_URI;
+ private static QName unitTestHeader = new QName("http://unit.test.security", "tokenId");
+
+ public UnitTestSecurityManager(ConfigurationContext context) {
+ super(context);
+ log.debug("UnitTestSecurityManager::UnitTestSecurityManager");
+ }
+
+ public void initSecurity(AxisModule moduleDesc) {
+ log.debug("UnitTestSecurityManager::initSecurity");
+ }
+
+ public SecurityToken getSecurityToken(MessageContext message)
+ {
+ log.debug("Enter: UnitTestSecurityManager::getSecurityToken(MessageContext)");
+
+ UnitTestSecurityToken result = new UnitTestSecurityToken(id++);
+ tokens.put(getTokenRecoveryData(result), result);
+
+ log.debug("Exit: UnitTestSecurityManager::getSecurityToken " + result);
+ return result;
+ }
+
+ public SecurityToken getSecurityToken(OMElement theSTR, MessageContext message)
+ {
+ log.debug("Enter: UnitTestSecurityManager::getSecurityToken(OMElement,MessageContext)");
+
+ OMElement reference = theSTR.getFirstChildWithName(new QName(secNamespace, "Reference"));
+ String securityTokenURI = reference.getAttributeValue(new QName("URI"));
+ String key = securityTokenURI;
+ SecurityToken result = (SecurityToken) tokens.get(key);
+
+ log.debug("Exit: UnitTestSecurityManager::getSecurityToken " + result);
+ return result;
+ }
+
+ public String getTokenRecoveryData(SecurityToken token) {
+ log.debug("Enter: UnitTestSecurityManager::getTokenRecoveryData");
+ String key = ((UnitTestSecurityToken)token).getURI();
+ log.debug("Exit: UnitTestSecurityManager::getTokenRecoveryData " + key);
+ return key;
+ }
+
+ public SecurityToken recoverSecurityToken(String tokenData) {
+ log.debug("Enter: UnitTestSecurityManager::recoverSecurityToken");
+ SecurityToken result = (SecurityToken) tokens.get(tokenData);
+ log.debug("Exit: UnitTestSecurityManager::recoverSecurityToken " + result);
+ return result;
+ }
+
+ public void checkProofOfPossession(SecurityToken token, OMElement messagePart,
+ MessageContext message) throws SandeshaException {
+ log.debug("Enter: UnitTestSecurityManager::checkProofOfPossession");
+ if(token == null) {
+ throw new SandeshaException("Security manager was passed a null token");
+ }
+
+ // Look for the header that we should have introduced in the 'apply' method
+ String key = ((UnitTestSecurityToken)token).getURI();
+ boolean foundToken = false;
+ SOAPEnvelope env = message.getEnvelope();
+ SOAPHeader headers = env.getHeader();
+ if(headers != null) {
+ Iterator tokens = headers.getChildrenWithName(unitTestHeader);
+ while(tokens.hasNext()) {
+ OMElement myHeader = (OMElement) tokens.next();
+ String text = myHeader.getText();
+ if(key.equals(text)) {
+ foundToken = true;
+ break;
+ }
+ }
+ }
+ if(!foundToken) {
+ SandeshaException e = new SandeshaException("Message was not secured with the correct token(s)");
+ e.printStackTrace(System.err);
+ throw e;
+ }
+
+ log.debug("Exit: UnitTestSecurityManager::checkProofOfPossession");
+ }
+
+ public OMElement createSecurityTokenReference(SecurityToken token, MessageContext message) {
+ log.debug("Enter: UnitTestSecurityManager::createSecurityTokenReference");
+
+ String uri = ((UnitTestSecurityToken)token).getURI();
+ String type = ((UnitTestSecurityToken)token).getValueType();
+
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMNamespace secNS = factory.createOMNamespace(secNamespace, "wsse");
+ OMElement str = factory.createOMElement("SecurityTokenReference", secNS);
+
+ OMElement ref = factory.createOMElement("Reference", secNS);
+ str.addChild(ref);
+
+ OMAttribute uriAttr = factory.createOMAttribute("URI", null, uri);
+ OMAttribute typeAttr = factory.createOMAttribute("ValueType", null, type);
+
+ ref.addAttribute(uriAttr);
+ ref.addAttribute(typeAttr);
+
+ log.debug("Exit: UnitTestSecurityManager::createSecurityTokenReference " + str);
+ return str;
+ }
+
+ public void applySecurityToken(SecurityToken token, MessageContext outboundMessage) throws SandeshaException {
+ log.debug("Enter: UnitTestSecurityManager::applySecurityToken");
+ if(token == null) {
+ throw new SandeshaException("Security manager was passed a null token");
+ }
+
+ // Add the header that pretends to secure the message
+ String key = ((UnitTestSecurityToken)token).getURI();
+ SOAPEnvelope env = outboundMessage.getEnvelope();
+ OMFactory factory = env.getOMFactory();
+
+ SOAPHeader headers = env.getHeader();
+
+ OMNamespace namespace = factory.createOMNamespace(unitTestHeader.getNamespaceURI(), "sec");
+ OMElement header = headers.addHeaderBlock(unitTestHeader.getLocalPart(), namespace);
+ header.setText(key);
+
+ log.debug("Exit: UnitTestSecurityManager::applySecurityToken");
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/security/UnitTestSecurityToken.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/security/UnitTestSecurityToken.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/security/UnitTestSecurityToken.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/security/UnitTestSecurityToken.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.security;
+
+class UnitTestSecurityToken implements SecurityToken {
+
+ private int id = 0;
+
+ UnitTestSecurityToken(int id) {
+ this.id = id;
+ }
+
+ /**
+ * The SecurityTokenReference that gets encoded into the CreateSequence message
+ * includes an URI string. This method returns the value to use.
+ */
+ String getURI() {
+ return "#BogusURI/" + id;
+ }
+
+ /**
+ * The SecurityTokenReference that gets encoded into the CreateSequence message
+ * includes a ValueType string. This method returns the value to use.
+ */
+ String getValueType() {
+ return "http://schemas.xmlsoap.org/ws/2005/02/sc/sct";
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/InvokerBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/InvokerBeanMgrTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/InvokerBeanMgrTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/InvokerBeanMgrTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,110 @@
+/*
+ * 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.storage;
+
+import org.apache.sandesha2.policy.SandeshaPolicyBean;
+import org.apache.sandesha2.storage.beanmanagers.InvokerBeanMgr;
+import org.apache.sandesha2.storage.beans.InvokerBean;
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContext;
+
+import java.util.Iterator;
+
+public class InvokerBeanMgrTest extends SandeshaTestCase {
+
+ InvokerBeanMgr mgr;
+ Transaction transaction;
+
+ public InvokerBeanMgrTest() {
+ super ("InvokerBeanMgrTest");
+ }
+
+ public void setUp() throws Exception {
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ SandeshaPolicyBean propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+ Parameter parameter = new Parameter ();
+ parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+ parameter.setValue(propertyBean);
+ axisConfig.addParameter(parameter);
+
+ ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ parameter = new Parameter(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+ axisConfig.addParameter(parameter);
+
+ StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
+ transaction = storageManager.getTransaction();
+ mgr = storageManager.getInvokerBeanMgr();
+ }
+
+ public void tearDown() throws Exception {
+ transaction.commit();
+ }
+
+ public void testDelete() throws SandeshaStorageException {
+ mgr.insert(new InvokerBean("Key1", 1001, "SeqId1"));
+ mgr.delete("Key1");
+ assertNull(mgr.retrieve("Key1"));
+ }
+
+ public void testFind() throws SandeshaStorageException {
+ mgr.insert(new InvokerBean("Key2", 1002, "SeqId2"));
+ mgr.insert(new InvokerBean("Key3", 1003, "SeqId2"));
+
+ InvokerBean bean = new InvokerBean();
+ bean.setSequenceID("SeqId2");
+
+ Iterator iter = mgr.find(bean).iterator();
+ InvokerBean tmp = (InvokerBean) iter.next();
+
+ if (tmp.getMessageContextRefKey().equals("Key2")) {
+ tmp = (InvokerBean) iter.next();
+ assertTrue(tmp.getMessageContextRefKey().equals("Key3"));
+ } else {
+ tmp = (InvokerBean) iter.next();
+ assertTrue(tmp.getMessageContextRefKey().equals("Key2"));
+
+ }
+ }
+
+ public void testInsert() throws SandeshaStorageException {
+ mgr.insert(new InvokerBean("Key4", 1004, "SeqId4"));
+ InvokerBean tmp = mgr.retrieve("Key4");
+ assertTrue(tmp.getMessageContextRefKey().equals("Key4"));
+ }
+
+ public void testRetrieve() throws SandeshaStorageException {
+ assertNull(mgr.retrieve("Key5"));
+ mgr.insert(new InvokerBean("Key5", 1004, "SeqId5"));
+ assertNotNull(mgr.retrieve("Key5"));
+ }
+
+ public void testUpdate() throws SandeshaStorageException {
+ InvokerBean bean = new InvokerBean("Key6", 1006, "SeqId6");
+ mgr.insert(bean);
+ bean.setMsgNo(1007);
+ mgr.update(bean);
+ InvokerBean tmp = mgr.retrieve("Key6");
+ assertTrue(tmp.getMsgNo() == 1007);
+ }
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/RMDBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/RMDBeanMgrTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/RMDBeanMgrTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/RMDBeanMgrTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,115 @@
+/*
+ * 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.storage;
+
+import org.apache.sandesha2.policy.SandeshaPolicyBean;
+import org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr;
+import org.apache.sandesha2.storage.beans.RMDBean;
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContext;
+
+import java.util.Iterator;
+
+public class RMDBeanMgrTest extends SandeshaTestCase {
+
+ private RMDBeanMgr mgr;
+ Transaction transaction;
+
+ public RMDBeanMgrTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ SandeshaPolicyBean propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+ Parameter parameter = new Parameter ();
+ parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+ parameter.setValue(propertyBean);
+ axisConfig.addParameter(parameter);
+
+ ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ parameter = new Parameter(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+ axisConfig.addParameter(parameter);
+
+ StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
+ transaction = storageManager.getTransaction();
+ mgr = storageManager.getRMDBeanMgr();
+
+ }
+
+ public void tearDown() throws Exception {
+ transaction.commit();
+ }
+
+ public void testDelete() throws SandeshaStorageException{
+ mgr.insert(new RMDBean("SeqId1", 1001));
+ mgr.delete("SeqId1");
+ assertNull(mgr.retrieve("SeqId1"));
+ }
+
+ public void testFind() throws SandeshaStorageException {
+ mgr.insert(new RMDBean("SeqId2", 1002));
+ mgr.insert(new RMDBean("SeqId3", 1002));
+
+ RMDBean target = new RMDBean();
+ target.setNextMsgNoToProcess(1002);
+
+ Iterator iterator = mgr.find(target).iterator();
+ RMDBean tmp = (RMDBean) iterator.next();
+
+ if (tmp.getSequenceID().equals("SeqId2")) {
+ tmp = (RMDBean) iterator.next();
+ tmp.getSequenceID().equals("SeqId3");
+ } else {
+ tmp = (RMDBean) iterator.next();
+ tmp.getSequenceID().equals("SeqId2");
+ }
+
+ }
+
+ public void testInsert() throws SandeshaStorageException {
+ RMDBean bean = new RMDBean("SeqId4", 1004);
+ mgr.insert(bean);
+ RMDBean tmp = mgr.retrieve("SeqId4");
+ assertTrue(tmp.getNextMsgNoToProcess() == 1004);
+ }
+
+ public void testRetrieve() throws SandeshaStorageException {
+ assertNull(mgr.retrieve("SeqId5"));
+ mgr.insert(new RMDBean("SeqId5", 1005));
+
+ RMDBean tmp = mgr.retrieve("SeqId5");
+ assertTrue(tmp.getNextMsgNoToProcess() == 1005);
+ }
+
+ public void testUpdate() throws SandeshaStorageException {
+ RMDBean bean = new RMDBean("SeqId6", 1006);
+ mgr.insert(bean);
+ bean.setNextMsgNoToProcess(1007);
+ mgr.update(bean);
+ RMDBean tmp = mgr.retrieve("SeqId6");
+ assertTrue(tmp.getNextMsgNoToProcess() ==1007);
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/RMSBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/RMSBeanMgrTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/RMSBeanMgrTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/RMSBeanMgrTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,141 @@
+/*
+ * 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.storage;
+
+import org.apache.sandesha2.policy.SandeshaPolicyBean;
+import org.apache.sandesha2.storage.beanmanagers.RMSBeanMgr;
+import org.apache.sandesha2.storage.beans.RMSBean;
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContext;
+
+import java.util.Iterator;
+
+
+public class RMSBeanMgrTest extends SandeshaTestCase {
+ private RMSBeanMgr mgr;
+ Transaction transaction;
+
+ public RMSBeanMgrTest() {
+ super("RMSBeanMgrTest");
+ }
+
+ public void setUp() throws Exception {
+
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ SandeshaPolicyBean propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+ Parameter parameter = new Parameter ();
+ parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+ parameter.setValue(propertyBean);
+ axisConfig.addParameter(parameter);
+
+ ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ parameter = new Parameter(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+ axisConfig.addParameter(parameter);
+
+ StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
+ transaction = storageManager.getTransaction();
+ mgr = storageManager.getRMSBeanMgr();
+ }
+
+ public void tearDown() throws Exception {
+ transaction.commit();
+ }
+
+ public void testDelete() throws SandeshaStorageException {
+ RMSBean rMSBean = new RMSBean ();
+ rMSBean.setInternalSequenceID("TmpSeqId1");
+ rMSBean.setCreateSeqMsgID("CreateSeqMsgId1");
+ rMSBean.setSequenceID("SeqId1");
+ mgr.insert(rMSBean);
+ mgr.delete("CreateSeqMsgId1");
+ assertNull(mgr.retrieve("CreateSeqMsgId1"));
+ }
+
+ public void testFind() throws SandeshaStorageException {
+ RMSBean createSeqBean1 = new RMSBean ();
+ createSeqBean1.setInternalSequenceID("TmpSeqId1");
+ createSeqBean1.setCreateSeqMsgID("CreateSeqMsgId1");
+ createSeqBean1.setSequenceID("SeqId1");
+
+ RMSBean createSeqBean2 = new RMSBean ();
+ createSeqBean2.setInternalSequenceID("TmpSeqId1");
+ createSeqBean2.setCreateSeqMsgID("CreateSeqMsgId2");
+ createSeqBean2.setSequenceID("SeqId2");
+
+ mgr.insert(createSeqBean1);
+ mgr.insert(createSeqBean2);
+
+ RMSBean target = new RMSBean();
+ target.setInternalSequenceID("TmpSeqId1");
+
+ Iterator iter = mgr.find(target).iterator();
+ RMSBean tmp = (RMSBean) iter.next();
+ if (tmp.getCreateSeqMsgID().equals("CreateSeqMsgId1")) {
+ tmp = (RMSBean) iter.next();
+ assertTrue(tmp.getCreateSeqMsgID().equals("CreateSeqMsgId2"));
+
+ } else {
+ tmp = (RMSBean) iter.next();
+ assertTrue(tmp.getCreateSeqMsgID().equals("CreateSeqMsgId1"));
+ }
+ }
+
+ public void testInsert() throws SandeshaStorageException{
+ RMSBean rMSBean = new RMSBean ();
+ rMSBean.setInternalSequenceID("TmpSeqId4");
+ rMSBean.setCreateSeqMsgID("CreateSeqMsgId4");
+ rMSBean.setSequenceID("SeqId4");
+ mgr.insert(rMSBean);
+ RMSBean tmpbean = mgr.retrieve("CreateSeqMsgId4");
+ assertTrue(tmpbean.getCreateSeqMsgID().equals("CreateSeqMsgId4"));
+ assertTrue(tmpbean.getSequenceID().equals("SeqId4"));
+ assertTrue(tmpbean.getInternalSequenceID().equals("TmpSeqId4"));
+ }
+
+
+ public void testRetrieve() throws SandeshaStorageException{
+ assertNull(mgr.retrieve("CreateSeqMsgId5"));
+
+ RMSBean rMSBean = new RMSBean ();
+ rMSBean.setInternalSequenceID("TmpSeqId5");
+ rMSBean.setCreateSeqMsgID("CreateSeqMsgId5");
+ rMSBean.setSequenceID("SeqId5");
+ mgr.insert(rMSBean);
+ RMSBean tmp = mgr.retrieve("CreateSeqMsgId5");
+ assertTrue(tmp.getCreateSeqMsgID().equals("CreateSeqMsgId5"));
+ }
+
+ public void testUpdate() throws SandeshaStorageException {
+ RMSBean rMSBean = new RMSBean ();
+ rMSBean.setInternalSequenceID("TmpSeqId6");
+ rMSBean.setCreateSeqMsgID("CreateSeqMsgId6");
+ rMSBean.setSequenceID("SeqId6");
+
+ mgr.insert(rMSBean);
+ rMSBean.setInternalSequenceID("TmpSeqId7");
+ mgr.update(rMSBean);
+ RMSBean tmp = mgr.retrieve("CreateSeqMsgId6");
+ assertTrue(tmp.getInternalSequenceID().equals("TmpSeqId7"));
+ }
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/SenderBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/SenderBeanMgrTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/SenderBeanMgrTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/storage/SenderBeanMgrTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sandesha2.storage;
+
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.policy.SandeshaPolicyBean;
+import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
+import org.apache.sandesha2.storage.beans.SenderBean;
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContext;
+
+import java.util.Iterator;
+
+
+public class SenderBeanMgrTest extends SandeshaTestCase {
+
+ private SenderBeanMgr mgr;
+ Transaction transaction;
+
+ public SenderBeanMgrTest() {
+ super("SenderBeanMgrTest");
+ }
+
+ public void setUp() throws Exception {
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ SandeshaPolicyBean propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+ Parameter parameter = new Parameter ();
+ parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+ parameter.setValue(propertyBean);
+ axisConfig.addParameter(parameter);
+
+ ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ parameter = new Parameter(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+ axisConfig.addParameter(parameter);
+
+ StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
+ transaction = storageManager.getTransaction();
+ mgr = storageManager.getSenderBeanMgr();
+ }
+
+ public void tearDown() throws Exception {
+ transaction.commit();
+ }
+
+ public void testDelete() throws SandeshaStorageException {
+ assertNull(mgr.retrieve(""));
+ try {
+ mgr.insert(new SenderBean("MsgId1", "Key1", false , 1001 , "TmpSeqId1", 1001));
+ } catch (Exception ex) {
+ fail("should not throw an exception");
+ }
+ assertNotNull(mgr.retrieve("MsgId1"));
+ }
+
+ public void testFind() {
+ try {
+ mgr.insert(new SenderBean("MsgId2", "Key2", false , 1001 , "TmpSeqId2", 1002));
+ mgr.insert(new SenderBean("MsgId3", "Key3", false , 1001 , "TmpSeqId2", 1003));
+
+ SenderBean target = new SenderBean();
+ target.setInternalSequenceID("TmpSeqId2");
+
+ Iterator iterator = mgr.find(target).iterator();
+ SenderBean tmp = (SenderBean) iterator.next();
+
+ if (tmp.getMessageID().equals("MsgId2")) {
+ tmp = (SenderBean) iterator.next();
+ assertTrue(tmp.getMessageID().equals("MsgId3"));
+ } else {
+ tmp = (SenderBean) iterator.next();
+ assertTrue(tmp.getMessageID().equals("MsgId2"));
+ }
+
+
+ } catch (SandeshaException e) {
+ fail("should not throw an exception");
+ }
+
+
+ }
+
+ public void testInsert() {
+// try {
+// mgr.insert(new SenderBean());
+// fail("should throw an exception");
+//
+// } catch (SandeshaException ex) {
+// }
+
+ try {
+ mgr.insert(new SenderBean("MsgId4","Key4", false , 1001 , "TmpSeqId4", 1004));
+ SenderBean tmp = mgr.retrieve("MsgId4");
+ assertTrue(tmp.getMessageContextRefKey().equals("Key4"));
+
+
+ } catch (SandeshaException e) {
+ fail("should not throw an exception");
+ }
+
+ }
+
+ public void testRetrieve() throws SandeshaStorageException {
+ assertNull(mgr.retrieve("MsgId5"));
+ try {
+ mgr.insert(new SenderBean("MsgId5", "Key5", false , 1001 , "TmpSeqId5", 1005));
+ } catch (SandeshaException e) {
+ fail("this should not throw an exception");
+ }
+ assertNotNull(mgr.retrieve("MsgId5"));
+ }
+
+ public void testUpdate() throws SandeshaStorageException {
+ SenderBean bean = new SenderBean("MsgId6", "Key6", false , 1001 , "TmpSeqId6", 1006);
+ try {
+ mgr.insert(bean);
+ } catch (SandeshaException e) {
+ fail("should not throw an exception");
+ }
+ bean.setSend(true);
+ mgr.update(bean);
+
+ SenderBean tmp = mgr.retrieve("MsgId6");
+ assertTrue(tmp.isSend());
+ }
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/utils/RangeStringTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/utils/RangeStringTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/utils/RangeStringTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/utils/RangeStringTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,104 @@
+/*
+ * 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.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.util.Range;
+import org.apache.sandesha2.util.RangeString;
+
+public class RangeStringTest extends SandeshaTestCase{
+
+
+ public RangeStringTest(String s){
+ super(s);
+ }
+
+ public void testStringToRangeAndBack(){
+
+ //our expected range is missing 6, 9, 10 and 11 and ends at 12
+ String finalRangeString = "[0,5][7,8][12,12]";
+
+ RangeString rString = new RangeString(finalRangeString);
+ assertTrue(rString.isMessageNumberInRanges(0));
+ assertTrue(rString.isMessageNumberInRanges(1));
+ assertTrue(rString.isMessageNumberInRanges(2));
+ assertTrue(rString.isMessageNumberInRanges(3));
+ assertTrue(rString.isMessageNumberInRanges(4));
+ assertTrue(rString.isMessageNumberInRanges(5));
+
+ assertFalse(rString.isMessageNumberInRanges(6));
+
+ assertTrue(rString.isMessageNumberInRanges(7));
+ assertTrue(rString.isMessageNumberInRanges(8));
+
+ assertFalse(rString.isMessageNumberInRanges(9));
+ assertFalse(rString.isMessageNumberInRanges(10));
+ assertFalse(rString.isMessageNumberInRanges(11));
+
+ assertTrue(rString.isMessageNumberInRanges(12));
+
+ //now just check some boundary conditions
+ assertFalse(rString.isMessageNumberInRanges(13));
+ assertFalse(rString.isMessageNumberInRanges(-1));
+
+ //now we get the string representation back
+ assertEquals(finalRangeString, rString.toString());
+
+ }
+
+
+ public void testGrowingRange(){
+ //start of missing msgs 2-9
+ String msgs = "[1,1][10,10]";
+
+ RangeString rString = new RangeString(msgs);
+ rString.addRange(new Range(2,2)); //msg 2 arrives
+ rString.addRange(new Range(8,9)); //msgs 8 and 9 arrive
+ rString.addRange(new Range(6,6)); // msg 6 arrives
+ rString.addRange(new Range(3,5)); //msgs 3,4 and 5 arrive
+ rString.addRange(new Range(3,4)); //msgs 3,4 are duplicated
+ rString.addRange(new Range(7,7)); //finally msg 7
+
+ //all msgs have now arrived
+ assertEquals("[1,10]", rString.toString());
+
+ //all messages are duplicated
+ rString.addRange(new Range(1,10));
+ //cehck we handle duplicates
+ assertEquals("[1,10]", rString.toString());
+ }
+
+ public void testSerialize()throws Exception{
+ String msgRange = "[1,100]";
+ RangeString r = new RangeString(msgRange);
+ //serialize
+ ByteArrayOutputStream memoryBuffer = new ByteArrayOutputStream();
+ ObjectOutputStream serializer = new ObjectOutputStream(memoryBuffer);
+ serializer.writeObject(r);
+ serializer.flush();
+ //deserialize
+ ObjectInputStream inStrm = new ObjectInputStream(new ByteArrayInputStream(memoryBuffer.toByteArray()));
+ RangeString newRangeString = (RangeString)inStrm.readObject();
+ assertEquals(msgRange, newRangeString.toString());
+ }
+
+
+}
\ No newline at end of file
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/AddressingVersionTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/AddressingVersionTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/AddressingVersionTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/AddressingVersionTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,122 @@
+/*
+ * 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.versions;
+
+import java.io.File;
+
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+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.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class AddressingVersionTest extends SandeshaTestCase {
+
+ private static boolean serverStarted = false;
+
+ public AddressingVersionTest () {
+ super ("AddressingVersionTest");
+ }
+
+ public void setUp () throws Exception {
+ super.setUp();
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+ if (!serverStarted)
+ startServer(repoPath, axis2_xml);
+ serverStarted = true;
+ }
+
+ /**
+ * Override the teardown processing
+ */
+ public void tearDown () {
+
+ }
+
+ public void testAddressingFinal() throws Exception {
+ Options clientOptions = new Options ();
+ clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Final.WSA_NAMESPACE);
+ runAddressingTest(clientOptions);
+ }
+
+ public void testAddressingSubmission() throws Exception {
+ Options clientOptions = new Options ();
+ clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+ runAddressingTest(clientOptions);
+ }
+
+ public void testAddressingDefault() throws Exception {
+ Options clientOptions = new Options ();
+ runAddressingTest(clientOptions);
+ }
+
+ public void testAddressingNone() throws Exception {
+ Options clientOptions = new Options ();
+ clientOptions.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);
+ runAddressingTest(clientOptions);
+ }
+
+ private void runAddressingTest(Options clientOptions) throws Exception {
+ String to = "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.setAction(pingAction);
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ clientOptions.setTo(new EndpointReference (to));
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping"));
+
+ long limit = System.currentTimeMillis() + waitTime;
+ Error lastError = null;
+ while(System.currentTimeMillis() < limit) {
+ Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+
+ try {
+ 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);
+
+ lastError = null;
+ break;
+ } catch(Error e) {
+ lastError = e;
+ }
+ }
+ if(lastError != null) throw lastError;
+
+ configContext.getListenerManager().stop();
+ serviceClient.cleanup();
+ }
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/RMVersionTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/RMVersionTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/RMVersionTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/RMVersionTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,183 @@
+/*
+ * 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.versions;
+
+import java.io.File;
+
+import org.apache.axiom.soap.SOAP11Constants;
+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.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class RMVersionTest extends SandeshaTestCase {
+
+ private static boolean serverStarted = false;
+
+ public RMVersionTest () {
+ super ("RMVersionTest");
+ }
+
+ public void setUp () throws Exception {
+ super.setUp();
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+ if (!serverStarted)
+ startServer(repoPath, axis2_xml);
+ serverStarted = true;
+ }
+
+ /**
+ * Override the teardown processing
+ */
+ public void tearDown () {
+
+ }
+
+ public void testRMSubmission () throws Exception {
+
+ String to = "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.setAction(pingAction);
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the addressing version as submission
+ clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_0);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ long limit = System.currentTimeMillis() + waitTime;
+ Error lastError = null;
+ while(System.currentTimeMillis() < limit) {
+ Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+
+ try {
+ 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);
+
+ lastError = null;
+ break;
+ } catch(Error e) {
+ lastError = e;
+ }
+ }
+ if(lastError != null) throw lastError;
+
+ configContext.getListenerManager().stop();
+ serviceClient.cleanup();
+ }
+
+ public void testRMOASIS () throws Exception {
+
+ String to = "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.setAction(pingAction);
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the RM version as OASIS.
+ clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ // Wait for the sequence to start up
+ long limit = System.currentTimeMillis() + waitTime;
+ Error lastError = null;
+ while(System.currentTimeMillis() < limit) {
+ Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+
+ try {
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_ESTABLISHED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ lastError = null;
+ break;
+ } catch(Error e) {
+ lastError = e;
+ }
+ }
+ if(lastError != null) throw lastError;
+
+ SandeshaClient.terminateSequence(serviceClient);
+
+ limit = System.currentTimeMillis() + waitTime;
+ while(System.currentTimeMillis() < limit) {
+ Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+
+ try {
+ 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);
+
+ lastError = null;
+ break;
+ } catch(Error e) {
+ lastError = e;
+ }
+ }
+ if(lastError != null) throw lastError;
+
+ configContext.getListenerManager().stop();
+ serviceClient.cleanup();
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/SOAPVersionTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/SOAPVersionTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/SOAPVersionTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/versions/SOAPVersionTest.java Mon Apr 23 02:54:53 2007
@@ -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.versions;
+
+import java.io.File;
+
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
+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.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class SOAPVersionTest extends SandeshaTestCase {
+
+ private static boolean serverStarted = false;
+
+ public SOAPVersionTest () {
+ super ("SOAPVersionTest");
+ }
+
+ public void setUp () throws Exception {
+ super.setUp();
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+ if (!serverStarted)
+ startServer(repoPath, axis2_xml);
+ serverStarted = true;
+ }
+
+ /**
+ * Override the teardown processing
+ */
+ public void tearDown () {
+
+ }
+
+ public void testSOAP11 () throws Exception {
+
+ String to = "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.setAction(pingAction);
+ clientOptions.setTo(new EndpointReference (to));
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the SOAP version as 1.1
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ long limit = System.currentTimeMillis() + waitTime;
+ Error lastError = null;
+ while(System.currentTimeMillis() < limit) {
+ Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+
+ try {
+ 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);
+
+ lastError = null;
+ break;
+ } catch(Error e) {
+ lastError = e;
+ }
+ }
+ if(lastError != null) throw lastError;
+
+ configContext.getListenerManager().stop();
+ serviceClient.cleanup();
+ }
+
+ public void testSOAP12 () throws AxisFault,InterruptedException {
+
+ String to = "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.setAction(pingAction);
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+
+ String sequenceKey = "sequence2";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the SOAP version as 1.2
+ clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ long limit = System.currentTimeMillis() + waitTime;
+ Error lastError = null;
+ while(System.currentTimeMillis() < limit) {
+ Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+
+ try {
+ 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);
+
+ lastError = null;
+ break;
+ } catch(Error e) {
+ lastError = e;
+ }
+ }
+ if(lastError != null) throw lastError;
+
+ configContext.getListenerManager().stop();
+ serviceClient.cleanup();
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/workers/ForceInboundDispatchTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/workers/ForceInboundDispatchTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/workers/ForceInboundDispatchTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/workers/ForceInboundDispatchTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,219 @@
+package org.apache.sandesha2.workers;
+
+import java.io.File;
+
+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.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.Transaction;
+import org.apache.sandesha2.storage.beans.RMDBean;
+import org.apache.sandesha2.storage.beans.RMSBean;
+import org.apache.sandesha2.util.RangeString;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class ForceInboundDispatchTest extends SandeshaTestCase {
+
+ private static ConfigurationContext serverConfigCtx = null;
+ private static boolean startedServer = false;
+
+ public ForceInboundDispatchTest () {
+ super ("ForceDispatchTest");
+ }
+
+ public void setUp () throws Exception {
+ super.setUp();
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+ if (!startedServer)
+ serverConfigCtx = startServer(repoPath, axis2_xml);
+ startedServer = true;
+ }
+
+ /**
+ * Override the teardown processing
+ */
+ public void tearDown () {
+
+ }
+
+ public void testForceInvoke () throws AxisFault,InterruptedException {
+
+ String to = "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.setAction(pingAction);
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ serviceClient.setOptions(clientOptions);
+
+ try{
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+
+ //now deliver the next out of order
+ clientOptions.setProperty(SandeshaClientConstants.MESSAGE_NUMBER,new Long(3));
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(5000);
+ StorageManager mgr = SandeshaUtil.getInMemoryStorageManager(configContext);
+ Transaction t = mgr.getTransaction();
+ String inboundSequenceID = SandeshaUtil.getSequenceIDFromInternalSequenceID(SandeshaUtil.getInternalSequenceID(to, sequenceKey),
+ mgr);
+ t.commit();
+
+ SandeshaClient.forceDispatchOfInboundMessages(serverConfigCtx,
+ inboundSequenceID,
+ true); //allow later msgs to be delivered
+
+ //check that the server is now expecting msg 4
+ StorageManager serverStore = SandeshaUtil.getInMemoryStorageManager(serverConfigCtx);
+ t = serverStore.getTransaction();
+ RMDBean rMDBean =
+ serverStore.getRMDBeanMgr().retrieve(inboundSequenceID);
+ assertNotNull(rMDBean);
+ assertEquals(rMDBean.getNextMsgNoToProcess(), 4);
+
+ //also check that the sequence has an out of order gap that contains msg 2
+ assertNotNull(rMDBean.getOutOfOrderRanges());
+ RangeString rangeString = rMDBean.getOutOfOrderRanges();
+ assertTrue(rangeString.isMessageNumberInRanges(2));
+ t.commit();
+
+ //we deliver msg 2
+ //set highest out msg number to 1
+ String internalSequenceId = SandeshaUtil.getInternalSequenceID(to, sequenceKey);
+ t = mgr.getTransaction();
+ RMSBean rmsBean = SandeshaUtil.getRMSBeanFromInternalSequenceId(mgr, internalSequenceId);
+ rmsBean.setNextMessageNumber(1);
+ // Update the bean
+ mgr.getRMSBeanMgr().update(rmsBean);
+ t.commit();
+
+ clientOptions.setProperty(SandeshaClientConstants.MESSAGE_NUMBER,new Long(2));
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+ }
+ finally{
+ configContext.getListenerManager().stop();
+ serviceClient.cleanup();
+ }
+
+ }
+
+ public void testForceInvokeWithDiscardGaps () throws AxisFault {
+
+ String to = "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.setAction(pingAction);
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+
+ String sequenceKey = "sequence2";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ serviceClient.setOptions(clientOptions);
+ try
+ {
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+
+ //now deliver the next out of order
+ clientOptions.setProperty(SandeshaClientConstants.MESSAGE_NUMBER,new Long(3));
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ String internalSequenceId = SandeshaUtil.getInternalSequenceID(to, sequenceKey);
+ waitForMessageToBeAcked(serviceClient, internalSequenceId);
+
+ StorageManager mgr = SandeshaUtil.getInMemoryStorageManager(configContext);
+ Transaction t = mgr.getTransaction();
+ String inboundSequenceID = SandeshaUtil.getSequenceIDFromInternalSequenceID(internalSequenceId,
+ mgr);
+ t.commit();
+
+ SandeshaClient.forceDispatchOfInboundMessages(serverConfigCtx, inboundSequenceID, false);
+
+ //check that the server is now expecting msg 4
+ StorageManager serverMgr = SandeshaUtil.getInMemoryStorageManager(serverConfigCtx);
+ t = serverMgr.getTransaction();
+ RMDBean rMDBean = serverMgr.getRMDBeanMgr().retrieve(inboundSequenceID);
+ assertNotNull(rMDBean);
+ assertEquals(rMDBean.getNextMsgNoToProcess(), 4);
+ t.commit();
+ }
+ finally{
+ configContext.getListenerManager().stop();
+ serviceClient.cleanup();
+ }
+
+ }
+
+ /**
+ * Waits for the maximum of "waittime" for a message to be acked, before returning control to the application.
+ * @throws SandeshaException
+ */
+ private void waitForMessageToBeAcked(ServiceClient serviceClient, String internalSequenceId) throws SandeshaException
+ {
+ // Get the highest out message number
+ ConfigurationContext context = serviceClient.getServiceContext().getConfigurationContext();
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());
+
+ // Get a transaction for the property finding
+ Transaction transaction = storageManager.getTransaction();
+
+ // Get the highest out message property
+ RMSBean rmsBean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, internalSequenceId);
+
+ transaction.commit();
+
+ long highestOutMsgNum = rmsBean.getHighestOutMessageNumber();
+ Long highestOutMsgKey = new Long(highestOutMsgNum);
+
+ long timeNow = System.currentTimeMillis();
+ long timeToComplete = timeNow + waitTime;
+ boolean complete = false;
+
+ while (!complete && timeNow < timeToComplete)
+ {
+ timeNow = System.currentTimeMillis();
+
+ try
+ {
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+
+ if (sequenceReport.getCompletedMessages().contains(highestOutMsgKey))
+ complete = true;
+ else
+ Thread.sleep(tickTime);
+
+ }
+ catch (Exception e)
+ {
+ // Ignore
+ }
+ }
+ }
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/AckRequestedTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/AckRequestedTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/AckRequestedTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/AckRequestedTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,63 @@
+/*
+ * 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.wsrm;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+
+public class AckRequestedTest extends SandeshaTestCase {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ String rmNamespace = Sandesha2Constants.SPEC_2005_02.NS_URI;
+
+ public AckRequestedTest() {
+ super("AckRequestedTest");
+ }
+
+ public void testFromOMElement() throws SandeshaException {
+ QName name = new QName(rmNamespace, "AckRequested");
+ AckRequested ackReq = new AckRequested(rmNamespace);
+ SOAPEnvelope env = getSOAPEnvelope("", "AckRequested.xml");
+ ackReq.fromOMElement(env.getHeader().getFirstChildWithName(name));
+
+ Identifier identifier = ackReq.getIdentifier();
+ assertEquals("uuid:897ee740-1624-11da-a28e-b3b9c4e71445", identifier.getIdentifier());
+ }
+
+ public void testToSOAPEnvelope() throws SandeshaException {
+ AckRequested ackReq = new AckRequested(rmNamespace);
+ Identifier identifier = new Identifier(rmNamespace);
+ identifier.setIndentifer("uuid:897ee740-1624-11da-a28e-b3b9c4e71445");
+ ackReq.setIdentifier(identifier);
+
+ SOAPEnvelope env = getEmptySOAPEnvelope();
+ ackReq.toSOAPEnvelope(env);
+
+ OMElement ackReqPart = env.getHeader().getFirstChildWithName(
+ new QName(rmNamespace, Sandesha2Constants.WSRM_COMMON.ACK_REQUESTED));
+ OMElement identifierPart = ackReqPart.getFirstChildWithName(
+ new QName(rmNamespace, Sandesha2Constants.WSRM_COMMON.IDENTIFIER));
+ assertEquals("uuid:897ee740-1624-11da-a28e-b3b9c4e71445", identifierPart.getText());
+ }
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CloseSequenceResponseTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CloseSequenceResponseTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CloseSequenceResponseTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CloseSequenceResponseTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.wsrm;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+
+import junit.framework.TestCase;
+
+public class CloseSequenceResponseTest extends TestCase {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ String rmNamespaceValue = Sandesha2Constants.SPEC_2005_02.NS_URI;
+ String addressingNamespaceValue = AddressingConstants.Final.WSA_NAMESPACE;
+
+ public CloseSequenceResponseTest() {
+// super("CreateSequenceResponseTest");
+
+ }
+
+ public void testFromOMElement() {
+
+ }
+
+ public void testToSOAPEnvelope() {}
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CloseSequenceTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CloseSequenceTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CloseSequenceTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CloseSequenceTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.wsrm;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+
+import junit.framework.TestCase;
+
+public class CloseSequenceTest extends TestCase {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ String rmNamespaceValue = Sandesha2Constants.SPEC_2005_02.NS_URI;
+ String addressingNamespaceValue = AddressingConstants.Final.WSA_NAMESPACE;
+
+ public CloseSequenceTest() {
+// super("CreateSequenceResponseTest");
+
+ }
+
+ public void testFromOMElement() {
+
+ }
+
+ public void testToSOAPEnvelope() {}
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CreateSequenceResponseTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CreateSequenceResponseTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CreateSequenceResponseTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CreateSequenceResponseTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,85 @@
+/*
+ * 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.wsrm;
+
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+public class CreateSequenceResponseTest extends SandeshaTestCase {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ String rmNamespaceValue = Sandesha2Constants.SPEC_2005_02.NS_URI;
+ String addressingNamespaceValue = Sandesha2Constants.SPEC_2005_02.ADDRESSING_NS_URI;
+
+ public CreateSequenceResponseTest() {
+ super("CreateSequenceResponseTest");
+
+ }
+
+ public void testFromOMElement() throws AxisFault {
+ CreateSequenceResponse res = new CreateSequenceResponse(rmNamespaceValue);
+ SOAPEnvelope env = getSOAPEnvelope("", "CreateSequenceResponse.xml");
+ res.fromOMElement(env.getBody());
+
+ Identifier identifier = res.getIdentifier();
+ assertEquals("uuid:88754b00-161a-11da-b6d6-8198de3c47c5", identifier.getIdentifier());
+
+ Accept accept = res.getAccept();
+ AcksTo acksTo = accept.getAcksTo ();
+ assertEquals("http://localhost:8070/axis/services/TestService", acksTo.getEPR().getAddress());
+
+ }
+
+ public void testToSOAPEnvelope() throws AxisFault {
+ CreateSequenceResponse res = new CreateSequenceResponse(rmNamespaceValue);
+
+ Identifier identifier = new Identifier(rmNamespaceValue);
+ identifier.setIndentifer("uuid:88754b00-161a-11da-b6d6-8198de3c47c5");
+ res.setIdentifier(identifier);
+
+ EndpointReference epr = new EndpointReference ("http://localhost:8070/axis/services/TestService");
+ Accept accept = new Accept(rmNamespaceValue);
+ AcksTo acksTo = new AcksTo(epr, rmNamespaceValue, addressingNamespaceValue);
+ accept.setAcksTo(acksTo);
+ res.setAccept(accept);
+
+ SOAPEnvelope env = getEmptySOAPEnvelope();
+ res.toSOAPEnvelope(env);
+
+ OMElement createSeqResponsePart = env.getBody().getFirstChildWithName(
+ new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE_RESPONSE));
+ OMElement identifierPart = createSeqResponsePart.getFirstChildWithName(
+ new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.IDENTIFIER));
+ assertEquals("uuid:88754b00-161a-11da-b6d6-8198de3c47c5", identifierPart.getText());
+
+ OMElement acceptPart = createSeqResponsePart.getFirstChildWithName(
+ new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.ACCEPT));
+ OMElement acksToPart = acceptPart.getFirstChildWithName(
+ new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.ACKS_TO));
+ OMElement addressPart = acksToPart.getFirstChildWithName(new QName(
+ addressingNamespaceValue, Sandesha2Constants.WSA.ADDRESS));
+ assertEquals("http://localhost:8070/axis/services/TestService", addressPart.getText());
+ }
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CreateSequenceTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CreateSequenceTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CreateSequenceTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/CreateSequenceTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,84 @@
+/*
+ * 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.wsrm;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+
+public class CreateSequenceTest extends SandeshaTestCase {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ String rmNamespaceValue = Sandesha2Constants.SPEC_2005_02.NS_URI;
+ String addressingNamespaceValue = Sandesha2Constants.SPEC_2005_02.ADDRESSING_NS_URI;
+
+ public CreateSequenceTest() {
+ super("CreateSequenceTest");
+ }
+
+ public void testfromOMElement() throws AxisFault {
+
+ CreateSequence createSequence = new CreateSequence(rmNamespaceValue);
+ createSequence.fromOMElement(getSOAPEnvelope("", "CreateSequence.xml").getBody());
+
+ AcksTo acksTo = createSequence.getAcksTo();
+ assertEquals("http://127.0.0.1:9090/axis/services/RMService", acksTo.getEPR().getAddress());
+
+ SequenceOffer offer = createSequence.getSequenceOffer();
+ Identifier identifier = offer.getIdentifer();
+ assertEquals("uuid:c3671020-15e0-11da-9b3b-f0439d4867bd", identifier.getIdentifier());
+
+ }
+
+ public void testToSOAPEnvelope() throws AxisFault {
+ CreateSequence createSequence = new CreateSequence(rmNamespaceValue);
+
+ EndpointReference epr = new EndpointReference("http://127.0.0.1:9090/axis/services/RMService");
+ AcksTo acksTo = new AcksTo(epr, rmNamespaceValue, addressingNamespaceValue);
+ createSequence.setAcksTo(acksTo);
+
+ SequenceOffer sequenceOffer = new SequenceOffer(rmNamespaceValue);
+ Identifier identifier = new Identifier(rmNamespaceValue);
+ identifier.setIndentifer("uuid:c3671020-15e0-11da-9b3b-f0439d4867bd");
+ sequenceOffer.setIdentifier(identifier);
+ createSequence.setSequenceOffer(sequenceOffer);
+
+ SOAPEnvelope envelope = getEmptySOAPEnvelope();
+ createSequence.toSOAPEnvelope(envelope);
+
+ OMElement createSequencePart = envelope.getBody().getFirstChildWithName(new QName(rmNamespaceValue,
+ Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE));
+ OMElement acksToPart = createSequencePart.getFirstChildWithName(new QName(
+ rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.ACKS_TO));
+ OMElement addressPart = acksToPart.getFirstChildWithName(new QName(
+ addressingNamespaceValue, Sandesha2Constants.WSA.ADDRESS));
+ assertEquals("http://127.0.0.1:9090/axis/services/RMService", addressPart.getText());
+
+ OMElement offerPart = createSequencePart.getFirstChildWithName(
+ new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.SEQUENCE_OFFER));
+ OMElement identifierPart = offerPart.getFirstChildWithName(
+ new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.IDENTIFIER));
+ assertEquals("uuid:c3671020-15e0-11da-9b3b-f0439d4867bd", identifierPart.getText());
+ }
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/MakeConnectionTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/MakeConnectionTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/MakeConnectionTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/MakeConnectionTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,89 @@
+/*
+ * 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.wsrm;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+
+public class MakeConnectionTest extends SandeshaTestCase {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ String rmNamespaceValue = Sandesha2Constants.SPEC_2007_02.NS_URI;
+ String mcNamespaceValue = Sandesha2Constants.SPEC_2007_02.MC_NS_URI;
+ String addressingNamespaceValue = AddressingConstants.Final.WSA_NAMESPACE;
+
+ public MakeConnectionTest() {
+ super("MakeConnectionTest");
+ }
+
+ public void testfromOMElement() throws AxisFault {
+ MakeConnection makeConnection = new MakeConnection(mcNamespaceValue);
+ SOAPEnvelope envelope = getSOAPEnvelope("", "MakeConnection.xml");
+ OMElement makeConnectionElement = envelope.getBody().getFirstChildWithName(new QName (mcNamespaceValue,Sandesha2Constants.WSRM_COMMON.MAKE_CONNECTION));
+ makeConnection.fromOMElement(makeConnectionElement);
+
+ Identifier identifier = makeConnection.getIdentifier();
+ assertNotNull(identifier);
+ assertEquals(identifier.getIdentifier(),"urn:uuid:6367739C8350488CD411576188379313");
+
+ Address address = makeConnection.getAddress();
+ assertNotNull(address);
+ assertEquals(address.getAddress(),"http://docs.oasis-open.org/wsrx/wsrm/200702/anonymous?id=550e8400-e29b-11d4-a716-446655440000");
+
+ }
+
+ public void testToSOAPEnvelope() throws SandeshaException {
+ MakeConnection makeConnection = new MakeConnection (mcNamespaceValue);
+
+ Address address = new Address (mcNamespaceValue);
+ address.setAddress("http://docs.oasis-open.org/wsrx/wsrm/200702/anonymous?id=550e8400-e29b-11d4-a716-446655440000");
+ Identifier identifier = new Identifier (rmNamespaceValue);
+ identifier.setIndentifer("uuid:c3671020-15e0-11da-9b3b-f0439d4867bd");
+
+ makeConnection.setAddress(address);
+ makeConnection.setIdentifier(identifier);
+
+ SOAPEnvelope envelope = getEmptySOAPEnvelope();
+ makeConnection.toSOAPEnvelope(envelope);
+
+ OMElement makeConnectionElement = envelope.getBody().getFirstChildWithName(
+ new QName (mcNamespaceValue,Sandesha2Constants.WSRM_COMMON.MAKE_CONNECTION));
+ assertNotNull(makeConnectionElement);
+
+ OMElement addressElement = makeConnectionElement.getFirstChildWithName(
+ new QName (mcNamespaceValue,Sandesha2Constants.WSA.ADDRESS));
+ assertNotNull(addressElement);
+ String addressValue = addressElement.getText();
+ assertEquals(addressValue,"http://docs.oasis-open.org/wsrx/wsrm/200702/anonymous?id=550e8400-e29b-11d4-a716-446655440000");
+
+ OMElement identifierElement = makeConnectionElement.getFirstChildWithName(
+ new QName (rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.IDENTIFIER));
+ assertNotNull(identifierElement);
+ String identifierValue = identifierElement.getText();
+ assertEquals(identifierValue,"uuid:c3671020-15e0-11da-9b3b-f0439d4867bd");
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/MessagePendingTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/MessagePendingTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/MessagePendingTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/wsrm/MessagePendingTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,70 @@
+/*
+ * 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.wsrm;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+
+public class MessagePendingTest extends SandeshaTestCase {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ String mcNamespace = Sandesha2Constants.SPEC_2007_02.MC_NS_URI;
+
+ public MessagePendingTest() {
+ super("MessagePendingTest");
+ }
+
+ public void testFromOMElement() throws SandeshaException {
+
+ MessagePending messagePending = new MessagePending (mcNamespace);
+ SOAPEnvelope env = getSOAPEnvelope("", "MessagePending.xml");
+
+ OMElement messagePendingElement = env.getHeader().getFirstChildWithName(
+ new QName (mcNamespace,Sandesha2Constants.WSRM_COMMON.MESSAGE_PENDING));
+ messagePending.fromOMElement(messagePendingElement);
+
+ assertTrue(messagePending.isPending());
+ }
+
+ public void testToOMElement() throws SandeshaException {
+
+ MessagePending messagePending = new MessagePending (mcNamespace);
+ messagePending.setPending(true);
+
+
+ SOAPEnvelope env = getEmptySOAPEnvelope();
+ messagePending.toSOAPEnvelope(env);
+
+ OMElement messagePendingElement = env.getHeader().getFirstChildWithName(
+ new QName (mcNamespace,Sandesha2Constants.WSRM_COMMON.MESSAGE_PENDING));
+ assertNotNull(messagePendingElement);
+ OMAttribute attribute = messagePendingElement.getAttribute(
+ new QName (Sandesha2Constants.WSRM_COMMON.PENDING));
+ String value = attribute.getAttributeValue();
+ assertEquals(value,"true");
+
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org