cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r611013 [2/2] - in /incubator/cxf/trunk/rt/databinding/aegis/src: main/java/org/apache/cxf/aegis/type/java5/ main/java/org/codehaus/ main/java/org/codehaus/xfire/ main/java/org/codehaus/xfire/aegis/ main/java/org/codehaus/xfire/aegis/type/ ...
Date Fri, 11 Jan 2008 01:44:49 GMT
Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireBean4.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireBean4.java?rev=611013&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireBean4.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireBean4.java
Thu Jan 10 17:44:45 2008
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.java5;
+
+@SuppressWarnings("deprecation")
+@org.codehaus.xfire.aegis.type.java5.XmlType(extensibleElements = false, extensibleAttributes
= false)
+public class XFireBean4 {
+    private String nillableProperty;
+
+    private String minOccursProperty;
+
+    @org.codehaus.xfire.aegis.type.java5.XmlElement(nillable = false)
+    public String getNillableProperty() {
+        return nillableProperty;
+    }
+
+    public void setNillableProperty(String nillableProperty) {
+        this.nillableProperty = nillableProperty;
+    }
+
+    @org.codehaus.xfire.aegis.type.java5.XmlElement(minOccurs = "1")
+    public String getMinOccursProperty() {
+        return minOccursProperty;
+    }
+
+    public void setMinOccursProperty(String minOccursProperty) {
+        this.minOccursProperty = minOccursProperty;
+    }
+}
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireBean4.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireBean4.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireService.java?rev=611013&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireService.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireService.java
Thu Jan 10 17:44:45 2008
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.java5;
+
+public class XFireService {
+    public XFireBean1 getXFireBean1() {
+        XFireBean1 bean = new XFireBean1();
+        bean.setAttributeProperty("attribute");
+        bean.setBogusProperty("bogus");
+        bean.setElementProperty("element");
+
+        return bean;
+    }
+
+    public XFireBean2 getXFireBean2() {
+        XFireBean2 bean = new XFireBean2();
+        bean.setAttributeProperty("attribute");
+        bean.setElementProperty("element");
+
+        return bean;
+    }
+}
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTestEnum.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTestEnum.java?rev=611013&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTestEnum.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTestEnum.java
Thu Jan 10 17:44:45 2008
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.java5;
+
+@SuppressWarnings("deprecation")
+@org.codehaus.xfire.aegis.type.java5.XmlType(namespace = "urn:xfire:foo")
+public enum XFireTestEnum {
+    VALUE1, VALUE2
+}
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTestEnum.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTestEnum.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTypeTest.java?rev=611013&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTypeTest.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTypeTest.java
Thu Jan 10 17:44:45 2008
@@ -0,0 +1,184 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.java5;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.apache.cxf.aegis.type.XMLTypeCreator;
+import org.apache.cxf.aegis.type.basic.BeanType;
+import org.apache.cxf.aegis.type.basic.StringType;
+import org.apache.cxf.common.util.SOAPConstants;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.service.Service;
+import org.junit.Before;
+import org.junit.Test;
+
+public class XFireTypeTest extends AbstractAegisTest {
+    private TypeMapping tm;
+    private Service service;
+    private AegisDatabinding databinding;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+
+        Server s = createService(XFireService.class);
+        service = s.getEndpoint().getService();
+        databinding = (AegisDatabinding) service.getDataBinding();
+
+        tm = databinding.getAegisContext().getTypeMapping();
+    }
+
+    @Test
+    public void testTM() {
+        assertTrue(tm.getTypeCreator() instanceof XMLTypeCreator);
+    }
+
+    @Test
+    public void testType() {
+        AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, XFireBean1.class, "urn:foo");
+
+        Iterator elements = info.getElements();
+        assertTrue(elements.hasNext());
+        QName element = (QName)elements.next();
+        assertTrue(elements.hasNext());
+
+        Type custom = info.getType(element);
+
+        if ("bogusProperty".equals(element.getLocalPart())) {
+            assertTrue(custom instanceof StringType);
+        } else if ("elementProperty".equals(element.getLocalPart())) {
+            assertTrue(custom instanceof CustomStringType);
+        } else {
+            fail("Unexpected element name: " + element.getLocalPart());
+        }
+        element = (QName)elements.next();
+        assertFalse(elements.hasNext());
+
+        custom = info.getType(element);
+
+        if ("bogusProperty".equals(element.getLocalPart())) {
+            assertTrue(custom instanceof StringType);
+        } else if ("elementProperty".equals(element.getLocalPart())) {
+            assertTrue(custom instanceof CustomStringType);
+        } else {
+            fail("Unexpected element name: " + element.getLocalPart());
+        }
+
+        Iterator atts = info.getAttributes();
+        assertTrue(atts.hasNext());
+        atts.next();
+        assertFalse(atts.hasNext());
+
+        assertTrue(info.isExtensibleElements());
+        assertTrue(info.isExtensibleAttributes());
+    }
+
+    @Test
+    public void testAegisType() {
+        BeanType type = (BeanType)tm.getTypeCreator().createType(XFireBean3.class);
+
+        assertFalse(type.getTypeInfo().getAttributes().hasNext());
+
+        Iterator itr = type.getTypeInfo().getElements();
+        assertTrue(itr.hasNext());
+        QName q = (QName)itr.next();
+        assertEquals("attProp", q.getLocalPart());
+    }
+
+    @Test
+    public void testExtensibilityOff() {
+        BeanType type = (BeanType)tm.getTypeCreator().createType(XFireBean4.class);
+
+        assertFalse(type.getTypeInfo().isExtensibleElements());
+        assertFalse(type.getTypeInfo().isExtensibleAttributes());
+    }
+
+    @Test
+    public void testNillableAndMinOccurs() {
+        BeanType type = (BeanType)tm.getTypeCreator().createType(XFireBean4.class);
+        AnnotatedTypeInfo info = (AnnotatedTypeInfo)type.getTypeInfo();
+        Iterator elements = info.getElements();
+        assertTrue(elements.hasNext());
+        // nillable first
+        QName element = (QName)elements.next();
+        if ("minOccursProperty".equals(element.getLocalPart())) {
+            assertEquals(1, info.getMinOccurs(element));
+        } else {
+            assertFalse(info.isNillable(element));
+        }
+
+        assertTrue(elements.hasNext());
+        // minOccurs = 1 second
+        element = (QName)elements.next();
+        if ("minOccursProperty".equals(element.getLocalPart())) {
+            assertEquals(1, info.getMinOccurs(element));
+        } else {
+            assertFalse(info.isNillable(element));
+        }
+    }
+
+    @Test
+    public void testWSDL() throws Exception {
+        Document wsdl = getWSDLDocument("XFireService");
+
+        addNamespace("xsd", SOAPConstants.XSD);
+        assertValid(
+                    "//xsd:complexType[@name='XFireBean1']/xsd:sequence/xsd:"
+                    + "element[@name='elementProperty']",
+                    wsdl);
+        assertValid("//xsd:complexType[@name='XFireBean1']/xsd:attribute"
+                    + "[@name='attributeProperty']",
+                    wsdl);
+        assertValid(
+                    "//xsd:complexType[@name='XFireBean1']/xsd:sequence/xsd:element"
+                    + "[@name='bogusProperty']",
+                    wsdl);
+
+        assertValid(
+                    "//xsd:complexType[@name='XFireBean2']/xsd:sequence/xsd:element"
+                    + "[@name='element'][@type='xsd:string']",
+                    wsdl);
+        assertValid(
+                    "//xsd:complexType[@name='XFireBean2']/xsd:attribute"
+                    + "[@name='attribute'][@type='xsd:string']",
+                    wsdl);
+    }
+
+    @Test
+    public void testGetSetRequired() throws Exception {
+        BeanType type = new BeanType(new AnnotatedTypeInfo(tm, BadBean.class, "urn:foo"));
+        type.setSchemaType(new QName("urn:foo", "BadBean"));
+
+        assertFalse(type.getTypeInfo().getElements().hasNext());
+    }
+
+    public static class BadBean {
+        public void setString(String string) {
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTypeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTypeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireXmlParamTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireXmlParamTypeTest.java?rev=611013&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireXmlParamTypeTest.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireXmlParamTypeTest.java
Thu Jan 10 17:44:45 2008
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.java5;
+
+import java.lang.reflect.Method;
+import javax.xml.namespace.QName;
+import org.w3c.dom.Document;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.type.Configuration;
+import org.apache.cxf.aegis.type.CustomTypeMapping;
+import org.apache.cxf.aegis.type.DefaultTypeCreator;
+import org.apache.cxf.aegis.type.Type;
+import org.junit.Before;
+import org.junit.Test;
+
+@SuppressWarnings("deprecation")
+public class XFireXmlParamTypeTest extends AbstractAegisTest {
+    private CustomTypeMapping tm;
+    private Java5TypeCreator creator;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+
+        tm = new CustomTypeMapping();
+        creator = new Java5TypeCreator();
+        creator.setNextCreator(new DefaultTypeCreator());
+        creator.setConfiguration(new Configuration());
+        tm.setTypeCreator(creator);
+    }
+
+    @Test
+    public void testType() throws Exception {
+        Method m = CustomTypeService.class.getMethod("doFoo", new Class[] {String.class});
+
+        Type type = creator.createType(m, 0);
+        tm.register(type);
+        assertTrue(type instanceof CustomStringType);
+        assertEquals(new QName("urn:xfire:foo", "custom"), type.getSchemaType());
+
+        type = creator.createType(m, -1);
+        tm.register(type);
+        assertTrue(type instanceof CustomStringType);
+        assertEquals(new QName("urn:xfire:foo", "custom"), type.getSchemaType());
+    }
+
+    @Test
+    public void testMapServiceWSDL() throws Exception {
+        createService(CustomTypeService.class, new CustomTypeService(), null);
+
+        Document wsdl = getWSDLDocument("CustomTypeService");
+        assertValid("//xsd:element[@name='s'][@type='ns0:custom']", wsdl);
+    }
+
+    public class CustomTypeService {
+
+        @org.codehaus.xfire.aegis.type.java5.XmlReturnType(type = CustomStringType.class,

+                                                           namespace = "urn:xfire:foo", name
= "custom")
+        public String doFoo(
+                            @org.codehaus.xfire.aegis.type.java5.XmlParamType(type = CustomStringType.class,
+                                          namespace = "urn:xfire:foo", name = "custom")
+                            String s) {
+            return null;
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireXmlParamTypeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireXmlParamTypeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message