Examples of ArrayAllocator


Examples of org.simpleframework.util.buffer.ArrayAllocator

   "--BbC04y--\r\n"+
   "--AaB03x--\r\n";
  
   public void testSimple() throws Exception {
      PartData list = new PartData();
      PartSeriesConsumer consumer = new PartSeriesConsumer(new ArrayAllocator(), list, "AaB03x".getBytes("UTF-8"));
      Cursor cursor = new StreamCursor(SIMPLE);
     
      while(!consumer.isFinished()) {
         consumer.consume(cursor);
      }  
View Full Code Here

Examples of org.simpleframework.util.buffer.ArrayAllocator

      assertEquals(consumer.getBody().getContent(), SIMPLE);
   }
  
   public void testNormal() throws Exception {
      PartData list = new PartData();
      PartSeriesConsumer consumer = new PartSeriesConsumer(new ArrayAllocator(), list, "AaB03x".getBytes("UTF-8"));
      Cursor cursor = new StreamCursor(NORMAL);
     
      while(!consumer.isFinished()) {
         consumer.consume(cursor);
      }  
View Full Code Here

Examples of org.simpleframework.util.buffer.ArrayAllocator

      assertEquals(consumer.getBody().getContent(), NORMAL);
   }
  
   public void testMixed() throws Exception {
      PartData list = new PartData();
      PartSeriesConsumer consumer = new PartSeriesConsumer(new ArrayAllocator(), list, "AaB03x".getBytes("UTF-8"));
      Cursor cursor = new StreamCursor(MIXED);
     
      while(!consumer.isFinished()) {
         consumer.consume(cursor);
      }  
View Full Code Here

Examples of org.simpleframework.util.buffer.ArrayAllocator

      assertEquals(consumer.getBody().getContent(), MIXED);
   }
  
   public void testDribble() throws Exception {
      PartData list = new PartData();
      PartSeriesConsumer consumer = new PartSeriesConsumer(new ArrayAllocator(), list, "AaB03x".getBytes("UTF-8"));
      Cursor cursor = new DribbleCursor(new StreamCursor(NORMAL), 1);
     
      while(!consumer.isFinished()) {
         consumer.consume(cursor);
      }  
View Full Code Here

Examples of org.simpleframework.util.buffer.ArrayAllocator

      }
      if(buf.length() > 0) {
         encode.write(buf.toString().getBytes("UTF-8"));
         plain.write(buf.toString().getBytes("UTF-8"));
      }
      buffer = new ArrayAllocator().allocate(); // N.B clear previous buffer
      encode.close();
      byte[] data = out.toByteArray();
      byte[] plainText = plain.toByteArray();
      //System.out.println(">>"+new String(data, 0, data.length, "UTF-8")+"<<");
      //System.out.println("}}"+new String(plainText, 0, plainText.length,"UTF-8")+"{{");
View Full Code Here

Examples of org.simpleframework.util.buffer.ArrayAllocator

  
   public void testPayload(int dribble) throws Exception {
      Cursor cursor = new DribbleCursor(new StreamCursor(PAYLOAD), 10);
      Channel channel = new MockChannel(cursor);
      MockSelector selector = new MockSelector();
      Collector body = new Collector(new ArrayAllocator(), channel);
      long time = System.currentTimeMillis();
     
      while(!selector.isReady()) {
         body.collect(selector);
      }
View Full Code Here

Examples of org.simpleframework.util.buffer.ArrayAllocator

import org.simpleframework.util.buffer.ArrayAllocator;

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);
     
View Full Code Here

Examples of org.simpleframework.util.buffer.ArrayAllocator

      assertEquals(cursor.ready(), -1);
      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 {
View Full Code Here

Examples of org.simpleframework.util.buffer.ArrayAllocator

      }
      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);
     
View Full Code Here

Examples of org.simpleframework.util.buffer.ArrayAllocator

      String requestBody = buf.toString();
     
      // Add the boundary to the request body
      buf.append("\r\n--");
      buf.append(new String(BOUNDARY, 0, BOUNDARY.length, "UTF-8"));
      buffer = new ArrayAllocator().allocate();
     
      DribbleCursor cursor = new DribbleCursor(new StreamCursor(buf.toString()), dribble);
     
      while(!consumer.isFinished()) {
         consumer.consume(cursor);
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.