Java Code Examples for org.jboss.netty.buffer.ChannelBuffers.copiedBuffer()

The following are Jave code examples for showing how to use copiedBuffer() of the org.jboss.netty.buffer.ChannelBuffers class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: athena   File: OpaqueLsa11Test.java   Source Code and License Vote up 6 votes
/**
 * Tests getLsaBodyAsByteArray()  method.
 */
@Test
public void testGetLsaBodyAsByteArray() throws Exception {
    opqueHeader = new OpaqueLsaHeader();
    opqueHeader.setLsType(11);
    opqueHeader.setLsPacketLen(48);
    opqueHeader.setLsCheckSum(10);
    opqueHeader.setAge(4);
    opqueHeader.setOpaqueId(1);
    opqueHeader.setOpaqueType(11);
    opqueHeader.setLsSequenceNo(250);
    opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
    opqueHeader.setOptions(2);
    opaqueLsa11 = new OpaqueLsa11(opqueHeader);
    channelBuffer = ChannelBuffers.copiedBuffer(packet);
    opaqueLsa11.readFrom(channelBuffer);
    result = opaqueLsa11.getLsaBodyAsByteArray();
    assertThat(result, is(notNullValue()));
}
 
Example 2
Project: athena   File: OpaqueLsa10Test.java   Source Code and License Vote up 6 votes
/**
 * Tests getLsaBodyAsByteArray() method.
 */
@Test(expected = Exception.class)
public void testGetLsaBodyAsByteArray2() throws Exception {
    opqueHeader = new OpaqueLsaHeader();
    opqueHeader.setLsType(10);
    opqueHeader.setLsPacketLen(48);
    opqueHeader.setLsCheckSum(10);
    opqueHeader.setAge(4);
    opqueHeader.setOpaqueId(1);
    opqueHeader.setOpaqueType(10);
    opqueHeader.setLsSequenceNo(250);
    opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
    opqueHeader.setOptions(2);
    opaqueLsa10 = new OpaqueLsa10(opqueHeader);
    linkTlv = new LinkTlv(new TlvHeader());
    opaqueLsa10.addValue(linkTlv);
    channelBuffer = ChannelBuffers.copiedBuffer(packet);
    opaqueLsa10.readFrom(channelBuffer);
    result = opaqueLsa10.getLsaBodyAsByteArray();
    assertThat(result, is(notNullValue()));
}
 
Example 3
Project: athena   File: OpaqueLsa10Test.java   Source Code and License Vote up 6 votes
/**
 * Tests asBytes() method.
 */
@Test(expected = Exception.class)
public void testAsBytes() throws Exception {
    opqueHeader = new OpaqueLsaHeader();
    opqueHeader.setLsType(10);
    opqueHeader.setLsPacketLen(48);
    opqueHeader.setLsCheckSum(10);
    opqueHeader.setAge(4);
    opqueHeader.setOpaqueId(1);
    opqueHeader.setOpaqueType(10);
    opqueHeader.setLsSequenceNo(250);
    opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
    opqueHeader.setOptions(66);
    opaqueLsa10 = new OpaqueLsa10(opqueHeader);
    channelBuffer = ChannelBuffers.copiedBuffer(packet);
    opaqueLsa10.readFrom(channelBuffer);
    result = opaqueLsa10.getLsaBodyAsByteArray();
    result = opaqueLsa10.asBytes();
    assertThat(result, is(notNullValue()));
}
 
Example 4
Project: athena   File: MaximumReservableBandwidthTest.java   Source Code and License Vote up 5 votes
/**
 * Tests readFrom() method.
 */
@Test
public void testReadFrom() throws Exception {
    header = new TlvHeader();
    header.setTlvType(6);
    header.setTlvLength(4);
    channelBuffer = ChannelBuffers.copiedBuffer(packet);
    maximumReservableBandwidth = new MaximumReservableBandwidth(header);
    maximumReservableBandwidth.readFrom(channelBuffer);
    assertThat(maximumReservableBandwidth, is(notNullValue()));
}
 
