Package org.simpleframework.http.core

Examples of org.simpleframework.http.core.StreamCursor.ready()


      Cursor cursor = new StreamCursor(SOURCE);
     
      while(!header.isFinished()) {
         header.consume(cursor);
      }     
      assertEquals(cursor.ready(), -1);
      assertEquals(header.getValue("Pragma"), null);
      assertEquals(header.getValue("User-Agent"), "");
      assertEquals(header.getValue("Content-Length"), "42");
      assertEquals(header.getValue("Content-Type"), "application/x-www-form-urlencoded");
      assertEquals(header.getValue("Host"), "some.host.com");
View Full Code Here


      Cursor cursor = new StreamCursor(EMPTY);
     
      while(!header.isFinished()) {
         header.consume(cursor);
      }     
      assertEquals(cursor.ready(), -1);
      assertEquals(header.getValue("Accept-Language"), "");
      assertEquals(header.getValue("Content-Length"), "");
      assertEquals(header.getValue("Content-Type"), "");
      assertEquals(header.getValue("Content-Disposition"), "");
      assertEquals(header.getValue("Transfer-Encoding"), "");
View Full Code Here

      assertEquals(list.getParts().size(), 1);
      assertEquals(list.getParts().get(0).getContentType().getPrimary(), "text");
      assertEquals(list.getParts().get(0).getContentType().getSecondary(), "plain");
      assertEquals(list.getParts().get(0).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file1.txt'");
      assertEquals(list.getParts().get(0).getContent(), "example contents of file1.txt ...");
      assertEquals(cursor.ready(), -1);    
      assertEquals(consumer.getBody().getContent(), SIMPLE);
   }
  
   public void testNormal() throws Exception {
      PartData list = new PartData();
View Full Code Here

      assertEquals(list.getParts().get(1).getContent(), "example contents of file2.txt");
      assertEquals(list.getParts().get(2).getContentType().getPrimary(), "text");
      assertEquals(list.getParts().get(2).getContentType().getSecondary(), "plain");
      assertEquals(list.getParts().get(2).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file3.txt'");
      assertEquals(list.getParts().get(2).getContent(), "example contents of file3.txt ...");
      assertEquals(cursor.ready(), -1);    
      assertEquals(consumer.getBody().getContent(), NORMAL);
   }
  
   public void testMixed() throws Exception {
      PartData list = new PartData();
View Full Code Here

      assertEquals(list.getParts().get(2).getContent(), "example contents of file3.txt ...");
      assertEquals(list.getParts().get(3).getContentType().getPrimary(), "text");
      assertEquals(list.getParts().get(3).getContentType().getSecondary(), "plain");
      assertEquals(list.getParts().get(3).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file4.txt'");
      assertEquals(list.getParts().get(3).getContent(), "example contents of file4.txt ...");
      assertEquals(cursor.ready(), -1);          
      assertEquals(consumer.getBody().getContent(), MIXED);
   }
  
   public void testDribble() throws Exception {
      PartData list = new PartData();
View Full Code Here

      TokenConsumer consumer = new TokenConsumer(allocator, "\r\n".getBytes());
      Cursor cursor = new StreamCursor("\r\n");
     
      consumer.consume(cursor);
     
      assertEquals(cursor.ready(), -1);
      assertTrue(consumer.isFinished())
   }
  
   public void testTokenConsumerException() throws IOException {
      Allocator allocator = new ArrayAllocator();
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.