Examples of ByteArrayContainerResponseWriter


Examples of org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter

      super.tearDown();
   }

   public void testErrorResponse() throws Exception
   {
      ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
      ContainerResponse response = launcher.service("GET", "/a/4", "", null, null, writer, null);
      assertEquals(500, response.getStatus());
      String entity = new String(writer.getBody());
      assertEquals(errorMessage, entity);
      assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
   }
View Full Code Here

Examples of org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter

      assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
   }

   public void testUncheckedException() throws Exception
   {
      ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
      ContainerResponse response = launcher.service("GET", "/a/3", "", null, null, writer, null);
      assertEquals(500, response.getStatus());
      String entity = new String(writer.getBody());
      assertEquals(errorMessage, entity);
      assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
   }
View Full Code Here

Examples of org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter

      assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
   }

   public void testWebApplicationExceptionWithCause() throws Exception
   {
      ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
      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);
      assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
   }
View Full Code Here

Examples of org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter

      assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
   }

   public void testWebApplicationExceptionWithoutCause() throws Exception
   {
      ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
      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));
   }
View Full Code Here

Examples of org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter

      assertNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
   }

   public void testWebApplicationExceptionWithResponse() throws Exception
   {
      ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
      ContainerResponse response = launcher.service("GET", "/a/1", "", null, null, writer, null);
      assertEquals(500, response.getStatus());
      String entity = new String(writer.getBody());
      assertEquals(errorMessage, entity);
      assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
   }
View Full Code Here

Examples of org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter

      assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
   }

   public void testErrorOnRequestLifeCycleEnd() throws Exception
   {
      ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
      try
      {
         FailingComponentRequestLifecycle.FAIL.set(true);
         launcher.service("GET", "/a/5", "", null, null, writer, null);
      }
View Full Code Here

Examples of org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter

   public void testGetScript() throws Exception
   {
      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.putSingle("Accept", "script/groovy");
      ByteArrayContainerResponseWriter wr = new ByteArrayContainerResponseWriter();
      ContainerResponse cres =
         launcher.service("POST", "/script/groovy/src/db1/ws/testRoot/script", "", headers, null, wr, null);
      assertEquals(200, cres.getStatus());
      compareStream(script.getProperty("jcr:data").getStream(), new ByteArrayInputStream(wr.getBody()));
   }
View Full Code Here

Examples of org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter

      ContainerRequestUserRole creq =
         new ContainerRequestUserRole("GET", new URI(REST_REPOSITORY_SERVICE_PATH
            + RestRepositoryService.Constants.OperationType.REPOSITORIES_LIST), new URI(""), null, new InputHeadersMap(
            headers));

      ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
      ContainerResponse cres = new ContainerResponse(responseWriter);
      handler.handleRequest(creq, cres);

      assertEquals(200, cres.getStatus());

      NamesList repositories = (NamesList)getObject(NamesList.class, responseWriter.getBody());

      assertNotNull(repositories);
      assertEquals(repositoryService.getConfig().getRepositoryConfigurations().size(), repositories.getNames().size());
   }
View Full Code Here

Examples of org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter

      ContainerRequestUserRole creq =
         new ContainerRequestUserRole("GET", new URI(REST_REPOSITORY_SERVICE_PATH
            + RestRepositoryService.Constants.OperationType.WORKSPACES_LIST + "/" + repoName + "/"), new URI(""), null,
            new InputHeadersMap(headers));

      ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
      ContainerResponse cres = new ContainerResponse(responseWriter);
      handler.handleRequest(creq, cres);

      assertEquals(200, cres.getStatus());

      NamesList workspaces = (NamesList)getObject(NamesList.class, responseWriter.getBody());

      assertNotNull(workspaces);
      assertEquals(repositoryService.getConfig().getRepositoryConfiguration(repoName).getWorkspaceEntries().size(),
         workspaces.getNames().size());
   }
View Full Code Here

Examples of org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter

      ContainerRequestUserRole creq =
         new ContainerRequestUserRole("GET", new URI(REST_REPOSITORY_SERVICE_PATH
            + RestRepositoryService.Constants.OperationType.DEFAULT_WS_CONFIG + "/" + repoName + "/"), new URI(""),
            null, new InputHeadersMap(headers));

      ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
      ContainerResponse cres = new ContainerResponse(responseWriter);
      handler.handleRequest(creq, cres);

      assertEquals(200, cres.getStatus());

      WorkspaceEntry workspaceEntry = (WorkspaceEntry)getObject(WorkspaceEntry.class, responseWriter.getBody());

      assertNotNull(workspaceEntry);
      assertEquals(repositoryService.getConfig().getRepositoryConfiguration(repoName).getDefaultWorkspaceName(),
         workspaceEntry.getName());
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.