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: */package org.apache.cxf.aegis.type.java5;
19:
20: import java.lang.reflect.Method;
21:
22: import javax.xml.namespace.QName;
23:
24: import org.w3c.dom.Document;
25:
26: import org.apache.cxf.aegis.AbstractAegisTest;
27: import org.apache.cxf.aegis.type.Configuration;
28: import org.apache.cxf.aegis.type.CustomTypeMapping;
29: import org.apache.cxf.aegis.type.DefaultTypeCreator;
30: import org.apache.cxf.aegis.type.Type;
31: import org.junit.Before;
32: import org.junit.Test;
33:
34: public class XmlParamTypeTest extends AbstractAegisTest {
35: private CustomTypeMapping tm;
36: private Java5TypeCreator creator;
37:
38: @Before
39: public void setUp() throws Exception {
40: super .setUp();
41:
42: tm = new CustomTypeMapping();
43: creator = new Java5TypeCreator();
44: creator.setNextCreator(new DefaultTypeCreator());
45: creator.setConfiguration(new Configuration());
46: tm.setTypeCreator(creator);
47: }
48:
49: @Test
50: public void testType() throws Exception {
51: Method m = CustomTypeService.class.getMethod("doFoo",
52: new Class[] { String.class });
53:
54: Type type = creator.createType(m, 0);
55: tm.register(type);
56: assertTrue(type instanceof CustomStringType);
57: assertEquals(new QName("urn:xfire:foo", "custom"), type
58: .getSchemaType());
59:
60: type = creator.createType(m, -1);
61: tm.register(type);
62: assertTrue(type instanceof CustomStringType);
63: assertEquals(new QName("urn:xfire:foo", "custom"), type
64: .getSchemaType());
65: }
66:
67: @Test
68: public void testMapServiceWSDL() throws Exception {
69: createService(CustomTypeService.class, null);
70:
71: Document wsdl = getWSDLDocument("CustomTypeService");
72: assertValid("//xsd:element[@name='s'][@type='ns0:custom']",
73: wsdl);
74: }
75:
76: public class CustomTypeService {
77:
78: @XmlReturnType(type=CustomStringType.class,namespace="urn:xfire:foo",name="custom")
79: public String doFoo(
80: @XmlParamType(type=CustomStringType.class,namespace="urn:xfire:foo",name="custom")
81: String s) {
82: return null;
83: }
84: }
85: }
|