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 di...@apache.org on 2007/08/09 02:51:42 UTC

svn commit: r564061 [12/15] - in /webservices/sandesha/branches/sandesha2/java/1_3: ./ modules/client/ modules/core/ modules/core/src/main/java/org/apache/sandesha2/ modules/core/src/main/java/org/apache/sandesha2/client/ modules/core/src/main/java/org...

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/SandeshaUtilTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/SandeshaUtilTest.java?view=diff&rev=564061&r1=564060&r2=564061
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/SandeshaUtilTest.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/SandeshaUtilTest.java Wed Aug  8 17:51:29 2007
@@ -1,199 +1,199 @@
-/*
- * 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.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.util.MessageContextBuilder;
-import org.apache.sandesha2.util.Range;
-import org.apache.sandesha2.util.RangeString;
-import org.apache.sandesha2.util.SandeshaUtil;
-import org.apache.sandesha2.wsrm.AcknowledgementRange;
-
-import junit.framework.TestCase;
-
-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 testInternalSequenceIDToSequenceKeyConversion() {
-		String toEPR = "http://127.0.0.1:1111/some_random_uri";
-		String sequenceKey = "1234abcd";
-		
-		String internalSequenceID = SandeshaUtil.getInternalSequenceID(toEPR, sequenceKey);
-		
-		//check that we can parse out the sequence key
-		assertEquals(sequenceKey, SandeshaUtil.getSequenceKeyFromInternalSequenceID(internalSequenceID, toEPR));
-		
-		//try an internal sequenceID without a sequenceKey - should get null
-		internalSequenceID = SandeshaUtil.getSequenceKeyFromInternalSequenceID(toEPR, null);
-		assertNull(SandeshaUtil.getSequenceKeyFromInternalSequenceID(internalSequenceID, toEPR));
-		
-		//for badly formed sequences, or for server-side response sequences, check 
-		//we just get null
-		String outgoingSequenceID = SandeshaUtil.getOutgoingSideInternalSequenceID(SandeshaUtil.getUUID());
-		assertNull(SandeshaUtil.getSequenceKeyFromInternalSequenceID(outgoingSequenceID, toEPR));
-		
-	}
-	
-	public void testGetAckRangesFromRangeStringOutOfOrder()throws SandeshaException{
-		
-		RangeString rangeString = new RangeString();
-		rangeString.addRange(new Range(3));
-		rangeString.addRange(new Range(6));
-		rangeString.addRange(new Range(1));
-		rangeString.addRange(new Range(5));
-		rangeString.addRange(new Range(8));
-		rangeString.addRange(new Range(2));
-		
-		ArrayList list = SandeshaUtil.getAckRangeArrayList(rangeString,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());
-	}
-	
-	public void testGetAckRangesFromRangeStringGapFilling () throws SandeshaException {
-		//build a range string to represent the completed messages
-		RangeString rangeString = new RangeString();
-		rangeString.addRange(new Range(1,3));
-		rangeString.addRange(new Range(4));
-		//insert a gap - number 5 is missing
-		rangeString.addRange(new Range(6));
-		//insert a gap - 7 and 8 are missing
-		rangeString.addRange(new Range(9, 10));
-		
-		ArrayList list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
-		assertNotNull(list);
-		//we expect 3 ranges: [1-4] [6] [9-10]
-		assertEquals(list.size(),3);
-		
-		Iterator it = list.iterator();
-		AcknowledgementRange ackRange = null;
-		
-		ackRange = (AcknowledgementRange) it.next();
-		assertNotNull(ackRange);
-		assertEquals(ackRange.getLowerValue(),1);
-		assertEquals(ackRange.getUpperValue(),4);
-		
-		ackRange = null;
-		ackRange = (AcknowledgementRange) it.next();
-		assertNotNull(ackRange);
-		assertEquals(ackRange.getLowerValue(),6);
-		assertEquals(ackRange.getUpperValue(),6);
-		
-		ackRange = null;
-		ackRange = (AcknowledgementRange) it.next();
-		assertNotNull(ackRange);
-		assertEquals(ackRange.getLowerValue(),9);
-		assertEquals(ackRange.getUpperValue(),10);
-		
-		assertFalse(it.hasNext());
-		
-		//ok, now plug a gap at msg 5
-		rangeString.addRange(new Range(5));
-		list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
-		assertNotNull(list);
-		//we expect 2 ranges: [1-6] [9-10]
-		it = list.iterator();
-		ackRange = null;
-		
-		ackRange = (AcknowledgementRange) it.next();
-		assertNotNull(ackRange);
-		assertEquals(ackRange.getLowerValue(),1);
-		assertEquals(ackRange.getUpperValue(),6);
-		
-		ackRange = null;
-		ackRange = (AcknowledgementRange) it.next();
-		assertNotNull(ackRange);
-		assertEquals(ackRange.getLowerValue(),9);
-		assertEquals(ackRange.getUpperValue(),10);
-		
-		assertFalse(it.hasNext());
-		
-		//plug all of the gaps - 7 and 8
-		rangeString.addRange(new Range(8));
-		rangeString.addRange(new Range(7,8)); 
-		list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
-		assertNotNull(list);
-		//we expect 1 ranges: [1-10]
-		it = list.iterator();
-		ackRange = null;
-		
-		ackRange = (AcknowledgementRange) it.next();
-		assertNotNull(ackRange);
-		assertEquals(ackRange.getLowerValue(),1);
-		assertEquals(ackRange.getUpperValue(),10);
-		
-		assertFalse(it.hasNext());
-	}
-	
-	/**
-	 * Checks that a Fault message can be created from an empty MessageContext
-	 * 
-	 * @throws Exception
-	 */
-	public void testCreateFaultMessageContext() throws Exception {
-		
-		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);
-		MessageContext messageContext = new MessageContext();
-		messageContext.setConfigurationContext(configContext);
-		messageContext = MessageContextBuilder.createFaultMessageContext(messageContext, new Exception());
-	}
-
-	
-	
-	
-}
+/*
+ * 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.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.util.MessageContextBuilder;
+import org.apache.sandesha2.util.Range;
+import org.apache.sandesha2.util.RangeString;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.wsrm.AcknowledgementRange;
+
+import junit.framework.TestCase;
+
+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 testInternalSequenceIDToSequenceKeyConversion() {
+		String toEPR = "http://127.0.0.1:1111/some_random_uri";
+		String sequenceKey = "1234abcd";
+		
+		String internalSequenceID = SandeshaUtil.getInternalSequenceID(toEPR, sequenceKey);
+		
+		//check that we can parse out the sequence key
+		assertEquals(sequenceKey, SandeshaUtil.getSequenceKeyFromInternalSequenceID(internalSequenceID, toEPR));
+		
+		//try an internal sequenceID without a sequenceKey - should get null
+		internalSequenceID = SandeshaUtil.getSequenceKeyFromInternalSequenceID(toEPR, null);
+		assertNull(SandeshaUtil.getSequenceKeyFromInternalSequenceID(internalSequenceID, toEPR));
+		
+		//for badly formed sequences, or for server-side response sequences, check 
+		//we just get null
+		String outgoingSequenceID = SandeshaUtil.getOutgoingSideInternalSequenceID(SandeshaUtil.getUUID());
+		assertNull(SandeshaUtil.getSequenceKeyFromInternalSequenceID(outgoingSequenceID, toEPR));
+		
+	}
+	
+	public void testGetAckRangesFromRangeStringOutOfOrder()throws SandeshaException{
+		
+		RangeString rangeString = new RangeString();
+		rangeString.addRange(new Range(3));
+		rangeString.addRange(new Range(6));
+		rangeString.addRange(new Range(1));
+		rangeString.addRange(new Range(5));
+		rangeString.addRange(new Range(8));
+		rangeString.addRange(new Range(2));
+		
+		ArrayList list = SandeshaUtil.getAckRangeArrayList(rangeString,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());
+	}
+	
+	public void testGetAckRangesFromRangeStringGapFilling () throws SandeshaException {
+		//build a range string to represent the completed messages
+		RangeString rangeString = new RangeString();
+		rangeString.addRange(new Range(1,3));
+		rangeString.addRange(new Range(4));
+		//insert a gap - number 5 is missing
+		rangeString.addRange(new Range(6));
+		//insert a gap - 7 and 8 are missing
+		rangeString.addRange(new Range(9, 10));
+		
+		ArrayList list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
+		assertNotNull(list);
+		//we expect 3 ranges: [1-4] [6] [9-10]
+		assertEquals(list.size(),3);
+		
+		Iterator it = list.iterator();
+		AcknowledgementRange ackRange = null;
+		
+		ackRange = (AcknowledgementRange) it.next();
+		assertNotNull(ackRange);
+		assertEquals(ackRange.getLowerValue(),1);
+		assertEquals(ackRange.getUpperValue(),4);
+		
+		ackRange = null;
+		ackRange = (AcknowledgementRange) it.next();
+		assertNotNull(ackRange);
+		assertEquals(ackRange.getLowerValue(),6);
+		assertEquals(ackRange.getUpperValue(),6);
+		
+		ackRange = null;
+		ackRange = (AcknowledgementRange) it.next();
+		assertNotNull(ackRange);
+		assertEquals(ackRange.getLowerValue(),9);
+		assertEquals(ackRange.getUpperValue(),10);
+		
+		assertFalse(it.hasNext());
+		
+		//ok, now plug a gap at msg 5
+		rangeString.addRange(new Range(5));
+		list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
+		assertNotNull(list);
+		//we expect 2 ranges: [1-6] [9-10]
+		it = list.iterator();
+		ackRange = null;
+		
+		ackRange = (AcknowledgementRange) it.next();
+		assertNotNull(ackRange);
+		assertEquals(ackRange.getLowerValue(),1);
+		assertEquals(ackRange.getUpperValue(),6);
+		
+		ackRange = null;
+		ackRange = (AcknowledgementRange) it.next();
+		assertNotNull(ackRange);
+		assertEquals(ackRange.getLowerValue(),9);
+		assertEquals(ackRange.getUpperValue(),10);
+		
+		assertFalse(it.hasNext());
+		
+		//plug all of the gaps - 7 and 8
+		rangeString.addRange(new Range(8));
+		rangeString.addRange(new Range(7,8)); 
+		list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
+		assertNotNull(list);
+		//we expect 1 ranges: [1-10]
+		it = list.iterator();
+		ackRange = null;
+		
+		ackRange = (AcknowledgementRange) it.next();
+		assertNotNull(ackRange);
+		assertEquals(ackRange.getLowerValue(),1);
+		assertEquals(ackRange.getUpperValue(),10);
+		
+		assertFalse(it.hasNext());
+	}
+	
+	/**
+	 * Checks that a Fault message can be created from an empty MessageContext
+	 * 
+	 * @throws Exception
+	 */
+	public void testCreateFaultMessageContext() throws Exception {
+		
+		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);
+		MessageContext messageContext = new MessageContext();
+		messageContext.setConfigurationContext(configContext);
+		messageContext = MessageContextBuilder.createFaultMessageContext(messageContext, new Exception());
+	}
+
+	
+	
+	
+}

