Package org.eclipse.jetty.io

Examples of org.eclipse.jetty.io.ByteArrayBuffer


    int read;
    while ((read = is.read(buffer)) != -1)
    {
      os.write(buffer, 0, read);
    }
    SipParser parser = new SipParser(new ByteArrayBuffer(os.toByteArray()), handler);
    parser.parse();
   
    SipMessage message = handler.getMessage();
    String toString = message.toString();
    System.out.println(message);
View Full Code Here


  {
    byte[] raw = getRawMessage("/responseA.dat");
    for (int i = 0; i < 100000; i++)
    {
      DnsMessage message = new DnsMessage();
      message.decode(new ByteArrayBuffer(raw));
    }
  }
View Full Code Here

  }
 
  public void testEncode(String name) throws Exception
  {
    byte[] raw = getRawMessage(name);
    Buffer origBuffer = new ByteArrayBuffer(raw);
    DnsMessage message = new DnsMessage();
    message.decode(origBuffer);
    origBuffer = new ByteArrayBuffer(raw);
    Buffer buffer = new ByteArrayBuffer(512);
    message.encode(buffer);
    byte[] encoded = buffer.asArray();
    //System.out.println(message);
   
    DnsMessage message2 = new DnsMessage();
    message2.decode(new ByteArrayBuffer(encoded));
   
    assertArrayEquals(raw, encoded);
  }
View Full Code Here

    return os.toByteArray();
  }
 
  public DnsMessage getMessage(String name) throws Exception
  {
    Buffer buffer = new ByteArrayBuffer(getRawMessage(name));
    DnsMessage message = new DnsMessage();
    message.decode(buffer);
    return message;
  }
View Full Code Here

    File file = new File(url.toURI());
    FileInputStream fin = new FileInputStream(file);
    byte[] b = new byte[(int) file.length()];
    fin.read(b);
   
    return new ByteArrayBuffer(b);
  }
View Full Code Here

    answer.setCommand(Common.CEA);
    AVPList l = new AVPList();
    answer.setAVPList(l);
    answer.setResultCode(Common.DIAMETER_SUCCESS);

    Buffer buffer = new ByteArrayBuffer(512);
    buffer = Codecs.__message.encode(buffer, answer);
    DiameterMessage message = Codecs.__message.decode(buffer);
    assertFalse(message.isRequest());
    assertEquals(Common.CEA, message.getCommand());
  }
View Full Code Here

    l.add(new AVP<Integer>(Common.FIRMWARE_REVISION, 2));
    l.add(new AVP<byte[]>(Sh.USER_DATA, "<shData>dasaiTag<shData>".getBytes()));

    for (int i = 24; i < 256; i++)
    {
      Buffer buffer = new ByteArrayBuffer(i);
      buffer = Codecs.__message.encode(buffer, answer);
      // System.out.println(buffer.putIndex() + " / " + i);
      DiameterMessage message = Codecs.__message.decode(buffer);
      // System.out.println(message);
      assertFalse(message.isRequest());
View Full Code Here

public class SipParserTest
{
  @Test
  public void testRequestLine() throws Exception
  {
    ByteArrayBuffer buffer = new ByteArrayBuffer("INVITE sip:foo.org SIP/2.0\r\n\r\n".getBytes(StringUtil.__UTF8));
   
    SipParser parser = new SipParser(buffer, new Handler());
    parser.parse();
   
    assertEquals("INVITE", _t0);
View Full Code Here

  }

  @Test
  public void testStatusLine() throws Exception
  {
    ByteArrayBuffer buffer = new ByteArrayBuffer("SIP/2.0 999 Foo\r\n\r\n".getBytes(StringUtil.__UTF8));
   
    SipParser parser = new SipParser(buffer, new Handler());
    parser.parse();
   
    assertEquals("SIP/2.0", _t0);
View Full Code Here

  }

  @Test
  public void testSpace() throws Exception
  {
    ByteArrayBuffer buffer = new ByteArrayBuffer(
        ("INVITE sip:foo.org SIP/2.0\015\012"
          + "foo:     bar   \015\012"
          + "\015\012").getBytes(StringUtil.__UTF8))
    SipParser parser = new SipParser(buffer, new Handler());
    parser.parse();
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.io.ByteArrayBuffer

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.