Author: mir
Date: Tue Mar 2 12:53:19 2010
New Revision: 918010
URL: http://svn.apache.org/viewvc?rev=918010&view=rev
Log:
CLEREZZA-129: merged changes from r917951 into trunk
Added:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/FormParamTest.java
- copied unchanged from r918006,
incubator/clerezza/issues/CLEREZZA-129/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/FormParamTest.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/util/TemplateEncoderTest.java
- copied unchanged from r918006,
incubator/clerezza/issues/CLEREZZA-129/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/util/TemplateEncoderTest.java
Removed:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/util/TestTemplateEncoder.java
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/
(props changed)
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/pom.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/AbstractServiceRootResourceTest.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/FelixServiceRootResourceTest.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/SimpleRootResource.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/pom.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/JaxRsHandler.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceDescriptor.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResources.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/util/TemplateEncoder.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/util/URITemplate.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/TestTemplate.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ResourcePathTest.java
Propchange:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 2 12:53:19 2010
@@ -1,4 +1,5 @@
/incubator/clerezza/issues/CLEREZZA-109/org.apache.clerezza.triaxrs:910447-910450
+/incubator/clerezza/issues/CLEREZZA-129/org.apache.clerezza.triaxrs:910457-918006
/incubator/clerezza/issues/CLEREZZA-43/org.apache.clerezza.triaxrs:891792-892499
/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs:893435-898896
/incubator/clerezza/issues/CLEREZZA-86/org.apache.clerezza.triaxrs:903135-910335
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/pom.xml?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/pom.xml
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/pom.xml
Tue Mar 2 12:53:19 2010
@@ -69,7 +69,17 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-osgi</artifactId>
<scope>provided</scope>
- <version>4.0</version>
+ <version>4.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.utils</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore-osgi</artifactId>
+ <scope>provided</scope>
</dependency>
<!-- pax exam related stuff -->
<dependency>
@@ -86,15 +96,7 @@
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-default</artifactId>
<scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore-osgi</artifactId>
- <version>4.0.1</version>
- <scope>test</scope>
- </dependency>
-
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -111,7 +113,6 @@
<plugin>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>maven-paxexam-plugin</artifactId>
- <version>1.2.0</version>
<executions>
<execution>
<id>generate-depends-file</id>
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/AbstractServiceRootResourceTest.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/AbstractServiceRootResourceTest.java?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/AbstractServiceRootResourceTest.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/AbstractServiceRootResourceTest.java
Tue Mar 2 12:53:19 2010
@@ -69,6 +69,8 @@
@Test
public void getHello() throws Exception {
URL serverURL = new URL("http://localhost:" + testHttpPort +
"/foo");
+ System.out.println("I AM HERE!");
+ Thread.sleep(40000);
HttpURLConnection connection = (HttpURLConnection)
serverURL.openConnection();
Assert.assertEquals("text/plain",
connection.getHeaderField("Content-Type"));
Reader reader = new
InputStreamReader(connection.getInputStream());
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/FelixServiceRootResourceTest.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/FelixServiceRootResourceTest.java?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/FelixServiceRootResourceTest.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/FelixServiceRootResourceTest.java
Tue Mar 2 12:53:19 2010
@@ -50,11 +50,20 @@
/*dsProfile(),*/
configProfile(),
webProfile(),
+ profile("felix.webconsole"),
junitBundles(),
frameworks(
felix()),
systemProperty("org.osgi.service.http.port").value(
- Integer.toString(testHttpPort)));
+ Integer.toString(testHttpPort))
+ // this just adds all what you write here to
java vm argumenents of the (new) osgi process.
+
//,vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
+ // this is necessary to let junit runner not
timout the remote process before attaching debugger
+ // setting timeout to 0 means wait as long as
the remote service comes available.
+ // starting with version 0.5.0 of PAx Exam this
is no longer required as by default the framework tests
+ // will not be triggered till the framework is
not started
+ //waitForFrameworkStartup()
+ );
}
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/SimpleRootResource.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/SimpleRootResource.java?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/SimpleRootResource.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs.tests/src/test/java/org/apache/clerezza/triaxrs/blackbox/osgi/SimpleRootResource.java
Tue Mar 2 12:53:19 2010
@@ -26,7 +26,7 @@
*
* @author reto
*/
-...@path("foo")
+...@path("/foo")
public class SimpleRootResource {
static final public String greeting = "hello";
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/pom.xml?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/pom.xml
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/pom.xml
Tue Mar 2 12:53:19 2010
@@ -29,6 +29,10 @@
<artifactId>org.apache.clerezza.jaxrs.extensions</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.utils</artifactId>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/JaxRsHandler.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/JaxRsHandler.java?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/JaxRsHandler.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/JaxRsHandler.java
Tue Mar 2 12:53:19 2010
@@ -24,7 +24,6 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
@@ -60,7 +59,6 @@
import org.apache.clerezza.triaxrs.providers.ProvidersImpl;
import org.apache.clerezza.triaxrs.util.MethodUtil;
import org.apache.clerezza.triaxrs.util.PathMatching;
-import org.apache.clerezza.triaxrs.util.TemplateEncoder;
import org.wymiwyg.wrhapi.Handler;
import org.wymiwyg.wrhapi.HandlerException;
import org.wymiwyg.wrhapi.HeaderName;
@@ -383,23 +381,15 @@
String pathPrefix) {
Path path = clazz.getAnnotation(Path.class);
if (path != null) {
- // URI encode the template, ignoring URI template
variable
- // specifications.
- String encodedPathTemplate;
- try {
- encodedPathTemplate =
TemplateEncoder.encode(pathPrefix
- + path.value(), "utf-8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
RootResourceDescriptor rootResourceDescriptor;
collectHttpMethods(clazz);
+ String completePath = pathPrefix + path.value();
if (instance == null) {
rootResourceDescriptor = new
RootResourceDescriptor(clazz,
- encodedPathTemplate);
+ completePath);
} else {
rootResourceDescriptor = new
RootResourceDescriptor(clazz,
- instance, encodedPathTemplate,
providers);
+ instance, completePath,
providers);
}
rootResources.add(rootResourceDescriptor);
applicationProvidedDescriptors.add(rootResourceDescriptor);
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceDescriptor.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceDescriptor.java?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceDescriptor.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceDescriptor.java
Tue Mar 2 12:53:19 2010
@@ -37,18 +37,18 @@
private Object instance;
private Logger logger =
LoggerFactory.getLogger(RootResourceDescriptor.class);
- public RootResourceDescriptor(Class<?> clazz, String
encodedPathTemplate) {
+ public RootResourceDescriptor(Class<?> clazz, String pathTemplate) {
super();
- uriTemplate = new URITemplate(encodedPathTemplate);
+ uriTemplate = new URITemplate(pathTemplate);
this.clazz = clazz;
//store methods of the class
//httpMethodsOfClass = ReflectionUtil.getMethodsOfClass(clazz);
}
public RootResourceDescriptor(Class<?> clazz, Object instance,
- String encodedPathTemplate, Providers providers) {
+ String pathTemplate, Providers providers) {
super();
- uriTemplate = new URITemplate(encodedPathTemplate);
+ uriTemplate = new URITemplate(pathTemplate);
this.clazz = clazz;
this.instance = instance;
if (instance != null) {
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/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/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
Tue Mar 2 12:53:19 2010
@@ -23,7 +23,6 @@
import org.apache.clerezza.jaxrs.extensions.HttpRequest;
import org.apache.clerezza.jaxrs.extensions.MethodResponse;
import org.apache.clerezza.jaxrs.extensions.RootResourceExecutor;
-import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -60,6 +59,7 @@
import org.apache.clerezza.triaxrs.util.PathMatching;
import org.apache.clerezza.triaxrs.util.TemplateEncoder;
import org.apache.clerezza.triaxrs.util.URITemplate;
+import org.apache.clerezza.utils.UriException;
import org.wymiwyg.wrhapi.HandlerException;
import org.wymiwyg.wrhapi.HeaderName;
@@ -592,7 +592,7 @@
private String templateUrlEncode(String value) {
try {
return TemplateEncoder.encode(value, "utf-8");
- } catch (UnsupportedEncodingException e) {
+ } catch (UriException e) {
throw new RuntimeException(e);
}
}
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResources.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResources.java?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResources.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResources.java
Tue Mar 2 12:53:19 2010
@@ -16,131 +16,140 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.clerezza.triaxrs;
-
+package org.apache.clerezza.triaxrs;
+
import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.clerezza.triaxrs.util.PathMatching;
+import org.apache.clerezza.triaxrs.util.TemplateEncoder;
+import org.apache.clerezza.utils.UriException;
+import org.apache.clerezza.utils.UriUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wymiwyg.wrhapi.HandlerException;
-
-/**
- * Manages a set of root-resources delivering a suitable root-resource given a
- * path.
- *
- * @author reto
- */
-public class RootResources {
-
- /**
- * @author mir
- *
- */
- public static class ResourceAndPathMatching {
-
- private Object rootResource;
- private PathMatching pathMatching;
-
- public ResourceAndPathMatching(Object rootResource,
- PathMatching pathMatching) {
- this.rootResource = rootResource;
- this.pathMatching = pathMatching;
- }
-
- public Object getRootResource() {
- return rootResource;
- }
-
- public PathMatching getPathMatching() {
- return pathMatching;
- }
-
- }
-
- private static ThreadLocal<String> requestUri = new
ThreadLocal<String>() {
- };
-
- public static String getCurrentRequestUri() {
- return requestUri.get();
- }
-
- final static private Logger logger = LoggerFactory
- .getLogger(RootResources.class);
-
- /**
- * we store the resource descriptors
- */
- SortedSet<RootResourceDescriptor> rootResourceDescriptors = new
TreeSet<RootResourceDescriptor>();
-
- /**
- * adds a {...@link RootResourceDescriptor}
- *
- * @param descriptor
- */
- public void add(RootResourceDescriptor descriptor) {
- // TODO Flag an error if the set includes more than one instance
- // of the same class.
- rootResourceDescriptors.add(descriptor);
- }
-
- /**
- * removes a {...@link RootResourceDescriptor}
- *
- * @param descriptor
- */
- public void remove(RootResourceDescriptor descriptor) {
- rootResourceDescriptors.remove(descriptor);
- }
-
- /**
- *
- * @return the number of available root resources
- */
- public int size() {
- return rootResourceDescriptors.size();
- }
-
- /**
- * Get the best matching root-resource for a path
- *
- * @param uriPath
- * @return the matching root-resource or null if no root resources
matches
- */
- public RootResourceDescriptor getDescriptor(String uriPath) {
- for (RootResourceDescriptor descriptor :
rootResourceDescriptors) {
-
- PathMatching pathMatching =
descriptor.getUriTemplate().match(
- uriPath);
- if (pathMatching != null) {
- return descriptor;
- }
- }
- return null;
- }
-
- ResourceAndPathMatching getResourceAndPathMatching(WebRequest request)
- throws HandlerException,
NoMatchingRootResourceException {
- String uriPath =
request.getWrhapiRequest().getRequestURI().getPath();
- requestUri.set(uriPath);
- PathMatching pathMatching = null;
- RootResourceDescriptor descriptor = null;
- Iterator<RootResourceDescriptor> descriptorIter =
rootResourceDescriptors
- .iterator();
- while (descriptorIter.hasNext()) {
- descriptor = descriptorIter.next();
- pathMatching =
descriptor.getUriTemplate().match(uriPath);
- if (pathMatching != null) {
- break;
- }
- }
-
- if (pathMatching == null) {
- throw new NoMatchingRootResourceException();
- }
- return new
ResourceAndPathMatching(descriptor.getInstance(request,
- pathMatching.getParameters()), pathMatching);
- }
-}
+
+/**
+ * Manages a set of root-resources delivering a suitable root-resource given a
+ * path.
+ *
+ * @author reto
+ */
+public class RootResources {
+
+ /**
+ * @author mir
+ *
+ */
+ public static class ResourceAndPathMatching {
+
+ private Object rootResource;
+ private PathMatching pathMatching;
+
+ public ResourceAndPathMatching(Object rootResource,
+ PathMatching pathMatching) {
+ this.rootResource = rootResource;
+ this.pathMatching = pathMatching;
+ }
+
+ public Object getRootResource() {
+ return rootResource;
+ }
+
+ public PathMatching getPathMatching() {
+ return pathMatching;
+ }
+
+ }
+
+ private static ThreadLocal<String> requestUri = new
ThreadLocal<String>() {
+ };
+
+ public static String getCurrentRequestUri() {
+ return requestUri.get();
+ }
+
+ final static private Logger logger = LoggerFactory
+ .getLogger(RootResources.class);
+
+ /**
+ * we store the resource descriptors
+ */
+ SortedSet<RootResourceDescriptor> rootResourceDescriptors = new
TreeSet<RootResourceDescriptor>();
+
+ /**
+ * adds a {...@link RootResourceDescriptor}
+ *
+ * @param descriptor
+ */
+ public void add(RootResourceDescriptor descriptor) {
+ // TODO Flag an error if the set includes more than one instance
+ // of the same class.
+ rootResourceDescriptors.add(descriptor);
+ }
+
+ /**
+ * removes a {...@link RootResourceDescriptor}
+ *
+ * @param descriptor
+ */
+ public void remove(RootResourceDescriptor descriptor) {
+ rootResourceDescriptors.remove(descriptor);
+ }
+
+ /**
+ *
+ * @return the number of available root resources
+ */
+ public int size() {
+ return rootResourceDescriptors.size();
+ }
+
+ /**
+ * Get the best matching root-resource for a path
+ *
+ * @param uriPath
+ * @return the matching root-resource or null if no root resources
matches
+ */
+ public RootResourceDescriptor getDescriptor(String uriPath) {
+ for (RootResourceDescriptor descriptor :
rootResourceDescriptors) {
+
+ PathMatching pathMatching =
descriptor.getUriTemplate().match(
+ uriPath);
+ if (pathMatching != null) {
+ return descriptor;
+ }
+ }
+ return null;
+ }
+
+ ResourceAndPathMatching getResourceAndPathMatching(WebRequest request)
+ throws HandlerException,
NoMatchingRootResourceException {
+ String uriPath;
+ try {
+ uriPath =
UriUtil.encodePartlyEncodedPath(request.getWrhapiRequest().getRequestURI().getPath(),
"UTF-8");
+ } catch (UriException ex) {
+ throw new RuntimeException(ex);
+ }
+ requestUri.set(uriPath);
+
+ PathMatching pathMatching = null;
+ RootResourceDescriptor descriptor = null;
+ Iterator<RootResourceDescriptor> descriptorIter =
rootResourceDescriptors
+ .iterator();
+ while (descriptorIter.hasNext()) {
+ descriptor = descriptorIter.next();
+ pathMatching =
descriptor.getUriTemplate().match(uriPath);
+ if (pathMatching != null) {
+ break;
+ }
+ }
+
+ if (pathMatching == null) {
+ throw new NoMatchingRootResourceException();
+ }
+ return new
ResourceAndPathMatching(descriptor.getInstance(request,
+ pathMatching.getParameters()), pathMatching);
+ }
+}
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/util/TemplateEncoder.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/util/TemplateEncoder.java?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/util/TemplateEncoder.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/util/TemplateEncoder.java
Tue Mar 2 12:53:19 2010
@@ -1,131 +1,12 @@
package org.apache.clerezza.triaxrs.util;
-//copied and modified from java.net.URLEncoder
-
-/*
- * @(#)URLEncoder.java 1.32 06/04/22
- *
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
- */
-
-import java.io.CharArrayWriter;
-import java.io.UnsupportedEncodingException;
+import java.io.StringWriter;
import java.net.URLDecoder;
-import java.nio.charset.Charset;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.UnsupportedCharsetException;
-import java.util.BitSet;
+import org.apache.clerezza.utils.UriException;
+import org.apache.clerezza.utils.UriUtil;
-/**
- * Utility class for HTML form encoding. This class contains static methods for
- * converting a String to the <CODE>application/x-www-form-urlencoded</CODE>
- * MIME format. For more information about HTML form encoding, consult the HTML
- * <A HREF="http://www.w3.org/TR/html4/">specification</A>.
- *
- * <p>
- * When encoding a String, the following rules apply:
- *
- * <p>
- * <ul>
- * <li>The alphanumeric characters "<code>a</code>" through "
- * <code>z</code>", "<code>A</code>" through
"<code>Z</code>
- * " and "<code>0</code>" through "<code>9</code>"
- * remain the same.
- * <li>The special characters "<code>.</code>", "<code>-</code>
- * ", "<code>*</code>", and "<code>_</code>" remain
the
- * same.
- * <li>The space character "<code> </code>" is converted into a
- * plus sign "<code>+</code>".
- * <li>All other characters are unsafe and are first converted into one or more
- * bytes using some encoding scheme. Then each byte is represented by the
- * 3-character string "<code>%<i>xy</i></code>", where <i>xy</i> is
- * the two-digit hexadecimal representation of the byte. The recommended
- * encoding scheme to use is UTF-8. However, for compatibility reasons, if an
- * encoding is not specified, then the default encoding of the platform is
used.
- * </ul>
- *
- * <p>
- * For example using UTF-8 as the encoding scheme the string "The string
- * ü@foo-bar" would get converted to
- * "The+string+%C3%BC%40foo-bar" because in UTF-8 the character
ü
- * is encoded as two bytes C3 (hex) and BC (hex), and the character @ is
encoded
- * as one byte 40 (hex).
- *
- * @author Herb Jellinek
- * @version 1.32, 04/22/06
- * @since JDK1.0
- */
public class TemplateEncoder {
- static BitSet dontNeedEncoding;
- static final int caseDiff = ('a' - 'A');
- static String dfltEncName = "utf-8";
-
- static {
-
- /*
- * The list of characters that are not encoded has been
determined as
- * follows:
- *
- * RFC 2396 states: ----- Data characters that are allowed in a
URI but
- * do not have a reserved purpose are called unreserved. These
include
- * upper and lower case letters, decimal digits, and a limited
set of
- * punctuation marks and symbols.
- *
- * unreserved = alphanum | mark
- *
- * mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
- *
- * Unreserved characters can be escaped without changing the
semantics
- * of the URI, but this should not be done unless the URI is
being used
- * in a context that does not allow the unescaped character to
appear.
- * -----
- *
- * It appears that both Netscape and Internet Explorer escape
all
- * special characters from this list with the exception of "-",
"_",
- * ".", "*". While it is not clear why they are escaping the
other
- * characters, perhaps it is safest to assume that there might
be
- * contexts in which the others are unsafe if not escaped.
Therefore, we
- * will use the same list. It is also noteworthy that this is
consistent
- * with O'Reilly's "HTML: The Definitive Guide" (page 164).
- *
- * As a last note, Intenet Explorer does not encode the "@"
character
- * which is clearly not unreserved according to the RFC. We are
being
- * consistent with the RFC in this matter, as is Netscape.
- */
-
- dontNeedEncoding = new BitSet(256);
- int i;
- for (i = 'a'; i <= 'z'; i++) {
- dontNeedEncoding.set(i);
- }
- for (i = 'A'; i <= 'Z'; i++) {
- dontNeedEncoding.set(i);
- }
- for (i = '0'; i <= '9'; i++) {
- dontNeedEncoding.set(i);
- }
- dontNeedEncoding.set(' '); /*
- *
encoding a space to a + is done in the
- *
encode() method
- */
- dontNeedEncoding.set('-');
- dontNeedEncoding.set('_');
- dontNeedEncoding.set('.');
- dontNeedEncoding.set('*');
- dontNeedEncoding.set('{');
- dontNeedEncoding.set('}');
- dontNeedEncoding.set('/');
- /*
- *
https://jsr311.dev.java.net/nonav/releases/0.10/javax/ws/rs/Path.html:
- * Note that percent encoded values are allowed in the literal
part of
- * the value, an implementation will recognize such values and
will not
- * double encode the '%' character.
- */
- dontNeedEncoding.set('%');
-
- }
-
+
/**
* You can't call the constructor.
*/
@@ -133,31 +14,6 @@
}
/**
- * Translates a string into <code>x-www-form-urlencoded</code> format.
This
- * method uses the platform's default encoding as the encoding scheme to
- * obtain the bytes for unsafe characters.
- *
- * @param s
- * <code>String</code> to be translated.
- * @deprecated The resulting string may vary depending on the platform's
- * default encoding. Instead, use the encode(String,String)
- * method to specify the encoding.
- * @return the translated <code>String</code>.
- */
- public static String encode(String s) {
-
- String str = null;
-
- try {
- str = encode(s, dfltEncName);
- } catch (UnsupportedEncodingException e) {
- // The system should always have the platform default
- }
-
- return str;
- }
-
- /**
* Translates a string into
<code>application/x-www-form-urlencoded</code>
* format using a specific encoding scheme. This method uses the
supplied
* encoding scheme to obtain the bytes for unsafe characters.
@@ -168,7 +24,7 @@
* UTF-8 should be used. Not doing so may introduce
* incompatibilites.</em>
*
- * @param s
+ * @param pathTemplate
* <code>String</code> to be translated.
* @param enc
* The name of a supported <a
@@ -180,111 +36,25 @@
* @see URLDecoder#decode(java.lang.String, java.lang.String)
* @since 1.4
*/
- public static String encode(String s, String enc)
- throws UnsupportedEncodingException {
-
- boolean needToChange = false;
- StringBuffer out = new StringBuffer(s.length());
- Charset charset;
- CharArrayWriter charArrayWriter = new CharArrayWriter();
-
- if (enc == null)
- throw new NullPointerException("charsetName");
-
- try {
- charset = Charset.forName(enc);
- } catch (IllegalCharsetNameException e) {
- throw new UnsupportedEncodingException(enc);
- } catch (UnsupportedCharsetException e) {
- throw new UnsupportedEncodingException(enc);
- }
- boolean inVariableName = false;
- for (int i = 0; i < s.length();) {
- int c = (int) s.charAt(i);
- if (c == '{') {
- out.append((char) c);
- inVariableName = true;
- i++;
- continue;
+ public static String encode(String pathTemplate, String enc)
+ throws UriException {
+ StringWriter sw = new StringWriter();
+ int index = 0;
+ while(true) {
+ int openCurlyIndex = pathTemplate.indexOf('{', index);
+ if (openCurlyIndex == -1) {
+ break;
}
- if (inVariableName) {
- out.append((char) c);
- i++;
- if (c == '}') {
- inVariableName = false;
- }
- continue;
- }
- // System.out.println("Examining character: " + c);
- if (dontNeedEncoding.get(c)) {
- if (c == ' ') {
- c = '+';
- needToChange = true;
- }
- // System.out.println("Storing: " + c);
- out.append((char) c);
- i++;
- } else {
- // convert to external encoding before hex
conversion
- do {
- charArrayWriter.write(c);
- /*
- * If this character represents the
start of a Unicode
- * surrogate pair, then pass in two
characters. It's not
- * clear what should be done if a bytes
reserved in the
- * surrogate pairs range occurs outside
of a legal surrogate
- * pair. For now, just treat it as if
it were any other
- * character.
- */
- if (c >= 0xD800 && c <= 0xDBFF) {
- /*
- *
System.out.println(Integer.toHexString(c) +
- * " is high surrogate");
- */
- if ((i + 1) < s.length()) {
- int d = (int)
s.charAt(i + 1);
- /*
- *
System.out.println("\tExamining " +
- *
Integer.toHexString(d));
- */
- if (d >= 0xDC00 && d <=
0xDFFF) {
- /*
- *
System.out.println("\t" +
- *
Integer.toHexString(d) +
- * " is low
surrogate");
- */
-
charArrayWriter.write(d);
- i++;
- }
- }
- }
- i++;
- } while (i < s.length()
- && !dontNeedEncoding.get((c =
(int) s.charAt(i))));
-
- charArrayWriter.flush();
- String str = new
String(charArrayWriter.toCharArray());
- byte[] ba = str.getBytes(charset);
- for (int j = 0; j < ba.length; j++) {
- out.append('%');
- char ch = Character.forDigit((ba[j] >>
4) & 0xF, 16);
- // converting to use uppercase letter
as part of
- // the hex value if ch is a letter.
- if (Character.isLetter(ch)) {
- ch -= caseDiff;
- }
- out.append(ch);
- ch = Character.forDigit(ba[j] & 0xF,
16);
- if (Character.isLetter(ch)) {
- ch -= caseDiff;
- }
- out.append(ch);
- }
- charArrayWriter.reset();
- needToChange = true;
+ int closeCurlyIndex = pathTemplate.indexOf('}',
openCurlyIndex);
+ if (closeCurlyIndex == -1) {
+ break;
}
+
sw.append(UriUtil.encodePartlyEncodedPath(pathTemplate.substring(index,
openCurlyIndex), enc));
+ sw.append(pathTemplate.substring(openCurlyIndex,
closeCurlyIndex + 1));
+ index = closeCurlyIndex + 1;
}
-
- return (needToChange ? out.toString() : s);
+
sw.append(UriUtil.encodePartlyEncodedPath(pathTemplate.substring(index,
pathTemplate.length()),enc));
+ return sw.toString();
}
+
}
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/util/URITemplate.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/util/URITemplate.java?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/util/URITemplate.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/util/URITemplate.java
Tue Mar 2 12:53:19 2010
@@ -27,6 +27,7 @@
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.clerezza.utils.UriException;
public class URITemplate implements Comparable<URITemplate> {
@@ -67,6 +68,11 @@
private String templateString;
public URITemplate(String rawTemplateString) {
+ try {
+ rawTemplateString =
TemplateEncoder.encode(rawTemplateString, "UTF-8");
+ } catch (UriException ex) {
+ throw new RuntimeException(ex);
+ }
if ((rawTemplateString.length() > 0) &&
(rawTemplateString.charAt(0) == '/')) {
this.templateString = rawTemplateString.substring(1);
} else {
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/TestTemplate.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/TestTemplate.java?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/TestTemplate.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/TestTemplate.java
Tue Mar 2 12:53:19 2010
@@ -23,7 +23,6 @@
import org.junit.Before;
import org.junit.Test;
-import org.apache.clerezza.triaxrs.JaxRsHandler;
import org.apache.clerezza.triaxrs.delegate.RuntimeDelegateImpl;
import org.apache.clerezza.triaxrs.mock.RequestImpl;
import org.apache.clerezza.triaxrs.mock.RequestURIImpl;
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ResourcePathTest.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ResourcePathTest.java?rev=918010&r1=918009&r2=918010&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ResourcePathTest.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ResourcePathTest.java
Tue Mar 2 12:53:19 2010
@@ -18,22 +18,19 @@
*/
package org.apache.clerezza.triaxrs.blackbox;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
import static org.junit.Assert.assertTrue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
-import org.easymock.EasyMock;
import org.junit.Test;
import org.apache.clerezza.triaxrs.JaxRsHandler;
+import org.apache.clerezza.triaxrs.mock.RequestImpl;
+import org.apache.clerezza.triaxrs.mock.RequestURIImpl;
+import org.apache.clerezza.triaxrs.mock.ResponseImpl;
import org.apache.clerezza.triaxrs.testutils.HandlerCreator;
+import org.junit.Before;
import org.wymiwyg.wrhapi.Method;
-import org.wymiwyg.wrhapi.Request;
-import org.wymiwyg.wrhapi.RequestURI;
-import org.wymiwyg.wrhapi.Response;
-
public class ResourcePathTest {
@@ -46,25 +43,121 @@
public void handleGet() {
methodInvokedForGet = true;
}
+
+ @Path("bar%20foo")
+ @GET
+ public void handleGet2() {
+ methodInvokedForGet = true;
+ }
+
+ @Path("da ja")
+ @GET
+ public void handleGet3() {
+ methodInvokedForGet = true;
+ }
+ }
+
+ @Path("test%20resource")
+ public static class MyResource2 {
+
+ @GET
+ public void handleGet() {
+ methodInvokedForGet = true;
+ }
+ }
+
+ @Path("bla bla")
+ public static class MyResource3 {
+
+ @GET
+ public void handleGet() {
+ methodInvokedForGet = true;
+ }
+ }
+
+ @Path("test+resource")
+ public static class MyResource4 {
+
+ @GET
+ public void handleGet() {
+ methodInvokedForGet = true;
+ }
+ }
+
+ @Before
+ public void reset() {
+ methodInvokedForGet = false;
+ }
+
+ @Test
+ public void requestOnResourcePathTest() throws Exception {
+ JaxRsHandler handler =
HandlerCreator.getHandler(MyResource.class);
+ RequestImpl requestMock = new RequestImpl();
+ RequestURIImpl requestUri = new RequestURIImpl();
+ requestUri.setPath("/foo");
+ requestMock.setRequestURI(requestUri);
+ requestMock.setMethod(Method.GET);
+ handler.handle(requestMock, new ResponseImpl());
+ assertTrue(methodInvokedForGet);
+ }
+
+ @Test
+ public void requestOnResourcePathContainingEncodedSpaceTest() throws
Exception {
+ JaxRsHandler handler =
HandlerCreator.getHandler(MyResource2.class);
+ RequestImpl requestMock = new RequestImpl();
+ RequestURIImpl requestUri = new RequestURIImpl();
+ requestUri.setPath("/test%20resource");
+ requestMock.setRequestURI(requestUri);
+ requestMock.setMethod(Method.GET);
+ handler.handle(requestMock, new ResponseImpl());
+ assertTrue(methodInvokedForGet);
}
@Test
- public void testOptions() throws Exception {
+ public void requestOnResourcePathContainingPlusTest() throws Exception {
+ JaxRsHandler handler =
HandlerCreator.getHandler(MyResource4.class);
+ RequestImpl requestMock = new RequestImpl();
+ RequestURIImpl requestUri = new RequestURIImpl();
+ requestUri.setPath("/test+resource");
+ requestMock.setRequestURI(requestUri);
+ requestMock.setMethod(Method.GET);
+ handler.handle(requestMock, new ResponseImpl());
+ assertTrue(methodInvokedForGet);
+ }
+
+ @Test
+ public void requestOnResourcePathContainingSpaceTest() throws Exception
{
+ JaxRsHandler handler =
HandlerCreator.getHandler(MyResource3.class);
+ RequestImpl requestMock = new RequestImpl();
+ RequestURIImpl requestUri = new RequestURIImpl();
+ requestUri.setPath("/bla%20bla");
+ requestMock.setRequestURI(requestUri);
+ requestMock.setMethod(Method.GET);
+ handler.handle(requestMock, new ResponseImpl());
+ assertTrue(methodInvokedForGet);
+ }
+ @Test
+ public void reqOnResMethodPathContainingEncSpaceTest() throws Exception
{
JaxRsHandler handler =
HandlerCreator.getHandler(MyResource.class);
-
- Request requestMock = EasyMock.createNiceMock(Request.class);
- Response responseMock = EasyMock.createNiceMock(Response.class);
-
expect(requestMock.getMethod()).andReturn(Method.GET).anyTimes();
- RequestURI requestURI =
EasyMock.createNiceMock(RequestURI.class);
- expect(requestURI.getPath()).andReturn("/foo");
-
expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
- replay(requestMock);
- replay(requestURI);
- replay(responseMock);
- handler.handle(requestMock, responseMock);
+ RequestImpl requestMock = new RequestImpl();
+ RequestURIImpl requestUri = new RequestURIImpl();
+ requestUri.setPath("/foo/bar%20foo");
+ requestMock.setRequestURI(requestUri);
+ requestMock.setMethod(Method.GET);
+ handler.handle(requestMock, new ResponseImpl());
assertTrue(methodInvokedForGet);
+ }
+ @Test
+ public void reqOnResMethodPathContainingSpaceTest() throws Exception {
+ JaxRsHandler handler =
HandlerCreator.getHandler(MyResource.class);
+ RequestImpl requestMock = new RequestImpl();
+ RequestURIImpl requestUri = new RequestURIImpl();
+ requestUri.setPath("/foo/da%20ja");
+ requestMock.setRequestURI(requestUri);
+ requestMock.setMethod(Method.GET);
+ handler.handle(requestMock, new ResponseImpl());
+ assertTrue(methodInvokedForGet);
}
}
-