cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r707100 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/model/ main/java/org/apache/cxf/jaxrs/utils/ test/java/org/apache/cxf/jaxrs/ test/java/org/apache/cxf/jaxrs/utils/
Date Wed, 22 Oct 2008 15:23:57 GMT
Author: sergeyb
Date: Wed Oct 22 08:23:56 2008
New Revision: 707100

URL: http://svn.apache.org/viewvc?rev=707100&view=rev
Log:
JAX-RS : fixing a typo introducing during refactoring with test

Added:
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/AnnotationTestUtilsTest.java
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/CustomerInfo.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java?rev=707100&r1=707099&r2=707100&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
Wed Oct 22 08:23:56 2008
@@ -84,8 +84,10 @@
     }
     
     public void setAnnotatedMethod(Method m) {
-        annotatedMethod = m;
-        checkMediaTypes();
+        if (m != null) {
+            annotatedMethod = m;
+            checkMediaTypes();
+        }
     }
     
     public Method getAnnotatedMethod() {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java?rev=707100&r1=707099&r2=707100&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
Wed Oct 22 08:23:56 2008
@@ -153,6 +153,12 @@
     }
     
     public static Method getAnnotatedMethod(Method m) {
+        Method annotatedMethod = doGetAnnotatedMethod(m);
+        return annotatedMethod == null ? m : annotatedMethod;
+    }
+    
+    private static Method doGetAnnotatedMethod(Method m) {
+        
         if (m == null) {
             return m;
         }
@@ -162,15 +168,16 @@
                 return m;
             }        
         }
-        
-        if (isMethodParamAnnotations(m.getAnnotations())) {
-            return m;
+        for (Annotation[] paramAnnotations : m.getParameterAnnotations()) {
+            if (isMethodParamAnnotations(paramAnnotations)) {
+                return m;
+            }
         }
         
         Class<?> superC = m.getDeclaringClass().getSuperclass();
-        if (superC != null) {
+        if (superC != null && Object.class != superC) {
             try {
-                Method method = getAnnotatedMethod(superC.getMethod(m.getName(), m.getParameterTypes()));
+                Method method = doGetAnnotatedMethod(superC.getMethod(m.getName(), m.getParameterTypes()));
                 if (method != null) {
                     return method;
                 }
@@ -180,7 +187,7 @@
         }
         for (Class<?> i : m.getDeclaringClass().getInterfaces()) {
             try {
-                Method method = getAnnotatedMethod(i.getMethod(m.getName(), m.getParameterTypes()));
+                Method method = doGetAnnotatedMethod(i.getMethod(m.getName(), m.getParameterTypes()));
                 if (method != null) {
                     return method;
                 }
@@ -188,7 +195,8 @@
                 // ignore
             }
         }
-        return m;
+        
+        return null;
     }
     
    

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/CustomerInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/CustomerInfo.java?rev=707100&r1=707099&r2=707100&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/CustomerInfo.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/CustomerInfo.java Wed Oct
22 08:23:56 2008
@@ -21,7 +21,9 @@
 
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.ContextResolver;
 
 public interface CustomerInfo {
-    void setUriInfoContext(@Context UriInfo uriInfo); 
+    void setUriInfoContext(@Context UriInfo uriInfo);
+    ContextResolver getContextResolver();
 }

Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/AnnotationTestUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/AnnotationTestUtilsTest.java?rev=707100&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/AnnotationTestUtilsTest.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/AnnotationTestUtilsTest.java
Wed Oct 22 08:23:56 2008
@@ -0,0 +1,57 @@
+/**
+ * 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.jaxrs.utils;
+
+import java.lang.reflect.Method;
+
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.cxf.jaxrs.Customer;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class AnnotationTestUtilsTest extends Assert {
+
+    @Test
+    public void testGetAnnotatedMethodFromInterface() throws Exception {
+        
+        Method m = 
+            Customer.class.getMethod("setUriInfoContext", 
+                                     new Class[]{UriInfo.class});
+        assertEquals(0, m.getAnnotations().length);
+        assertEquals(0, m.getParameterAnnotations()[0].length);
+        Method annotatedMethod = AnnotationUtils.getAnnotatedMethod(m);
+        assertNotSame(m, annotatedMethod);
+        assertEquals(1, annotatedMethod.getParameterAnnotations()[0].length);
+    }
+    
+    @Test
+    public void testGetAnnotatedMethodFromClass() throws Exception {
+        
+        Method m = 
+            Customer.class.getMethod("getContextResolver", 
+                                     new Class[]{});
+        assertEquals(0, m.getAnnotations().length);
+        Method annotatedMethod = AnnotationUtils.getAnnotatedMethod(m);
+        assertSame(m, annotatedMethod);
+    }
+    
+    
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/AnnotationTestUtilsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/AnnotationTestUtilsTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message