Package org.simpleframework.http.message

Examples of org.simpleframework.http.message.TokenConsumer


public class TokenConsumerTest extends TestCase {
  
   public void testTokenConsumer() throws IOException {
      Allocator allocator = new ArrayAllocator();
      TokenConsumer consumer = new TokenConsumer(allocator, "\r\n".getBytes());
      Cursor cursor = new StreamCursor("\r\n");
     
      consumer.consume(cursor);
     
      assertEquals(cursor.ready(), -1);
      assertTrue(consumer.isFinished())
   }
View Full Code Here


      assertTrue(consumer.isFinished())
   }
  
   public void testTokenConsumerException() throws IOException {
      Allocator allocator = new ArrayAllocator();
      TokenConsumer consumer = new TokenConsumer(allocator, "\r\n".getBytes());
      Cursor cursor = new StreamCursor("--\r\n");
      boolean exception = false;
     
      try {
         consumer.consume(cursor);
      } catch(Exception e) {
         exception = true;
      }
      assertTrue("Exception not thrown for invalid token", exception);
   }
View Full Code Here

      assertTrue("Exception not thrown for invalid token", exception);
   }
  
   public void testTokenConsumerDribble() throws IOException {
      Allocator allocator = new ArrayAllocator();
      TokenConsumer consumer = new TokenConsumer(allocator, "This is a large token to be consumed\r\n".getBytes());
      DribbleCursor cursor = new DribbleCursor(new StreamCursor("This is a large token to be consumed\r\n0123456789"), 1);

      consumer.consume(cursor);
     
      assertEquals(cursor.ready(), 1);
      assertTrue(consumer.isFinished());
      assertEquals(cursor.read(), '0');
      assertEquals(cursor.read(), '1');
      assertEquals(cursor.read(), '2');
   }
View Full Code Here

TOP

Related Classes of org.simpleframework.http.message.TokenConsumer

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.