Package org.exoplatform.services.test.mock

Examples of org.exoplatform.services.test.mock.MockHttpServletRequest


      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


      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

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

      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

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

      container.registerComponentInstance(TestContainerComponent.class.getName(), new TestContainerComponent());
      registry(Resource4.class);

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

      // 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 = launcher.service("GET", "/a", "", null, null, envctx);
      assertEquals(204, resp.getStatus());
View Full Code Here

   {
      Resource1 r = new Resource1();
      registry(r);

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

TOP

Related Classes of org.exoplatform.services.test.mock.MockHttpServletRequest

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.