Package org.simpleframework.transport

Examples of org.simpleframework.transport.Cursor


   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() 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);
      assertEquals(header.getValue("Content-Length"), "42");
      assertEquals(header.getValue("Content-Type"), "application/x-www-form-urlencoded");
      assertEquals(header.getValue("Host"), "some.host.com");
      assertEquals(header.getValues("Accept").size(), 4);
      assertEquals(header.getValues("Accept").get(0), "image/gif");
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

      }
      buffer = new ArrayAllocator().allocate();
     
      String requestBody = buf.toString();
      FixedConsumer consumer = new FixedConsumer(this, limitSize);
      Cursor cursor = new DribbleCursor(new StreamCursor(requestBody), dribble);
      byte[] requestBytes = requestBody.getBytes("UTF-8");
     
      while(!consumer.isFinished()) {
         consumer.consume(cursor);
      }
View Full Code Here

   public void testPerformance(byte[] request, String path) throws Exception {
      long start = System.currentTimeMillis();
     
      for(int i = 0; i < 10000; i++) {
         RequestConsumer header = new RequestConsumer();
         Cursor cursor = new StreamCursor(request);
     
         while(!header.isFinished()) {
            header.consume(cursor);
         }
        
         assertEquals(cursor.ready(), -1);
         assertEquals(header.getPath().getPath(), path);    
      }
      System.err.printf("%s time=%s%n", path, (System.currentTimeMillis() - start));
   }
View Full Code Here

   public void testHeader() throws Exception {
      long start = System.currentTimeMillis();
     
      for(int i = 0; i < 10000; i++) {
         RequestConsumer header = new RequestConsumer();
         Cursor cursor = new StreamCursor(SOURCE_1);
     
         while(!header.isFinished()) {
            header.consume(cursor);
         }
        
         assertEquals(cursor.ready(), -1);
         assertEquals(header.getTarget(), "/index.html");
         assertEquals(header.getMethod(), "POST");
         assertEquals(header.getMajor(), 1);
         assertEquals(header.getMinor(), 0);
         assertEquals(header.getValue("Content-Length"), "42");
View Full Code Here

TOP

Related Classes of org.simpleframework.transport.Cursor

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.