Package org.jboss.seam.mock

Examples of org.jboss.seam.mock.ResourceRequestEnvironment$ResourceRequest


   ResourceRequestEnvironment requestEnv;

   @BeforeClass
   public void prepareEnv() throws Exception
   {
      requestEnv = new ResourceRequestEnvironment(this)
      {
         @Override
         public Map<String, Object> getDefaultHeaders()
         {
            return new HashMap<String, Object>()


   @Test(dataProvider = "contextDataTypes")
   public void testContextData(String pathSegment) throws Exception
   {
      final String path = "/restv1/contextData" + pathSegment;

      new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, path)
      {

         @Override
         protected void prepareRequest(EnhancedMockHttpServletRequest request)
         {

   public void createTaskTest() throws Exception
   {
      final String mimeType = "application/json";
      final String representation = "{\"task\":{\"name\":\"Test task\"}}";
     
      new ResourceRequest(new ResourceRequestEnvironment(this), Method.POST, "/v1/auth/category/School/unresolved")
      {
        
         @Override
         protected void prepareRequest(EnhancedMockHttpServletRequest request)
         {

   public void editTaskTest() throws Exception
   {
      final String mimeType = "application/xml";
      final String representation = "<task><id>4</id><name>Learn new English vocabulary</name></task>";

      new ResourceRequest(new ResourceRequestEnvironment(this), Method.PUT, "/v1/auth/category/School/unresolved/4")
      {

         @Override
         protected void prepareRequest(EnhancedMockHttpServletRequest request)
         {
            super.prepareRequest(request);
            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
            request.addHeader("Content-Type", mimeType);
            request.setContentType(mimeType);
            request.setContent(representation.getBytes());
         }

         @Override
         protected void onResponse(EnhancedMockHttpServletResponse response)
         {
            super.onResponse(response);
            assertEquals(response.getStatus(), 204, "Unexpected response code.");
         }

      }.run();

      new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/v1/auth/category/School/unresolved/4")
      {

         @Override
         protected void prepareRequest(EnhancedMockHttpServletRequest request)
         {

   }
  
   @Test
   public void deleteTaskTest() throws Exception
   {
      new ResourceRequest(new ResourceRequestEnvironment(this), Method.DELETE, "/v1/auth/category/School/unresolved/2")
      {
        
         @Override
         protected void prepareRequest(EnhancedMockHttpServletRequest request)
         {

   public void resolveTask() throws Exception {
     
      final String mimeType = "application/xml";
      final String representation = "<task><id>14</id></task>";
     
      new ResourceRequest(new ResourceRequestEnvironment(this), Method.PUT, "/v1/auth/category/School/resolved/14")
      {

         @Override
         protected void prepareRequest(EnhancedMockHttpServletRequest request)
         {

   }
  
   @Test(dataProvider="data")
   public void editTaskTest(final String mimeType, final String expectedResponsePart) throws Exception
   {
      new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/v1/user/demo/tasks/resolved")
      {

         @Override
         protected void prepareRequest(EnhancedMockHttpServletRequest request)
         {

   }

   @Test(dataProvider = "query")
   public void getCategoryListTest(final String contentType, final String expectedResponse) throws Exception
   {
      new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/v1/auth/category")
      {

         @Override
         protected void prepareRequest(EnhancedMockHttpServletRequest request)
         {

   }

   @Test
   public void deleteCategoryTest() throws Exception
   {
      new ResourceRequest(new ResourceRequestEnvironment(this), Method.DELETE, "/v1/auth/category/Work")
      {

         @Override
         protected void prepareRequest(EnhancedMockHttpServletRequest request)
         {

     
      final String uri = "/v1/auth/category/Test%20Category";
      final String mimeType = "application/json";
      final String expectedResponse = "{\"category\":{\"name\":\"Test Category\"}}";
     
      new ResourceRequest(new ResourceRequestEnvironment(this), Method.PUT, uri)
      {

         @Override
         protected void prepareRequest(EnhancedMockHttpServletRequest request)
         {
            super.prepareRequest(request);
            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
         }

         @Override
         protected void onResponse(EnhancedMockHttpServletResponse response)
         {
            super.onResponse(response);
            assertEquals(response.getStatus(), 201, "Unexpected response code.");
         }

      }.run();

      new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, uri)
      {

         @Override
         protected void prepareRequest(EnhancedMockHttpServletRequest request)
         {

TOP

Related Classes of org.jboss.seam.mock.ResourceRequestEnvironment$ResourceRequest

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.