Propchange: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/SandeshaUtilTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/SquenceOfferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/CreateSequenceRefusedFaultTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/CreateSequenceRefusedFaultTest.java?view=diff&rev=564061&r1=564060&r2=564061
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/CreateSequenceRefusedFaultTest.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/CreateSequenceRefusedFaultTest.java Wed Aug  8 17:51:29 2007
@@ -1,150 +1,150 @@
-/*
- * 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.faulttests;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.sandesha2.RMMsgContext;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.SandeshaTestCase;
-import org.apache.sandesha2.storage.beans.RMSBean;
-import org.apache.sandesha2.util.RMMsgCreator;
-import org.apache.sandesha2.util.SpecSpecificConstants;
-import org.apache.sandesha2.wsrm.AcksTo;
-import org.apache.sandesha2.wsrm.CreateSequence;
-
-
-public class CreateSequenceRefusedFaultTest extends SandeshaTestCase {
-
-	private static final String server_repoPath = "target" + File.separator
-	    + "repos" + File.separator + "server";
-
-	private static final String server_axis2_xml = "target" + File.separator
-	    + "repos" + File.separator + "server" + File.separator
-	    + "server_axis2.xml";
-	
-	private static ConfigurationContext serverConfigContext;
-	
-	public CreateSequenceRefusedFaultTest() {
-		super("CreateSequenceProcessorTest");
-	}
-
-	public void setUp() throws Exception {
-		super.setUp();
-		serverConfigContext = startServer(server_repoPath, server_axis2_xml);
-	}
-
-	/**
-	 * Sends a Create Sequence message to an RM Destination that will be refused.
-	 * 
-	 * @throws Exception
-	 */
-	public void testCreateSequenceSOAPFault() throws Exception {
-
-    // Open a connection to the endpoint
-		HttpURLConnection connection = 
-			FaultTestUtils.getHttpURLConnection("http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService",
-					"http://docs.oasis-open.org/ws-rx/wsrm/200702/CreateSequence");
-
-		OutputStream tmpOut2 = connection.getOutputStream();
-
-		byte ar[] = getMessageAsBytes();
-		
-		// Send the message to the socket.
-		tmpOut2.write(ar);
-		tmpOut2.flush();
-
-		// Get the response message from the connection
-		String message = FaultTestUtils.retrieveResponseMessage(connection);
-    
-    // Check that the fault message isn't null
-    assertNotNull(message);
-    
-    // Check that the response contains the wsrm:CreateSequenceRefused tag    
-    assertTrue(message.indexOf("CreateSequenceRefused") > -1);
-    
-    // Disconnect at the end of the test
-    connection.disconnect();
-	}
-	
-	/**
-	 * Get a Create Sequence message as bytes
-	 * 
-	 * This generates a CreateSequenceMessage that has a "bad" AcksTo value which 
-	 * will generate a Fault from the service.
-	 * @return
-	 */
-	private byte[] getMessageAsBytes() throws Exception
-	{
-		String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
-
-		SOAPFactory factory = new SOAP11Factory();
-		SOAPEnvelope dummyEnvelope = factory.getDefaultEnvelope();
-		
-		// Create a "new" application message
-		MessageContext messageContext = new MessageContext();
-		messageContext.setConfigurationContext(serverConfigContext);
-		messageContext.setAxisService(serverConfigContext.getAxisConfiguration().getService("RMSampleService"));		
-		messageContext.setEnvelope(dummyEnvelope);
-		
-		RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
-		
-		// Create an RMSBean so the create sequence message can be created
-		RMSBean rmsBean = new RMSBean();
-		rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
-		rmsBean.setToEPR(to);
-		rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_NONE_URI);
-				
-		// Create a Create Sequence message
-		// generating a new create sequeuce message.
-		RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(rmsBean, applicationRMMsg);
-		messageContext = createSeqRMMessage.getMessageContext();
-		messageContext.setWSAAction(SpecSpecificConstants.getCreateSequenceAction(Sandesha2Constants.SPEC_VERSIONS.v1_1));
-
-		CreateSequence createSeqResPart = (CreateSequence) createSeqRMMessage
-		.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
-
-		createSeqResPart.setAcksTo(
-				new AcksTo(new EndpointReference(AddressingConstants.Final.WSA_NONE_URI), 
-									 SpecSpecificConstants.getRMNamespaceValue(rmsBean.getRMVersion()),
-						       AddressingConstants.Final.WSA_NAMESPACE));
-		
-		// Update the SOAP Envelope of the message
-		createSeqRMMessage.addSOAPEnvelope();
-
-		SOAPEnvelope envelope = createSeqRMMessage.getMessageContext().getEnvelope();
-		
-		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-		
-		envelope.serialize(outputStream);
-		
-		return outputStream.toByteArray();
-	}
-}
-
-
-
+/*
+ * 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.faulttests;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.storage.beans.RMSBean;
+import org.apache.sandesha2.util.RMMsgCreator;
+import org.apache.sandesha2.util.SpecSpecificConstants;
+import org.apache.sandesha2.wsrm.AcksTo;
+import org.apache.sandesha2.wsrm.CreateSequence;
+
+
+public class CreateSequenceRefusedFaultTest extends SandeshaTestCase {
+
+	private static final String server_repoPath = "target" + File.separator
+	    + "repos" + File.separator + "server";
+
+	private static final String server_axis2_xml = "target" + File.separator
+	    + "repos" + File.separator + "server" + File.separator
+	    + "server_axis2.xml";
+	
+	private static ConfigurationContext serverConfigContext;
+	
+	public CreateSequenceRefusedFaultTest() {
+		super("CreateSequenceProcessorTest");
+	}
+
+	public void setUp() throws Exception {
+		super.setUp();
+		serverConfigContext = startServer(server_repoPath, server_axis2_xml);
+	}
+
+	/**
+	 * Sends a Create Sequence message to an RM Destination that will be refused.
+	 * 
+	 * @throws Exception
+	 */
+	public void testCreateSequenceSOAPFault() throws Exception {
+
+    // Open a connection to the endpoint
+		HttpURLConnection connection = 
+			FaultTestUtils.getHttpURLConnection("http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService",
+					"http://docs.oasis-open.org/ws-rx/wsrm/200702/CreateSequence");
+
+		OutputStream tmpOut2 = connection.getOutputStream();
+
+		byte ar[] = getMessageAsBytes();
+		
+		// Send the message to the socket.
+		tmpOut2.write(ar);
+		tmpOut2.flush();
+
+		// Get the response message from the connection
+		String message = FaultTestUtils.retrieveResponseMessage(connection);
+    
+    // Check that the fault message isn't null
+    assertNotNull(message);
+    
+    // Check that the response contains the wsrm:CreateSequenceRefused tag    
+    assertTrue(message.indexOf("CreateSequenceRefused") > -1);
+    
+    // Disconnect at the end of the test
+    connection.disconnect();
+	}
+	
+	/**
+	 * Get a Create Sequence message as bytes
+	 * 
+	 * This generates a CreateSequenceMessage that has a "bad" AcksTo value which 
+	 * will generate a Fault from the service.
+	 * @return
+	 */
+	private byte[] getMessageAsBytes() throws Exception
+	{
+		String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+		SOAPFactory factory = new SOAP11Factory();
+		SOAPEnvelope dummyEnvelope = factory.getDefaultEnvelope();
+		
+		// Create a "new" application message
+		MessageContext messageContext = new MessageContext();
+		messageContext.setConfigurationContext(serverConfigContext);
+		messageContext.setAxisService(serverConfigContext.getAxisConfiguration().getService("RMSampleService"));		
+		messageContext.setEnvelope(dummyEnvelope);
+		
+		RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
+		
+		// Create an RMSBean so the create sequence message can be created
+		RMSBean rmsBean = new RMSBean();
+		rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
+		rmsBean.setToEPR(to);
+		rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_NONE_URI);
+				
+		// Create a Create Sequence message
+		// generating a new create sequeuce message.
+		RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(rmsBean, applicationRMMsg);
+		messageContext = createSeqRMMessage.getMessageContext();
+		messageContext.setWSAAction(SpecSpecificConstants.getCreateSequenceAction(Sandesha2Constants.SPEC_VERSIONS.v1_1));
+
+		CreateSequence createSeqResPart = (CreateSequence) createSeqRMMessage
+		.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
+
+		createSeqResPart.setAcksTo(
+				new AcksTo(new EndpointReference(AddressingConstants.Final.WSA_NONE_URI), 
+									 SpecSpecificConstants.getRMNamespaceValue(rmsBean.getRMVersion()),
+						       AddressingConstants.Final.WSA_NAMESPACE));
+		
+		// Update the SOAP Envelope of the message
+		createSeqRMMessage.addSOAPEnvelope();
+
+		SOAPEnvelope envelope = createSeqRMMessage.getMessageContext().getEnvelope();
+		
+		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+		
+		envelope.serialize(outputStream);
+		
+		return outputStream.toByteArray();
+	}
+}
+
+
+

