Package org.simpleframework.util.buffer

Examples of org.simpleframework.util.buffer.ArrayAllocator


     
      assertEquals(cursor.ready(), -1);
   }
  
   public void start(Channel channel) throws IOException {  
      start(new EntityCollector(new ArrayAllocator(), null, channel));
   }
View Full Code Here


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

      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

      }
      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

      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

   }
  
   public void testChunk(int chunkSize, int count) throws Exception {
      MockSender sender = new MockSender((chunkSize * count) + 1024);
      MockMonitor monitor = new MockMonitor();
      ChunkedConsumer validator = new ChunkedConsumer(new ArrayAllocator());
      ChunkedProducer producer = new ChunkedProducer(sender, monitor);
      byte[] chunk = new byte[chunkSize];
     
      for(int i = 0; i < chunk.length; i++) {
         chunk[i] = (byte)String.valueOf(i).charAt(0);
View Full Code Here

class ReplyConsumer extends BuilderConsumer {

   public Builder builder;

   public ReplyConsumer() {
      this(new ArrayAllocator(), new ResponseBuilder());
   }
View Full Code Here

      if(dribble < PAYLOAD.length) {
         cursor = new DribbleCursor(cursor, dribble);
      }
      Channel channel = new MockChannel(cursor);
      MockSelector selector = new MockSelector();
      Collector body = new EntityCollector(new ArrayAllocator(), null, channel);
     
      while(!selector.isReady()) {
         body.collect(selector);
      }  
      Request request = new RequestEntity(body, null);
View Full Code Here

   "... contents of file1.txt ...\r\n"+
   "--AaB03x\r\n";
  
   public void testHeader() throws Exception {
      PartList list = new PartList();
      PartConsumer consumer = new PartConsumer(new ArrayAllocator(), list, "AaB03x".getBytes("UTF-8"));
      Cursor cursor = new StreamCursor(SOURCE);
     
      while(!consumer.isFinished()) {
         consumer.consume(cursor);
      }  
View Full Code Here

  
   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 EntityCollector(new ArrayAllocator(), null, channel);
      long time = System.currentTimeMillis();
     
      while(!selector.isReady()) {
         body.collect(selector);
      }
View Full Code Here

TOP

Related Classes of org.simpleframework.util.buffer.ArrayAllocator

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.