You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2017/11/21 11:15:11 UTC

[cxf] branch master updated (fff17b4 -> 3d964a1)

This is an automated email from the ASF dual-hosted git repository.

sergeyb pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from fff17b4  [CXF-7561] Adding missing resources
     new 21645b1  Update TypeVariable check ResourceUtils.java and UnitTest
     new 00a73dd  Merge branch 'fix-resource-utils' of git://github.com/evaristowb/cxf into evaristowb-fix-resource-utils
     new 3d964a1  Merge branch 'evaristowb-fix-resource-utils'

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/cxf/jaxrs/utils/ResourceUtils.java  |   4 +-
 .../cxf/jaxrs/model/wadl/WadlGeneratorTest.java    | 120 +++++++++++++++++++++
 2 files changed, 123 insertions(+), 1 deletion(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@cxf.apache.org" <co...@cxf.apache.org>'].

[cxf] 01/03: Update TypeVariable check ResourceUtils.java and UnitTest

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sergeyb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 21645b13d26fe235befa5c0b8a2c431a8bde34b1
Author: Evaristo Wychoski Benfatti <ev...@ubuntu-server>
AuthorDate: Mon Nov 20 10:04:24 2017 -0200

    Update TypeVariable check ResourceUtils.java and UnitTest
---
 .../org/apache/cxf/jaxrs/utils/ResourceUtils.java  |   4 +-
 .../cxf/jaxrs/model/wadl/WadlGeneratorTest.java    | 120 +++++++++++++++++++++
 2 files changed, 123 insertions(+), 1 deletion(-)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
index 90c4d95..a8d05ef 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
@@ -27,6 +27,7 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.security.AccessController;
@@ -696,7 +697,8 @@ public final class ResourceUtils {
             type = InjectionUtils.getActualType(genericType);
             isCollection = true;
         }
-        if (type == Object.class && !(genericType instanceof Class)) {
+        if (type == Object.class && !(genericType instanceof Class)
+            || genericType instanceof TypeVariable) {
             Type theType = InjectionUtils.processGenericTypeIfNeeded(serviceClass,
                                                       Object.class,
                                                       genericType);
diff --git a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
index 55acf61..7e397f3 100644
--- a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
+++ b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
@@ -44,6 +44,7 @@ import org.apache.cxf.endpoint.EndpointImpl;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.jaxrs.JAXRSServiceImpl;
 import org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl;
+import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
@@ -936,4 +937,123 @@ public class WadlGeneratorTest extends Assert {
             return transfer;
         }
     }
+
+    @XmlRootElement(namespace = "http://example.com")
+    public static class Super {
+        private int id;
+        private String name;
+        public int getId() {
+            return id;
+        }
+        public void setId(int id) {
+            this.id = id;
+        }
+        public String getName() {
+            return name;
+        }
+        public void setName(String name) {
+            this.name = name;
+        }
+    }
+
+    public static class SuperResource<T extends Super> {
+
+        @PUT
+        @Path("set")
+        @Produces("application/xml")
+        @Consumes("application/xml")
+        public T set(T transfer) {
+            return transfer;
+        }
+
+    }
+
+    @XmlRootElement(namespace = "http://example.com")
+    public static class Actual extends Super { }
+
+    public static class ActualResource extends SuperResource<Actual> { }
+
+    private void setUpGenericImplementationTest() {
+        ServerProviderFactory.getInstance().clearProviders();
+        AbstractResourceInfo.clearAllMaps();
+    }
+
+    @Test
+    public void testGenericImplementation() throws Exception {
+        setUpGenericImplementationTest();
+
+        WadlGenerator wg = new WadlGenerator();
+        wg.setApplicationTitle("My Application");
+        wg.setNamespacePrefix("ns");
+        ClassResourceInfo cri =
+            ResourceUtils.createClassResourceInfo(ActualResource.class, ActualResource.class, true, true);
+        Message m = mockMessage("http://example.com", "/", WadlGenerator.WADL_QUERY, cri);
+        Response r = handleRequest(wg, m);
+        checkResponse(r);
+        Document doc = StaxUtils.read(new StringReader(r.getEntity().toString()));
+        checkDocs(doc.getDocumentElement(), "My Application", "", "");
+        List<Element> grammarEls = DOMUtils.getChildrenWithName(doc.getDocumentElement(),
+                                                                WadlGenerator.WADL_NS,
+                                                                "grammars");
+        assertEquals(1, grammarEls.size());
+        List<Element> schemasEls = DOMUtils.getChildrenWithName(grammarEls.get(0),
+                                                                Constants.URI_2001_SCHEMA_XSD,
+                                                                "schema");
+        assertEquals(2, schemasEls.size());
+        assertEquals("http://example.com", schemasEls.get(0).getAttribute("targetNamespace"));
+        assertEquals("http://example.com", schemasEls.get(1).getAttribute("targetNamespace"));
+
+        List<Element> importEls = DOMUtils.getChildrenWithName(schemasEls.get(0),
+                Constants.URI_2001_SCHEMA_XSD,
+                "import");
+        assertEquals(1, importEls.size());
+
+        List<Element> typeEls = DOMUtils.getChildrenWithName(schemasEls.get(0),
+                Constants.URI_2001_SCHEMA_XSD,
+                "element");
+        assertEquals(2, typeEls.size());
+        assertEquals("actual", typeEls.get(0).getAttribute("name"));
+        assertEquals("actual", typeEls.get(0).getAttribute("type"));
+        assertEquals("super", typeEls.get(1).getAttribute("name"));
+        assertEquals("super", typeEls.get(1).getAttribute("type"));
+
+        List<Element> complexTypeEls = DOMUtils.getChildrenWithName(schemasEls.get(1),
+                Constants.URI_2001_SCHEMA_XSD,
+                "complexType");
+        assertEquals(2, complexTypeEls.size());
+        assertEquals("actual", complexTypeEls.get(0).getAttribute("name"));
+        assertEquals("super", complexTypeEls.get(1).getAttribute("name"));
+
+        Element ccActualElement =
+                (Element)complexTypeEls.get(0).getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD,
+                                                  "complexContent").item(0);
+        Element extensionActualElement =
+            (Element)ccActualElement.getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD,
+                                              "extension").item(0);
+        Element sequenceActualElement =
+                (Element)ccActualElement.getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD,
+                                                  "sequence").item(0);
+        assertEquals("super", extensionActualElement.getAttribute("base"));
+        assertEquals(0, sequenceActualElement.getChildNodes().getLength());
+
+        Element sequenceSuperElement =
+                (Element)complexTypeEls.get(1).getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD,
+                                                  "sequence").item(0);
+        List<Element> superEls = DOMUtils.getChildrenWithName(sequenceSuperElement,
+                Constants.URI_2001_SCHEMA_XSD,
+                "element");
+        assertEquals(2, superEls.size());
+        assertEquals("id", superEls.get(0).getAttribute("name"));
+        assertEquals("xs:int", superEls.get(0).getAttribute("type"));
+        assertEquals("name", superEls.get(1).getAttribute("name"));
+        assertEquals("xs:string", superEls.get(1).getAttribute("type"));
+
+        List<Element> reps = DOMUtils.findAllElementsByTagNameNS(doc.getDocumentElement(),
+                                       WadlGenerator.WADL_NS, "representation");
+        assertEquals(2, reps.size());
+        assertEquals("ns1:actual", reps.get(0).getAttribute("element"));
+        assertEquals("ns1:actual", reps.get(1).getAttribute("element"));
+
+    }
+
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.

