01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.axis2.description;
21:
22: import org.apache.axis2.AbstractTestCase;
23: import org.apache.axis2.AxisFault;
24: import org.apache.axis2.context.MessageContext;
25: import org.apache.axis2.engine.AxisConfiguration;
26: import org.apache.axis2.engine.Handler;
27: import org.apache.axis2.handlers.AbstractHandler;
28:
29: import javax.xml.namespace.QName;
30:
31: public class RegistryTest extends AbstractTestCase {
32: private AxisConfiguration reg = new AxisConfiguration();
33: AxisService service = new AxisService("Service1");
34:
35: public RegistryTest(String testName) {
36: super (testName);
37: }
38:
39: public void testHandlerMetadata() throws AxisFault {
40: HandlerDescription hmd = new HandlerDescription();
41: testParameteInClude(hmd);
42: }
43:
44: public void testService() throws AxisFault {
45: reg.addService(service);
46: testParameteInClude(service);
47: }
48:
49: public void testModule() throws AxisFault {
50: AxisModule module = new AxisModule("module1");
51: module.setParent(reg);
52: testParameteInClude(module);
53: testFlowIncludeTest(module);
54: }
55:
56: public void testOperation() throws AxisFault {
57: AxisOperation op = new InOutAxisOperation(new QName("op"));
58: op.setParent(service);
59: testParameteInClude(op);
60: }
61:
62: public void testParameteInClude(ParameterInclude parmInclude)
63: throws AxisFault {
64: String key = "value1";
65: Parameter p = new Parameter(key, "value2");
66: parmInclude.addParameter(p);
67: assertEquals(p, parmInclude.getParameter(key));
68: }
69:
70: public void testFlowIncludeTest(AxisModule flowInclude) {
71: Flow flow1 = new Flow();
72: Flow flow2 = new Flow();
73: Flow flow3 = new Flow();
74:
75: flowInclude.setInFlow(flow1);
76: flowInclude.setFaultInFlow(flow2);
77: flowInclude.setOutFlow(flow3);
78: assertSame(flow1, flowInclude.getInFlow());
79: assertSame(flow2, flowInclude.getFaultInFlow());
80: assertSame(flow3, flowInclude.getOutFlow());
81: }
82:
83: public void testHandlers() throws AxisFault {
84: Handler handler = new AbstractHandler() {
85:
86: public InvocationResponse invoke(MessageContext msgContext) {
87: return InvocationResponse.CONTINUE;
88: }
89: };
90: handler.init(new HandlerDescription());
91: assertNull(handler.getName());
92: assertNull(handler.getParameter("hello"));
93: }
94:
95: }
|