01: /*
02: * Copyright 2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package org.springframework.ws.server.endpoint.mapping;
18:
19: import javax.xml.namespace.QName;
20:
21: import junit.framework.TestCase;
22: import org.springframework.ws.MockWebServiceMessage;
23: import org.springframework.ws.MockWebServiceMessageFactory;
24: import org.springframework.ws.context.DefaultMessageContext;
25: import org.springframework.ws.context.MessageContext;
26:
27: public class PayloadRootQNameEndpointMappingTest extends TestCase {
28:
29: private PayloadRootQNameEndpointMapping mapping;
30:
31: protected void setUp() throws Exception {
32: mapping = new PayloadRootQNameEndpointMapping();
33: }
34:
35: public void testResolveQNames() throws Exception {
36: MockWebServiceMessage request = new MockWebServiceMessage(
37: "<root/>");
38: MessageContext context = new DefaultMessageContext(request,
39: new MockWebServiceMessageFactory());
40:
41: QName qName = mapping.resolveQName(context);
42: assertNotNull("mapping returns null", qName);
43: assertEquals("mapping returns invalid qualified name",
44: new QName("root"), qName);
45: }
46:
47: public void testGetQNameNameNamespace() throws Exception {
48: MockWebServiceMessage request = new MockWebServiceMessage(
49: "<prefix:localname xmlns:prefix=\"namespace\"/>");
50: MessageContext context = new DefaultMessageContext(request,
51: new MockWebServiceMessageFactory());
52:
53: QName qName = mapping.resolveQName(context);
54: assertNotNull("mapping returns null", qName);
55: assertEquals("mapping returns invalid method name", new QName(
56: "namespace", "localname", "prefix"), qName);
57: }
58: }
|