Package org.simpleframework.http

Examples of org.simpleframework.http.Request


      Collector body = new Collector(new ArrayAllocator(), channel);
     
      while(!selector.isReady()) {
         body.collect(selector);
      }  
      Request request = new RequestEntity(body, null);
      List<Part> list = request.getParts();     
     
      assertEquals(request.getParameter("a"), "b");
      assertEquals(request.getParameter("c"), "d");
      assertEquals(request.getParameter("e"), "f");
      assertEquals(request.getParameter("g"), "h");       
      assertEquals(request.getTarget(), "/index.html?a=b&c=d&e=f&g=h&a=1");
      assertEquals(request.getMethod(), "POST");
      assertEquals(request.getMajor(), 1);
      assertEquals(request.getMinor(), 0);
      assertEquals(request.getContentType().getPrimary(), "multipart");
      assertEquals(request.getContentType().getSecondary(), "form-data");    
      assertEquals(request.getValue("Host"), "some.host.com");
      assertEquals(request.getValues("Accept").size(), 4);
      assertEquals(request.getValues("Accept").get(0), "image/gif");
      assertEquals(request.getValues("Accept").get(1), "image/png");
      assertEquals(request.getValues("Accept").get(2), "image/jpeg");
      assertEquals(request.getValues("Accept").get(3), "*")
      assertEquals(request.getCookie("UID").getValue(), "1234-5678");
      assertEquals(request.getCookie("UID").getPath(), "/");
      assertEquals(request.getCookie("UID").getDomain(), ".host.com");
      assertEquals(request.getCookie("NAME").getValue(), "Niall Gallagher");
      assertEquals(request.getCookie("NAME").getPath(), "/");
      assertEquals(request.getCookie("NAME").getDomain(), null);
      assertEquals(list.size(), 4);
      assertEquals(list.get(0).getContentType().getPrimary(), "text");
      assertEquals(list.get(0).getContentType().getSecondary(), "plain");
      assertEquals(list.get(0).getHeader("Content-Disposition"), "file; name=\"file1\"; filename=\"file1.txt\"; modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
      assertEquals(list.get(0).getName(), "file1");
      assertEquals(list.get(0).getFileName(), "file1.txt");
      assertEquals(list.get(0).isFile(), true);
      assertEquals(list.get(0).getContent(), "example contents of file1.txt");
      assertEquals(request.getPart("file1").getContent(), "example contents of file1.txt");
      assertEquals(list.get(1).getContentType().getPrimary(), "text");
      assertEquals(list.get(1).getContentType().getSecondary(), "plain");
      assertEquals(list.get(1).getHeader("Content-Disposition"), "file; name=\"file2\"; filename=\"file2.txt\"");
      assertEquals(list.get(1).getContentType().getPrimary(), "text");
      assertEquals(list.get(1).getName(), "file2");
      assertEquals(list.get(1).getFileName(), "file2.txt");
      assertEquals(list.get(1).isFile(), true);
      assertEquals(list.get(1).getContent(), "example contents of file2.txt ...");
      assertEquals(request.getPart("file2").getContent(), "example contents of file2.txt ...");
      assertEquals(list.get(2).getContentType().getSecondary(), "plain");
      assertEquals(list.get(2).getHeader("Content-Disposition"), "file; name=\"file3\"; filename=\"file3.txt\"");
      assertEquals(list.get(2).getName(), "file3");
      assertEquals(list.get(2).getFileName(), "file3.txt");
      assertEquals(list.get(2).isFile(), true);
      assertEquals(list.get(2).getContent(), "example contents of file3.txt ...");
      assertEquals(request.getPart("file3").getContent(), "example contents of file3.txt ...");
      assertEquals(list.get(3).getContentType().getPrimary(), "text");
      assertEquals(list.get(3).getContentType().getSecondary(), "plain");
      assertEquals(list.get(3).getHeader("Content-Disposition"), "file; name=\"file4\"; filename=\"file4.txt\"");
      assertEquals(list.get(3).getName(), "file4");
      assertEquals(list.get(3).getFileName(), "file4.txt");
      assertEquals(list.get(3).isFile(), true);
      assertEquals(list.get(3).getContent(), "example contents of file4.txt ...");
      assertEquals(request.getPart("file4").getContent(), "example contents of file4.txt ...");
      assertEquals(cursor.ready(), -1);    
      assertEquals(request.getContent(), BODY);     
   }
