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.tools.java2wsdl.generator.wsdl11.annotator;
19:
20: import java.util.List;
21: import javax.xml.namespace.QName;
22:
23: import org.apache.cxf.tools.java2wsdl.generator.wsdl11.model.WrapperBeanClass;
24: import org.junit.Assert;
25: import org.junit.Test;
26:
27: public class WrapperBeanAnnotatorTest extends Assert {
28:
29: @Test
30: public void testAnnotate() {
31: String pkgName = "org.apache.cxf.tools.fortest.withannotation.doc.jaxws";
32: WrapperBeanClass clz = new WrapperBeanClass();
33: clz.setFullClassName(pkgName + ".SayHi");
34: clz
35: .setElementName(new QName(
36: "http://doc.withannotation.fortest.tools.cxf.apache.org/",
37: "sayHi"));
38:
39: clz.annotate(new WrapperBeanAnnotator());
40: List<String> annotations = clz.getAnnotations();
41:
42: String expectedNamespace = "http://doc.withannotation.fortest.tools.cxf.apache.org/";
43:
44: assertTrue(annotations
45: .contains("@XmlRootElement(namespace = \""
46: + expectedNamespace + "\", name = \"sayHi\")"));
47: assertTrue(annotations.contains("@XmlType(namespace = \""
48: + expectedNamespace + "\", name = \"sayHi\")"));
49: assertTrue(annotations
50: .contains("@XmlAccessorType(XmlAccessType.FIELD)"));
51:
52: WrapperBeanClass resWrapperClass = new WrapperBeanClass();
53: resWrapperClass.setFullClassName(pkgName + ".SayHiResponse");
54: resWrapperClass
55: .setElementName(new QName(
56: "http://doc.withannotation.fortest.tools.cxf.apache.org/",
57: "sayHiResponse"));
58:
59: resWrapperClass.annotate(new WrapperBeanAnnotator());
60: annotations = resWrapperClass.getAnnotations();
61:
62: assertTrue(annotations
63: .contains("@XmlRootElement(namespace = \""
64: + expectedNamespace
65: + "\", name = \"sayHiResponse\")"));
66: assertTrue(annotations.contains("@XmlType(namespace = \""
67: + expectedNamespace + "\", name = \"sayHiResponse\")"));
68: assertTrue(annotations
69: .contains("@XmlAccessorType(XmlAccessType.FIELD)"));
70: }
71: }
|