Propchange: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/CreateSequenceRefusedFaultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/CreateSequenceRefusedInboundFaultTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/CreateSequenceRefusedInboundFaultTest.java?view=diff&rev=564061&r1=564060&r2=564061
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/CreateSequenceRefusedInboundFaultTest.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/CreateSequenceRefusedInboundFaultTest.java Wed Aug  8 17:51:29 2007
@@ -1,133 +1,133 @@
-/*
- * 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.faulttests;
-
-import java.io.File;
-
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axis2.Constants;
-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;
-import org.apache.sandesha2.util.SandeshaUtil;
-
-public class CreateSequenceRefusedInboundFaultTest extends SandeshaTestCase {
-	
-	private boolean startedServer = false;
-	
-	public CreateSequenceRefusedInboundFaultTest() {
-		super("CreateSequenceRefusedInboundFaultTest");
-	}
-
-	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) {
-			startServer(repoPath, axis2_xml);
-			startedServer = true;
-		}
-	}
-	
-	public void tearDown()throws Exception {
-		super.tearDown();
-	}
-	
-	/** Test removed for the moment as RM 1.0 faults are not processed by the chain.
-	 * The GlobalInHandler needs to detect if the message is a fault and assign an appropriate
-	 * operation.
-	 * @throws Exception
-	 */
-	public void testSOAP11CreateSequenceRefusedInboundFault () throws Exception {
-		runTest(false);
-	}
-
-	public void testSOAP12CreateSequenceRefusedInboundFault () throws Exception {
-		runTest(true);
-	}
-
-	private void runTest(boolean runSoap12) 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(echoAction);
-		clientOptions.setTo(new EndpointReference (to));
-
-		//setting the SOAP version as 1.2
-		if (runSoap12)
-			clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-
-		String sequenceKey = SandeshaUtil.getUUID();
-		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
-		
-		ServiceClient serviceClient = new ServiceClient (configContext,null);
-		
-		// Set a bad acks to so the CreateSequence will be refused.
-		String acksTo = AddressingConstants.Final.WSA_NONE_URI;
-		clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
-		
-		clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-		clientOptions.setUseSeparateListener(true);		
-		clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
-		serviceClient.setOptions(clientOptions);		
-		
-		TestCallback callback1 = new TestCallback ("Callback 1");
-		serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1",sequenceKey),callback1);
-        
-		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 {
-		        //assertions for the out sequence.
-				SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
-				assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
-				assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
-				
-				assertTrue(callback1.isErrorReported());
-				assertEquals(callback1.getResult(),null);
-				
-				lastError = null;
-				break;
-			} catch(Error e) {
-				lastError = e;
-			}
-		}
-
-		if(lastError != null) throw lastError;
-
-		configContext.getListenerManager().stop();
-		serviceClient.cleanup();
-
-	}
-	
-}
-
+/*
+ * 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.faulttests;
+
+import java.io.File;
+
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axis2.Constants;
+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;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class CreateSequenceRefusedInboundFaultTest extends SandeshaTestCase {
+	
+	private boolean startedServer = false;
+	
+	public CreateSequenceRefusedInboundFaultTest() {
+		super("CreateSequenceRefusedInboundFaultTest");
+	}
+
+	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) {
+			startServer(repoPath, axis2_xml);
+			startedServer = true;
+		}
+	}
+	
+	public void tearDown()throws Exception {
+		super.tearDown();
+	}
+	
+	/** Test removed for the moment as RM 1.0 faults are not processed by the chain.
+	 * The GlobalInHandler needs to detect if the message is a fault and assign an appropriate
+	 * operation.
+	 * @throws Exception
+	 */
+	public void testSOAP11CreateSequenceRefusedInboundFault () throws Exception {
+		runTest(false);
+	}
+
+	public void testSOAP12CreateSequenceRefusedInboundFault () throws Exception {
+		runTest(true);
+	}
+
+	private void runTest(boolean runSoap12) 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(echoAction);
+		clientOptions.setTo(new EndpointReference (to));
+
+		//setting the SOAP version as 1.2
+		if (runSoap12)
+			clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+		String sequenceKey = SandeshaUtil.getUUID();
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		
+		ServiceClient serviceClient = new ServiceClient (configContext,null);
+		
+		// Set a bad acks to so the CreateSequence will be refused.
+		String acksTo = AddressingConstants.Final.WSA_NONE_URI;
+		clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+		
+		clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+		clientOptions.setUseSeparateListener(true);		
+		clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+		serviceClient.setOptions(clientOptions);		
+		
+		TestCallback callback1 = new TestCallback ("Callback 1");
+		serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1",sequenceKey),callback1);
+        
+		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 {
+		        //assertions for the out sequence.
+				SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+				assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+				assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+				
+				assertTrue(callback1.isErrorReported());
+				assertEquals(callback1.getResult(),null);
+				
+				lastError = null;
+				break;
+			} catch(Error e) {
+				lastError = e;
+			}
+		}
+
+		if(lastError != null) throw lastError;
+
+		configContext.getListenerManager().stop();
+		serviceClient.cleanup();
+
+	}
+	
+}
+

