Search in sources :

Example 1 with SocketChannelEmul

use of kg.apc.emulators.SocketChannelEmul in project jmeter-plugins by undera.

the class HTTPRawSamplerTest method testReadResponse.

/**
 * Test of readResponse method, of class HTTPRawSampler.
 */
@Test
public void testReadResponse() throws Exception {
    System.out.println("readResponse");
    SocketChannelEmul sock = new SocketChannelEmul();
    sock.setBytesToRead(ByteBuffer.wrap("test".getBytes()));
    SampleResult res = new SampleResult();
    res.sampleStart();
    byte[] expResult = "test".getBytes();
    byte[] result = instance.readResponse(sock, res);
    assertEquals(expResult.length, result.length);
}
Also used : SocketChannelEmul(kg.apc.emulators.SocketChannelEmul) SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 2 with SocketChannelEmul

use of kg.apc.emulators.SocketChannelEmul in project jmeter-plugins by undera.

the class SocketChannelWithTimeoutsTest method testWrite_Empty.

@Test
public void testWrite_Empty() throws Exception {
    System.out.println("write");
    SocketChannelWithTimeoutsEmul instance = new SocketChannelWithTimeoutsEmul();
    SocketChannelEmul sc = (SocketChannelEmul) instance.socketChannel;
    assertEquals(4, instance.write(ByteBuffer.wrap("test".getBytes())));
    Assert.assertEquals(4, sc.getWrittenBytesCount());
    assertEquals(0, instance.write(ByteBuffer.wrap("".getBytes())));
    Assert.assertEquals(0, sc.getWrittenBytesCount());
}
Also used : SocketChannelEmul(kg.apc.emulators.SocketChannelEmul)

Aggregations

SocketChannelEmul (kg.apc.emulators.SocketChannelEmul)2 SampleResult (org.apache.jmeter.samplers.SampleResult)1