Debian Codegraph @

test/outparams2/TestOutParams2.java

raw
1 package test.outparams2;
2
3 import javax.xml.rpc.holders.StringHolder;
4
5 import junit.framework.TestCase;
6
7 import org.apache.axis.EngineConfiguration;
8 import org.apache.axis.Message;
9 import org.apache.axis.client.Call;
10 import org.apache.axis.client.Service;
11 import org.apache.axis.configuration.DefaultEngineConfigurationFactory;
12 import org.apache.axis.configuration.SimpleProvider;
13 import org.apache.axis.description.JavaServiceDesc;
14 import org.apache.axis.description.OperationDesc;
15 import org.apache.axis.description.ParameterDesc;
16 import org.apache.axis.description.ServiceDesc;
17 import org.apache.axis.handlers.soap.SOAPService;
18 import org.apache.axis.message.SOAPEnvelope;
19 import org.apache.axis.providers.java.RPCProvider;
20 import org.apache.axis.server.AxisServer;
21 import org.apache.axis.transport.local.LocalTransport;
22
23 /**
24 * Test if operation is invoked with parameters in good order when out parameter
25 * is not the last parameter. <br>
26 * It makes sure that bug described at
27 * http://issues.apache.org/jira/browse/AXIS-1975 is corrected.
28 *
29 * @author Cedric Chabanois ([email protected])
30 */
31 public class TestOutParams2 extends TestCase {
32
33 /** A fixed message, with one parameter */
34 private final String message = "<?xml version=\"1.0\"?>\n"
35 + "<soapenv:Envelope "
36 + "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" "
37 + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
38 + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
39 + "<soapenv:Body>\n"
40 + "<ns1:serviceMethod soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" "
41 + "xmlns:ns1=\"outParamsTest\"><in1>18</in1></ns1:serviceMethod>\n"
42 + "</soapenv:Body></soapenv:Envelope>\n";
43
44 private Service s_service = null;
45
46 private Call client = null;
47
48 private SimpleProvider provider = new SimpleProvider();
49
50 private AxisServer server = new AxisServer(provider);
51
52 private static boolean called = false;
53
54 public TestOutParams2(String name) {
55 super(name);
56 server.init();
57 }
58
59 public TestOutParams2() {
60 super("Test Out Params");
61 }
62
63 public void testOutputParams() throws Exception {
64 // Register the service
65 s_service = new Service();
66 client = (Call) s_service.createCall();
67
68 SOAPService service = new SOAPService(null, new RPCProvider(), null);
69 service.setName("TestOutParamsService");
70 service.setOption("className", "test.outparams2.TestOutParams2");
71 service.setOption("allowedMethods", "serviceMethod");
72
73 ServiceDesc description = new JavaServiceDesc();
74 OperationDesc operation = new OperationDesc();
75 operation.setName("serviceMethod");
76 ParameterDesc out1 = new ParameterDesc();
77 out1.setName("out1");
78 out1.setMode(ParameterDesc.OUT);
79 operation.addParameter(out1);
80 ParameterDesc in1 = new ParameterDesc();
81 in1.setName("in1");
82 in1.setMode(ParameterDesc.IN);
83 operation.addParameter(in1);
84 description.addOperationDesc(operation);
85 service.setServiceDescription(description);
86
87 EngineConfiguration defaultConfig = (new DefaultEngineConfigurationFactory())
88 .getServerEngineConfig();
89 SimpleProvider config = new SimpleProvider(defaultConfig);
90 config.deployService("outParamsTest", service);
91 provider.deployService("outParamsTest", service);
92
93 // Make sure the local transport uses the server we just configured
94 client.setTransport(new LocalTransport(server));
95
96 Message msg = new Message(message, false);
97 SOAPEnvelope env = msg.getSOAPEnvelope();
98
99 // invoke
100 client.invoke(env);
101 assertTrue(this.called);
102 }
103
104 public void serviceMethod(StringHolder out1, byte in1) {
105 called = true;
106 }
107
108 public static void main(String args[]) {
109 try {
110 TestOutParams2 tester = new TestOutParams2("OutParams Test");
111 tester.testOutputParams();
112 } catch (Exception e) {
113 e.printStackTrace();
114 }
115 }
116 }