Propchange: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/CreateSequenceRefusedInboundFaultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/FaultTestUtils.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/FaultTestUtils.java?view=diff&rev=564061&r1=564060&r2=564061
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/FaultTestUtils.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/FaultTestUtils.java Wed Aug  8 17:51:29 2007
@@ -1,113 +1,113 @@
-/*
- * 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.faulttests;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-public class FaultTestUtils {
-
-	/** 
-	 * Sets up a connection to an HTTP endpoint
-	 * @return
-	 */
-	public static HttpURLConnection getHttpURLConnection(String uri, String soapAction) throws Exception {
-    // Open a connection to the endpoint
-		URL endPointURL = new URL(uri);
-		
-		HttpURLConnection connection = (HttpURLConnection) endPointURL.openConnection();
-		connection.setDoOutput(true);
-		connection.setDoInput(true);
-		connection.setRequestMethod("POST");
-		connection.addRequestProperty("SOAPAction", soapAction);
-		connection.setRequestProperty("Content-Type", "text/xml"); 
-		 
-		connection.connect();
-
-		return connection;
-	}
-	
-	/**
-	 * Reads a response from the HttpURLConnection instance
-	 * @param connection
-	 * @return
-	 * @throws IOException 
-	 */
-	public static final String retrieveResponseMessage(HttpURLConnection connection) throws IOException {
-		
-		InputStream tmpIn2 = connection.getInputStream();
-
-		// Read the sync response
-		boolean done = false;
-
-    byte[]      buffer = new byte[4096];
-    String      message = null;
-    int         saved = 0 ;
-    int         len ;
-    
-    a:
-		for (;;) {
-			if (done) {
-				break;
-			}
-
-			len = buffer.length;
-			// Used to be 1, but if we block it doesn't matter
-			// however 1 will break with some servers, including apache
-			if (len == 0) {
-				len = buffer.length;
-			}
-			if (saved + len > buffer.length) {
-				len = buffer.length - saved;
-			}
-			int len1 = 0;
-
-			while (len1 == 0) {
-				try {
-					len1 = tmpIn2.read(buffer, saved, len);
-				} catch (Exception ex) {
-					ex.printStackTrace();
-					if (done && saved == 0) {
-						break a;
-					}
-					len1 = -1;
-					break;
-				}
-			}
-			len = len1;
-
-			if (len == -1 && saved == 0) {
-				break;
-			}
-			if (len == -1) {
-				done = true;
-			}
-
-			// No matter how we may (or may not) format it, send it
-			// on unformatted - we don't want to mess with how its
-			// sent to the other side, just how its displayed
-
-			message = new String(buffer, 0, len);
-
-			System.out.println(message);
-		}
-
-    return message;
-	}
-}
+/*
+ * 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.faulttests;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+public class FaultTestUtils {
+
+	/** 
+	 * Sets up a connection to an HTTP endpoint
+	 * @return
+	 */
+	public static HttpURLConnection getHttpURLConnection(String uri, String soapAction) throws Exception {
+    // Open a connection to the endpoint
+		URL endPointURL = new URL(uri);
+		
+		HttpURLConnection connection = (HttpURLConnection) endPointURL.openConnection();
+		connection.setDoOutput(true);
+		connection.setDoInput(true);
+		connection.setRequestMethod("POST");
+		connection.addRequestProperty("SOAPAction", soapAction);
+		connection.setRequestProperty("Content-Type", "text/xml"); 
+		 
+		connection.connect();
+
+		return connection;
+	}
+	
+	/**
+	 * Reads a response from the HttpURLConnection instance
+	 * @param connection
+	 * @return
+	 * @throws IOException 
+	 */
+	public static final String retrieveResponseMessage(HttpURLConnection connection) throws IOException {
+		
+		InputStream tmpIn2 = connection.getInputStream();
+
+		// Read the sync response
+		boolean done = false;
+
+    byte[]      buffer = new byte[4096];
+    String      message = null;
+    int         saved = 0 ;
+    int         len ;
+    
+    a:
+		for (;;) {
+			if (done) {
+				break;
+			}
+
+			len = buffer.length;
+			// Used to be 1, but if we block it doesn't matter
+			// however 1 will break with some servers, including apache
+			if (len == 0) {
+				len = buffer.length;
+			}
+			if (saved + len > buffer.length) {
+				len = buffer.length - saved;
+			}
+			int len1 = 0;
+
+			while (len1 == 0) {
+				try {
+					len1 = tmpIn2.read(buffer, saved, len);
+				} catch (Exception ex) {
+					ex.printStackTrace();
+					if (done && saved == 0) {
+						break a;
+					}
+					len1 = -1;
+					break;
+				}
+			}
+			len = len1;
+
+			if (len == -1 && saved == 0) {
+				break;
+			}
+			if (len == -1) {
+				done = true;
+			}
+
+			// No matter how we may (or may not) format it, send it
+			// on unformatted - we don't want to mess with how its
+			// sent to the other side, just how its displayed
+
+			message = new String(buffer, 0, len);
+
+			System.out.println(message);
+		}
+
+    return message;
+	}
+}

