File: TestStructure.java

package info (click to toggle)
axis 1.4-29
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 52,100 kB
  • sloc: java: 129,124; xml: 10,602; jsp: 983; sh: 84; cs: 36; makefile: 18
file content (189 lines) | stat: -rw-r--r-- 8,341 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package test.wsdd;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.axis.Chain;
import org.apache.axis.Handler;
import org.apache.axis.TargetedChain;
import org.apache.axis.configuration.FileProvider;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.server.AxisServer;

import java.io.InputStream;

/**
 *  Positive test of basic structure of a WSDD document
 */ 
public class TestStructure extends TestCase
{
    static final String INPUT_FILE = "testStructure1.wsdd";
    AxisServer server;

    public TestStructure (String name) 
    {
        super(name);
    }

    public static Test suite() 
    {
        return new TestSuite(TestStructure.class);
    }

    protected void setUp() 
    {
        InputStream is = getClass().getResourceAsStream(INPUT_FILE);
        FileProvider provider = new FileProvider(is);
        server = new AxisServer(provider);
    }

    public static void main(String[] args) throws Exception 
    {
        TestStructure tester = new TestStructure("TestStructure");
        tester.setUp();
        tester.testServiceBackReference();
    }
    
    public void testChainAnonymousHandler() throws Exception
    {
        Chain chainOne = (Chain) server.getHandler("chain.one");
        assertNotNull("chain.one should be non-null!", chainOne);

        Handler chainOne_handlers[] = chainOne.getHandlers();
        assertNotNull("chain.one/handlers should be non-null!", 
                      chainOne_handlers);
        assertTrue("chain.one should have exactly 1 handler!",
                (1 == chainOne_handlers.length));

        Handler chainOne_handler = chainOne_handlers[0];
        assertNotNull("chain.one's handler should be non-null!",
                      chainOne_handler);
        assertTrue("chain.one's handler should be a JWSHandler!",
                (chainOne_handler instanceof 
                 org.apache.axis.handlers.JWSHandler));
    }

    public void testServiceBackReference() throws Exception
    {
        SOAPService serviceOne = (SOAPService)server.getService("service.one");
        assertNotNull("service.one should be non-null!", serviceOne);

        Chain serviceOne_responseFlow = (Chain)serviceOne.getResponseHandler();
        assertNotNull("service.two/responseFlow should be non-null!",
                      serviceOne_responseFlow);

        Handler serviceOne_responseFlow_handlers[] = 
                             serviceOne_responseFlow.getHandlers();
        assertNotNull("service.one/responseFlow/handlers should be non-null!",
                        serviceOne_responseFlow_handlers);
        assertTrue("service.one should have exactly 1 handler!",
                (1 == serviceOne_responseFlow_handlers.length));

        Handler serviceOne_responseFlow_handler = 
                        serviceOne_responseFlow_handlers[0];
        assertNotNull("service.one's handler should be non-null!",
                      serviceOne_responseFlow_handler);
        assertTrue("service.one's handler should be a RPCProvider!",
                    (serviceOne_responseFlow_handler instanceof
                         org.apache.axis.providers.java.RPCProvider));

        Handler serviceOne_handler_byName = server.getHandler("BackReference");
        assertTrue("service.one's 'BackReference' should be same as directly accessed 'BR'!",
                   (serviceOne_responseFlow_handler == 
                            serviceOne_handler_byName));

         /*******************************************************
          <service name="service.two" provider="java:MSG">
           <requestFlow>
             <handler type="BackReference"/>
           </requestFlow>
          </service>
         ******************************************************/
        SOAPService serviceTwo = null;
        serviceTwo = (SOAPService) server.getService("service.two");
        assertTrue("service.two should be non-null!",
                   (null != serviceTwo));

        Chain serviceTwo_requestFlow = (Chain) serviceTwo.getRequestHandler();
        assertTrue("service.two/requestFlow should be non-null!",
                (null != serviceTwo_requestFlow));

        Handler serviceTwo_requestFlow_handlers[] = 
                                serviceTwo_requestFlow.getHandlers();
        assertTrue("service.two/requestFlow/handlers should be non-null!",
                (null != serviceTwo_requestFlow_handlers));
        assertTrue("service.two should have exactly 1 handler!",
                (1 == serviceTwo_requestFlow_handlers.length));

        Handler serviceTwo_requestFlow_handler = 
                                serviceTwo_requestFlow_handlers[0];
        assertTrue("service.two's handler should be non-null!",
                (null != serviceTwo_requestFlow_handler));
        assertTrue("service.two's handler should be a RPCProvider!",
                    (serviceTwo_requestFlow_handler instanceof
                                org.apache.axis.providers.java.RPCProvider));

        assertTrue("service.two's 'BackReference' should be same as service.one's!",
                   (serviceTwo_requestFlow_handler == 
                            serviceOne_responseFlow_handler));
    }

    public void testTransportForwardReference()
            throws Exception
    {
        TargetedChain transportOne = 
                        (TargetedChain)server.getTransport("transport.one");
        assertNotNull("transport.one should be non-null!", transportOne);

        Chain transportOne_responseFlow = 
                        (Chain)transportOne.getResponseHandler();
        assertNotNull("transport.two/responseFlow should be non-null!",
                      transportOne_responseFlow);

        Handler transportOne_responseFlow_handlers[] = 
                        transportOne_responseFlow.getHandlers();
        assertNotNull("transport.one/responseFlow/handlers should be non-null!",
                      transportOne_responseFlow_handlers);
        assertTrue("transport.one should have exactly 1 handler!",
                (1 == transportOne_responseFlow_handlers.length));

        Handler transportOne_responseFlow_handler =
                        transportOne_responseFlow_handlers[0];
        assertNotNull("transport.one's handler should be non-null!",
                      transportOne_responseFlow_handler);
        assertTrue("transport.one's handler should be a URLMapper!",
                    (transportOne_responseFlow_handler instanceof 
                                org.apache.axis.handlers.http.URLMapper));

        Handler transportOne_handler_byName = 
                server.getHandler("ForwardReference");
        assertTrue("transport.one's 'ForwardReference' should be same as directly accessed 'BR'!",
                   (transportOne_responseFlow_handler == 
                            transportOne_handler_byName));

        TargetedChain transportTwo = 
                (TargetedChain)server.getTransport("transport.two");
        assertNotNull("transport.two should be non-null!", transportTwo);

        Chain transportTwo_requestFlow = (Chain) transportTwo.getRequestHandler();
        assertNotNull("transport.two/requestFlow should be non-null!",
                      transportTwo_requestFlow);

        Handler transportTwo_requestFlow_handlers[] = 
                transportTwo_requestFlow.getHandlers();
        assertNotNull("transport.two/requestFlow/handlers should be non-null!",
                      transportTwo_requestFlow_handlers);
        assertTrue("transport.two should have exactly 1 handler!",
                (1 == transportTwo_requestFlow_handlers.length));

        Handler transportTwo_requestFlow_handler = transportTwo_requestFlow_handlers[0];
        assertNotNull("transport.two's handler should be non-null!",
                      transportTwo_requestFlow_handler);
        assertTrue("transport.two's handler should be a URLMapper!",
                    (transportTwo_requestFlow_handler instanceof 
                        org.apache.axis.handlers.http.URLMapper));

        assertTrue("transport.two's 'ForwardReference' should be same as transport.one's!",
                   (transportTwo_requestFlow_handler == transportOne_responseFlow_handler));
    }
}