use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestRandomController method testRandomOrder.
@Test
public void testRandomOrder() {
testLog.debug("Testing RandomController");
RandomController roc = new RandomController();
roc.addTestElement(new TestSampler("zero"));
roc.addTestElement(new TestSampler("one"));
roc.addTestElement(new TestSampler("two"));
roc.addTestElement(new TestSampler("three"));
TestElement sampler = null;
List<String> usedSamplers = new ArrayList<>();
roc.initialize();
while ((sampler = roc.next()) != null) {
String samplerName = sampler.getName();
if (usedSamplers.contains(samplerName)) {
assertTrue("Duplicate sampler returned from next()", false);
}
usedSamplers.add(samplerName);
}
assertEquals(1, usedSamplers.size());
assertTrue(Arrays.asList("zero", "one", "two", "three").contains(usedSamplers.get(0)));
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestRandomOrderController method testRandomOrderOneElement.
@Test
public void testRandomOrderOneElement() {
RandomOrderController roc = new RandomOrderController();
roc.addTestElement(new TestSampler("zero"));
TestElement sampler = null;
List<String> usedSamplers = new ArrayList<>();
roc.initialize();
while ((sampler = roc.next()) != null) {
String samplerName = sampler.getName();
if (usedSamplers.contains(samplerName)) {
assertTrue("Duplicate sampler returned from next()", false);
}
usedSamplers.add(samplerName);
}
assertEquals("All samplers were returned", 1, usedSamplers.size());
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestRandomOrderController method testRandomOrder.
@Test
public void testRandomOrder() {
testLog.debug("Testing RandomOrderController");
RandomOrderController roc = new RandomOrderController();
roc.addTestElement(new TestSampler("zero"));
roc.addTestElement(new TestSampler("one"));
roc.addTestElement(new TestSampler("two"));
roc.addTestElement(new TestSampler("three"));
TestElement sampler = null;
List<String> usedSamplers = new ArrayList<>();
roc.initialize();
while ((sampler = roc.next()) != null) {
String samplerName = sampler.getName();
if (usedSamplers.contains(samplerName)) {
assertTrue("Duplicate sampler returned from next()", false);
}
usedSamplers.add(samplerName);
}
assertEquals("All samplers were returned", 4, usedSamplers.size());
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestValueReplacer method testReplaceStringWithBackslash.
@Test
public void testReplaceStringWithBackslash() throws Exception {
ValueReplacer replacer = new ValueReplacer();
replacer.setUserDefinedVariables(variables.getUserDefinedVariables());
TestElement element = new ConfigTestElement();
String input = "\\${server} \\ \\\\ \\\\\\ \\, ";
element.setProperty(new StringProperty("domain", input));
replacer.replaceValues(element);
element.setRunningVersion(true);
assertEquals(input, element.getPropertyAsString("domain"));
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestValueReplacer method testReplaceFunctionWithBackslash.
/*
* This test should be compared with the one above.
* Here, the string contains a valid variable reference, so all
* backslashes are also processed.
*
* See https://bz.apache.org/bugzilla/show_bug.cgi?id=53534
*/
@Test
public void testReplaceFunctionWithBackslash() throws Exception {
ValueReplacer replacer = new ValueReplacer();
replacer.setUserDefinedVariables(variables.getUserDefinedVariables());
TestElement element = new ConfigTestElement();
String input = "${server} \\ \\\\ \\\\\\ \\, ";
element.setProperty(new StringProperty("domain", input));
replacer.replaceValues(element);
element.setRunningVersion(true);
assertEquals("jakarta.apache.org \\ \\ \\\\ , ", element.getPropertyAsString("domain"));
}
Aggregations