View Full Code Here


      Collector body = new EntityCollector(new ArrayAllocator(), null, channel);
     
      while(!selector.isReady()) {
         body.collect(selector);
      }  
      Request request = new RequestEntity(body, null);
      Form form = request.getForm();
      List<Part> list = form.getParts();     
     
      assertEquals(form.get("a"), "b");
      assertEquals(form.get("c"), "d");
      assertEquals(form.get("e"), "f");
      assertEquals(form.get("g"), "h");
      assertEquals(form.getAll("a").size(), 2);
      assertEquals(form.getAll("a").get(0), "b");
      assertEquals(form.getAll("a").get(1), "1");       
      assertEquals(request.getTarget(), "/index.html?a=b&c=d&e=f&g=h&a=1");
      assertEquals(request.getMethod(), "POST");
      assertEquals(request.getMajor(), 1);
      assertEquals(request.getMinor(), 0);
      assertEquals(request.getContentType().getPrimary(), "multipart");
      assertEquals(request.getContentType().getSecondary(), "form-data");    
      assertEquals(request.getValue("Host"), "some.host.com");
      assertEquals(request.getValues("Accept").size(), 4);
      assertEquals(request.getValues("Accept").get(0), "image/gif");
      assertEquals(request.getValues("Accept").get(1), "image/png");
      assertEquals(request.getValues("Accept").get(2), "image/jpeg");
      assertEquals(request.getValues("Accept").get(3), "*")
      assertEquals(request.getCookie("UID").getValue(), "1234-5678");
      assertEquals(request.getCookie("UID").getPath(), "/");
      assertEquals(request.getCookie("UID").getDomain(), ".host.com");
      assertEquals(request.getCookie("NAME").getValue(), "Niall Gallagher");
      assertEquals(request.getCookie("NAME").getPath(), "/");
      assertEquals(request.getCookie("NAME").getDomain(), null);
      assertEquals(list.size(), 4);
      assertEquals(list.get(0).getContentType().getPrimary(), "text");
      assertEquals(list.get(0).getContentType().getSecondary(), "plain");
      assertEquals(list.get(0).getHeader("Content-Disposition"), "file; name=\"file1\"; filename=\"file1.txt\"; modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
      assertEquals(list.get(0).getName(), "file1");
      assertEquals(list.get(0).getFileName(), "file1.txt");
      assertEquals(list.get(0).isFile(), true);
      assertEquals(list.get(0).getContent(), "example contents of file1.txt");
      assertEquals(request.getForm().getPart("file1").getContent(), "example contents of file1.txt");
      assertEquals(list.get(1).getContentType().getPrimary(), "text");
      assertEquals(list.get(1).getContentType().getSecondary(), "plain");
      assertEquals(list.get(1).getHeader("Content-Disposition"), "file; name=\"file2\"; filename=\"file2.txt\"");
      assertEquals(list.get(1).getContentType().getPrimary(), "text");
      assertEquals(list.get(1).getName(), "file2");
      assertEquals(list.get(1).getFileName(), "file2.txt");
      assertEquals(list.get(1).isFile(), true);
      assertEquals(list.get(1).getContent(), "example contents of file2.txt ...");
      assertEquals(request.getForm().getPart("file2").getContent(), "example contents of file2.txt ...");
      assertEquals(list.get(2).getContentType().getSecondary(), "plain");
      assertEquals(list.get(2).getHeader("Content-Disposition"), "file; name=\"file3\"; filename=\"file3.txt\"");
      assertEquals(list.get(2).getName(), "file3");
      assertEquals(list.get(2).getFileName(), "file3.txt");
      assertEquals(list.get(2).isFile(), true);
      assertEquals(list.get(2).getContent(), "example contents of file3.txt ...");
      assertEquals(request.getForm().getPart("file3").getContent(), "example contents of file3.txt ...");
      assertEquals(list.get(3).getContentType().getPrimary(), "text");
      assertEquals(list.get(3).getContentType().getSecondary(), "plain");
      assertEquals(list.get(3).getHeader("Content-Disposition"), "file; name=\"file4\"; filename=\"file4.txt\"");
      assertEquals(list.get(3).getName(), "file4");
      assertEquals(list.get(3).getFileName(), "file4.txt");
      assertEquals(list.get(3).isFile(), true);
      assertEquals(list.get(3).getContent(), "example contents of file4.txt ...");
      assertEquals(request.getForm().getPart("file4").getContent(), "example contents of file4.txt ...");
      assertEquals(cursor.ready(), -1);    
      assertEquals(request.getContent(), BODY);     
   }
View Full Code Here

    }
   
    @Test public void
    indicatesResourcesThatAreNotFound() throws IOException {
        final Resource resource = engine.resolve(new AddressParser("http://ci-eye/sausage"));
        final Request request = context.mock(Request.class);
        final Response response = context.mock(Response.class);
       
        context.checking(new Expectations() {{
            oneOf(response).setCode(404);
            allowing(response).getOutputStream(); will(returnValue(new ByteArrayOutputStream()));
View Full Code Here

    }

    @Test public void
    redirectsLandscapeResourcesWithoutTrailingSlash() throws IOException {
        final Resource resource = engine.resolve(new AddressParser("http://ci-eye/landscapes/myLandscape"));
        final Request request = context.mock(Request.class);
        final Response response = context.mock(Response.class);
       
        context.checking(new Expectations() {{
            oneOf(response).setCode(301);
            allowing(response).getOutputStream(); will(returnValue(new ByteArrayOutputStream()));
View Full Code Here

TOP

Related Classes of org.simpleframework.http.Request

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.