Author: reto
Date: Tue Jan 26 11:46:14 2010
New Revision: 903185
URL: http://svn.apache.org/viewvc?rev=903185&view=rev
Log:
CLEREZZA-86: applied agron's patch, fixed test
Added:
incubator/clerezza/issues/CLEREZZA-86/
incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs/
- copied from r903134,
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/
Modified:
incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java
Modified:
incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java?rev=903185&r1=903134&r2=903185&view=diff
==============================================================================
---
incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
(original)
+++
incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
Tue Jan 26 11:46:14 2010
@@ -59,6 +59,7 @@
import org.apache.clerezza.triaxrs.util.URITemplate;
import org.wymiwyg.wrhapi.HandlerException;
import org.wymiwyg.wrhapi.HeaderName;
+import org.wymiwyg.wrhapi.RequestURI;
/**
* @scr.component
@@ -239,6 +240,12 @@
for (Method method : result) {
method2PathParams.put(method,
inheritedPathParams);
}
+ } else
if(remainingPath.equals(RequestURI.Type.NO_RESOURCE.toString())){
+ result =
MethodUtil.getAnnotatedMethods(instance.getClass());
+ for (Method method : result){
+ method.getDeclaredAnnotations();
+ method2PathParams.put(method,
inheritedPathParams);
+ }
} else {
SortedSet<MethodDescriptor> methodDescriptors =
getSubThingMethodDescriptors(instance
.getClass());
@@ -544,7 +551,7 @@
String allowHeader = "";
for (Annotation annotation : annotationList) {
HttpMethod httpMethod =
annotation.annotationType().getAnnotation(HttpMethod.class);
- if (httpMethod != null) {
+ if (httpMethod != null &&
!(allowHeader.contains(httpMethod.value()))) {
allowHeader += httpMethod.value()+",";
}
}
Modified:
incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java?rev=903185&r1=903134&r2=903185&view=diff
==============================================================================
---
incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java
(original)
+++
incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java
Tue Jan 26 11:46:14 2010
@@ -41,6 +41,7 @@
import org.wymiwyg.wrhapi.HeaderName;
import org.wymiwyg.wrhapi.Method;
+import org.wymiwyg.wrhapi.RequestURI;
public class AutoGeneratedOptionsTest {
@@ -123,4 +124,29 @@
Assert.assertFalse(allow.contains("POST"));
Assert.assertFalse(allow.contains("FOO"));
}
+
+ @Test
+ public void testResponseToOptionsRequestWithNoResource() throws
Exception {
+ JaxRsHandler handler =
HandlerCreator.getHandler(MyResource.class);
+ RequestURIImpl uri = new RequestURIImpl();
+ RequestImpl request = new RequestImpl();
+ ResponseImpl response = new ResponseImpl();
+
+ uri.setType(RequestURI.Type.NO_RESOURCE);
+ request.setRequestURI(uri);
+ request.setMethod(Method.OPTIONS);
+ handler.handle(request, response);
+ Map<HeaderName,String[]> headers = response.getHeaders();
+ String[] allowHeader = headers.get(HeaderName.ALLOW);
+ Assert.assertNotNull(allowHeader);
+ String allow = "";
+ for(String st : allowHeader){
+ allow += st;
+ }
+
+ Assert.assertTrue(allow.contains("PROPFIND"));
+ Assert.assertTrue(allow.contains("GET"));
+ Assert.assertTrue(allow.contains("POST"));
+ Assert.assertTrue(allow.contains("FOO"));
+ }
}