Package org.exoplatform.services.rest.impl

Examples of org.exoplatform.services.rest.impl.EnvironmentContext


      RequestLifeCycle.begin(container);

      RequestHandler requestHandler = (RequestHandler)container.getComponentInstanceOfType(RequestHandler.class);

      EnvironmentContext env = new EnvironmentContext();
      env.put(HttpServletRequest.class, httpRequest);
      env.put(HttpServletResponse.class, httpResponse);
      env.put(ServletConfig.class, config);
      env.put(ServletContext.class, getServletContext());

      try
      {
         EnvironmentContext.setCurrent(env);
         ServletContainerRequest request = new ServletContainerRequest(httpRequest);
View Full Code Here


   public void testInvokerFilter() throws Exception
   {
      Resource1 r = new Resource1();
      registry(r);

      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);

      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);
   }
View Full Code Here

      assertEquals(1, binder.getSize());
      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 =
         launcher.service("GET", "http://localhost:8080/context/a/b", "http://localhost:8080/context", null, null,
            writer, envctx);
      assertEquals(200, resp.getStatus());
View Full Code Here

      w.flush();
      h.putSingle("content-type", "multipart/form-data; boundary=abcdef");

      byte[] data = out.toByteArray();

      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);
   }
View Full Code Here

   public void test0() throws Exception
   {
      registry(Resource1.class);

      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);

      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());

      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());

      unregistry(Resource1.class);
View Full Code Here

TOP

Related Classes of org.exoplatform.services.rest.impl.EnvironmentContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.