use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class DummySamplerTest method testSample.
@Test
public void testSample() {
System.out.println("sample");
String data = "test";
DummySampler instance = new DummySampler();
instance.setResponseData(data);
SampleResult result = instance.sample(null);
Assert.assertEquals(data, result.getResponseDataAsString());
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class FlexibleFileWriterTest method testSampleOccurred.
@Test
public void testSampleOccurred() throws IOException {
System.out.println("sampleOccurred");
SampleResult res = new SampleResult();
res.setResponseData("test".getBytes());
SampleEvent e = new SampleEvent(res, "Test");
FlexibleFileWriter instance = new FlexibleFileWriter();
instance.setColumns("isSuccsessful|\\t||\\t|latency");
String tmpFile = File.createTempFile("ffw_test_", ".txt").getAbsolutePath();
instance.setFilename(tmpFile);
instance.testStarted();
for (int n = 0; n < 10; n++) {
String exp = "0\t|\t" + n;
System.out.println(exp);
res.setLatency(n);
res.setSampleLabel("n" + n);
instance.sampleOccurred(e);
// ByteBuffer written = instance.fileEmul.getWrittenBytes();
// assertEquals(exp, JMeterPluginsUtils.byteBufferToString(written));
}
instance.testEnded();
assertTrue(tmpFile.length() > 0);
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class FlexibleFileWriterTest method testSampleOccurred_var.
@Test
public void testSampleOccurred_var() throws IOException {
System.out.println("sampleOccurred-var");
SampleResult res = new SampleResult();
res.setResponseData("test".getBytes());
JMeterVariables vars = new JMeterVariables();
vars.put("TEST1", "TEST");
SampleEvent e = new SampleEvent(res, "Test", vars);
FlexibleFileWriter instance = new FlexibleFileWriter();
instance.setFilename(File.createTempFile("ffw_test_", ".txt").getAbsolutePath());
System.out.println("prop: " + JMeterUtils.getProperty("sample_variables"));
System.out.println("count: " + SampleEvent.getVarCount());
instance.setColumns("variable#0| |variable#| |variable#4t");
instance.testStarted();
for (int n = 0; n < 10; n++) {
String exp = "TEST variable# variable#4t";
System.out.println(exp);
instance.sampleOccurred(e);
// ByteBuffer written = instance.fileEmul.getWrittenBytes();
// assertEquals(exp, JMeterPluginsUtils.byteBufferToString(written));
}
instance.testEnded();
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class FlexibleFileWriterTest method testSampleOccurred_labels.
@Test
public void testSampleOccurred_labels() throws IOException {
System.out.println("sampleOccurred_labels");
SampleResult res = new SampleResult();
res.setResponseData("test".getBytes());
FlexibleFileWriter instance = new FlexibleFileWriter();
instance.setFilename(File.createTempFile("ffw_test_", ".txt").getAbsolutePath());
instance.setColumns("threadName|\\t|sampleLabel");
instance.testStarted();
res.setSampleLabel("SAMPLELBL");
res.setThreadName("THRDNAME");
SampleEvent e = new SampleEvent(res, "Test");
instance.sampleOccurred(e);
// ByteBuffer written = instance.fileEmul.getWrittenBytes();
// assertEquals(exp, JMeterPluginsUtils.byteBufferToString(written));
instance.testEnded();
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class DbMonSampleResultTest method testGetValue_SampleResult.
/**
* Test of getValue method, of class DbMonSampleResult.
*/
@Test
public void testGetValue_SampleResult() {
System.out.println("getValue");
SampleResult res = new SampleResult();
res.setResponseMessage("0");
double expResult = 0.0;
double result = DbMonSampleResult.getValue(res);
assertEquals(expResult, result, 0.0);
// TODO review the generated test code and remove the default call to fail.
}
Aggregations