[exo-jcr-commits] exo-jcr SVN: r2698 - in ws/trunk: exo.ws.rest.core/src/test/java/org/exoplatform/services/rest and 6 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Jun 24 11:06:32 EDT 2010
Author: aparfonov
Date: 2010-06-24 11:06:31 -0400 (Thu, 24 Jun 2010)
New Revision: 2698
Added:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/tools/ResourceLauncher.java
Removed:
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/AbstractResourceTest.java
Modified:
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/BaseTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/RequestFilterTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ResponseFilterTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/HeadMethodTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MediaTypeTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodInvokerFilterTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodReturnTypeTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/OptionsMethodTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/ParametersInjectionTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ContextResolverTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ExceptionMapperTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/FormEntityTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JAXBEntityTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JsonEntityTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/OtherEntityTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ProviderContextParameterInjectionTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/AcceptResourceTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/AnnotationInheritanceTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ApplicationTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ContextParametersInjectionTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/MatchedURIsAndResourcesTest.java
ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/BaseTest.java
ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyContextParamTest.java
ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyDependenciesTest.java
ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyExoComponentTest.java
ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySecureRestrictionTest.java
ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySimpleTest.java
Log:
EXOJCR-230 :
Added: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/tools/ResourceLauncher.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/tools/ResourceLauncher.java (rev 0)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/tools/ResourceLauncher.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -0,0 +1,101 @@
+/**
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.rest.tools;
+
+import org.exoplatform.services.rest.ContainerResponseWriter;
+import org.exoplatform.services.rest.RequestHandler;
+import org.exoplatform.services.rest.impl.ContainerRequest;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.impl.EnvironmentContext;
+import org.exoplatform.services.rest.impl.InputHeadersMap;
+import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
+
+import java.io.ByteArrayInputStream;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class ResourceLauncher
+{
+ private final RequestHandler requestHandler;
+
+ public ResourceLauncher(RequestHandler requestHandler)
+ {
+ this.requestHandler = requestHandler;
+ }
+
+ /**
+ * @param method HTTP method
+ * @param requestURI full requested URI
+ * @param baseURI base requested URI
+ * @param headers HTTP headers
+ * @param data data
+ * @param writer response writer
+ * @param env environment context
+ * @return response
+ * @throws Exception if any error occurs
+ */
+ public ContainerResponse service(String method, String requestURI, String baseURI,
+ Map<String, List<String>> headers, byte[] data, ContainerResponseWriter writer, EnvironmentContext env)
+ throws Exception
+ {
+
+ if (headers == null)
+ headers = new MultivaluedMapImpl();
+
+ ByteArrayInputStream in = null;
+ if (data != null)
+ in = new ByteArrayInputStream(data);
+
+ if (env == null)
+ env = new EnvironmentContext();
+ EnvironmentContext.setCurrent(env);
+
+ if (writer == null)
+ writer = new DummyContainerResponseWriter();
+
+ ContainerRequest request =
+ new ContainerRequest(method, new URI(requestURI), new URI(baseURI), in, new InputHeadersMap(headers));
+ ContainerResponse response = new ContainerResponse(writer);
+ requestHandler.handleRequest(request, response);
+ return response;
+ }
+
+ /**
+ * @param method HTTP method
+ * @param requestURI full requested URI
+ * @param baseURI base requested URI
+ * @param headers HTTP headers
+ * @param data data
+ * @param env environment context
+ * @return response
+ * @throws Exception if any error occurs
+ */
+ public ContainerResponse service(String method, String requestURI, String baseURI,
+ Map<String, List<String>> headers, byte[] data, EnvironmentContext env) throws Exception
+ {
+ return service(method, requestURI, baseURI, headers, data, new DummyContainerResponseWriter(), env);
+ }
+
+}
Property changes on: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/tools/ResourceLauncher.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Deleted: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/AbstractResourceTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/AbstractResourceTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/AbstractResourceTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.rest;
-
-import org.exoplatform.services.rest.impl.ContainerRequest;
-import org.exoplatform.services.rest.impl.ContainerResponse;
-import org.exoplatform.services.rest.impl.EnvironmentContext;
-import org.exoplatform.services.rest.impl.InputHeadersMap;
-import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
-import org.exoplatform.services.rest.tools.DummyContainerResponseWriter;
-import org.exoplatform.services.test.mock.MockHttpServletRequest;
-
-import java.io.ByteArrayInputStream;
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.MultivaluedMap;
-
-/**
- * @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
- * @version $Id: $
- */
-public abstract class AbstractResourceTest extends BaseTest
-{
-
- // public void setUp() throws Exception {
- // super.setUp();
- // }
-
- public ContainerResponse service(String method, String requestURI, String baseURI,
- Map<String, List<String>> headers, byte[] data, ContainerResponseWriter writer) throws Exception
- {
-
- if (headers == null)
- headers = new MultivaluedMapImpl();
-
- ByteArrayInputStream in = null;
- if (data != null)
- in = new ByteArrayInputStream(data);
-
- EnvironmentContext envctx = new EnvironmentContext();
- HttpServletRequest httpRequest =
- new MockHttpServletRequest("", in, in != null ? in.available() : 0, method, headers);
- envctx.put(HttpServletRequest.class, httpRequest);
- EnvironmentContext.setCurrent(envctx);
- ContainerRequest request =
- new ContainerRequest(method, new URI(requestURI), new URI(baseURI), in, new InputHeadersMap(headers));
- ContainerResponse response = new ContainerResponse(writer);
- requestHandler.handleRequest(request, response);
- return response;
- }
-
- public ContainerResponse service(String method, String requestURI, String baseURI,
- MultivaluedMap<String, String> headers, byte[] data) throws Exception
- {
- return service(method, requestURI, baseURI, headers, data, new DummyContainerResponseWriter());
-
- }
-
-}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/BaseTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/BaseTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/BaseTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -25,6 +25,7 @@
import org.exoplatform.services.rest.impl.ProviderBinder;
import org.exoplatform.services.rest.impl.RequestHandlerImpl;
import org.exoplatform.services.rest.impl.ResourceBinder;
+import org.exoplatform.services.rest.tools.ResourceLauncher;
/**
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
@@ -41,6 +42,8 @@
protected RequestHandlerImpl requestHandler;
+ protected ResourceLauncher launcher;
+
public void setUp() throws Exception
{
StandaloneContainer.setConfigurationPath("src/test/resources/conf/standalone/test-configuration.xml");
@@ -53,6 +56,7 @@
// System.out.println("##########################"+providers);
ApplicationContextImpl.setCurrent(new ApplicationContextImpl(null, null, providers));
binder.clear();
+ launcher = new ResourceLauncher(requestHandler);
}
public void tearDown() throws Exception
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.ExtHttpHeaders;
import org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter;
@@ -34,7 +34,7 @@
* @author <a href="mailto:max.shaposhnik at exoplatform.com">Max Shaposhnik</a>
* @version $Id: ExceptionsTest
*/
-public class ExceptionsTest extends AbstractResourceTest
+public class ExceptionsTest extends BaseTest
{
@Path("a")
@@ -100,7 +100,7 @@
public void testErrorResponse() throws Exception
{
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
- ContainerResponse response = service("GET", "/a/4", "", null, null, writer);
+ ContainerResponse response = launcher.service("GET", "/a/4", "", null, null, writer, null);
assertEquals(500, response.getStatus());
String entity = new String(writer.getBody());
assertEquals(errorMessage, entity);
@@ -110,7 +110,7 @@
public void testUncheckedException() throws Exception
{
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
- ContainerResponse response = service("GET", "/a/3", "", null, null, writer);
+ ContainerResponse response = launcher.service("GET", "/a/3", "", null, null, writer, null);
assertEquals(500, response.getStatus());
String entity = new String(writer.getBody());
assertEquals(errorMessage, entity);
@@ -120,7 +120,7 @@
public void testWebApplicationExceptionWithCause() throws Exception
{
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
- ContainerResponse response = service("GET", "/a/0", "", null, null, writer);
+ ContainerResponse response = launcher.service("GET", "/a/0", "", null, null, writer, null);
assertEquals(500, response.getStatus());
String entity = new String(writer.getBody());
assertEquals(new Exception(errorMessage).toString(), entity);
@@ -130,7 +130,7 @@
public void testWebApplicationExceptionWithoutCause() throws Exception
{
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
- ContainerResponse response = service("GET", "/a/2", "", null, null, writer);
+ ContainerResponse response = launcher.service("GET", "/a/2", "", null, null, writer, null);
assertEquals(500, response.getStatus());
assertNull(response.getEntity());
assertNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
@@ -139,7 +139,7 @@
public void testWebApplicationExceptionWithResponse() throws Exception
{
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
- ContainerResponse response = service("GET", "/a/1", "", null, null, writer);
+ ContainerResponse response = launcher.service("GET", "/a/1", "", null, null, writer, null);
assertEquals(500, response.getStatus());
String entity = new String(writer.getBody());
assertEquals(errorMessage, entity);
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,9 +18,10 @@
*/
package org.exoplatform.services.rest.impl;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.GenericContainerResponse;
import org.exoplatform.services.rest.Property;
+import org.exoplatform.services.test.mock.MockHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Encoded;
@@ -39,7 +40,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class RequestDispatcherTest extends AbstractResourceTest
+public class RequestDispatcherTest extends BaseTest
{
@Path("/a")
@@ -107,12 +108,12 @@
{
Resource1 r1 = new Resource1();
registry(r1);
- assertEquals("m0", service("POST", "/a", "", null, null).getEntity());
- assertEquals("m1", service("POST", "/a/b", "", null, null).getEntity());
- assertEquals("m2.0", service("POST", "/a/b/c", "", null, null).getEntity());
- assertEquals("m2.1", service("POST", "/a/b/c/d", "", null, null).getEntity());
- assertEquals("m3.0", service("POST", "/a/b/c/d/e", "", null, null).getEntity());
- assertEquals("m3.1", service("POST", "/a/b/c/d/e/f", "", null, null).getEntity());
+ assertEquals("m0", launcher.service("POST", "/a", "", null, null, null).getEntity());
+ assertEquals("m1", launcher.service("POST", "/a/b", "", null, null, null).getEntity());
+ assertEquals("m2.0", launcher.service("POST", "/a/b/c", "", null, null, null).getEntity());
+ assertEquals("m2.1", launcher.service("POST", "/a/b/c/d", "", null, null, null).getEntity());
+ assertEquals("m3.0", launcher.service("POST", "/a/b/c/d/e", "", null, null, null).getEntity());
+ assertEquals("m3.1", launcher.service("POST", "/a/b/c/d/e/f", "", null, null, null).getEntity());
unregistry(r1);
}
@@ -153,10 +154,10 @@
{
Resource2 r2 = new Resource2();
registry(r2);
- assertEquals("m0", service("POST", "/", "", null, null).getEntity());
- assertEquals("m1", service("POST", "/a", "", null, null).getEntity());
- assertEquals("#x y", service("POST", "/1/a/b%20/c/%23x%20y", "", null, null).getEntity());
- assertEquals("%23x%20y", service("POST", "/2/a/b%20/c/%23x%20y", "", null, null).getEntity());
+ assertEquals("m0", launcher.service("POST", "/", "", null, null, null).getEntity());
+ assertEquals("m1", launcher.service("POST", "/a", "", null, null, null).getEntity());
+ assertEquals("#x y", launcher.service("POST", "/1/a/b%20/c/%23x%20y", "", null, null, null).getEntity());
+ assertEquals("%23x%20y", launcher.service("POST", "/2/a/b%20/c/%23x%20y", "", null, null, null).getEntity());
unregistry(r2);
}
@@ -208,9 +209,9 @@
public void testResourceConstructorAndFields() throws Exception
{
registry(Resource3.class);
- assertEquals("/a/b/c/d/m0", service("GET", "/a/b/c/d/m0", "", null, null).getEntity());
- assertEquals("c", service("GET", "/a/b/c/d/m1", "", null, null).getEntity());
- assertEquals("d", service("GET", "/a/b/c/d/m2", "", null, null).getEntity());
+ assertEquals("/a/b/c/d/m0", launcher.service("GET", "/a/b/c/d/m0", "", null, null, null).getEntity());
+ assertEquals("c", launcher.service("GET", "/a/b/c/d/m1", "", null, null, null).getEntity());
+ assertEquals("d", launcher.service("GET", "/a/b/c/d/m2", "", null, null, null).getEntity());
unregistry(Resource3.class);
}
@@ -258,7 +259,14 @@
{
container.registerComponentInstance(TestContainerComponent.class.getName(), new TestContainerComponent());
registry(Resource4.class);
- service("GET", "/aaa/bbb", "", null, null);
+
+ EnvironmentContext envctx = new EnvironmentContext();
+
+ HttpServletRequest httpRequest = new MockHttpServletRequest("/aaa/bbb", null, 0, "GET", null);
+ envctx.put(HttpServletRequest.class, httpRequest);
+
+ launcher.service("GET", "/aaa/bbb", "", null, null, envctx);
+
unregistry(Resource4.class);
}
@@ -287,12 +295,13 @@
public void testResourceConstructorFail() throws Exception
{
registry(ResourceFail.class);
- GenericContainerResponse resp = service("GET", "/_a/b/c/d/m0", "", null, null);
+ GenericContainerResponse resp = launcher.service("GET", "/_a/b/c/d/m0", "", null, null, null);
String entity = (String)resp.getEntity();
assertTrue(entity.startsWith("Can't instantiate resource "));
assertEquals(javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), resp.getStatus());
unregistry(ResourceFail.class);
}
+
//--------------------------------------
@Path("a/{b}/{c}")
@@ -328,16 +337,16 @@
public void testResource5() throws Exception
{
registry(Resource5.class);
- service("GET", "/a/b/c/d?q1=q1&q2=q2", "", null, null);
+ launcher.service("GET", "/a/b/c/d?q1=q1&q2=q2", "", null, null, null);
unregistry(Resource5.class);
}
//--------------------------------------
-
+
public void testFieldSuperClass() throws Exception
{
registry(EndResource.class);
- service("GET", "/a", "", null, null);
+ launcher.service("GET", "/a", "", null, null, null);
unregistry(EndResource.class);
}
@@ -348,7 +357,7 @@
@Context
public Request request;
-
+
@Context
protected UriInfo something;
}
@@ -365,7 +374,7 @@
{
@Context
private HttpHeaders header;
-
+
@Context
private SecurityContext something;
@@ -382,40 +391,40 @@
assertNotNull(header);
}
}
-
+
// -----------------------------------------------
-
+
public void testPropertyInjection() throws Exception
{
registry(Resource6.class);
RequestHandlerImpl.setProperty("prop1", "hello");
RequestHandlerImpl.setProperty("prop2", "test");
- service("GET", "/a", "", null, null);
+ launcher.service("GET", "/a", "", null, null, null);
unregistry(Resource6.class);
-
+
}
@Path("a")
public static class Resource6
{
-
+
@Property("prop1")
private String prop1;
-
+
private final String prop2;
-
+
public Resource6(@Property("prop2") String cProp)
{
this.prop2 = cProp;
}
-
+
@GET
public void m1()
{
assertEquals("hello", prop1);
assertEquals("test", prop2);
}
-
+
}
-
+
}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/RequestFilterTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/RequestFilterTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/RequestFilterTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,10 +18,11 @@
*/
package org.exoplatform.services.rest.impl;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.Filter;
import org.exoplatform.services.rest.GenericContainerRequest;
import org.exoplatform.services.rest.RequestFilter;
+import org.exoplatform.services.test.mock.MockHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DELETE;
@@ -37,7 +38,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class RequestFilterTest extends AbstractResourceTest
+public class RequestFilterTest extends BaseTest
{
@Filter
@@ -110,7 +111,7 @@
public void testWithoutFilter1() throws Exception
{
registry(Resource1.class);
- ContainerResponse resp = service("GET", "/a", "", null, null);
+ ContainerResponse resp = launcher.service("GET", "/a", "", null, null, null);
assertEquals(405, resp.getStatus());
assertEquals(1, resp.getHttpHeaders().get("allow").size());
assertTrue(resp.getHttpHeaders().get("allow").get(0).toString().contains("POST"));
@@ -124,8 +125,12 @@
// add filter that can change method
providers.addRequestFilter(RequestFilter1.class);
+ EnvironmentContext envctx = new EnvironmentContext();
+ HttpServletRequest httpRequest = new MockHttpServletRequest("/a", null, 0, "GET", null);
+ envctx.put(HttpServletRequest.class, httpRequest);
+
// should get status 204
- ContainerResponse resp = service("GET", "/a", "", null, null);
+ ContainerResponse resp = launcher.service("GET", "/a", "", null, null, envctx);
assertEquals(204, resp.getStatus());
unregistry(Resource1.class);
@@ -135,7 +140,7 @@
public void testFilter2() throws Exception
{
registry(Resource1.class);
- ContainerResponse resp = service("GET", "/a/b/c/d/e", "", null, null);
+ ContainerResponse resp = launcher.service("GET", "/a/b/c/d/e", "", null, null, null);
assertEquals(405, resp.getStatus());
assertEquals(1, resp.getHttpHeaders().get("allow").size());
assertTrue(resp.getHttpHeaders().get("allow").get(0).toString().contains("DELETE"));
@@ -144,7 +149,7 @@
providers.addRequestFilter(new RequestFilter2());
// not should get status 204
- resp = service("GET", "/a/b/c/d/e", "", null, null);
+ resp = launcher.service("GET", "/a/b/c/d/e", "", null, null, null);
assertEquals(204, resp.getStatus());
unregistry(Resource1.class);
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ResponseFilterTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ResponseFilterTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ResponseFilterTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,10 +18,11 @@
*/
package org.exoplatform.services.rest.impl;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.Filter;
import org.exoplatform.services.rest.GenericContainerResponse;
import org.exoplatform.services.rest.ResponseFilter;
+import org.exoplatform.services.test.mock.MockHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.POST;
@@ -37,7 +38,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class ResponseFilterTest extends AbstractResourceTest
+public class ResponseFilterTest extends BaseTest
{
@Filter
@@ -99,7 +100,7 @@
@Produces("text/plain")
public String m1()
{
- // text/plain will be overridden in response filter
+ // text/plain will be overridden in response filter
return "{\"name\":\"andrew\", \"password\":\"hello\"}";
}
@@ -111,18 +112,23 @@
{
Resource1 r = new Resource1();
registry(r);
- ContainerResponse resp = service("POST", "/a", "", null, null);
+
+ EnvironmentContext envctx = new EnvironmentContext();
+ HttpServletRequest httpRequest = new MockHttpServletRequest("/a", null, 0, "POST", null);
+ envctx.put(HttpServletRequest.class, httpRequest);
+
+ ContainerResponse resp = launcher.service("POST", "/a", "", null, null, envctx);
assertEquals(204, resp.getStatus());
// should not be any changes after add this
providers.addResponseFilter(new ResponseFilter2());
- resp = service("POST", "/a", "", null, null);
+ resp = launcher.service("POST", "/a", "", null, null, envctx);
assertEquals(204, resp.getStatus());
// add response filter and try again
providers.addResponseFilter(ResponseFilter1.class);
- resp = service("POST", "/a", "", null, null);
+ resp = launcher.service("POST", "/a", "", null, null, envctx);
assertEquals(200, resp.getStatus());
assertEquals("text/plain", resp.getContentType().toString());
assertEquals("to be or not to be", resp.getEntity());
@@ -134,7 +140,7 @@
{
Resource1 r = new Resource1();
registry(r);
- ContainerResponse resp = service("POST", "/a/b/c/d/e", "", null, null);
+ ContainerResponse resp = launcher.service("POST", "/a/b/c/d/e", "", null, null, null);
assertEquals(200, resp.getStatus());
assertEquals("text/plain", resp.getContentType().toString());
assertEquals("{\"name\":\"andrew\", \"password\":\"hello\"}", resp.getEntity());
@@ -142,7 +148,7 @@
// add response filter and try again
providers.addResponseFilter(new ResponseFilter2());
- resp = service("POST", "/a/b/c/d/e", "", null, null);
+ resp = launcher.service("POST", "/a/b/c/d/e", "", null, null, null);
assertEquals(200, resp.getStatus());
assertEquals("application/json", resp.getContentType().toString());
assertEquals("{\"name\":\"andrew\", \"password\":\"hello\"}", resp.getEntity());
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/HeadMethodTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/HeadMethodTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/HeadMethodTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.method;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
@@ -27,11 +27,11 @@
/**
* Created by The eXo Platform SAS. <br/>
* Date: 21 Jan 2009
- *
+ *
* @author <a href="mailto:dmitry.kataev at exoplatform.com.ua">Dmytro Katayev</a>
* @version $Id: HeadMethodTest.java
*/
-public class HeadMethodTest extends AbstractResourceTest
+public class HeadMethodTest extends BaseTest
{
@Path("/a")
@@ -69,8 +69,8 @@
Resource1 resource1 = new Resource1();
registry(resource1);
- assertEquals("get", service("GET", "/a", "", null, null).getEntity());
- assertEquals(200, service("HEAD", "/a", "", null, null).getStatus());
+ assertEquals("get", launcher.service("GET", "/a", "", null, null, null).getEntity());
+ assertEquals(200, launcher.service("HEAD", "/a", "", null, null, null).getStatus());
unregistry(resource1);
@@ -78,9 +78,9 @@
registry(resource2);
- assertEquals("get", service("GET", "/b", "", null, null).getEntity());
- assertEquals(200, service("HEAD", "/b", "", null, null).getStatus());
- assertNull(service("HEAD", "/b", "", null, null).getEntity());
+ assertEquals("get", launcher.service("GET", "/b", "", null, null, null).getEntity());
+ assertEquals(200, launcher.service("HEAD", "/b", "", null, null, null).getStatus());
+ assertNull(launcher.service("HEAD", "/b", "", null, null, null).getEntity());
unregistry(resource2);
}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MediaTypeTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MediaTypeTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MediaTypeTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.method;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
import javax.ws.rs.Consumes;
@@ -32,13 +32,13 @@
/**
* Created by The eXo Platform SAS.
- *
+ *
* <br/>Date: 22 Jan 2009
*
* @author <a href="mailto:dmitry.kataev at exoplatform.com.ua">Dmytro Katayev</a>
- * @version $Id: MediaTypeTest.java
+ * @version $Id: MediaTypeTest.java
*/
-public class MediaTypeTest extends AbstractResourceTest
+public class MediaTypeTest extends BaseTest
{
@Path("/a")
@@ -90,21 +90,21 @@
registry(resource1);
registry(resource2);
- assertEquals(200, service("GET", "/a", "", null, null).getStatus());
- assertEquals("m0", service("GET", "/a", "", null, null).getEntity());
- assertEquals(MediaType.WILDCARD_TYPE, service("GET", "/a", "", null, null).getContentType());
+ assertEquals(200, launcher.service("GET", "/a", "", null, null, null).getStatus());
+ assertEquals("m0", launcher.service("GET", "/a", "", null, null, null).getEntity());
+ assertEquals(MediaType.WILDCARD_TYPE, launcher.service("GET", "/a", "", null, null, null).getContentType());
- assertEquals(200, service("GET", "/b/c", "", null, null).getStatus());
- assertEquals(MediaType.TEXT_PLAIN_TYPE, service("GET", "/b/c", "", null, null).getContentType());
+ assertEquals(200, launcher.service("GET", "/b/c", "", null, null, null).getStatus());
+ assertEquals(MediaType.TEXT_PLAIN_TYPE, launcher.service("GET", "/b/c", "", null, null, null).getContentType());
- assertEquals(200, service("GET", "/b/d", "", null, null).getStatus());
- assertEquals(MediaType.TEXT_XML_TYPE, service("GET", "/b/d", "", null, null).getContentType());
+ assertEquals(200, launcher.service("GET", "/b/d", "", null, null, null).getStatus());
+ assertEquals(MediaType.TEXT_XML_TYPE, launcher.service("GET", "/b/d", "", null, null, null).getContentType());
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.add(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
- assertEquals(406, service("GET", "/b/d", "", headers, null).getStatus());
- assertEquals(MediaType.TEXT_XML_TYPE, service("GET", "/b/d", "", null, null).getContentType());
+ assertEquals(406, launcher.service("GET", "/b/d", "", headers, null, null).getStatus());
+ assertEquals(MediaType.TEXT_XML_TYPE, launcher.service("GET", "/b/d", "", null, null, null).getContentType());
unregistry(resource1);
unregistry(resource2);
@@ -144,19 +144,19 @@
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
- assertEquals(200, service("GET", "/d/e", "", headers, null).getStatus());
- assertEquals("m0", service("GET", "/d/e", "", headers, null).getEntity());
+ assertEquals(200, launcher.service("GET", "/d/e", "", headers, null, null).getStatus());
+ assertEquals("m0", launcher.service("GET", "/d/e", "", headers, null, null).getEntity());
headers = new MultivaluedMapImpl();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
- assertEquals(200, service("GET", "/d/f", "", headers, null).getStatus());
- assertEquals("m1", service("GET", "/d/f", "", headers, null).getEntity());
+ assertEquals(200, launcher.service("GET", "/d/f", "", headers, null, null).getStatus());
+ assertEquals("m1", launcher.service("GET", "/d/f", "", headers, null, null).getEntity());
headers = new MultivaluedMapImpl();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML);
- assertEquals(415, service("GET", "/d/f", "", headers, null).getStatus());
+ assertEquals(415, launcher.service("GET", "/d/f", "", headers, null, null).getStatus());
unregistry(resource4);
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodInvokerFilterTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodInvokerFilterTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodInvokerFilterTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,13 +18,15 @@
*/
package org.exoplatform.services.rest.impl.method;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.Filter;
+import org.exoplatform.services.rest.impl.EnvironmentContext;
import org.exoplatform.services.rest.impl.ResourceBinder;
import org.exoplatform.services.rest.method.MethodInvokerFilter;
import org.exoplatform.services.rest.resource.GenericMethodResource;
import org.exoplatform.services.rest.resource.ResourceMethodDescriptor;
import org.exoplatform.services.rest.resource.SubResourceMethodDescriptor;
+import org.exoplatform.services.test.mock.MockHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
@@ -40,7 +42,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class MethodInvokerFilterTest extends AbstractResourceTest
+public class MethodInvokerFilterTest extends BaseTest
{
@Filter
@@ -132,11 +134,26 @@
{
Resource1 r = new Resource1();
registry(r);
- assertEquals(204, service("GET", "/a/b", "", null, null).getStatus());
- assertEquals(204, service("GET", "/a", "", null, null).getStatus());
+
+ EnvironmentContext envctx = new EnvironmentContext();
+
+ HttpServletRequest httpRequest = new MockHttpServletRequest("/a/b", null, 0, "GET", null);
+ envctx.put(HttpServletRequest.class, httpRequest);
+ assertEquals(204, launcher.service("GET", "/a/b", "", null, null, envctx).getStatus());
+
+ httpRequest = new MockHttpServletRequest("/a", null, 0, "GET", null);
+ envctx.put(HttpServletRequest.class, httpRequest);
+ assertEquals(204, launcher.service("GET", "/a", "", null, null, envctx).getStatus());
+
providers.addMethodInvokerFilter(MethodInvokerFilter1.class);
- assertEquals(400, service("GET", "/a/b", "", null, null).getStatus());
- assertEquals(204, service("GET", "/a", "", null, null).getStatus());
+
+ httpRequest = new MockHttpServletRequest("/a/b", null, 0, "GET", null);
+ envctx.put(HttpServletRequest.class, httpRequest);
+ assertEquals(400, launcher.service("GET", "/a/b", "", null, null, envctx).getStatus());
+
+ httpRequest = new MockHttpServletRequest("/a", null, 0, "GET", null);
+ envctx.put(HttpServletRequest.class, httpRequest);
+ assertEquals(204, launcher.service("GET", "/a", "", null, null, envctx).getStatus());
unregistry(r);
}
@@ -144,11 +161,11 @@
{
Resource2 r = new Resource2();
registry(r);
- assertEquals(204, service("GET", "/b/c", "", null, null).getStatus());
- assertEquals(204, service("GET", "/b/d", "", null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/b/c", "", null, null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/b/d", "", null, null, null).getStatus());
providers.addMethodInvokerFilter(new MethodInvokerFilter2());
- assertEquals(400, service("GET", "/b/c", "", null, null).getStatus());
- assertEquals(204, service("GET", "/b/d", "", null, null).getStatus());
+ assertEquals(400, launcher.service("GET", "/b/c", "", null, null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/b/d", "", null, null, null).getStatus());
unregistry(r);
}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodReturnTypeTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodReturnTypeTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodReturnTypeTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.method;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import java.util.List;
@@ -34,7 +34,7 @@
* @author <a href="mailto:dmitry.kataev at exoplatform.com.ua">Dmytro Katayev</a>
* @version $Id: ResourceReturnTypeTest.java
*/
-public class MethodReturnTypeTest extends AbstractResourceTest
+public class MethodReturnTypeTest extends BaseTest
{
@Path("/a")
@@ -92,30 +92,30 @@
registry(r);
// void Results in an empty entity body with a 204 status code.
- assertEquals(204, service("GET", "/a/0", "", null, null).getStatus());
- assertNull(service("GET", "/a/0", "", null, null).getEntity());
+ assertEquals(204, launcher.service("GET", "/a/0", "", null, null, null).getStatus());
+ assertNull(launcher.service("GET", "/a/0", "", null, null, null).getEntity());
// Response Results in an entity body mapped from the entity property of the
// Response
// with the status code specified by the status property of the Response.
- assertEquals(200, service("GET", "/a/1", "", null, null).getStatus());
- assertEquals("body", service("GET", "/a/1", "", null, null).getEntity());
+ assertEquals(200, launcher.service("GET", "/a/1", "", null, null, null).getStatus());
+ assertEquals("body", launcher.service("GET", "/a/1", "", null, null, null).getEntity());
// GenericEntity Results: null return value results in a 204 status code
- assertEquals(204, service("GET", "/a/2", "", null, null).getStatus());
- assertNull(service("GET", "/a/2", "", null, null).getEntity());
+ assertEquals(204, launcher.service("GET", "/a/2", "", null, null, null).getStatus());
+ assertNull(launcher.service("GET", "/a/2", "", null, null, null).getEntity());
// a null return value results in a 204 status code.
- assertEquals(204, service("GET", "/a/3", "", null, null).getStatus());
- assertNull(service("GET", "/a/3", "", null, null).getEntity());
+ assertEquals(204, launcher.service("GET", "/a/3", "", null, null, null).getStatus());
+ assertNull(launcher.service("GET", "/a/3", "", null, null, null).getEntity());
// Other Results: null return value results in a 204 status code
- assertEquals(204, service("GET", "/a/5", "", null, null).getStatus());
- assertNull(service("GET", "/a/5", "", null, null).getEntity());
+ assertEquals(204, launcher.service("GET", "/a/5", "", null, null, null).getStatus());
+ assertNull(launcher.service("GET", "/a/5", "", null, null, null).getEntity());
// Other Results: null return value results in a 204 status code
- assertEquals(200, service("GET", "/a/6", "", null, null).getStatus());
- assertNotNull(service("GET", "/a/6", "", null, null).getEntity());
+ assertEquals(200, launcher.service("GET", "/a/6", "", null, null, null).getStatus());
+ assertNotNull(launcher.service("GET", "/a/6", "", null, null, null).getEntity());
unregistry(r);
}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/OptionsMethodTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/OptionsMethodTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/OptionsMethodTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.method;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -32,11 +32,11 @@
/**
* Created by The eXo Platform SAS. <br/>
* Date: 21 Jan 2009
- *
+ *
* @author <a href="mailto:dmitry.kataev at exoplatform.com.ua">Dmytro Katayev</a>
* @version $Id: OptionsMethodTest.java
*/
-public class OptionsMethodTest extends AbstractResourceTest
+public class OptionsMethodTest extends BaseTest
{
@Target(ElementType.METHOD)
@@ -74,13 +74,13 @@
{
Resource1 resource1 = new Resource1();
registry(resource1);
- assertEquals("options", service("OPTIONS", "/a", "", null, null).getEntity());
+ assertEquals("options", launcher.service("OPTIONS", "/a", "", null, null, null).getEntity());
unregistry(resource1);
Resource2 resource2 = new Resource2();
registry(resource2);
- assertEquals(200, service("OPTIONS", "/b", "", null, null).getStatus());
- assertNotNull(service("OPTIONS", "/b", "", null, null).getResponse().getMetadata());
+ assertEquals(200, launcher.service("OPTIONS", "/b", "", null, null, null).getStatus());
+ assertNotNull(launcher.service("OPTIONS", "/b", "", null, null, null).getResponse().getMetadata());
}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/ParametersInjectionTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/ParametersInjectionTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/ParametersInjectionTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.method;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.Property;
import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
import org.exoplatform.services.rest.impl.RequestHandlerImpl;
@@ -46,7 +46,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class ParametersInjectionTest extends AbstractResourceTest
+public class ParametersInjectionTest extends BaseTest
{
@Path("/a/{x}")
@@ -222,46 +222,46 @@
{
Resource1 r1 = new Resource1();
registry(r1);
- assertEquals(204, service("GET", "/a/test/0/test", "", null, null).getStatus());
- assertEquals(204, service("GET", "/a/test/1/test", "", null, null).getStatus());
- assertEquals(204, service("GET", "/a/test/2/test", "", null, null).getStatus());
- assertEquals(204, service("GET", "/a/test/3/test", "", null, null).getStatus());
- assertEquals(204, service("GET", "/a/3333/4/2222", "", null, null).getStatus());
- assertEquals(204, service("GET", "/a/5555/5/4444", "", null, null).getStatus());
- assertEquals(204, service("GET", "/a/test/6/test", "", null, null).getStatus());
- assertEquals(204, service("GET", "/a/test/7/test?x=1&y=2&x=3&y=4&x=5", "", null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/a/test/0/test", "", null, null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/a/test/1/test", "", null, null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/a/test/2/test", "", null, null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/a/test/3/test", "", null, null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/a/3333/4/2222", "", null, null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/a/5555/5/4444", "", null, null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/a/test/6/test", "", null, null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/a/test/7/test?x=1&y=2&x=3&y=4&x=5", "", null, null, null).getStatus());
MultivaluedMap<String, String> h = new MultivaluedMapImpl();
h.putSingle("foo", "to be or not to be");
h.putSingle("bar", "to be or not to be");
- assertEquals(204, service("GET", "/a/test/8/test", "", h, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/a/test/8/test", "", h, null, null).getStatus());
h.clear();
h.putSingle("Content-Type", "application/x-www-form-urlencoded");
- assertEquals(204, service("POST", "/a/test/9/test", "", h,
- "bar=to%20be%20or%20not%20to%20be&foo=to%20be%20or%20not%20to%20be".getBytes("UTF-8")).getStatus());
+ assertEquals(204, launcher.service("POST", "/a/test/9/test", "", h,
+ "bar=to%20be%20or%20not%20to%20be&foo=to%20be%20or%20not%20to%20be".getBytes("UTF-8"), null).getStatus());
h.clear();
h.putSingle("Cookie",
"$Version=1;foo=foo;$Domain=exo.com;$Path=/exo,$Version=1;bar=ar;$Domain=exo.com;$Path=/exo");
- assertEquals(204, service("GET", "/a/test/11/test", "", h, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/a/test/11/test", "", h, null, null).getStatus());
- assertEquals(204, service("GET", "/a/111/12/222", "", null, null).getStatus());
+ assertEquals(204, launcher.service("GET", "/a/111/12/222", "", null, null, null).getStatus());
- assertEquals("111", service("GET", "/a/111/13", "", null, null).getEntity());
- assertEquals("222", service("GET", "/a/111/13?query=222", "", null, null).getEntity());
+ assertEquals("111", launcher.service("GET", "/a/111/13", "", null, null, null).getEntity());
+ assertEquals("222", launcher.service("GET", "/a/111/13?query=222", "", null, null, null).getEntity());
try
{
- assertEquals("hello", service("GET", "/a/111/14", "", null, null).getEntity());
+ assertEquals("hello", launcher.service("GET", "/a/111/14", "", null, null, null).getEntity());
RequestHandlerImpl.setProperty("prop1", "to be or not to be");
- assertEquals("to be or not to be", service("GET", "/a/111/14", "", null, null).getEntity());
+ assertEquals("to be or not to be", launcher.service("GET", "/a/111/14", "", null, null, null).getEntity());
}
finally
{
RequestHandlerImpl.setProperty("prop1", null);
}
-
+
unregistry(r1);
}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ContextResolverTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ContextResolverTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ContextResolverTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.rest.impl.provider;
+import org.exoplatform.services.rest.BaseTest;
+
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.Provider;
@@ -26,7 +28,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class ContextResolverTest extends org.exoplatform.services.rest.AbstractResourceTest
+public class ContextResolverTest extends BaseTest
{
@Provider
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ExceptionMapperTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ExceptionMapperTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ExceptionMapperTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.provider;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.impl.ContainerResponse;
import javax.ws.rs.GET;
@@ -31,7 +31,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class ExceptionMapperTest extends AbstractResourceTest
+public class ExceptionMapperTest extends BaseTest
{
public static class ExceptionMapper1 implements ExceptionMapper<IllegalArgumentException>
@@ -136,24 +136,24 @@
{
registry(Resource1.class);
- ContainerResponse resp = service("GET", "/a/1", "", null, null);
+ ContainerResponse resp = launcher.service("GET", "/a/1", "", null, null, null);
assertEquals(200, resp.getStatus());
assertEquals("IllegalArgumentException", resp.getEntity());
- resp = service("GET", "/a/2", "", null, null);
+ resp = launcher.service("GET", "/a/2", "", null, null, null);
assertEquals(200, resp.getStatus());
assertEquals("RuntimeException", resp.getEntity());
- resp = service("GET", "/a/3", "", null, null);
+ resp = launcher.service("GET", "/a/3", "", null, null, null);
assertEquals(200, resp.getStatus());
assertEquals("WebApplicationException", resp.getEntity());
- resp = service("GET", "/a/4", "", null, null);
- // WebApplicationException with entity - must not be overridden
+ resp = launcher.service("GET", "/a/4", "", null, null, null);
+ // WebApplicationException with entity - must not be overridden
assertEquals(500, resp.getStatus());
assertEquals("this exception must not be hidden by any ExceptionMapper", resp.getEntity());
- resp = service("GET", "/a/5", "", null, null);
+ resp = launcher.service("GET", "/a/5", "", null, null, null);
assertEquals(200, resp.getStatus());
assertEquals("MockException", resp.getEntity());
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/FormEntityTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/FormEntityTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/FormEntityTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -19,15 +19,19 @@
package org.exoplatform.services.rest.impl.provider;
import org.apache.commons.fileupload.FileItem;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
+import org.exoplatform.services.rest.impl.EnvironmentContext;
import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
+import org.exoplatform.services.test.mock.MockHttpServletRequest;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
@@ -38,7 +42,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class FormEntityTest extends AbstractResourceTest
+public class FormEntityTest extends BaseTest
{
@Path("/")
@@ -72,8 +76,8 @@
MultivaluedMap<String, String> h = new MultivaluedMapImpl();
h.putSingle("content-type", "application/x-www-form-urlencoded");
h.putSingle("content-length", "" + data.length);
- assertEquals(204, service("POST", "/a", "", h, data).getStatus());
- assertEquals(204, service("POST", "/b", "", h, data).getStatus());
+ assertEquals(204, launcher.service("POST", "/a", "", h, data, null).getStatus());
+ assertEquals(204, launcher.service("POST", "/b", "", h, data, null).getStatus());
unregistry(r1);
}
@@ -190,7 +194,15 @@
h.putSingle("content-type", "multipart/form-data; boundary=abcdef");
byte[] data = out.toByteArray();
- assertEquals(204, service("POST", "/", "", h, data).getStatus());
+
+ EnvironmentContext envctx = new EnvironmentContext();
+
+ HttpServletRequest httpRequest =
+ new MockHttpServletRequest("/", new ByteArrayInputStream(data), data.length, "POST", h);
+ envctx.put(HttpServletRequest.class, httpRequest);
+
+ assertEquals(204, launcher.service("POST", "/", "", h, data, envctx).getStatus());
+
unregistry(r2);
}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JAXBEntityTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JAXBEntityTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JAXBEntityTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.provider;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.generated.Book;
import org.exoplatform.services.rest.impl.ContainerResponse;
import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
@@ -36,7 +36,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class JAXBEntityTest extends AbstractResourceTest
+public class JAXBEntityTest extends BaseTest
{
@Path("/")
@@ -79,7 +79,7 @@
book.setAuthor("William Shakespeare");
book.setTitle("Hamlet");
book.setSendByPost(true);
- // ignore some fields
+ // ignore some fields
return book;
}
@@ -91,7 +91,7 @@
book.setAuthor("William Shakespeare\n");
book.setTitle("Hamlet\n");
book.setSendByPost(false);
- // ignore some fields
+ // ignore some fields
return book;
}
}
@@ -111,10 +111,10 @@
h.putSingle("content-type", "application/xml");
byte[] data = XML_DATA.getBytes("UTF-8");
h.putSingle("content-length", "" + data.length);
- assertEquals(204, service("POST", "/a", "", h, data).getStatus());
+ assertEquals(204, launcher.service("POST", "/a", "", h, data, null).getStatus());
// Object transfered via XML (JAXB)
- assertEquals(204, service("POST", "/b", "", h, data).getStatus());
+ assertEquals(204, launcher.service("POST", "/b", "", h, data, null).getStatus());
unregistry(r1);
}
@@ -127,7 +127,7 @@
// Resource2#m1()
h.putSingle("accept", "application/xml");
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
- ContainerResponse response = service("GET", "/", "", h, null, writer);
+ ContainerResponse response = launcher.service("GET", "/", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("application/xml", response.getContentType().toString());
Book book = (Book)response.getEntity();
@@ -137,7 +137,7 @@
// Resource2#m2()
writer = new ByteArrayContainerResponseWriter();
- response = service("POST", "/", "", h, null, writer);
+ response = launcher.service("POST", "/", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("application/xml", response.getContentType().toString());
book = (Book)response.getEntity();
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JsonEntityTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JsonEntityTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JsonEntityTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.provider;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.generated.Book;
import org.exoplatform.services.rest.impl.ContainerResponse;
import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
@@ -35,7 +35,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class JsonEntityTest extends AbstractResourceTest
+public class JsonEntityTest extends BaseTest
{
@Path("/")
@@ -96,7 +96,7 @@
// with JSON transformation for Book have restriction can't pass BigDecimal
// (has not simple constructor and it is not in JSON known types)
h.putSingle("content-length", "" + jsonData.length);
- assertEquals(204, service("POST", "/", "", h, jsonData).getStatus());
+ assertEquals(204, launcher.service("POST", "/", "", h, jsonData, null).getStatus());
unregistry(r1);
}
@@ -109,7 +109,7 @@
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
// Resource2#m1()
- ContainerResponse response = service("GET", "/", "", h, null, writer);
+ ContainerResponse response = launcher.service("GET", "/", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("application/json", response.getContentType().toString());
Book book = (Book)response.getEntity();
@@ -118,7 +118,7 @@
assertTrue(book.isSendByPost());
// Resource2#m2()
- response = service("POST", "/", "", h, null, writer);
+ response = launcher.service("POST", "/", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("application/json", response.getContentType().toString());
book = (Book)response.getEntity();
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/OtherEntityTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/OtherEntityTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/OtherEntityTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.provider;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.impl.ContainerResponse;
import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
import org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter;
@@ -52,7 +52,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class OtherEntityTest extends AbstractResourceTest
+public class OtherEntityTest extends BaseTest
{
@Path("/")
@@ -136,24 +136,24 @@
// next types allowed for any content-type
// h.putSingle("content-type", "application/octet-stream");
- assertEquals(204, service("POST", "/bytes", "", h, data).getStatus());
+ assertEquals(204, launcher.service("POST", "/bytes", "", h, data, null).getStatus());
- assertEquals(204, service("POST", "/string", "", h, data).getStatus());
+ assertEquals(204, launcher.service("POST", "/string", "", h, data, null).getStatus());
- assertEquals(204, service("POST", "/stream", "", h, data).getStatus());
+ assertEquals(204, launcher.service("POST", "/stream", "", h, data, null).getStatus());
- assertEquals(204, service("POST", "/reader", "", h, data).getStatus());
+ assertEquals(204, launcher.service("POST", "/reader", "", h, data, null).getStatus());
// next types required application/xml, text/xml or
// application/xhtml+xml content-type
h.putSingle("content-type", "application/xml");
data = XML_DATA.getBytes("UTF-8");
h.putSingle("content-length", "" + data.length);
- assertEquals(204, service("POST", "/dom", "", h, data).getStatus());
+ assertEquals(204, launcher.service("POST", "/dom", "", h, data, null).getStatus());
- assertEquals(204, service("POST", "/sax", "", h, data).getStatus());
+ assertEquals(204, launcher.service("POST", "/sax", "", h, data, null).getStatus());
- assertEquals(204, service("POST", "/ss", "", h, data).getStatus());
+ assertEquals(204, launcher.service("POST", "/ss", "", h, data, null).getStatus());
unregistry(r1);
}
@@ -249,24 +249,24 @@
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
h.putSingle("accept", "text/plain");
- ContainerResponse response = service("GET", "/bytes", "", h, null, writer);
+ ContainerResponse response = launcher.service("GET", "/bytes", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("application/octet-stream", response.getContentType().toString());
assertEquals("to be or not to be".getBytes("UTF-8").length + "", response.getHttpHeaders().getFirst(
HttpHeaders.CONTENT_LENGTH).toString());
assertEquals("to be or not to be", new String(writer.getBody()));
- response = service("GET", "/string", "", h, null, writer);
+ response = launcher.service("GET", "/string", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("text/plain", response.getContentType().toString());
assertEquals("to be or not to be", new String(writer.getBody()));
- response = service("GET", "/stream", "", h, null, writer);
+ response = launcher.service("GET", "/stream", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("application/octet-stream", response.getContentType().toString());
assertEquals("to be or not to be", new String(writer.getBody()));
- response = service("GET", "/reader", "", h, null, writer);
+ response = launcher.service("GET", "/reader", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("text/plain", response.getContentType().toString());
assertEquals("to be or not to be", new String(writer.getBody()));
@@ -275,33 +275,33 @@
String xml = pattern.matcher(XML_DATA).replaceFirst("");
h.putSingle("accept", "application/xml");
- response = service("GET", "/dom", "", h, null, writer);
+ response = launcher.service("GET", "/dom", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("application/xml", response.getContentType().toString());
String result = new String(writer.getBody());
result = pattern.matcher(result).replaceFirst("");
assertEquals(xml, result);
- response = service("GET", "/sax", "", h, null, writer);
+ response = launcher.service("GET", "/sax", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("application/xml", response.getContentType().toString());
result = new String(writer.getBody());
result = pattern.matcher(result).replaceFirst("");
assertEquals(xml, result);
- response = service("GET", "/ss", "", h, null, writer);
+ response = launcher.service("GET", "/ss", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("application/xml", response.getContentType().toString());
result = new String(writer.getBody());
result = pattern.matcher(result).replaceFirst("");
assertEquals(xml, result);
- response = service("GET", "/so", "", h, null, writer);
+ response = launcher.service("GET", "/so", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("application/octet-stream", response.getContentType().toString());
assertEquals("to be or not to be", new String(writer.getBody()));
- response = service("GET", "/response", "", h, null, writer);
+ response = launcher.service("GET", "/response", "", h, null, writer, null);
assertEquals(200, response.getStatus());
assertEquals("text/plain", response.getContentType().toString());
assertEquals("to be or not to be".getBytes("UTF-8").length + "", response.getHttpHeaders().getFirst(
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ProviderContextParameterInjectionTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ProviderContextParameterInjectionTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/ProviderContextParameterInjectionTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,10 +18,13 @@
*/
package org.exoplatform.services.rest.impl.provider;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.impl.EnvironmentContext;
import org.exoplatform.services.rest.provider.EntityProvider;
+import org.exoplatform.services.test.mock.MockHttpServletRequest;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -30,6 +33,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
+import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
@@ -49,7 +53,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class ProviderContextParameterInjectionTest extends AbstractResourceTest
+public class ProviderContextParameterInjectionTest extends BaseTest
{
public static class MockEntity
@@ -191,7 +195,7 @@
@Context
private Providers providers;
- @GET
+ @POST
@Path("1")
public MockEntity m0(MockEntity me)
{
@@ -221,13 +225,23 @@
{
registry(Resource1.class);
- ContainerResponse resp = service("GET", "/a/1", "", null, "to be or not to be".getBytes());
+ EnvironmentContext envctx = new EnvironmentContext();
+
+ HttpServletRequest httpRequest =
+ new MockHttpServletRequest("/a/1", new ByteArrayInputStream("to be or not to be".getBytes()), 18, "POST", null);
+ envctx.put(HttpServletRequest.class, httpRequest);
+
+ ContainerResponse resp = launcher.service("POST", "/a/1", "", null, "to be or not to be".getBytes(), envctx);
assertEquals("to be", ((MockEntity)resp.getEntity()).entity);
- resp = service("GET", "/a/2", "", null, null);
+ httpRequest = new MockHttpServletRequest("/a/2", null, 0, "GET", null);
+ envctx.put(HttpServletRequest.class, httpRequest);
+ resp = launcher.service("GET", "/a/2", "", null, null, envctx);
assertEquals(200, resp.getStatus());
- resp = service("GET", "/a/3", "", null, null);
+ httpRequest = new MockHttpServletRequest("/a/3", null, 0, "GET", null);
+ envctx.put(HttpServletRequest.class, httpRequest);
+ resp = launcher.service("GET", "/a/3", "", null, null, envctx);
assertEquals(200, resp.getStatus());
assertEquals("to be to not to be", resp.getEntity());
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/AcceptResourceTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/AcceptResourceTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/AcceptResourceTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.resource;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
import javax.ws.rs.Consumes;
@@ -32,7 +32,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class AcceptResourceTest extends AbstractResourceTest
+public class AcceptResourceTest extends BaseTest
{
@Path("/a")
@@ -204,14 +204,14 @@
{
MultivaluedMap<String, String> h = new MultivaluedMapImpl();
h.putSingle("content-type", contentType);
- return (String)service("POST", "/a", "", h, null).getEntity();
+ return (String)launcher.service("POST", "/a", "", h, null, null).getEntity();
}
private String testAcceptedMediaType(String acceptMediaType) throws Exception
{
MultivaluedMap<String, String> h = new MultivaluedMapImpl();
h.putSingle("accept", acceptMediaType);
- return (String)service("GET", "/a", "", h, null).getEntity();
+ return (String)launcher.service("GET", "/a", "", h, null, null).getEntity();
}
private String testComplex(String contentType, String acceptMediaType) throws Exception
@@ -219,6 +219,6 @@
MultivaluedMap<String, String> h = new MultivaluedMapImpl();
h.putSingle("content-type", contentType);
h.putSingle("accept", acceptMediaType);
- return (String)service("POST", "/a", "", h, null).getEntity();
+ return (String)launcher.service("POST", "/a", "", h, null, null).getEntity();
}
}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/AnnotationInheritanceTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/AnnotationInheritanceTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/AnnotationInheritanceTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.resource;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -28,11 +28,11 @@
/**
* Created by The eXo Platform SAS. <br/>
* Date: 23 Jan 2009
- *
+ *
* @author <a href="mailto:dmitry.kataev at exoplatform.com.ua">Dmytro Katayev</a>
* @version $Id: AnnotationInheritanceTest.java
*/
-public class AnnotationInheritanceTest extends AbstractResourceTest
+public class AnnotationInheritanceTest extends BaseTest
{
public static interface ResourceInterface
@@ -61,7 +61,7 @@
}
}
- //
+ //
public static interface ResourceInterface1
{
@@ -102,16 +102,16 @@
registry(resource1);
- assertEquals(200, service("GET", "/a", "", null, null).getStatus());
- assertEquals("m0", service("GET", "/a", "", null, null).getEntity());
- assertEquals(MediaType.TEXT_XML_TYPE, service("GET", "/a", "", null, null).getContentType());
+ assertEquals(200, launcher.service("GET", "/a", "", null, null, null).getStatus());
+ assertEquals("m0", launcher.service("GET", "/a", "", null, null, null).getEntity());
+ assertEquals(MediaType.TEXT_XML_TYPE, launcher.service("GET", "/a", "", null, null, null).getContentType());
unregistry(resource1);
registry(resource2);
- assertEquals(200, service("GET", "/a", "", null, null).getStatus());
- assertEquals("m0", service("GET", "/a", "", null, null).getEntity());
- assertEquals(MediaType.APPLICATION_ATOM_XML_TYPE, service("GET", "/a", "", null, null).getContentType());
+ assertEquals(200, launcher.service("GET", "/a", "", null, null, null).getStatus());
+ assertEquals("m0", launcher.service("GET", "/a", "", null, null, null).getEntity());
+ assertEquals(MediaType.APPLICATION_ATOM_XML_TYPE, launcher.service("GET", "/a", "", null, null, null).getContentType());
unregistry(resource2);
}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ApplicationTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ApplicationTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ApplicationTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.resource;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.Filter;
import org.exoplatform.services.rest.GenericContainerRequest;
import org.exoplatform.services.rest.GenericContainerResponse;
@@ -41,7 +41,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class ApplicationTest extends AbstractResourceTest
+public class ApplicationTest extends BaseTest
{
public static class Application1 extends javax.ws.rs.core.Application
@@ -151,7 +151,7 @@
}
}
-
+
@Filter
public static class MethodInvokerFilter1 implements MethodInvokerFilter
{
@@ -160,9 +160,9 @@
{
invFilter = true;
}
-
+
}
-
+
@Filter
public static class RequestFilter1 implements RequestFilter
{
@@ -171,9 +171,9 @@
{
requestFilter = true;
}
-
+
}
-
+
@Filter
public static class ResponseFilter1 implements ResponseFilter
{
@@ -182,7 +182,7 @@
{
responseFilter = true;
}
-
+
}
public void testRegistry()
@@ -199,40 +199,40 @@
private static boolean requestFilter = false;
private static boolean responseFilter = false;
private static boolean invFilter = false;
-
+
public void testAsResources() throws Exception
{
binder.addApplication(new Application1());
// per-request
- ContainerResponse resp = service("GET", "/a", "", null, null);
+ ContainerResponse resp = launcher.service("GET", "/a", "", null, null, null);
assertEquals(200, resp.getStatus());
String hash10 = (String)resp.getEntity();
- resp = service("GET", "/a", "", null, null);
+ resp = launcher.service("GET", "/a", "", null, null, null);
String hash11 = (String)resp.getEntity();
// new instance of resource for each request
assertFalse(hash10.equals(hash11));
// singleton
- resp = service("GET", "/c", "", null, null);
+ resp = launcher.service("GET", "/c", "", null, null, null);
assertEquals(200, resp.getStatus());
String hash20 = (String)resp.getEntity();
- resp = service("GET", "/c", "", null, null);
+ resp = launcher.service("GET", "/c", "", null, null, null);
String hash21 = (String)resp.getEntity();
// singleton resource
assertTrue(hash20.equals(hash21));
// check per-request ExceptionMapper as example of provider
- resp = service("GET", "/b", "", null, null);
+ resp = launcher.service("GET", "/b", "", null, null, null);
// should be 200 status instead 500 if ExceptionMapper works correct
assertEquals(200, resp.getStatus());
assertEquals("test Runtime Exception", resp.getEntity());
// check singleton ExceptionMapper as example of provider
- resp = service("GET", "/d", "", null, null);
+ resp = launcher.service("GET", "/d", "", null, null, null);
// should be 200 status instead 500 if ExceptionMapper works correct
assertEquals(200, resp.getStatus());
assertEquals("test Illegal State Exception", resp.getEntity());
-
+
// check are filters were visited
assertTrue(requestFilter);
assertTrue(responseFilter);
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ContextParametersInjectionTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ContextParametersInjectionTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ContextParametersInjectionTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.resource;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.InitialProperties;
import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
import org.exoplatform.services.rest.impl.header.HeaderHelper;
@@ -38,7 +38,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class ContextParametersInjectionTest extends AbstractResourceTest
+public class ContextParametersInjectionTest extends BaseTest
{
@Path("/a/b")
@@ -231,17 +231,19 @@
private void injectionTest() throws Exception
{
- assertEquals("http://localhost/test/a/b/c", service("GET", "http://localhost/test/a/b/c",
- "http://localhost/test", null, null).getEntity());
+ assertEquals("http://localhost/test/a/b/c", launcher.service("GET", "http://localhost/test/a/b/c",
+ "http://localhost/test", null, null, null).getEntity());
MultivaluedMap<String, String> h = new MultivaluedMapImpl();
h.add("Accept", "text/xml");
h.add("Accept", "text/plain;q=0.7");
- assertEquals("text/xml,text/plain;q=0.7", service("GET", "http://localhost/test/a/b/d", "http://localhost/test",
- h, null).getEntity());
- assertEquals("GET", service("GET", "http://localhost/test/a/b/e", "http://localhost/test", null, null)
- .getEntity());
- assertEquals(204, service("GET", "http://localhost/test/a/b/f", "http://localhost/test", null, null).getStatus());
- assertEquals(204, service("GET", "http://localhost/test/a/b/g", "http://localhost/test", null, null).getStatus());
+ assertEquals("text/xml,text/plain;q=0.7", launcher.service("GET", "http://localhost/test/a/b/d",
+ "http://localhost/test", h, null, null).getEntity());
+ assertEquals("GET", launcher.service("GET", "http://localhost/test/a/b/e", "http://localhost/test", null, null,
+ null).getEntity());
+ assertEquals(204, launcher.service("GET", "http://localhost/test/a/b/f", "http://localhost/test", null, null,
+ null).getStatus());
+ assertEquals(204, launcher.service("GET", "http://localhost/test/a/b/g", "http://localhost/test", null, null,
+ null).getStatus());
}
}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/MatchedURIsAndResourcesTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/MatchedURIsAndResourcesTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/MatchedURIsAndResourcesTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.rest.impl.resource;
-import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.BaseTest;
import org.exoplatform.services.rest.impl.header.HeaderHelper;
import java.util.ArrayList;
@@ -33,7 +33,7 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class MatchedURIsAndResourcesTest extends AbstractResourceTest
+public class MatchedURIsAndResourcesTest extends BaseTest
{
@Path("/a/b")
@@ -114,10 +114,10 @@
{
Resource1 r1 = new Resource1();
registry(r1);
- assertEquals("/1,/a/b", service("GET", "http://localhost/test/a/b/1", "http://localhost/test", null, null)
- .getEntity());
- assertEquals("Resource1", service("GET", "http://localhost/test/a/b/2", "http://localhost/test", null, null)
- .getEntity());
+ assertEquals("/1,/a/b", launcher.service("GET", "http://localhost/test/a/b/1", "http://localhost/test", null,
+ null, null).getEntity());
+ assertEquals("Resource1", launcher.service("GET", "http://localhost/test/a/b/2", "http://localhost/test", null,
+ null, null).getEntity());
unregistry(r1);
}
@@ -125,10 +125,10 @@
{
Resource1 r1 = new Resource1();
registry(r1);
- assertEquals("/1,/sub,/a/b", service("GET", "http://localhost/test/a/b/sub/1", "http://localhost/test", null,
- null).getEntity());
- assertEquals("SubResource1,Resource1", service("GET", "http://localhost/test/a/b/sub/2", "http://localhost/test",
- null, null).getEntity());
+ assertEquals("/1,/sub,/a/b", launcher.service("GET", "http://localhost/test/a/b/sub/1", "http://localhost/test",
+ null, null, null).getEntity());
+ assertEquals("SubResource1,Resource1", launcher.service("GET", "http://localhost/test/a/b/sub/2",
+ "http://localhost/test", null, null, null).getEntity());
unregistry(r1);
}
@@ -136,10 +136,10 @@
{
Resource1 r1 = new Resource1();
registry(r1);
- assertEquals("/1,/sub-sub,/sub,/a/b", service("GET", "http://localhost/test/a/b/sub/sub-sub/1",
- "http://localhost/test", null, null).getEntity());
- assertEquals("SubResource2,SubResource1,Resource1", service("GET", "http://localhost/test/a/b/sub/sub-sub/2",
- "http://localhost/test", null, null).getEntity());
+ assertEquals("/1,/sub-sub,/sub,/a/b", launcher.service("GET", "http://localhost/test/a/b/sub/sub-sub/1",
+ "http://localhost/test", null, null, null).getEntity());
+ assertEquals("SubResource2,SubResource1,Resource1", launcher.service("GET",
+ "http://localhost/test/a/b/sub/sub-sub/2", "http://localhost/test", null, null, null).getEntity());
unregistry(r1);
}
}
Modified: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/BaseTest.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/BaseTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/BaseTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -22,28 +22,13 @@
import junit.framework.TestCase;
import org.exoplatform.container.StandaloneContainer;
-import org.exoplatform.services.rest.ContainerResponseWriter;
import org.exoplatform.services.rest.ext.groovy.GroovyJaxrsPublisher;
import org.exoplatform.services.rest.impl.ApplicationContextImpl;
-import org.exoplatform.services.rest.impl.ContainerRequest;
-import org.exoplatform.services.rest.impl.ContainerResponse;
-import org.exoplatform.services.rest.impl.EnvironmentContext;
-import org.exoplatform.services.rest.impl.InputHeadersMap;
-import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
import org.exoplatform.services.rest.impl.ProviderBinder;
import org.exoplatform.services.rest.impl.RequestHandlerImpl;
import org.exoplatform.services.rest.impl.ResourceBinder;
-import org.exoplatform.services.rest.tools.DummyContainerResponseWriter;
-import org.exoplatform.services.test.mock.MockHttpServletRequest;
+import org.exoplatform.services.rest.tools.ResourceLauncher;
-import java.io.ByteArrayInputStream;
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.MultivaluedMap;
-
/**
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id$
@@ -60,6 +45,8 @@
protected GroovyJaxrsPublisher groovyPublisher;
+ protected ResourceLauncher launcher;
+
public void setUp() throws Exception
{
StandaloneContainer.setConfigurationPath("src/test/resources/conf/standalone/test-configuration.xml");
@@ -72,40 +59,11 @@
ApplicationContextImpl.setCurrent(new ApplicationContextImpl(null, null, providers));
binder.clear();
groovyPublisher = (GroovyJaxrsPublisher)container.getComponentInstanceOfType(GroovyJaxrsPublisher.class);
+ launcher = new ResourceLauncher(requestHandler);
}
public void tearDown() throws Exception
{
}
- public ContainerResponse service(String method, String requestURI, String baseURI,
- Map<String, List<String>> headers, byte[] data, ContainerResponseWriter writer) throws Exception
- {
-
- if (headers == null)
- headers = new MultivaluedMapImpl();
-
- ByteArrayInputStream in = null;
- if (data != null)
- in = new ByteArrayInputStream(data);
-
- EnvironmentContext envctx = new EnvironmentContext();
- HttpServletRequest httpRequest =
- new MockHttpServletRequest(requestURI, in, in != null ? in.available() : 0, method, headers);
- envctx.put(HttpServletRequest.class, httpRequest);
- EnvironmentContext.setCurrent(envctx);
- ContainerRequest request =
- new ContainerRequest(method, new URI(requestURI), new URI(baseURI), in, new InputHeadersMap(headers));
- ContainerResponse response = new ContainerResponse(writer);
- requestHandler.handleRequest(request, response);
- return response;
- }
-
- public ContainerResponse service(String method, String requestURI, String baseURI,
- MultivaluedMap<String, String> headers, byte[] data) throws Exception
- {
- return service(method, requestURI, baseURI, headers, data, new DummyContainerResponseWriter());
-
- }
-
}
Modified: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyContextParamTest.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyContextParamTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyContextParamTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -21,10 +21,14 @@
import org.exoplatform.services.rest.ext.BaseTest;
import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.impl.EnvironmentContext;
import org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter;
+import org.exoplatform.services.test.mock.MockHttpServletRequest;
import java.io.InputStream;
+import javax.servlet.http.HttpServletRequest;
+
/**
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: GroovyContextParamTest.java 2647 2010-06-17 08:39:29Z aparfonov
@@ -60,8 +64,16 @@
assertEquals(1, groovyPublisher.resources.size());
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
+
+ EnvironmentContext envctx = new EnvironmentContext();
+
+ HttpServletRequest httpRequest =
+ new MockHttpServletRequest("http://localhost:8080/context/a/b", null, 0, "GET", null);
+ envctx.put(HttpServletRequest.class, httpRequest);
+
ContainerResponse resp =
- service("GET", "http://localhost:8080/context/a/b", "http://localhost:8080/context", null, null, writer);
+ launcher.service("GET", "http://localhost:8080/context/a/b", "http://localhost:8080/context", null, null,
+ writer, envctx);
assertEquals(200, resp.getStatus());
assertEquals("GET\n/context/a/b", new String(writer.getBody()));
}
Modified: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyDependenciesTest.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyDependenciesTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyDependenciesTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -50,7 +50,7 @@
{
groovyPublisher.publishPerRequest(script, new BaseResourceId("GMain1"));
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
- ContainerResponse resp = service("GET", "/a", "", null, null, writer);
+ ContainerResponse resp = launcher.service("GET", "/a", "", null, null, writer, null);
assertEquals(200, resp.getStatus());
assertEquals("dependencies.Dep1", new String(writer.getBody()));
}
Modified: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyExoComponentTest.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyExoComponentTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovyExoComponentTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -75,7 +75,7 @@
assertEquals(1, groovyPublisher.resources.size());
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
- ContainerResponse resp = service("GET", "/a/b", "", null, null, writer);
+ ContainerResponse resp = launcher.service("GET", "/a/b", "", null, null, writer, null);
assertEquals(200, resp.getStatus());
assertEquals("exo container's component", new String(writer.getBody()));
}
Modified: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySecureRestrictionTest.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySecureRestrictionTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySecureRestrictionTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -47,7 +47,7 @@
{
groovyPublisher.publishPerRequest(script, new BaseResourceId("g1"));
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
- ContainerResponse resp = service("GET", "/a/b", "", null, null, writer);
+ ContainerResponse resp = launcher.service("GET", "/a/b", "", null, null, writer, null);
assertEquals(500, resp.getStatus());
assertTrue(new String(writer.getBody()).startsWith("access denied"));
}
Modified: ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySimpleTest.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySimpleTest.java 2010-06-24 15:00:00 UTC (rev 2697)
+++ ws/trunk/exo.ws.rest.ext/src/test/java/org/exoplatform/services/rest/ext/groovy/GroovySimpleTest.java 2010-06-24 15:06:31 UTC (rev 2698)
@@ -73,7 +73,7 @@
assertEquals("file:/groovy/script/jaxrs", cs);
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
- ContainerResponse resp = service("GET", "/a/groovy", "", null, null, writer);
+ ContainerResponse resp = launcher.service("GET", "/a/groovy", "", null, null, writer, null);
assertEquals(200, resp.getStatus());
assertEquals("hello groovy", new String(writer.getBody()));
More information about the exo-jcr-commits
mailing list