Example 5
Project: athena   File: IsisNeighborTlvTest.java   Source Code and License Vote up 5 votes
/**
 * Tests readFrom() method.
 */
@Test
public void testReadFrom() throws Exception {
    channelBuffer = ChannelBuffers.copiedBuffer(tlv);
    isisNeighborTlv.readFrom(channelBuffer);
    assertThat(isisNeighborTlv.neighbor().size(), is(1));
}
 
Example 6
Project: athena   File: L1L2HelloPduTest.java   Source Code and License Vote up 5 votes
/**
 * Tests asByte() method.
 */
@Test
public void testAsBytes() throws Exception {
    channelBuffer = ChannelBuffers.copiedBuffer(helloL1L2);
    l1L2HelloPdu.readFrom(channelBuffer);
    result = l1L2HelloPdu.asBytes();
    assertThat(l1L2HelloPdu, is(notNullValue()));
}
 
Example 7
Project: athena   File: ProtocolSupportedTlvTest.java   Source Code and License Vote up 5 votes
/**
 * Tests asBytes() method.
 */
@Test
public void testAsBytes() throws Exception {
    channelBuffer = ChannelBuffers.copiedBuffer(tlv);
    protocolSupportedTlv.readFrom(channelBuffer);
    result = protocolSupportedTlv.asBytes();
    assertThat(result, is(notNullValue()));
}
 
Example 8
Project: traccar-service   File: ChecksumTest.java   Source Code and License Vote up 5 votes
@Test
public void testCrc16() {
    ChannelBuffer buf = ChannelBuffers.copiedBuffer("123456789", StandardCharsets.US_ASCII);

    Assert.assertEquals(0x906e, Checksum.crc16(Checksum.CRC16_X25, buf.toByteBuffer()));
    Assert.assertEquals(0x29b1, Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.toByteBuffer()));
    Assert.assertEquals(0x2189, Checksum.crc16(Checksum.CRC16_KERMIT, buf.toByteBuffer()));
    Assert.assertEquals(0x31c3, Checksum.crc16(Checksum.CRC16_XMODEM, buf.toByteBuffer()));
    Assert.assertEquals(0xe5cc, Checksum.crc16(Checksum.CRC16_AUG_CCITT, buf.toByteBuffer()));
    Assert.assertEquals(0xd64e, Checksum.crc16(Checksum.CRC16_GENIBUS, buf.toByteBuffer()));
    Assert.assertEquals(0x6f91, Checksum.crc16(Checksum.CRC16_MCRF4XX, buf.toByteBuffer()));
}
 
Example 9
Project: athena   File: InterfaceIpAddressTest.java   Source Code and License Vote up 5 votes
/**
 * Tests readFrom() method.
 */
@Test
public void testReadFrom1() throws Exception {
    tlvHeader = new TlvHeader();
    tlvHeader.setTlvType(3);
    tlvHeader.setTlvLength(4);
    interfaceIpAddress = new NeighborIpAddress(tlvHeader);
    channelBuffer = ChannelBuffers.copiedBuffer(packet1);
    interfaceIpAddress.readFrom(channelBuffer);
    assertThat(interfaceIpAddress, is(notNullValue()));
}
 
Example 10
Project: athena   File: MetricOfInternalReachabilityTest.java   Source Code and License Vote up 5 votes
/**
 * Tests readFrom() method.
 */
@Test
public void testReadFrom() throws Exception {
    channelBuffer = ChannelBuffers.copiedBuffer(internalReachability);
    reachability.readFrom(channelBuffer);
    assertThat(reachability, is(notNullValue()));
}
 
Example 11
Project: athena   File: AsbrSummaryLsaTest.java   Source Code and License Vote up 5 votes
/**
 * Tests readFrom() method.
 */
@Test
public void testReadFrom() throws Exception {
    inputByteArray = createByteForNetworkLsa();
    lsaHeader = createLsaHeader();
    asbrSummaryLsa = new AsbrSummaryLsa(lsaHeader);
    channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
    asbrSummaryLsa.readFrom(channelBuffer);
    assertThat(asbrSummaryLsa, is(notNullValue()));
}
 
