use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class HTTPRawSamplerTest method testSample.
@Test
public void testSample() throws MalformedURLException, IOException {
System.out.println("sample");
String req = "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n";
String resp = "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\nTEST";
instance.setRequestData(req);
instance.setParseResult(true);
instance.sockEmul.setBytesToRead(ByteBuffer.wrap(resp.getBytes()));
SampleResult result = instance.sample(null);
// System.err.println(result.getResponseDataAsString().length());
assertEquals(ByteBuffer.wrap(req.getBytes()), instance.sockEmul.getWrittenBytes());
assertTrue(result.isSuccessful());
assertEquals("200", result.getResponseCode());
assertEquals("TEST", result.getResponseDataAsString());
assertTrue(!instance.sockEmul.isOpen());
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class HTTPRawSamplerTest method testSample_keepalive.
/**
* Test of sample method, of class HTTPRawSampler.
*/
@Test
public void testSample_keepalive() throws MalformedURLException, IOException {
System.out.println("sample");
String req = "TEST";
String resp = "TEST";
instance.setRequestData(req);
instance.setUseKeepAlive(true);
instance.sockEmul.setBytesToRead(ByteBuffer.wrap(resp.getBytes()));
SampleResult result = instance.sample(null);
assertTrue(instance.sockEmul.isOpen());
instance.setUseKeepAlive(false);
instance.sockEmul.setBytesToRead(ByteBuffer.wrap(resp.getBytes()));
instance.sample(null);
assertFalse(instance.sockEmul.isOpen());
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class HTTPRawSamplerTest method testSample_hugeparse.
@Test
public void testSample_hugeparse() throws MalformedURLException, IOException {
System.out.println("sample");
final int testDataSize = 1000000;
String req = "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n";
String resp = "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n" + TestJMeterUtils.getTestData(testDataSize);
instance.setRequestData(req);
instance.setParseResult(true);
instance.sockEmul.setBytesToRead(ByteBuffer.wrap(resp.getBytes()));
SampleResult result = instance.sample(null);
// System.err.println(result.getResponseDataAsString().length());
assertEquals(ByteBuffer.wrap(req.getBytes()), instance.sockEmul.getWrittenBytes());
assertTrue(result.isSuccessful());
assertEquals("200", result.getResponseCode());
System.out.println("Len: " + result.getResponseDataAsString().length());
assertEquals(testDataSize, result.getResponseDataAsString().length());
assertTrue(!instance.sockEmul.isOpen());
}
use of org.apache.jmeter.samplers.SampleResult 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);
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class HTTPRawSamplerTest method testProcessIO_fileOnly.
/**
* Test of processIO method, of class HTTPRawSampler.
*/
@Test
public void testProcessIO_fileOnly() throws Exception {
System.out.println("processIO");
SampleResult res = new SampleResult();
res.sampleStart();
instance.setPort("0");
String file = this.getClass().getResource("/testSendFile.raw").getPath();
instance.setFileToSend(file);
instance.processIO(res);
assertEquals(new File(file).length(), instance.sockEmul.getWrittenBytesCount());
}
Aggregations