[cxf] 02/03: Merge branch 'fix-resource-utils' of git://github.com/evaristowb/cxf into evaristowb-fix-resource-utils

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sergeyb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 00a73dd200ee6b2df2bba96738b0641e4f59daf9
Merge: fff17b4 21645b1
Author: Sergey Beryozkin <sb...@gmail.com>
AuthorDate: Tue Nov 21 11:08:58 2017 +0000

    Merge branch 'fix-resource-utils' of git://github.com/evaristowb/cxf into evaristowb-fix-resource-utils

 .../org/apache/cxf/jaxrs/utils/ResourceUtils.java  |   4 +-
 .../cxf/jaxrs/model/wadl/WadlGeneratorTest.java    | 120 +++++++++++++++++++++
 2 files changed, 123 insertions(+), 1 deletion(-)

-- 
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.

[cxf] 03/03: Merge branch 'evaristowb-fix-resource-utils'

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sergeyb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 3d964a1f62598ce2f289792912f5e0e4ab11e9a2
Merge: fff17b4 00a73dd
Author: Sergey Beryozkin <sb...@gmail.com>
AuthorDate: Tue Nov 21 11:14:29 2017 +0000

    Merge branch 'evaristowb-fix-resource-utils'

 .../org/apache/cxf/jaxrs/utils/ResourceUtils.java  |   4 +-
 .../cxf/jaxrs/model/wadl/WadlGeneratorTest.java    | 120 +++++++++++++++++++++
 2 files changed, 123 insertions(+), 1 deletion(-)

-- 
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.