Propchange: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/FaultTestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/InvalidAcknowledgementTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/InvalidAcknowledgementTest.java?view=diff&rev=564061&r1=564060&r2=564061
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/InvalidAcknowledgementTest.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/InvalidAcknowledgementTest.java Wed Aug  8 17:51:29 2007
@@ -1,279 +1,279 @@
-/*
- * Copyright 2007 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.faulttests;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.sandesha2.RMMsgContext;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.SandeshaTestCase;
-import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.Transaction;
-import org.apache.sandesha2.storage.beanmanagers.RMSBeanMgr;
-import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
-import org.apache.sandesha2.storage.beans.RMSBean;
-import org.apache.sandesha2.storage.beans.SenderBean;
-import org.apache.sandesha2.util.RangeString;
-import org.apache.sandesha2.util.SandeshaUtil;
-import org.apache.sandesha2.util.SpecSpecificConstants;
-import org.apache.sandesha2.wsrm.AcknowledgementRange;
-import org.apache.sandesha2.wsrm.Identifier;
-import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
-
-
-public class InvalidAcknowledgementTest extends SandeshaTestCase {
-
-	private static final String server_repoPath = "target" + File.separator
-	    + "repos" + File.separator + "server";
-
-	private static final String server_axis2_xml = "target" + File.separator
-	    + "repos" + File.separator + "server" + File.separator
-	    + "server_axis2.xml";
-	
-	private ConfigurationContext serverConfigContext;
-	
-	public InvalidAcknowledgementTest() {
-		super("InvalidAcknowledgementTest");
-	}
-
-	public void setUp() throws Exception {
-		super.setUp();
-		serverConfigContext = startServer(server_repoPath, server_axis2_xml);
-	}
-
-	/**
-	 * Sends an ACK message to an RM Source that will be refused and should be
-	 * rejected with an InvalidAck fault
-	 * 
-	 * We mock up a RMS sequence on the server, this is for us to then use for the fault.
-	 * 
-	 * @throws Exception
-	 */
-	public void testInvalidAcknowledgementSOAPFault() throws Exception {		
-		// Create an RMS on the service.
-		StorageManager storageManager = 
-			SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
-		
-		RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();
-		
-		String seqID = SandeshaUtil.getUUID();
-		
-		// Mockup an RMSBean
-		RMSBean rmsBean = new RMSBean();
-		rmsBean.setCreateSeqMsgID(SandeshaUtil.getUUID());
-		rmsBean.setSequenceID(seqID);
-		rmsBean.setInternalSequenceID(SandeshaUtil.getInternalSequenceID(seqID, null));
-		rmsBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
-		rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
-		rmsBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
-		rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
-		rmsBean.setClientCompletedMessages(new RangeString());
-		rmsBean.setNextMessageNumber(1);
-		
-		// Create a transaction and insert the RMSBean
-		Transaction tran = storageManager.getTransaction();
-		
-		rmsBeanMgr.insert(rmsBean);
-		
-		tran.commit();
-		
-    // Open a connection to the endpoint, using the sequence ack as the action
-		HttpURLConnection connection = 
-			FaultTestUtils.getHttpURLConnection("http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService",
-					"http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");
-
-		OutputStream tmpOut2 = connection.getOutputStream();
-		byte ar[] = getAppMessageAsBytes(seqID);
-		
-		// Send the message to the socket.
-		tmpOut2.write(ar);
-		tmpOut2.flush();
-
-		// Get the response message from the connection
-		String message = FaultTestUtils.retrieveResponseMessage(connection);
-    
-    // Check that the fault message isn't null
-    assertNotNull(message);
-    
-    // Check that the response contains the InvalidAcknowledgement tag    
-    assertTrue(message.indexOf("InvalidAcknowledgement") > -1);
-    
-    // Check that the <wsrm:Identifier>seqID</wsrm:Identifier> matches the sequence ID specified
-    String faultID = message.substring(message.indexOf("<wsrm:Identifier>") + 17, message.indexOf("</wsrm:Identifier>"));
-    assertEquals(seqID, faultID);
-    
-    // Disconnect at the end of the test
-    connection.disconnect();
-	}
-	
-	/**
-	 * Sends an ACK message to an RM Source that will be refused and should be
-	 * rejected with an InvalidAck fault
-	 * 
-	 * We mock up a RMS sequence on the server, this is for us to then use for the fault.
-	 * Mock up a couple of SenderBeans which match the 1, 2, 3 message numbers
-	 * Set the highest out message number to be 3
-	 * 
-	 * Send an ack range in for 1 - 3, Indicate that message 1 has been sent, but no more.
-	 * 
-	 * @throws Exception
-	 */
-	public void testInvalidAcknowledgementFromBeanNotSentSOAPFault() throws Exception {
-		
-		// Create an RMS on the service.
-		StorageManager storageManager = 
-			SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
-		
-		RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();
-		SenderBeanMgr senderMgr = storageManager.getSenderBeanMgr();
-		
-		String seqID = SandeshaUtil.getUUID();
-		
-		// Mockup an RMSBean
-		RMSBean rmsBean = new RMSBean();
-		rmsBean.setCreateSeqMsgID(SandeshaUtil.getUUID());
-		rmsBean.setSequenceID(seqID);
-		rmsBean.setInternalSequenceID(SandeshaUtil.getInternalSequenceID(seqID, null));
-		rmsBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
-		rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
-		rmsBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
-		rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
-		rmsBean.setClientCompletedMessages(new RangeString());
-		rmsBean.setNextMessageNumber(4);
-		rmsBean.setHighestOutMessageNumber(3);
-		
-		SenderBean bean1 = getSenderBean(seqID, 1, 1);
-		SenderBean bean2 = getSenderBean(seqID, 0, 2);
-		SenderBean bean3 = getSenderBean(seqID, 1, 3);		
-
-		// Create a transaction and insert the RMSBean
-		Transaction tran = storageManager.getTransaction();
-		
-		rmsBeanMgr.insert(rmsBean);
-		senderMgr.insert(bean1);
-		senderMgr.insert(bean2);
-		senderMgr.insert(bean3);		
-		
-		tran.commit();
-		
-    // Open a connection to the endpoint, using the sequence ack as the action
-		HttpURLConnection connection = 
-			FaultTestUtils.getHttpURLConnection("http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService",
-					"http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");
-
-		OutputStream tmpOut2 = connection.getOutputStream();
-		byte ar[] = getAppMessageAsBytes(seqID);
-		
-		// Send the message to the socket.
-		tmpOut2.write(ar);
-		tmpOut2.flush();
-
-		// Get the response message from the connection
-		String message = FaultTestUtils.retrieveResponseMessage(connection);
-    
-    // Check that the fault message isn't null
-    assertNotNull(message);
-    
-    // Check that the response contains the InvalidAcknowledgement tag    
-    assertTrue(message.indexOf("wsrm:InvalidAcknowledgement") > -1);
-    
-    // Check that the <wsrm:Identifier>seqID</wsrm:Identifier> matches the sequence ID specified
-    String faultID = message.substring(message.indexOf("<wsrm:Identifier>") + 17, message.indexOf("</wsrm:Identifier>"));
-    assertEquals(seqID, faultID);
-    
-    // Disconnect at the end of the test
-    connection.disconnect();
-	}
-
-	/**
-	 * Get a SequenceAck message as bytes
-	 * 
-	 * @return
-	 */
-	private byte[] getAppMessageAsBytes(String sequenceId) throws Exception
-	{
-		SOAPFactory factory = new SOAP11Factory();
-		SOAPEnvelope dummyEnvelope = factory.getDefaultEnvelope();
-		
-		// Create a "new" application message
-		MessageContext messageContext = new MessageContext();
-		messageContext.setConfigurationContext(serverConfigContext);
-		messageContext.setAxisService(serverConfigContext.getAxisConfiguration().getService("RMSampleService"));		
-		messageContext.setEnvelope(dummyEnvelope);
-		
-		RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
-		
-		// Generate the SequenceAck field.
-		// -------------------------------
-		String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(Sandesha2Constants.SPEC_VERSIONS.v1_1);
-
-		SequenceAcknowledgement sequenceAck = new SequenceAcknowledgement(rmNamespaceValue);
-		// Set the sequenceId
-		Identifier id = new Identifier(rmNamespaceValue);
-		id.setIndentifer(sequenceId);
-		sequenceAck.setIdentifier(id);
-		
-		// Set the Invalid range!
-		AcknowledgementRange ackRange = new AcknowledgementRange(rmNamespaceValue);
-		ackRange.setLowerValue(1);
-		ackRange.setUpperValue(3);
-		sequenceAck.addAcknowledgementRanges(ackRange);
-
-		// Set the SequenceAcknowledgement part in the message
-		applicationRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT, sequenceAck);
-		applicationRMMsg.addSOAPEnvelope();
-
-		// --------------------------------------------
-		// Finished generating SequenceAck part
-		
-		// Create an RMSBean so the create sequence message can be created
-		messageContext.setWSAAction("http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");
-
-		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-		
-		// Serialize the application message
-		applicationRMMsg.getMessageContext().getEnvelope().serialize(outputStream);
-		
-		return outputStream.toByteArray();
-	}
-	
-	private static SenderBean getSenderBean(String seqID, int sendCount, int messageNo) {
-		SenderBean bean = new SenderBean();
-		bean.setInternalSequenceID(SandeshaUtil.getInternalSequenceID(seqID, null));	
-		bean.setSequenceID(seqID);
-		bean.setMessageID(SandeshaUtil.getUUID());		
-		bean.setSentCount(sendCount);
-		bean.setSend(true);
-		bean.setReSend(true);
-		bean.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
-		bean.setMessageNumber(messageNo);
-		
-		return bean;
-	}
-}
-
-
-
+/*
+ * Copyright 2007 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.faulttests;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.Transaction;
+import org.apache.sandesha2.storage.beanmanagers.RMSBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
+import org.apache.sandesha2.storage.beans.RMSBean;
+import org.apache.sandesha2.storage.beans.SenderBean;
+import org.apache.sandesha2.util.RangeString;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.util.SpecSpecificConstants;
+import org.apache.sandesha2.wsrm.AcknowledgementRange;
+import org.apache.sandesha2.wsrm.Identifier;
+import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
+
+
+public class InvalidAcknowledgementTest extends SandeshaTestCase {
+
+	private static final String server_repoPath = "target" + File.separator
+	    + "repos" + File.separator + "server";
+
+	private static final String server_axis2_xml = "target" + File.separator
+	    + "repos" + File.separator + "server" + File.separator
+	    + "server_axis2.xml";
+	
+	private ConfigurationContext serverConfigContext;
+	
+	public InvalidAcknowledgementTest() {
+		super("InvalidAcknowledgementTest");
+	}
+
+	public void setUp() throws Exception {
+		super.setUp();
+		serverConfigContext = startServer(server_repoPath, server_axis2_xml);
+	}
+
+	/**
+	 * Sends an ACK message to an RM Source that will be refused and should be
+	 * rejected with an InvalidAck fault
+	 * 
+	 * We mock up a RMS sequence on the server, this is for us to then use for the fault.
+	 * 
+	 * @throws Exception
+	 */
+	public void testInvalidAcknowledgementSOAPFault() throws Exception {		
+		// Create an RMS on the service.
+		StorageManager storageManager = 
+			SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
+		
+		RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();
+		
+		String seqID = SandeshaUtil.getUUID();
+		
+		// Mockup an RMSBean
+		RMSBean rmsBean = new RMSBean();
+		rmsBean.setCreateSeqMsgID(SandeshaUtil.getUUID());
+		rmsBean.setSequenceID(seqID);
+		rmsBean.setInternalSequenceID(SandeshaUtil.getInternalSequenceID(seqID, null));
+		rmsBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+		rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+		rmsBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+		rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
+		rmsBean.setClientCompletedMessages(new RangeString());
+		rmsBean.setNextMessageNumber(1);
+		
+		// Create a transaction and insert the RMSBean
+		Transaction tran = storageManager.getTransaction();
+		
+		rmsBeanMgr.insert(rmsBean);
+		
+		tran.commit();
+		
+    // Open a connection to the endpoint, using the sequence ack as the action
+		HttpURLConnection connection = 
+			FaultTestUtils.getHttpURLConnection("http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService",
+					"http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");
+
+		OutputStream tmpOut2 = connection.getOutputStream();
+		byte ar[] = getAppMessageAsBytes(seqID);
+		
+		// Send the message to the socket.
+		tmpOut2.write(ar);
+		tmpOut2.flush();
+
+		// Get the response message from the connection
+		String message = FaultTestUtils.retrieveResponseMessage(connection);
+    
+    // Check that the fault message isn't null
+    assertNotNull(message);
+    
+    // Check that the response contains the InvalidAcknowledgement tag    
+    assertTrue(message.indexOf("InvalidAcknowledgement") > -1);
+    
+    // Check that the <wsrm:Identifier>seqID</wsrm:Identifier> matches the sequence ID specified
+    String faultID = message.substring(message.indexOf("<wsrm:Identifier>") + 17, message.indexOf("</wsrm:Identifier>"));
+    assertEquals(seqID, faultID);
+    
+    // Disconnect at the end of the test
+    connection.disconnect();
+	}
+	
+	/**
+	 * Sends an ACK message to an RM Source that will be refused and should be
+	 * rejected with an InvalidAck fault
+	 * 
+	 * We mock up a RMS sequence on the server, this is for us to then use for the fault.
+	 * Mock up a couple of SenderBeans which match the 1, 2, 3 message numbers
+	 * Set the highest out message number to be 3
+	 * 
+	 * Send an ack range in for 1 - 3, Indicate that message 1 has been sent, but no more.
+	 * 
+	 * @throws Exception
+	 */
+	public void testInvalidAcknowledgementFromBeanNotSentSOAPFault() throws Exception {
+		
+		// Create an RMS on the service.
+		StorageManager storageManager = 
+			SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
+		
+		RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();
+		SenderBeanMgr senderMgr = storageManager.getSenderBeanMgr();
+		
+		String seqID = SandeshaUtil.getUUID();
+		
+		// Mockup an RMSBean
+		RMSBean rmsBean = new RMSBean();
+		rmsBean.setCreateSeqMsgID(SandeshaUtil.getUUID());
+		rmsBean.setSequenceID(seqID);
+		rmsBean.setInternalSequenceID(SandeshaUtil.getInternalSequenceID(seqID, null));
+		rmsBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+		rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+		rmsBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+		rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
+		rmsBean.setClientCompletedMessages(new RangeString());
+		rmsBean.setNextMessageNumber(4);
+		rmsBean.setHighestOutMessageNumber(3);
+		
+		SenderBean bean1 = getSenderBean(seqID, 1, 1);
+		SenderBean bean2 = getSenderBean(seqID, 0, 2);
+		SenderBean bean3 = getSenderBean(seqID, 1, 3);		
+
+		// Create a transaction and insert the RMSBean
+		Transaction tran = storageManager.getTransaction();
+		
+		rmsBeanMgr.insert(rmsBean);
+		senderMgr.insert(bean1);
+		senderMgr.insert(bean2);
+		senderMgr.insert(bean3);		
+		
+		tran.commit();
+		
+    // Open a connection to the endpoint, using the sequence ack as the action
+		HttpURLConnection connection = 
+			FaultTestUtils.getHttpURLConnection("http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService",
+					"http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");
+
+		OutputStream tmpOut2 = connection.getOutputStream();
+		byte ar[] = getAppMessageAsBytes(seqID);
+		
+		// Send the message to the socket.
+		tmpOut2.write(ar);
+		tmpOut2.flush();
+
+		// Get the response message from the connection
+		String message = FaultTestUtils.retrieveResponseMessage(connection);
+    
+    // Check that the fault message isn't null
+    assertNotNull(message);
+    
+    // Check that the response contains the InvalidAcknowledgement tag    
+    assertTrue(message.indexOf("wsrm:InvalidAcknowledgement") > -1);
+    
+    // Check that the <wsrm:Identifier>seqID</wsrm:Identifier> matches the sequence ID specified
+    String faultID = message.substring(message.indexOf("<wsrm:Identifier>") + 17, message.indexOf("</wsrm:Identifier>"));
+    assertEquals(seqID, faultID);
+    
+    // Disconnect at the end of the test
+    connection.disconnect();
+	}
+
+	/**
+	 * Get a SequenceAck message as bytes
+	 * 
+	 * @return
+	 */
+	private byte[] getAppMessageAsBytes(String sequenceId) throws Exception
+	{
+		SOAPFactory factory = new SOAP11Factory();
+		SOAPEnvelope dummyEnvelope = factory.getDefaultEnvelope();
+		
+		// Create a "new" application message
+		MessageContext messageContext = new MessageContext();
+		messageContext.setConfigurationContext(serverConfigContext);
+		messageContext.setAxisService(serverConfigContext.getAxisConfiguration().getService("RMSampleService"));		
+		messageContext.setEnvelope(dummyEnvelope);
+		
+		RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
+		
+		// Generate the SequenceAck field.
+		// -------------------------------
+		String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(Sandesha2Constants.SPEC_VERSIONS.v1_1);
+
+		SequenceAcknowledgement sequenceAck = new SequenceAcknowledgement(rmNamespaceValue);
+		// Set the sequenceId
+		Identifier id = new Identifier(rmNamespaceValue);
+		id.setIndentifer(sequenceId);
+		sequenceAck.setIdentifier(id);
+		
+		// Set the Invalid range!
+		AcknowledgementRange ackRange = new AcknowledgementRange(rmNamespaceValue);
+		ackRange.setLowerValue(1);
+		ackRange.setUpperValue(3);
+		sequenceAck.addAcknowledgementRanges(ackRange);
+
+		// Set the SequenceAcknowledgement part in the message
+		applicationRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT, sequenceAck);
+		applicationRMMsg.addSOAPEnvelope();
+
+		// --------------------------------------------
+		// Finished generating SequenceAck part
+		
+		// Create an RMSBean so the create sequence message can be created
+		messageContext.setWSAAction("http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");
+
+		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+		
+		// Serialize the application message
+		applicationRMMsg.getMessageContext().getEnvelope().serialize(outputStream);
+		
+		return outputStream.toByteArray();
+	}
+	
+	private static SenderBean getSenderBean(String seqID, int sendCount, int messageNo) {
+		SenderBean bean = new SenderBean();
+		bean.setInternalSequenceID(SandeshaUtil.getInternalSequenceID(seqID, null));	
+		bean.setSequenceID(seqID);
+		bean.setMessageID(SandeshaUtil.getUUID());		
+		bean.setSentCount(sendCount);
+		bean.setSend(true);
+		bean.setReSend(true);
+		bean.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
+		bean.setMessageNumber(messageNo);
+		
+		return bean;
+	}
+}
+
+
+

