KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > transport > tcp > TCPTransportTest


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.axis2.transport.tcp;
17
18 import junit.framework.TestCase;
19 import org.apache.axis2.engine.AxisFault;
20 import org.apache.axis2.om.impl.llom.builder.StAXBuilder;
21 import org.apache.axis2.soap.SOAPEnvelope;
22 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
23
24 import javax.xml.stream.XMLInputFactory;
25 import javax.xml.stream.XMLStreamReader;
26 import java.io.InputStream JavaDoc;
27
28 public class TCPTransportTest extends TestCase {
29     public TCPTransportTest(String JavaDoc arg0) {
30         super(arg0);
31         // TODO Auto-generated constructor stub
32
}
33
34     public void testTransportSender() throws AxisFault {
35 // Thread thead = new Thread(new Runnable() {
36
// public void run() {
37
// try {
38
// ServerSocket serverSocket = new ServerSocket(45678);
39
// Socket s = serverSocket.accept();
40
// assertNotNull(createSOAPEnvelope(s.getInputStream()));
41
// } catch (AxisFault e) {
42
// // TODO Auto-generated catch block
43
// e.printStackTrace();
44
// } catch (IOException e) {
45
// // TODO Auto-generated catch block
46
// e.printStackTrace();
47
// }
48
// }
49
// });
50
// thead.start();
51
//
52
// TCPTransportSender ts = new TCPTransportSender();
53
// MessageContext msgctx = new MessageContext(null, null, null, null);
54
// msgctx.setTo(new EndpointReference(AddressingConstants.WSA_TO,"http://127.0.0.1:45679"));
55
//
56
// msgctx.setEnvelope(createSOAPEnvelope(Thread.currentThread().getContextClassLoader().getResourceAsStream("org/apache/axis2/transport/sample.xml")));
57
// ts.invoke(msgctx);
58

59
60     }
61     
62 // public void testTransportReciver(){
63
// ConfigurationContext configContext = new ConfigurationContext(new AxisConfigurationImpl());
64
// ServiceDescription serviceDesc = new ServiceDescription(new QName("TempService"));
65
// OperationDescription opDesc = new OperationDescription();
66
// TCPServer tcpServer = new TCPServer();
67
// }
68

69
70     public SOAPEnvelope createSOAPEnvelope(InputStream JavaDoc in) throws AxisFault {
71         try {
72             XMLStreamReader xmlreader =
73                 XMLInputFactory.newInstance().createXMLStreamReader(in);
74             StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader);
75             return (SOAPEnvelope) builder.getDocumentElement();
76         } catch (Exception JavaDoc e) {
77             throw new AxisFault(e.getMessage(), e);
78         }
79     }
80
81 }
82
Popular Tags