use of java.net.DatagramPacket in project pinpoint by naver.
the class UdpSocketTest method testMaxBytes.
@Test
public void testMaxBytes() throws IOException {
DatagramPacket packet1 = newDatagramPacket(50000);
sender.send(packet1);
DatagramPacket r1 = newDatagramPacket(50000);
receiver.receive(r1);
logger.debug("packetSize:{}", r1.getLength());
}
use of java.net.DatagramPacket in project pinpoint by naver.
the class NioUdpDataSenderTest method waitMessageReceived.
private void waitMessageReceived(int expectReceiveMessageCount) throws IOException {
byte[] receiveData = new byte[65535];
DatagramPacket datagramPacket = new DatagramPacket(receiveData, 0, receiveData.length);
int remainCount = expectReceiveMessageCount;
while (remainCount > 0) {
remainCount--;
receiver.receive(datagramPacket);
}
}
use of java.net.DatagramPacket in project pinpoint by naver.
the class PacketUtilsTest method testSliceData1.
@Test
public void testSliceData1() throws Exception {
DatagramPacket packet = createPacket(10);
packet.setLength(5);
byte[] bytes1 = PacketUtils.sliceData(packet, 0);
Assert.assertEquals(bytes1.length, 5);
}
use of java.net.DatagramPacket in project pinpoint by naver.
the class UDPReceiverTest method sendSocketBufferSize.
@Test
public void sendSocketBufferSize() throws IOException {
DatagramPacket datagramPacket = new DatagramPacket(new byte[0], 0, 0);
DatagramSocket datagramSocket = new DatagramSocket();
datagramSocket.connect(new InetSocketAddress("127.0.0.1", 9995));
datagramSocket.send(datagramPacket);
datagramSocket.close();
}
use of java.net.DatagramPacket in project pinpoint by naver.
the class NetworkAvailabilityCheckPacketFilterTest method testFilter.
@Test
public void testFilter() throws Exception {
SocketAddress localSocketAddress = senderSocket.getLocalSocketAddress();
logger.debug("localSocket:{}", localSocketAddress);
NetworkAvailabilityCheckPacket packet = new NetworkAvailabilityCheckPacket();
boolean skipResult = filter.filter(receiverSocket, packet, new InetSocketAddress("localhost", senderSocket.getLocalPort()));
Assert.assertEquals(skipResult, TBaseFilter.BREAK);
DatagramPacket receivePacket = new DatagramPacket(new byte[100], 100);
senderSocket.receive(receivePacket);
Assert.assertEquals(receivePacket.getLength(), NetworkAvailabilityCheckPacket.DATA_OK.length);
Assert.assertArrayEquals(Arrays.copyOf(receivePacket.getData(), NetworkAvailabilityCheckPacket.DATA_OK.length), NetworkAvailabilityCheckPacket.DATA_OK);
}
Aggregations