Thilina, Is there a relationship with this to Axis2-95 ? If yes, please comment/resolve that issue.
-- Chinthaka > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Friday, August 05, 2005 9:20 AM > To: [email protected] > Subject: svn commit: r230387 - in > /webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa > : EchoRawSwATest.java EchoSwA.java swainput.txt > > Author: thilina > Date: Thu Aug 4 20:20:22 2005 > New Revision: 230387 > > URL: http://svn.apache.org/viewcvs?rev=230387&view=rev > Log: > Soap with Attachments test case(Sample) > We are sending a SwA request to Axis2 by opening a socket... > > Added: > > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > swainput.txt > Modified: > > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > EchoRawSwATest.java > > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > EchoSwA.java > > Modified: > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > EchoRawSwATest.java > URL: > http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integrat > ion/test/org/apache/axis2/swa/EchoRawSwATest.java?rev=230387&r1=230386&r2= > 230387&view=diff > ========================================================================== > ==== > --- > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > EchoRawSwATest.java (original) > +++ > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > EchoRawSwATest.java Thu Aug 4 20:20:22 2005 > @@ -21,6 +21,7 @@ > */ > > import java.io.InputStream; > +import java.io.OutputStream; > import java.net.Socket; > > import javax.xml.namespace.QName; > @@ -29,45 +30,36 @@ > > import org.apache.axis2.Constants; > import org.apache.axis2.addressing.EndpointReference; > -import org.apache.axis2.context.MessageContext; > import org.apache.axis2.context.ServiceContext; > +import org.apache.axis2.description.OperationDescription; > +import org.apache.axis2.description.ParameterImpl; > import org.apache.axis2.description.ServiceDescription; > -import org.apache.axis2.engine.AxisConfiguration; > import org.apache.axis2.integration.UtilServer; > import org.apache.axis2.om.OMText; > import org.apache.axis2.om.impl.llom.OMTextImpl; > -import org.apache.axis2.util.Utils; > +import org.apache.axis2.receivers.AbstractMessageReceiver; > +import org.apache.axis2.receivers.RawXMLINOutMessageReceiver; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > +import org.apache.wsdl.WSDLService; > > public class EchoRawSwATest extends TestCase { > - private EndpointReference targetEPR = new > EndpointReference("http://127.0.0.1:" > - + (UtilServer.TESTING_PORT) > - + "/axis/services/EchoSwAService/echoAttachment"); > + private EndpointReference targetEPR = new EndpointReference( > + "http://127.0.0.1:" + (UtilServer.TESTING_PORT) > + + "/axis/services/EchoSwAService/echoAttachment"); > > private Log log = LogFactory.getLog(getClass()); > > private QName serviceName = new QName("EchoSwAService"); > > private QName operationName = new QName("echoAttachment"); > - > - private QName transportName = new QName("http://localhost/my", > - "NullTransport"); > - > - private String imageInFileName = "img/test.jpg"; > - > - private String imageOutFileName = "mtom/img/testOut.jpg"; > - > - private AxisConfiguration engineRegistry; > - > - private MessageContext mc; > - > + > private ServiceContext serviceContext; > > private ServiceDescription service; > > private boolean finish = false; > - > + > private OMTextImpl expectedTextData; > > public EchoRawSwATest() { > @@ -80,11 +72,21 @@ > > protected void setUp() throws Exception { > UtilServer.start(Constants.TESTING_PATH + "MTOM- > enabledRepository"); > - service = Utils.createSimpleService(serviceName, > EchoSwA.class.getName(), > - operationName); > + service = new ServiceDescription(serviceName); > + > service.setClassLoader(Thread.currentThread().getContextClassLoader()); > + service > + .addParameter(new ParameterImpl( > + AbstractMessageReceiver.SERVICE_CLASS, > EchoSwA.class > + .getName())); > + > + OperationDescription axisOp = new > OperationDescription(operationName); > + axisOp.setMessageReciever(new RawXMLINOutMessageReceiver()); > + axisOp.setStyle(WSDLService.STYLE_DOC); > + service.addOperation(axisOp); > UtilServer.deployService(service); > serviceContext = UtilServer.getConfigurationContext() > .createServiceContext(service.getName()); > + > } > > protected void tearDown() throws Exception { > @@ -92,16 +94,32 @@ > UtilServer.stop(); > } > > - > public void testEchoXMLSync() throws Exception { > - Socket socket = new Socket("127.0.0.1",5555); > - > + Socket socket = new Socket("127.0.0.1", 5555); > + OutputStream outStream = socket.getOutputStream(); > + InputStream inStream = socket.getInputStream(); > + InputStream requestMsgInStream = > getResourceAsStream("org/apache/axis2/swa/swainput.txt"); > + while (requestMsgInStream.available() > 0) { > + int data = requestMsgInStream.read(); > + outStream.write(data); > + } > + outStream.flush(); > + socket.shutdownOutput(); > + byte[] i = new byte[1]; > + StringBuffer stringBuffer = new StringBuffer(); > + while ((i[0] = (byte)inStream.read()) != -1) { > + stringBuffer.append(new String(i)); > + } > + socket.close(); > + assertTrue(stringBuffer.toString().indexOf("Apache Axis2 - The > NExt Generation Web Services Engine")>0); > + > assertTrue(stringBuffer.toString().indexOf("multipart/related")>0); > } > > private InputStream getResourceAsStream(String path) { > ClassLoader cl = Thread.currentThread().getContextClassLoader(); > return cl.getResourceAsStream(path); > } > + > private void compareWithCreatedOMText(OMText actualTextData) { > String originalTextValue = expectedTextData.getText(); > String returnedTextValue = actualTextData.getText(); > > Modified: > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > EchoSwA.java > URL: > http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integrat > ion/test/org/apache/axis2/swa/EchoSwA.java?rev=230387&r1=230386&r2=230387& > view=diff > ========================================================================== > ==== > --- > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > EchoSwA.java (original) > +++ > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > EchoSwA.java Thu Aug 4 20:20:22 2005 > @@ -42,7 +42,7 @@ > > public OMElement echoAttachment(OMElement omEle) { > OMElement child = (OMElement)omEle.getFirstChild(); > - OMAttribute attr = (OMAttribute)child.getAttributes(new > QName("href")).next(); > + OMAttribute attr = (OMAttribute)child.getFirstAttribute(new > QName("href")); > String contentID = attr.getValue(); > MIMEHelper attachment = > (MIMEHelper)msgcts.getProperty(MIMEHelper.ATTACHMENTS); > contentID = contentID.trim(); > > Added: > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > swainput.txt > URL: > http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integrat > ion/test/org/apache/axis2/swa/swainput.txt?rev=230387&view=auto > ========================================================================== > ==== > --- > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > swainput.txt (added) > +++ > webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/ > swainput.txt Thu Aug 4 20:20:22 2005 > @@ -0,0 +1,24 @@ > +POST /axis/services/EchoSwAService/echoAttachment HTTP/1.0 > > +Content-Type: multipart/related; type="text/xml"; > start="<9D645C8EBB837CE54ABD027A3659535D>"; boundary="---- > =_Part_0_1977511.1123163571138" > > +Accept: application/soap+xml, application/dime, multipart/related, text/* > > +User-Agent: Axis/1.2.1 > > +Host: 127.0.0.1:8081 > > +Cache-Control: no-cache > > +Pragma: no-cache > > +SOAPAction: "" > > + > > + > > +------=_Part_0_1977511.1123163571138 > > +Content-Type: text/xml; charset=UTF-8 > > +Content-Transfer-Encoding: binary > > +Content-Id: <9D645C8EBB837CE54ABD027A3659535D> > > + > > +<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema- > instance"><soapenv:Body><echoAttachment xmlns=""><source > href="cid:3936AE19FBED55AE4620B81C73BDD76E" > xmlns=""/></echoAttachment></soapenv:Body></soapenv:Envelope> > > +------=_Part_0_1977511.1123163571138 > > +Content-Type: text/plain > > +Content-Transfer-Encoding: binary > > +Content-Id: <3936AE19FBED55AE4620B81C73BDD76E> > > + > > +Apache Axis2 - The NExt Generation Web Services Engine > + > > +------=_Part_0_1977511.1123163571138-- > > >
