Package org.simpleframework.http.core

Examples of org.simpleframework.http.core.StreamCursor


   public void testNoFinalCRLF() throws Exception {
      byte[] data = SOURCE.getBytes("UTF-8");
      byte[] boundary = "mxvercagiykxaqsdvrfabfhfpaseejrg".getBytes("UTF-8");
      Allocator allocator = new ArrayAllocator();
      FileUploadConsumer consumer = new FileUploadConsumer(allocator, boundary, data.length);     
      Cursor cursor = new StreamCursor(data);
     
      while(!consumer.isFinished()) {
         consumer.consume(cursor);
     
      assertEquals(consumer.getBody().getContent(), SOURCE);
View Full Code Here


   public void testNoFinalCRLSWithDribble() throws Exception {
      byte[] data = SOURCE.getBytes("UTF-8");
      byte[] boundary = "mxvercagiykxaqsdvrfabfhfpaseejrg".getBytes("UTF-8");
      Allocator allocator = new ArrayAllocator();
      FileUploadConsumer consumer = new FileUploadConsumer(allocator, boundary, data.length);     
      Cursor cursor = new StreamCursor(data);
      DribbleCursor dribble = new DribbleCursor(cursor, 1);
     
      while(!consumer.isFinished()) {
         consumer.consume(dribble);
     
View Full Code Here

   public void testNoFinalCRLSWithDribble3() throws Exception {
      byte[] data = SOURCE.getBytes("UTF-8");
      byte[] boundary = "mxvercagiykxaqsdvrfabfhfpaseejrg".getBytes("UTF-8");
      Allocator allocator = new ArrayAllocator();
      FileUploadConsumer consumer = new FileUploadConsumer(allocator, boundary, data.length);     
      Cursor cursor = new StreamCursor(data);
      DribbleCursor dribble = new DribbleCursor(cursor, 3);
     
      while(!consumer.isFinished()) {
         consumer.consume(dribble);
     
View Full Code Here

   public void setUp() {
      boundary = new BoundaryConsumer(new ArrayAllocator(), BOUNDARY);
   }
  
   public void testBoundary() throws Exception {
      StreamCursor cursor = new StreamCursor(new ByteArrayInputStream(NORMAL));
     
      while(!boundary.isFinished()) {
         boundary.consume(cursor);
      }
      assertEquals(cursor.read(), 'X');
      assertEquals(cursor.read(), 'Y');
      assertTrue(boundary.isFinished());
      assertFalse(boundary.isEnd());
      assertFalse(cursor.isReady());
   }
View Full Code Here

      assertFalse(boundary.isEnd());
      assertFalse(cursor.isReady());
   }
  
   public void testTerminal() throws Exception {
      StreamCursor cursor = new StreamCursor(new ByteArrayInputStream(TERMINAL));
     
      while(!boundary.isFinished()) {
         boundary.consume(cursor);
      }
      assertEquals(cursor.read(), 'X');
      assertEquals(cursor.read(), 'Y');
      assertTrue(boundary.isFinished());
      assertTrue(boundary.isEnd());
      assertFalse(cursor.isReady());
   }
View Full Code Here

      assertTrue(boundary.isEnd());
      assertFalse(cursor.isReady());
   }
  
   public void testDribble() throws Exception {
      DribbleCursor cursor = new DribbleCursor(new StreamCursor(new ByteArrayInputStream(TERMINAL)), 3);
     
      while(!boundary.isFinished()) {
         boundary.consume(cursor);
      }  
      assertEquals(cursor.read(), 'X');
      assertEquals(cursor.read(), 'Y');
      assertTrue(boundary.isFinished());
      assertTrue(boundary.isEnd());
      assertFalse(cursor.isReady());
     
      boundary.clear();
     
      cursor = new DribbleCursor(new StreamCursor(new ByteArrayInputStream(TERMINAL)), 1);
     
      while(!boundary.isFinished()) {
         boundary.consume(cursor);
      }  
      assertEquals(cursor.read(), 'X');
View Full Code Here

   public void setUp() throws IOException {
      header = new SegmentConsumer();
   }
  
   public void testHeader() throws Exception
      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

      assertEquals(header.getContentType().getSecondary(), "x-www-form-urlencoded");
      assertEquals(header.getTransferEncoding(), "chunked");     
   }
  
   public void testEmptyHeader() throws Exception
      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(header.getContentType().getPrimary(), null);
      assertEquals(header.getContentType().getSecondary(), null);  
   }
  
   public void testDribble() throws Exception
      Cursor cursor = new DribbleCursor(new StreamCursor(SOURCE), 1);
     
      while(!header.isFinished()) {
         header.consume(cursor);
      }     
      assertEquals(cursor.ready(), -1);
View Full Code Here

   "--AaB03x\r\n";
  
   public void testHeader() throws Exception {
      PartData list = new PartData();
      PartConsumer consumer = new PartConsumer(new ArrayAllocator(), list, "AaB03x".getBytes("UTF-8"), 8192);
      Cursor cursor = new StreamCursor(SOURCE);
     
      while(!consumer.isFinished()) {
         consumer.consume(cursor);
      }  
      assertEquals(list.getParts().size(), 1);
View Full Code Here

TOP

Related Classes of org.simpleframework.http.core.StreamCursor

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.