Example 12
Project: athena   File: AreaAddressTlvTest.java   Source Code and License Vote up 5 votes
/**
 * Tests asBytes() method.
 */
@Test
public void testAsBytes() throws Exception {
    channelBuffer = ChannelBuffers.copiedBuffer(tlv);
    areaAddressTlv.readFrom(channelBuffer);
    result1 = areaAddressTlv.asBytes();
    assertThat(result1, is(notNullValue()));
}
 
Example 13
Project: athena   File: PaddingTlvTest.java   Source Code and License Vote up 5 votes
/**
 * Tests readFrom() method.
 */
@Test
public void testReadFrom() throws Exception {
    channelBuffer = ChannelBuffers.copiedBuffer(tlv);
    paddingTlv.readFrom(channelBuffer);
    assertThat(paddingTlv, is(notNullValue()));
}
 
Example 14
Project: athena   File: RemoteInterfaceIpAddressTest.java   Source Code and License Vote up 5 votes
/**
 * Tests readFrom() method.
 */
@Test
public void testReadFrom1() throws Exception {
    tlvHeader = new TlvHeader();
    tlvHeader.setTlvType(4);
    tlvHeader.setTlvLength(4);
    remoteInterfaceIpAddress = new RemoteInterfaceIpAddress(tlvHeader);
    channelBuffer = ChannelBuffers.copiedBuffer(packet1);
    remoteInterfaceIpAddress.readFrom(channelBuffer);
    assertThat(remoteInterfaceIpAddress, is(notNullValue()));
}
 
Example 15
Project: athena   File: ProtocolSupportedTlvTest.java   Source Code and License Vote up 5 votes
/**
 * Tests readFrom() method.
 */
@Test
public void testReadFrom() throws Exception {
    channelBuffer = ChannelBuffers.copiedBuffer(tlv);
    protocolSupportedTlv.readFrom(channelBuffer);
    supported = protocolSupportedTlv.protocolSupported();
    assertThat(supported.size(), is(1));
}
 
Example 16
Project: athena   File: OspfUtilTest.java   Source Code and License Vote up 5 votes
/**
 * Tests readLsaHeader() method.
 */
@Test
public void testReadreadLsaHeader() throws Exception {
    byte[] header = {0, 2, 2, 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0, 0, 1, 58, -100, 0, 48};
    channelBuffer = ChannelBuffers.copiedBuffer(header);
    lsaHeader = OspfUtil.readLsaHeader(channelBuffer);
    assertThat(lsaHeader, is(notNullValue()));
}
 
Example 17
Project: athena   File: AreaAddressTlvTest.java   Source Code and License Vote up 5 votes
/**
 * Tests readFrom() method.
 */
@Test
public void testReadFrom() throws Exception {
    channelBuffer = ChannelBuffers.copiedBuffer(tlv);
    areaAddressTlv.readFrom(channelBuffer);
    assertThat(areaAddressTlv.areaAddress().size(), is(1));
}
 
Example 18
Project: athena   File: CsnpTest.java   Source Code and License Vote up 5 votes
/**
 * Tests completeSequenceNumberPduBody() method.
 */
@Test
public void testCompleteSequenceNumberPduBody() throws Exception {
    channelBuffer = ChannelBuffers.copiedBuffer(csnpBytes);
    csnp.readFrom(channelBuffer);
    result = csnp.completeSequenceNumberPduBody();
    assertThat(result, is(notNullValue()));
}
 
Example 19
Project: athena   File: HostNameTlvTest.java   Source Code and License Vote up 5 votes
/**
 * Tests asBytes() method.
 */
@Test
public void testAsBytes() throws Exception {
    channelBuffer = ChannelBuffers.copiedBuffer(tlv);
    hostNameTlv.readFrom(channelBuffer);
    result1 = hostNameTlv.asBytes();
    assertThat(result1, is(notNullValue()));
}
 
Example 20
Project: traccar-service   File: ProtocolTest.java   Source Code and License Vote up 4 votes
protected ChannelBuffer buffer(String... data) {
    return ChannelBuffers.copiedBuffer(concatenateStrings(data), StandardCharsets.ISO_8859_1);
}