Propchange: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/InvalidAcknowledgementTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/MessageNumberRolloverFaultTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/MessageNumberRolloverFaultTest.java?view=diff&rev=564061&r1=564060&r2=564061
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/MessageNumberRolloverFaultTest.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/MessageNumberRolloverFaultTest.java Wed Aug  8 17:51:29 2007
@@ -1,180 +1,180 @@
-/*
- * Copyright 2007 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.faulttests;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.sandesha2.RMMsgContext;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.SandeshaTestCase;
-import org.apache.sandesha2.msgreceivers.RMMessageReceiver;
-import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.Transaction;
-import org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr;
-import org.apache.sandesha2.storage.beans.RMDBean;
-import org.apache.sandesha2.util.Range;
-import org.apache.sandesha2.util.RangeString;
-import org.apache.sandesha2.util.SandeshaUtil;
-import org.apache.sandesha2.util.SpecSpecificConstants;
-import org.apache.sandesha2.wsrm.Identifier;
-import org.apache.sandesha2.wsrm.MessageNumber;
-import org.apache.sandesha2.wsrm.Sequence;
-
-
-public class MessageNumberRolloverFaultTest extends SandeshaTestCase {
-
-	private static final String server_repoPath = "target" + File.separator
-	    + "repos" + File.separator + "server";
-
-	private static final String server_axis2_xml = "target" + File.separator
-	    + "repos" + File.separator + "server" + File.separator
-	    + "server_axis2.xml";
-	
-	private ConfigurationContext serverConfigContext;
-	
-	public MessageNumberRolloverFaultTest() {
-		super("MessageNumberRolloverFaultTest");
-	}
-
-	public void setUp() throws Exception {
-		super.setUp();
-		serverConfigContext = startServer(server_repoPath, server_axis2_xml);
-	}
-
-	/**
-	 * Sends an application message to the RMD.
-	 * The RMD should reject the message with a MessageRolloverFault
-	 * 
-	 * @throws Exception
-	 */
-	public void testMessageNumberRolloverFault() throws Exception {
-    // Open a connection to the endpoint
-		HttpURLConnection connection = 
-			FaultTestUtils.getHttpURLConnection("http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService",
-					pingAction);
-
-		StorageManager storageManager = 
-			SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
-		
-		RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
-		
-		String seqID = SandeshaUtil.getUUID();
-		
-		// Mockup an RMSBean
-		RMDBean rmdBean = new RMDBean();
-		rmdBean.setSequenceID(seqID);
-		rmdBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
-		rmdBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
-		rmdBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
-		rmdBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
-		rmdBean.setServerCompletedMessages(new RangeString());
-		rmdBean.getServerCompletedMessages().addRange(new Range(1, Long.MAX_VALUE -1));
-		rmdBean.getServerCompletedMessages().addRange(new Range(Long.MAX_VALUE, Long.MAX_VALUE));
-		
-		// Create a transaction and insert the RMSBean
-		Transaction tran = storageManager.getTransaction();
-		
-		rmdBeanMgr.insert(rmdBean);
-		
-		tran.commit();
-
-		
-		OutputStream tmpOut2 = connection.getOutputStream();
-
-		byte ar[] = getAppMessageAsBytes(seqID);
-		
-		// Send the message to the socket.
-		tmpOut2.write(ar);
-		tmpOut2.flush();
-
-		// Get the response message from the connection
-		String message = FaultTestUtils.retrieveResponseMessage(connection);
-    
-    // Check that the fault message isn't null
-    assertNotNull(message);
-    
-    // Check that the response contains the MessageNumberRollover tag    
-    assertTrue(message.indexOf("wsrm:MessageNumberRollover") > -1);
-    
-    // Disconnect at the end of the test
-    connection.disconnect();
-	}
-	
-	/**
-	 * Get an application message as bytes
-	 * 
-	 * This sets the message number to "Long.maxValue"
-	 * 
-	 * @return
-	 */
-	private byte[] getAppMessageAsBytes(String uuid) throws Exception
-	{
-		SOAPFactory factory = new SOAP11Factory();
-		SOAPEnvelope dummyEnvelope = factory.getDefaultEnvelope();
-		
-		// Create a "new" application message
-		MessageContext messageContext = new MessageContext();
-		messageContext.setConfigurationContext(serverConfigContext);
-		messageContext.setAxisService(serverConfigContext.getAxisConfiguration().getService("RMSampleService"));		
-		messageContext.setEnvelope(dummyEnvelope);
-		
-		RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
-		
-		// Generate the Sequence field.
-		// -------------------------------
-		String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(Sandesha2Constants.SPEC_VERSIONS.v1_1);
-
-		Sequence sequence = new Sequence(rmNamespaceValue);
-		MessageNumber msgNumber = new MessageNumber(rmNamespaceValue);
-		msgNumber.setMessageNumber(Long.MAX_VALUE);
-		sequence.setMessageNumber(msgNumber);
-		Identifier id1 = new Identifier(rmNamespaceValue);
-		id1.setIndentifer(uuid);
-		sequence.setIdentifier(id1);
-		applicationRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE, sequence);
-		applicationRMMsg.addSOAPEnvelope();
-
-		// --------------------------------------------
-		// Finished generating Sequence part
-		
-		// Create an RMSBean so the create sequence message can be created
-		messageContext.setWSAAction(pingAction);
-
-		// Set the AxisOperation to be InOut
-		AxisOperation operation = messageContext.getAxisService().getOperation(Sandesha2Constants.RM_IN_OUT_OPERATION);
-		operation.setMessageReceiver(new RMMessageReceiver());
-		messageContext.setAxisOperation(operation);
-
-		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-		
-		// Serialize the application message
-		applicationRMMsg.getMessageContext().getEnvelope().serialize(outputStream);
-		
-		return outputStream.toByteArray();
-	}
-}
-
+/*
+ * Copyright 2007 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.faulttests;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.msgreceivers.RMMessageReceiver;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.Transaction;
+import org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr;
+import org.apache.sandesha2.storage.beans.RMDBean;
+import org.apache.sandesha2.util.Range;
+import org.apache.sandesha2.util.RangeString;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.util.SpecSpecificConstants;
+import org.apache.sandesha2.wsrm.Identifier;
+import org.apache.sandesha2.wsrm.MessageNumber;
+import org.apache.sandesha2.wsrm.Sequence;
+
+
+public class MessageNumberRolloverFaultTest extends SandeshaTestCase {
+
+	private static final String server_repoPath = "target" + File.separator
+	    + "repos" + File.separator + "server";
+
+	private static final String server_axis2_xml = "target" + File.separator
+	    + "repos" + File.separator + "server" + File.separator
+	    + "server_axis2.xml";
+	
+	private ConfigurationContext serverConfigContext;
+	
+	public MessageNumberRolloverFaultTest() {
+		super("MessageNumberRolloverFaultTest");
+	}
+
+	public void setUp() throws Exception {
+		super.setUp();
+		serverConfigContext = startServer(server_repoPath, server_axis2_xml);
+	}
+
+	/**
+	 * Sends an application message to the RMD.
+	 * The RMD should reject the message with a MessageRolloverFault
+	 * 
+	 * @throws Exception
+	 */
+	public void testMessageNumberRolloverFault() throws Exception {
+    // Open a connection to the endpoint
+		HttpURLConnection connection = 
+			FaultTestUtils.getHttpURLConnection("http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService",
+					pingAction);
+
+		StorageManager storageManager = 
+			SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
+		
+		RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
+		
+		String seqID = SandeshaUtil.getUUID();
+		
+		// Mockup an RMSBean
+		RMDBean rmdBean = new RMDBean();
+		rmdBean.setSequenceID(seqID);
+		rmdBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+		rmdBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+		rmdBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+		rmdBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
+		rmdBean.setServerCompletedMessages(new RangeString());
+		rmdBean.getServerCompletedMessages().addRange(new Range(1, Long.MAX_VALUE -1));
+		rmdBean.getServerCompletedMessages().addRange(new Range(Long.MAX_VALUE, Long.MAX_VALUE));
+		
+		// Create a transaction and insert the RMSBean
+		Transaction tran = storageManager.getTransaction();
+		
+		rmdBeanMgr.insert(rmdBean);
+		
+		tran.commit();
+
+		
+		OutputStream tmpOut2 = connection.getOutputStream();
+
+		byte ar[] = getAppMessageAsBytes(seqID);
+		
+		// Send the message to the socket.
+		tmpOut2.write(ar);
+		tmpOut2.flush();
+
+		// Get the response message from the connection
+		String message = FaultTestUtils.retrieveResponseMessage(connection);
+    
+    // Check that the fault message isn't null
+    assertNotNull(message);
+    
+    // Check that the response contains the MessageNumberRollover tag    
+    assertTrue(message.indexOf("wsrm:MessageNumberRollover") > -1);
+    
+    // Disconnect at the end of the test
+    connection.disconnect();
+	}
+	
+	/**
+	 * Get an application message as bytes
+	 * 
+	 * This sets the message number to "Long.maxValue"
+	 * 
+	 * @return
+	 */
+	private byte[] getAppMessageAsBytes(String uuid) throws Exception
+	{
+		SOAPFactory factory = new SOAP11Factory();
+		SOAPEnvelope dummyEnvelope = factory.getDefaultEnvelope();
+		
+		// Create a "new" application message
+		MessageContext messageContext = new MessageContext();
+		messageContext.setConfigurationContext(serverConfigContext);
+		messageContext.setAxisService(serverConfigContext.getAxisConfiguration().getService("RMSampleService"));		
+		messageContext.setEnvelope(dummyEnvelope);
+		
+		RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
+		
+		// Generate the Sequence field.
+		// -------------------------------
+		String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(Sandesha2Constants.SPEC_VERSIONS.v1_1);
+
+		Sequence sequence = new Sequence(rmNamespaceValue);
+		MessageNumber msgNumber = new MessageNumber(rmNamespaceValue);
+		msgNumber.setMessageNumber(Long.MAX_VALUE);
+		sequence.setMessageNumber(msgNumber);
+		Identifier id1 = new Identifier(rmNamespaceValue);
+		id1.setIndentifer(uuid);
+		sequence.setIdentifier(id1);
+		applicationRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE, sequence);
+		applicationRMMsg.addSOAPEnvelope();
+
+		// --------------------------------------------
+		// Finished generating Sequence part
+		
+		// Create an RMSBean so the create sequence message can be created
+		messageContext.setWSAAction(pingAction);
+
+		// Set the AxisOperation to be InOut
+		AxisOperation operation = messageContext.getAxisService().getOperation(Sandesha2Constants.RM_IN_OUT_OPERATION);
+		operation.setMessageReceiver(new RMMessageReceiver());
+		messageContext.setAxisOperation(operation);
+
+		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+		
+		// Serialize the application message
+		applicationRMMsg.getMessageContext().getEnvelope().serialize(outputStream);
+		
+		return outputStream.toByteArray();
+	}
+}
+

Propchange: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/faulttests/MessageNumberRolloverFaultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



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