You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2009/05/10 20:19:30 UTC
svn commit: r773382 [2/6] - in /jakarta/jmeter/trunk/test/src/org/apache:
jmeter/engine/ jmeter/engine/util/ jmeter/extractor/ jmeter/functions/
jmeter/gui/action/ jmeter/gui/util/ jmeter/junit/ jmeter/junit/stubs/
jmeter/monitor/model/ jmeter/monitor/...
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java Sun May 10 18:19:28 2009
@@ -50,140 +50,140 @@
*/
public class PackageTest extends JMeterTestCase {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggingManager.getLoggerForClass();
-// static {
-// LoggingManager.setPriority("DEBUG","jmeter");
-// LoggingManager.setTarget(new java.io.PrintWriter(System.out));
-// }
-
- public PackageTest(String arg0) {
- super(arg0);
- }
-
- // Create the CSVRead function and set its parameters.
- private static CSVRead setCSVReadParams(String p1, String p2) throws Exception {
- CSVRead cr = new CSVRead();
- Collection parms = new LinkedList();
- if (p1 != null) {
- parms.add(new CompoundVariable(p1));
- }
- if (p2 != null) {
- parms.add(new CompoundVariable(p2));
- }
- cr.setParameters(parms);
- return cr;
- }
-
- // Create the StringFromFile function and set its parameters.
- private static StringFromFile SFFParams(String p1, String p2, String p3, String p4) throws Exception {
- StringFromFile sff = new StringFromFile();
- Collection parms = new LinkedList();
- if (p1 != null) {
- parms.add(new CompoundVariable(p1));
- }
- if (p2 != null) {
- parms.add(new CompoundVariable(p2));
- }
- if (p3 != null) {
- parms.add(new CompoundVariable(p3));
- }
- if (p4 != null) {
- parms.add(new CompoundVariable(p4));
- }
- sff.setParameters(parms);
- return sff;
- }
-
- // Create the SplitFile function and set its parameters.
- private static SplitFunction SplitParams(String p1, String p2, String p3) throws Exception {
- SplitFunction split = new SplitFunction();
- Collection parms = new LinkedList();
- parms.add(new CompoundVariable(p1));
- if (p2 != null) {
- parms.add(new CompoundVariable(p2));
- }
- if (p3 != null) {
- parms.add(new CompoundVariable(p3));
- }
- split.setParameters(parms);
- return split;
- }
-
- // Create the BeanShell function and set its parameters.
- private static BeanShell BSHFParams(String p1, String p2, String p3) throws Exception {
- BeanShell bsh = new BeanShell();
- bsh.setParameters(MakeParams(p1, p2, p3));
- return bsh;
- }
-
- private static Collection MakeParams(String p1, String p2, String p3) {
- Collection parms = new LinkedList();
- if (p1 != null) {
- parms.add(new CompoundVariable(p1));
- }
- if (p2 != null) {
- parms.add(new CompoundVariable(p2));
- }
- if (p3 != null) {
- parms.add(new CompoundVariable(p3));
- }
- return parms;
- }
-
- public static Test suite() throws Exception {
- TestSuite allsuites = new TestSuite("Function PackageTest");
-
- if (!BeanShellInterpreter.isInterpreterPresent()){
- final String msg = "BeanShell jar not present, tests ignored";
- log.warn(msg);
- } else {
- TestSuite bsh = new TestSuite("BeanShell");
- bsh.addTest(new PackageTest("BSH1"));
- allsuites.addTest(bsh);
- }
-
- TestSuite suite = new TestSuite("SingleThreaded");
- suite.addTest(new PackageTest("CSVParams"));
- suite.addTest(new PackageTest("CSVNoFile"));
- suite.addTest(new PackageTest("CSVSetup"));
- suite.addTest(new PackageTest("CSVRun"));
-
- suite.addTest(new PackageTest("CSValias"));
- suite.addTest(new PackageTest("CSVBlankLine"));
- allsuites.addTest(suite);
-
- // Reset files
- suite.addTest(new PackageTest("CSVSetup"));
- TestSuite par = new ActiveTestSuite("Parallel");
- par.addTest(new PackageTest("CSVThread1"));
- par.addTest(new PackageTest("CSVThread2"));
- allsuites.addTest(par);
-
- TestSuite sff = new TestSuite("StringFromFile");
- sff.addTest(new PackageTest("SFFTest1"));
- sff.addTest(new PackageTest("SFFTest2"));
- sff.addTest(new PackageTest("SFFTest3"));
- sff.addTest(new PackageTest("SFFTest4"));
- sff.addTest(new PackageTest("SFFTest5"));
- allsuites.addTest(sff);
-
- TestSuite split = new TestSuite("SplitFunction");
- split.addTest(new PackageTest("splitTest1"));
- allsuites.addTest(split);
-
- TestSuite xpath = new TestSuite("XPath");
- xpath.addTest(new PackageTest("XPathtestColumns"));
- xpath.addTest(new PackageTest("XPathtestDefault"));
- xpath.addTest(new PackageTest("XPathtestNull"));
- xpath.addTest(new PackageTest("XPathtestrowNum"));
+// static {
+// LoggingManager.setPriority("DEBUG","jmeter");
+// LoggingManager.setTarget(new java.io.PrintWriter(System.out));
+// }
+
+ public PackageTest(String arg0) {
+ super(arg0);
+ }
+
+ // Create the CSVRead function and set its parameters.
+ private static CSVRead setCSVReadParams(String p1, String p2) throws Exception {
+ CSVRead cr = new CSVRead();
+ Collection parms = new LinkedList();
+ if (p1 != null) {
+ parms.add(new CompoundVariable(p1));
+ }
+ if (p2 != null) {
+ parms.add(new CompoundVariable(p2));
+ }
+ cr.setParameters(parms);
+ return cr;
+ }
+
+ // Create the StringFromFile function and set its parameters.
+ private static StringFromFile SFFParams(String p1, String p2, String p3, String p4) throws Exception {
+ StringFromFile sff = new StringFromFile();
+ Collection parms = new LinkedList();
+ if (p1 != null) {
+ parms.add(new CompoundVariable(p1));
+ }
+ if (p2 != null) {
+ parms.add(new CompoundVariable(p2));
+ }
+ if (p3 != null) {
+ parms.add(new CompoundVariable(p3));
+ }
+ if (p4 != null) {
+ parms.add(new CompoundVariable(p4));
+ }
+ sff.setParameters(parms);
+ return sff;
+ }
+
+ // Create the SplitFile function and set its parameters.
+ private static SplitFunction SplitParams(String p1, String p2, String p3) throws Exception {
+ SplitFunction split = new SplitFunction();
+ Collection parms = new LinkedList();
+ parms.add(new CompoundVariable(p1));
+ if (p2 != null) {
+ parms.add(new CompoundVariable(p2));
+ }
+ if (p3 != null) {
+ parms.add(new CompoundVariable(p3));
+ }
+ split.setParameters(parms);
+ return split;
+ }
+
+ // Create the BeanShell function and set its parameters.
+ private static BeanShell BSHFParams(String p1, String p2, String p3) throws Exception {
+ BeanShell bsh = new BeanShell();
+ bsh.setParameters(MakeParams(p1, p2, p3));
+ return bsh;
+ }
+
+ private static Collection MakeParams(String p1, String p2, String p3) {
+ Collection parms = new LinkedList();
+ if (p1 != null) {
+ parms.add(new CompoundVariable(p1));
+ }
+ if (p2 != null) {
+ parms.add(new CompoundVariable(p2));
+ }
+ if (p3 != null) {
+ parms.add(new CompoundVariable(p3));
+ }
+ return parms;
+ }
+
+ public static Test suite() throws Exception {
+ TestSuite allsuites = new TestSuite("Function PackageTest");
+
+ if (!BeanShellInterpreter.isInterpreterPresent()){
+ final String msg = "BeanShell jar not present, tests ignored";
+ log.warn(msg);
+ } else {
+ TestSuite bsh = new TestSuite("BeanShell");
+ bsh.addTest(new PackageTest("BSH1"));
+ allsuites.addTest(bsh);
+ }
+
+ TestSuite suite = new TestSuite("SingleThreaded");
+ suite.addTest(new PackageTest("CSVParams"));
+ suite.addTest(new PackageTest("CSVNoFile"));
+ suite.addTest(new PackageTest("CSVSetup"));
+ suite.addTest(new PackageTest("CSVRun"));
+
+ suite.addTest(new PackageTest("CSValias"));
+ suite.addTest(new PackageTest("CSVBlankLine"));
+ allsuites.addTest(suite);
+
+ // Reset files
+ suite.addTest(new PackageTest("CSVSetup"));
+ TestSuite par = new ActiveTestSuite("Parallel");
+ par.addTest(new PackageTest("CSVThread1"));
+ par.addTest(new PackageTest("CSVThread2"));
+ allsuites.addTest(par);
+
+ TestSuite sff = new TestSuite("StringFromFile");
+ sff.addTest(new PackageTest("SFFTest1"));
+ sff.addTest(new PackageTest("SFFTest2"));
+ sff.addTest(new PackageTest("SFFTest3"));
+ sff.addTest(new PackageTest("SFFTest4"));
+ sff.addTest(new PackageTest("SFFTest5"));
+ allsuites.addTest(sff);
+
+ TestSuite split = new TestSuite("SplitFunction");
+ split.addTest(new PackageTest("splitTest1"));
+ allsuites.addTest(split);
+
+ TestSuite xpath = new TestSuite("XPath");
+ xpath.addTest(new PackageTest("XPathtestColumns"));
+ xpath.addTest(new PackageTest("XPathtestDefault"));
+ xpath.addTest(new PackageTest("XPathtestNull"));
+ xpath.addTest(new PackageTest("XPathtestrowNum"));
xpath.addTest(new PackageTest("XPathEmpty"));
xpath.addTest(new PackageTest("XPathFile1"));
xpath.addTest(new PackageTest("XPathFile2"));
xpath.addTest(new PackageTest("XPathNoFile"));
- allsuites.addTest(xpath);
-
+ allsuites.addTest(xpath);
+
TestSuite random = new TestSuite("Random");
random.addTest(new PackageTest("randomTest1"));
allsuites.addTest(random);
@@ -214,156 +214,156 @@
allsuites.addTest(intSum);
return allsuites;
- }
+ }
+
+ private JMeterContext jmctx = null;
+
+ private JMeterVariables vars = null;
+
+ public void setUp() {
+ jmctx = JMeterContextService.getContext();
+ jmctx.setVariables(new JMeterVariables());
+ vars = jmctx.getVariables();
+ }
+
+ public void BSH1() throws Exception {
+ String fn = "testfiles/BeanShellTest.bsh";
+ BeanShell bsh;
+ try {
+ bsh = BSHFParams(null, null, null);
+ fail("Expected InvalidVariableException");
+ } catch (InvalidVariableException e) {
+ }
+
+ try {
+ bsh = BSHFParams("", "", "");
+ fail("Expected InvalidVariableException");
+ } catch (InvalidVariableException e) {
+ }
- private JMeterContext jmctx = null;
+ try {
+ bsh = BSHFParams("", "", null);
+ assertEquals("", bsh.execute());
+ } catch (InvalidVariableException e) {
+ fail("BeanShell not present");
+ }
+
+ bsh = BSHFParams("1", null, null);
+ assertEquals("1", bsh.execute());
+
+ bsh = BSHFParams("1+1", "VAR", null);
+ assertEquals("2", bsh.execute());
+ assertEquals("2", vars.get("VAR"));
+
+ // Check some initial variables
+ bsh = BSHFParams("return threadName", null, null);
+ assertEquals(Thread.currentThread().getName(), bsh.execute());
+ bsh = BSHFParams("return log.getClass().getName()", null, null);
+ assertEquals(log.getClass().getName(), bsh.execute());
+
+ // Check source works
+ bsh = BSHFParams("source (\"testfiles/BeanShellTest.bsh\")", null, null);
+ assertEquals("9876", bsh.execute());
+
+ // Check persistence
+ bsh = BSHFParams("${SCR1}", null, null);
+
+ vars.put("SCR1", "var1=11");
+ assertEquals("11", bsh.execute());
+
+ vars.put("SCR1", "var2=22");
+ assertEquals("22", bsh.execute());
+
+ vars.put("SCR1", "x=var1");
+ assertEquals("11", bsh.execute());
+
+ vars.put("SCR1", "++x");
+ assertEquals("12", bsh.execute());
+
+ vars.put("VAR1", "test");
+ vars.put("SCR1", "vars.get(\"VAR1\")");
+ assertEquals("test", bsh.execute());
+
+ // Check init file functioning
+ JMeterUtils.getJMeterProperties().setProperty(BeanShell.INIT_FILE, fn);
+ bsh = BSHFParams("${SCR2}", null, null);
+ vars.put("SCR2", "getprop(\"" + BeanShell.INIT_FILE + "\")");
+ assertEquals(fn, bsh.execute());// Check that bsh has read the file
+ vars.put("SCR2", "getprop(\"avavaav\",\"default\")");
+ assertEquals("default", bsh.execute());
+ vars.put("SCR2", "++i");
+ assertEquals("1", bsh.execute());
+ vars.put("SCR2", "++i");
+ assertEquals("2", bsh.execute());
+
+ }
+
+ public void splitTest1() throws Exception {
+ SplitFunction split = null;
+ String src = "";
+
+ try {
+ split = SplitParams("a,b,c", null, null);
+ fail("Expected InvalidVariableException (wrong number of parameters)");
+ } catch (InvalidVariableException e) {
+ // OK
+ }
+ src = "a,b,c";
+ split = SplitParams(src, "VAR1", null);
+ assertEquals(src, split.execute());
+ assertEquals(src, vars.get("VAR1"));
+ assertEquals("3", vars.get("VAR1_n"));
+ assertEquals("a", vars.get("VAR1_1"));
+ assertEquals("b", vars.get("VAR1_2"));
+ assertEquals("c", vars.get("VAR1_3"));
+ assertNull(vars.get("VAR1_4"));
+
+ split = SplitParams(src, "VAR2", ",");
+ assertEquals(src, split.execute());
+ assertEquals(src, vars.get("VAR2"));
+ assertEquals("3", vars.get("VAR2_n"));
+ assertEquals("a", vars.get("VAR2_1"));
+ assertEquals("b", vars.get("VAR2_2"));
+ assertEquals("c", vars.get("VAR2_3"));
+ assertNull(vars.get("VAR2_4"));
- private JMeterVariables vars = null;
+ src = "a|b|c";
+ split = SplitParams(src, "VAR3", "|");
+ assertEquals(src, split.execute());
+ assertEquals(src, vars.get("VAR3"));
+ assertEquals("3", vars.get("VAR3_n"));
+ assertEquals("a", vars.get("VAR3_1"));
+ assertEquals("b", vars.get("VAR3_2"));
+ assertEquals("c", vars.get("VAR3_3"));
+ assertNull(vars.get("VAR3_4"));
+
+ src = "a|b||";
+ split = SplitParams(src, "VAR4", "|");
+ assertEquals(src, split.execute());
+ assertEquals(src, vars.get("VAR4"));
+ assertEquals("4", vars.get("VAR4_n"));
+ assertEquals("a", vars.get("VAR4_1"));
+ assertEquals("b", vars.get("VAR4_2"));
+ assertEquals("?", vars.get("VAR4_3"));
+ assertNull(vars.get("VAR4_5"));
- public void setUp() {
- jmctx = JMeterContextService.getContext();
- jmctx.setVariables(new JMeterVariables());
- vars = jmctx.getVariables();
- }
-
- public void BSH1() throws Exception {
- String fn = "testfiles/BeanShellTest.bsh";
- BeanShell bsh;
- try {
- bsh = BSHFParams(null, null, null);
- fail("Expected InvalidVariableException");
- } catch (InvalidVariableException e) {
- }
-
- try {
- bsh = BSHFParams("", "", "");
- fail("Expected InvalidVariableException");
- } catch (InvalidVariableException e) {
- }
-
- try {
- bsh = BSHFParams("", "", null);
- assertEquals("", bsh.execute());
- } catch (InvalidVariableException e) {
- fail("BeanShell not present");
- }
-
- bsh = BSHFParams("1", null, null);
- assertEquals("1", bsh.execute());
-
- bsh = BSHFParams("1+1", "VAR", null);
- assertEquals("2", bsh.execute());
- assertEquals("2", vars.get("VAR"));
-
- // Check some initial variables
- bsh = BSHFParams("return threadName", null, null);
- assertEquals(Thread.currentThread().getName(), bsh.execute());
- bsh = BSHFParams("return log.getClass().getName()", null, null);
- assertEquals(log.getClass().getName(), bsh.execute());
-
- // Check source works
- bsh = BSHFParams("source (\"testfiles/BeanShellTest.bsh\")", null, null);
- assertEquals("9876", bsh.execute());
-
- // Check persistence
- bsh = BSHFParams("${SCR1}", null, null);
-
- vars.put("SCR1", "var1=11");
- assertEquals("11", bsh.execute());
-
- vars.put("SCR1", "var2=22");
- assertEquals("22", bsh.execute());
-
- vars.put("SCR1", "x=var1");
- assertEquals("11", bsh.execute());
-
- vars.put("SCR1", "++x");
- assertEquals("12", bsh.execute());
-
- vars.put("VAR1", "test");
- vars.put("SCR1", "vars.get(\"VAR1\")");
- assertEquals("test", bsh.execute());
-
- // Check init file functioning
- JMeterUtils.getJMeterProperties().setProperty(BeanShell.INIT_FILE, fn);
- bsh = BSHFParams("${SCR2}", null, null);
- vars.put("SCR2", "getprop(\"" + BeanShell.INIT_FILE + "\")");
- assertEquals(fn, bsh.execute());// Check that bsh has read the file
- vars.put("SCR2", "getprop(\"avavaav\",\"default\")");
- assertEquals("default", bsh.execute());
- vars.put("SCR2", "++i");
- assertEquals("1", bsh.execute());
- vars.put("SCR2", "++i");
- assertEquals("2", bsh.execute());
-
- }
-
- public void splitTest1() throws Exception {
- SplitFunction split = null;
- String src = "";
-
- try {
- split = SplitParams("a,b,c", null, null);
- fail("Expected InvalidVariableException (wrong number of parameters)");
- } catch (InvalidVariableException e) {
- // OK
- }
- src = "a,b,c";
- split = SplitParams(src, "VAR1", null);
- assertEquals(src, split.execute());
- assertEquals(src, vars.get("VAR1"));
- assertEquals("3", vars.get("VAR1_n"));
- assertEquals("a", vars.get("VAR1_1"));
- assertEquals("b", vars.get("VAR1_2"));
- assertEquals("c", vars.get("VAR1_3"));
- assertNull(vars.get("VAR1_4"));
-
- split = SplitParams(src, "VAR2", ",");
- assertEquals(src, split.execute());
- assertEquals(src, vars.get("VAR2"));
- assertEquals("3", vars.get("VAR2_n"));
- assertEquals("a", vars.get("VAR2_1"));
- assertEquals("b", vars.get("VAR2_2"));
- assertEquals("c", vars.get("VAR2_3"));
- assertNull(vars.get("VAR2_4"));
-
- src = "a|b|c";
- split = SplitParams(src, "VAR3", "|");
- assertEquals(src, split.execute());
- assertEquals(src, vars.get("VAR3"));
- assertEquals("3", vars.get("VAR3_n"));
- assertEquals("a", vars.get("VAR3_1"));
- assertEquals("b", vars.get("VAR3_2"));
- assertEquals("c", vars.get("VAR3_3"));
- assertNull(vars.get("VAR3_4"));
-
- src = "a|b||";
- split = SplitParams(src, "VAR4", "|");
- assertEquals(src, split.execute());
- assertEquals(src, vars.get("VAR4"));
- assertEquals("4", vars.get("VAR4_n"));
- assertEquals("a", vars.get("VAR4_1"));
- assertEquals("b", vars.get("VAR4_2"));
- assertEquals("?", vars.get("VAR4_3"));
- assertNull(vars.get("VAR4_5"));
-
- src = "a,,c";
- vars.put("VAR", src);
- split = SplitParams("${VAR}", "VAR", null);
- assertEquals(src, split.execute());
- assertEquals("3", vars.get("VAR_n"));
- assertEquals("a", vars.get("VAR_1"));
- assertEquals("?", vars.get("VAR_2"));
- assertEquals("c", vars.get("VAR_3"));
+ src = "a,,c";
+ vars.put("VAR", src);
+ split = SplitParams("${VAR}", "VAR", null);
+ assertEquals(src, split.execute());
+ assertEquals("3", vars.get("VAR_n"));
+ assertEquals("a", vars.get("VAR_1"));
+ assertEquals("?", vars.get("VAR_2"));
+ assertEquals("c", vars.get("VAR_3"));
assertNull(vars.get("VAR_4"));
- src = "a,b";
- vars.put("VAR", src);
- split = SplitParams("${VAR}", "VAR", null);
- assertEquals(src, split.execute());
- assertEquals("2", vars.get("VAR_n"));
- assertEquals("a", vars.get("VAR_1"));
- assertEquals("b", vars.get("VAR_2"));
+ src = "a,b";
+ vars.put("VAR", src);
+ split = SplitParams("${VAR}", "VAR", null);
+ assertEquals(src, split.execute());
+ assertEquals("2", vars.get("VAR_n"));
+ assertEquals("a", vars.get("VAR_1"));
+ assertEquals("b", vars.get("VAR_2"));
assertNull(vars.get("VAR_3"));
src = "a,,c,";
@@ -379,366 +379,366 @@
}
- public void SFFTest1() throws Exception {
- StringFromFile sff1 = SFFParams("testfiles/SFFTest#'.'txt", "", "1", "3");
- assertEquals("uno", sff1.execute());
- assertEquals("dos", sff1.execute());
- assertEquals("tres", sff1.execute());
- assertEquals("cuatro", sff1.execute());
- assertEquals("cinco", sff1.execute());
- assertEquals("one", sff1.execute());
- assertEquals("two", sff1.execute());
- sff1.execute();
- sff1.execute();
- assertEquals("five", sff1.execute());
- assertEquals("eins", sff1.execute());
- sff1.execute();
- sff1.execute();
- sff1.execute();
- assertEquals("fuenf", sff1.execute());
- try {
- sff1.execute();
- fail("Should have thrown JMeterStopThreadException");
- } catch (JMeterStopThreadException e) {
- // expected
- }
- }
-
- public void SFFTest2() throws Exception {
- StringFromFile sff = SFFParams("testfiles/SFFTest1.txt", "", null, null);
- assertEquals("uno", sff.execute());
- assertEquals("dos", sff.execute());
- assertEquals("tres", sff.execute());
- assertEquals("cuatro", sff.execute());
- assertEquals("cinco", sff.execute());
- assertEquals("uno", sff.execute()); // Restarts
- assertEquals("dos", sff.execute());
- assertEquals("tres", sff.execute());
- assertEquals("cuatro", sff.execute());
- assertEquals("cinco", sff.execute());
- }
-
- public void SFFTest3() throws Exception {
- StringFromFile sff = SFFParams("testfiles/SFFTest1.txt", "", "", "");
- assertEquals("uno", sff.execute());
- assertEquals("dos", sff.execute());
- assertEquals("tres", sff.execute());
- assertEquals("cuatro", sff.execute());
- assertEquals("cinco", sff.execute());
- assertEquals("uno", sff.execute()); // Restarts
- assertEquals("dos", sff.execute());
- assertEquals("tres", sff.execute());
- assertEquals("cuatro", sff.execute());
- assertEquals("cinco", sff.execute());
- }
-
- public void SFFTest4() throws Exception {
- StringFromFile sff = SFFParams("xxtestfiles/SFFTest1.txt", "", "", "");
- assertEquals(StringFromFile.ERR_IND, sff.execute());
- assertEquals(StringFromFile.ERR_IND, sff.execute());
- }
-
- // Test that only loops twice
- public void SFFTest5() throws Exception {
- StringFromFile sff = SFFParams("testfiles/SFFTest1.txt", "", "", "2");
- assertEquals("uno", sff.execute());
- assertEquals("dos", sff.execute());
- assertEquals("tres", sff.execute());
- assertEquals("cuatro", sff.execute());
- assertEquals("cinco", sff.execute());
- assertEquals("uno", sff.execute());
- assertEquals("dos", sff.execute());
- assertEquals("tres", sff.execute());
- assertEquals("cuatro", sff.execute());
- assertEquals("cinco", sff.execute());
- try {
- sff.execute();
- fail("Should have thrown JMeterStopThreadException");
- } catch (JMeterStopThreadException e) {
- // expected
- }
- }
-
- // Function objects to be tested
- private static CSVRead cr1, cr2, cr3, cr4, cr5, cr6;
-
- // Helper class used to implement co-routine between two threads
- private static class Baton {
- void pass() {
- done();
- try {
- // System.out.println(">wait:"+Thread.currentThread().getName());
- wait(1000);
- } catch (InterruptedException e) {
- System.out.println(e);
- }
- // System.out.println("<wait:"+Thread.currentThread().getName());
-
- }
-
- void done() {
- // System.out.println(">done:"+Thread.currentThread().getName());
- notifyAll();
- }
-
- }
-
- private static final Baton baton = new Baton();
-
- public void CSVThread1() throws Exception {
- Thread.currentThread().setName("One");
- synchronized (baton) {
-
- assertEquals("b1", cr1.execute(null, null));
-
- assertEquals("", cr4.execute(null, null));
-
- assertEquals("b2", cr1.execute(null, null));
-
- baton.pass();
-
- assertEquals("", cr4.execute(null, null));
-
- assertEquals("b4", cr1.execute(null, null));
-
- assertEquals("", cr4.execute(null, null));
-
- baton.pass();
-
- assertEquals("b3", cr1.execute(null, null));
-
- assertEquals("", cr4.execute(null, null));
-
- baton.done();
- }
- }
-
- public void CSVThread2() throws Exception {
- Thread.currentThread().setName("Two");
- Thread.sleep(500);// Allow other thread to start
- synchronized (baton) {
-
- assertEquals("b3", cr1.execute(null, null));
-
- assertEquals("", cr4.execute(null, null));
-
- baton.pass();
-
- assertEquals("b1", cr1.execute(null, null));
-
- assertEquals("", cr4.execute(null, null));
-
- assertEquals("b2", cr1.execute(null, null));
-
- baton.pass();
-
- assertEquals("", cr4.execute(null, null));
-
- assertEquals("b4", cr1.execute(null, null));
-
- baton.done();
- }
- }
-
- public void CSVRun() throws Exception {
- assertEquals("b1", cr1.execute(null, null));
- assertEquals("c1", cr2.execute(null, null));
- assertEquals("d1", cr3.execute(null, null));
-
- assertEquals("", cr4.execute(null, null));
- assertEquals("b2", cr1.execute(null, null));
- assertEquals("c2", cr2.execute(null, null));
- assertEquals("d2", cr3.execute(null, null));
-
- assertEquals("", cr4.execute(null, null));
- assertEquals("b3", cr1.execute(null, null));
- assertEquals("c3", cr2.execute(null, null));
- assertEquals("d3", cr3.execute(null, null));
-
- assertEquals("", cr4.execute(null, null));
- assertEquals("b4", cr1.execute(null, null));
- assertEquals("c4", cr2.execute(null, null));
- assertEquals("d4", cr3.execute(null, null));
-
- assertEquals("", cr4.execute(null, null));
- assertEquals("b1", cr1.execute(null, null));
- assertEquals("c1", cr2.execute(null, null));
- assertEquals("d1", cr3.execute(null, null));
-
- assertEquals("a1", cr5.execute(null, null));
- assertEquals("", cr6.execute(null, null));
- assertEquals("a2", cr5.execute(null, null));
-
- }
-
- public void CSVParams() throws Exception {
- try {
- setCSVReadParams(null, null);
- fail("Should have failed");
- } catch (InvalidVariableException e) {
- }
- try {
- setCSVReadParams(null, "");
- fail("Should have failed");
- } catch (InvalidVariableException e) {
- }
- try {
- setCSVReadParams("", null);
- fail("Should have failed");
- } catch (InvalidVariableException e) {
- }
- }
-
- public void CSVSetup() throws Exception {
- cr1 = setCSVReadParams("testfiles/test.csv", "1");
- cr2 = setCSVReadParams("testfiles/test.csv", "2");
- cr3 = setCSVReadParams("testfiles/test.csv", "3");
- cr4 = setCSVReadParams("testfiles/test.csv", "next");
- cr5 = setCSVReadParams("", "0");
- cr6 = setCSVReadParams("", "next");
- }
-
- public void CSValias() throws Exception {
- cr1 = setCSVReadParams("testfiles/test.csv", "*A");
- cr2 = setCSVReadParams("*A", "1");
- cr3 = setCSVReadParams("*A", "next");
-
- cr4 = setCSVReadParams("testfiles/test.csv", "*B");
- cr5 = setCSVReadParams("*B", "2");
- cr6 = setCSVReadParams("*B", "next");
-
- String s;
-
- s = cr1.execute(null, null); // open as *A
- assertEquals("", s);
- s = cr2.execute(null, null); // col 1, line 1, *A
- assertEquals("b1", s);
-
- s = cr4.execute(null, null);// open as *B
- assertEquals("", s);
- s = cr5.execute(null, null);// col2 line 1
- assertEquals("c1", s);
-
- s = cr3.execute(null, null);// *A next
- assertEquals("", s);
- s = cr2.execute(null, null);// col 1, line 2, *A
- assertEquals("b2", s);
-
- s = cr5.execute(null, null);// col2, line 1, *B
- assertEquals("c1", s);
-
- s = cr6.execute(null, null);// *B next
- assertEquals("", s);
-
- s = cr5.execute(null, null);// col2, line 2, *B
- assertEquals("c2", s);
-
- }
-
- public void CSVNoFile() throws Exception {
- String s;
-
- cr1 = setCSVReadParams("xtestfiles/test.csv", "1");
- log.info("Expecting file not found");
- s = cr1.execute(null, null);
- assertEquals("", s);
-
- cr2 = setCSVReadParams("xtestfiles/test.csv", "next");
- log.info("Expecting no entry for file");
- s = cr2.execute(null, null);
- assertEquals("", s);
-
- cr3 = setCSVReadParams("xtestfiles/test.csv", "*ABC");
- log.info("Expecting file not found");
- s = cr3.execute(null, null);
- assertEquals("", s);
-
- cr4 = setCSVReadParams("*ABC", "1");
- log.info("Expecting cannot open file");
- s = cr4.execute(null, null);
- assertEquals("", s);
- }
-
- // Check blank lines are treated as EOF
- public void CSVBlankLine() throws Exception {
- CSVRead csv1 = setCSVReadParams("testfiles/testblank.csv", "1");
- CSVRead csv2 = setCSVReadParams("testfiles/testblank.csv", "next");
-
- String s;
-
- for (int i = 1; i <= 2; i++) {
- s = csv1.execute(null, null);
- assertEquals("b1", s);
-
- s = csv2.execute(null, null);
- assertEquals("", s);
-
- s = csv1.execute(null, null);
- assertEquals("b2", s);
-
- s = csv2.execute(null, null);
- assertEquals("", s);
- }
-
- }
-
- // XPathFileContainer tests
-
- public void XPathtestNull() throws Exception {
- try {
- new XPathFileContainer("nosuch.xml", "/");
- fail("Should not find the file");
- } catch (FileNotFoundException e) {
- }
- }
-
- public void XPathtestrowNum() throws Exception {
- XPathFileContainer f = new XPathFileContainer("../build.xml", "/project/target/@name");
- assertNotNull(f);
- // assertEquals("Expected 4 lines",4,f.size());
-
- int myRow = f.nextRow();
- assertEquals(0, myRow);
- assertEquals(1, f.getNextRow());
-
- myRow = f.nextRow();
- assertEquals(1, myRow);
- assertEquals(2, f.getNextRow());
-
- myRow = f.nextRow();
- assertEquals(2, myRow);
- assertEquals(3, f.getNextRow());
-
- // myRow = f.nextRow();
- // assertEquals(3,myRow);
- // assertEquals(0,f.getNextRow());
-
- // myRow = f.nextRow();
- // assertEquals(0,myRow);
- // assertEquals(1,f.getNextRow());
-
- }
-
- public void XPathtestColumns() throws Exception {
- XPathFileContainer f = new XPathFileContainer("../build.xml", "/project/target/@name");
- assertNotNull(f);
- assertTrue("Not empty", f.size() > 0);
- int last = 0;
- for (int i = 0; i < f.size(); i++) {
- last = f.nextRow();
- log.debug("found [" + i + "]" + f.getXPathString(last));
- }
- assertEquals(last + 1, f.size());
-
- }
-
- public void XPathtestDefault() throws Exception {
- XPathFileContainer f = new XPathFileContainer("../build.xml", "/project/@default");
- assertNotNull(f);
- assertTrue("Not empty", f.size() > 0);
- assertEquals("install", f.getXPathString(0));
+ public void SFFTest1() throws Exception {
+ StringFromFile sff1 = SFFParams("testfiles/SFFTest#'.'txt", "", "1", "3");
+ assertEquals("uno", sff1.execute());
+ assertEquals("dos", sff1.execute());
+ assertEquals("tres", sff1.execute());
+ assertEquals("cuatro", sff1.execute());
+ assertEquals("cinco", sff1.execute());
+ assertEquals("one", sff1.execute());
+ assertEquals("two", sff1.execute());
+ sff1.execute();
+ sff1.execute();
+ assertEquals("five", sff1.execute());
+ assertEquals("eins", sff1.execute());
+ sff1.execute();
+ sff1.execute();
+ sff1.execute();
+ assertEquals("fuenf", sff1.execute());
+ try {
+ sff1.execute();
+ fail("Should have thrown JMeterStopThreadException");
+ } catch (JMeterStopThreadException e) {
+ // expected
+ }
+ }
+
+ public void SFFTest2() throws Exception {
+ StringFromFile sff = SFFParams("testfiles/SFFTest1.txt", "", null, null);
+ assertEquals("uno", sff.execute());
+ assertEquals("dos", sff.execute());
+ assertEquals("tres", sff.execute());
+ assertEquals("cuatro", sff.execute());
+ assertEquals("cinco", sff.execute());
+ assertEquals("uno", sff.execute()); // Restarts
+ assertEquals("dos", sff.execute());
+ assertEquals("tres", sff.execute());
+ assertEquals("cuatro", sff.execute());
+ assertEquals("cinco", sff.execute());
+ }
+
+ public void SFFTest3() throws Exception {
+ StringFromFile sff = SFFParams("testfiles/SFFTest1.txt", "", "", "");
+ assertEquals("uno", sff.execute());
+ assertEquals("dos", sff.execute());
+ assertEquals("tres", sff.execute());
+ assertEquals("cuatro", sff.execute());
+ assertEquals("cinco", sff.execute());
+ assertEquals("uno", sff.execute()); // Restarts
+ assertEquals("dos", sff.execute());
+ assertEquals("tres", sff.execute());
+ assertEquals("cuatro", sff.execute());
+ assertEquals("cinco", sff.execute());
+ }
+
+ public void SFFTest4() throws Exception {
+ StringFromFile sff = SFFParams("xxtestfiles/SFFTest1.txt", "", "", "");
+ assertEquals(StringFromFile.ERR_IND, sff.execute());
+ assertEquals(StringFromFile.ERR_IND, sff.execute());
+ }
+
+ // Test that only loops twice
+ public void SFFTest5() throws Exception {
+ StringFromFile sff = SFFParams("testfiles/SFFTest1.txt", "", "", "2");
+ assertEquals("uno", sff.execute());
+ assertEquals("dos", sff.execute());
+ assertEquals("tres", sff.execute());
+ assertEquals("cuatro", sff.execute());
+ assertEquals("cinco", sff.execute());
+ assertEquals("uno", sff.execute());
+ assertEquals("dos", sff.execute());
+ assertEquals("tres", sff.execute());
+ assertEquals("cuatro", sff.execute());
+ assertEquals("cinco", sff.execute());
+ try {
+ sff.execute();
+ fail("Should have thrown JMeterStopThreadException");
+ } catch (JMeterStopThreadException e) {
+ // expected
+ }
+ }
+
+ // Function objects to be tested
+ private static CSVRead cr1, cr2, cr3, cr4, cr5, cr6;
+
+ // Helper class used to implement co-routine between two threads
+ private static class Baton {
+ void pass() {
+ done();
+ try {
+ // System.out.println(">wait:"+Thread.currentThread().getName());
+ wait(1000);
+ } catch (InterruptedException e) {
+ System.out.println(e);
+ }
+ // System.out.println("<wait:"+Thread.currentThread().getName());
+
+ }
+
+ void done() {
+ // System.out.println(">done:"+Thread.currentThread().getName());
+ notifyAll();
+ }
+
+ }
+
+ private static final Baton baton = new Baton();
+
+ public void CSVThread1() throws Exception {
+ Thread.currentThread().setName("One");
+ synchronized (baton) {
+
+ assertEquals("b1", cr1.execute(null, null));
+
+ assertEquals("", cr4.execute(null, null));
+
+ assertEquals("b2", cr1.execute(null, null));
+
+ baton.pass();
+
+ assertEquals("", cr4.execute(null, null));
- }
+ assertEquals("b4", cr1.execute(null, null));
+
+ assertEquals("", cr4.execute(null, null));
+
+ baton.pass();
+
+ assertEquals("b3", cr1.execute(null, null));
+
+ assertEquals("", cr4.execute(null, null));
+
+ baton.done();
+ }
+ }
+
+ public void CSVThread2() throws Exception {
+ Thread.currentThread().setName("Two");
+ Thread.sleep(500);// Allow other thread to start
+ synchronized (baton) {
+
+ assertEquals("b3", cr1.execute(null, null));
+
+ assertEquals("", cr4.execute(null, null));
+
+ baton.pass();
+
+ assertEquals("b1", cr1.execute(null, null));
+
+ assertEquals("", cr4.execute(null, null));
+
+ assertEquals("b2", cr1.execute(null, null));
+
+ baton.pass();
+
+ assertEquals("", cr4.execute(null, null));
+
+ assertEquals("b4", cr1.execute(null, null));
+
+ baton.done();
+ }
+ }
+
+ public void CSVRun() throws Exception {
+ assertEquals("b1", cr1.execute(null, null));
+ assertEquals("c1", cr2.execute(null, null));
+ assertEquals("d1", cr3.execute(null, null));
+
+ assertEquals("", cr4.execute(null, null));
+ assertEquals("b2", cr1.execute(null, null));
+ assertEquals("c2", cr2.execute(null, null));
+ assertEquals("d2", cr3.execute(null, null));
+
+ assertEquals("", cr4.execute(null, null));
+ assertEquals("b3", cr1.execute(null, null));
+ assertEquals("c3", cr2.execute(null, null));
+ assertEquals("d3", cr3.execute(null, null));
+
+ assertEquals("", cr4.execute(null, null));
+ assertEquals("b4", cr1.execute(null, null));
+ assertEquals("c4", cr2.execute(null, null));
+ assertEquals("d4", cr3.execute(null, null));
+
+ assertEquals("", cr4.execute(null, null));
+ assertEquals("b1", cr1.execute(null, null));
+ assertEquals("c1", cr2.execute(null, null));
+ assertEquals("d1", cr3.execute(null, null));
+
+ assertEquals("a1", cr5.execute(null, null));
+ assertEquals("", cr6.execute(null, null));
+ assertEquals("a2", cr5.execute(null, null));
+
+ }
+
+ public void CSVParams() throws Exception {
+ try {
+ setCSVReadParams(null, null);
+ fail("Should have failed");
+ } catch (InvalidVariableException e) {
+ }
+ try {
+ setCSVReadParams(null, "");
+ fail("Should have failed");
+ } catch (InvalidVariableException e) {
+ }
+ try {
+ setCSVReadParams("", null);
+ fail("Should have failed");
+ } catch (InvalidVariableException e) {
+ }
+ }
+
+ public void CSVSetup() throws Exception {
+ cr1 = setCSVReadParams("testfiles/test.csv", "1");
+ cr2 = setCSVReadParams("testfiles/test.csv", "2");
+ cr3 = setCSVReadParams("testfiles/test.csv", "3");
+ cr4 = setCSVReadParams("testfiles/test.csv", "next");
+ cr5 = setCSVReadParams("", "0");
+ cr6 = setCSVReadParams("", "next");
+ }
+
+ public void CSValias() throws Exception {
+ cr1 = setCSVReadParams("testfiles/test.csv", "*A");
+ cr2 = setCSVReadParams("*A", "1");
+ cr3 = setCSVReadParams("*A", "next");
+
+ cr4 = setCSVReadParams("testfiles/test.csv", "*B");
+ cr5 = setCSVReadParams("*B", "2");
+ cr6 = setCSVReadParams("*B", "next");
+
+ String s;
+
+ s = cr1.execute(null, null); // open as *A
+ assertEquals("", s);
+ s = cr2.execute(null, null); // col 1, line 1, *A
+ assertEquals("b1", s);
+
+ s = cr4.execute(null, null);// open as *B
+ assertEquals("", s);
+ s = cr5.execute(null, null);// col2 line 1
+ assertEquals("c1", s);
+
+ s = cr3.execute(null, null);// *A next
+ assertEquals("", s);
+ s = cr2.execute(null, null);// col 1, line 2, *A
+ assertEquals("b2", s);
+
+ s = cr5.execute(null, null);// col2, line 1, *B
+ assertEquals("c1", s);
+
+ s = cr6.execute(null, null);// *B next
+ assertEquals("", s);
+
+ s = cr5.execute(null, null);// col2, line 2, *B
+ assertEquals("c2", s);
+
+ }
+
+ public void CSVNoFile() throws Exception {
+ String s;
+
+ cr1 = setCSVReadParams("xtestfiles/test.csv", "1");
+ log.info("Expecting file not found");
+ s = cr1.execute(null, null);
+ assertEquals("", s);
+
+ cr2 = setCSVReadParams("xtestfiles/test.csv", "next");
+ log.info("Expecting no entry for file");
+ s = cr2.execute(null, null);
+ assertEquals("", s);
+
+ cr3 = setCSVReadParams("xtestfiles/test.csv", "*ABC");
+ log.info("Expecting file not found");
+ s = cr3.execute(null, null);
+ assertEquals("", s);
+
+ cr4 = setCSVReadParams("*ABC", "1");
+ log.info("Expecting cannot open file");
+ s = cr4.execute(null, null);
+ assertEquals("", s);
+ }
+
+ // Check blank lines are treated as EOF
+ public void CSVBlankLine() throws Exception {
+ CSVRead csv1 = setCSVReadParams("testfiles/testblank.csv", "1");
+ CSVRead csv2 = setCSVReadParams("testfiles/testblank.csv", "next");
+
+ String s;
+
+ for (int i = 1; i <= 2; i++) {
+ s = csv1.execute(null, null);
+ assertEquals("b1", s);
+
+ s = csv2.execute(null, null);
+ assertEquals("", s);
+
+ s = csv1.execute(null, null);
+ assertEquals("b2", s);
+
+ s = csv2.execute(null, null);
+ assertEquals("", s);
+ }
+
+ }
+
+ // XPathFileContainer tests
+
+ public void XPathtestNull() throws Exception {
+ try {
+ new XPathFileContainer("nosuch.xml", "/");
+ fail("Should not find the file");
+ } catch (FileNotFoundException e) {
+ }
+ }
+
+ public void XPathtestrowNum() throws Exception {
+ XPathFileContainer f = new XPathFileContainer("../build.xml", "/project/target/@name");
+ assertNotNull(f);
+ // assertEquals("Expected 4 lines",4,f.size());
+
+ int myRow = f.nextRow();
+ assertEquals(0, myRow);
+ assertEquals(1, f.getNextRow());
+
+ myRow = f.nextRow();
+ assertEquals(1, myRow);
+ assertEquals(2, f.getNextRow());
+
+ myRow = f.nextRow();
+ assertEquals(2, myRow);
+ assertEquals(3, f.getNextRow());
+
+ // myRow = f.nextRow();
+ // assertEquals(3,myRow);
+ // assertEquals(0,f.getNextRow());
+
+ // myRow = f.nextRow();
+ // assertEquals(0,myRow);
+ // assertEquals(1,f.getNextRow());
+
+ }
+
+ public void XPathtestColumns() throws Exception {
+ XPathFileContainer f = new XPathFileContainer("../build.xml", "/project/target/@name");
+ assertNotNull(f);
+ assertTrue("Not empty", f.size() > 0);
+ int last = 0;
+ for (int i = 0; i < f.size(); i++) {
+ last = f.nextRow();
+ log.debug("found [" + i + "]" + f.getXPathString(last));
+ }
+ assertEquals(last + 1, f.size());
+
+ }
+
+ public void XPathtestDefault() throws Exception {
+ XPathFileContainer f = new XPathFileContainer("../build.xml", "/project/@default");
+ assertNotNull(f);
+ assertTrue("Not empty", f.size() > 0);
+ assertEquals("install", f.getXPathString(0));
+
+ }
public void XPathEmpty() throws Exception{
XPath xp = setupXPath("","");
@@ -837,7 +837,7 @@
Collection parms = MakeParams("0","10000000000","VAR");
r.setParameters(parms);
//String s =
- r.execute(null,null);
+ r.execute(null,null);
}
public void variableTest1() throws Exception {
@@ -916,44 +916,44 @@
}
public void sumTest() throws Exception {
- IntSum is = new IntSum();
- checkInvalidParameterCounts(is,2);
- checkSum(is,"3", new String[]{"1","2"});
+ IntSum is = new IntSum();
+ checkInvalidParameterCounts(is,2);
+ checkSum(is,"3", new String[]{"1","2"});
checkSumNoVar(is,"3", new String[]{"1","2"});
- checkSum(is,"1", new String[]{"-1","1","1","1","-2","1"});
+ checkSum(is,"1", new String[]{"-1","1","1","1","-2","1"});
checkSumNoVar(is,"1", new String[]{"-1","1","1","1","-2","1"});
- String maxIntVal = Integer.toString(Integer.MAX_VALUE);
- String minIntVal = Integer.toString(Integer.MIN_VALUE);
- checkSum(is,maxIntVal, new String[]{maxIntVal,"0"});
- checkSum(is,minIntVal, new String[]{maxIntVal,"1"}); // wrap-round check
-
- is = null; // prevent accidental use below
-
- LongSum ls = new LongSum();
- checkInvalidParameterCounts(ls,2);
- checkSum(ls,"3", new String[]{"1","2"});
- checkSum(ls,"1", new String[]{"-1","1","1","1","-1","0"});
+ String maxIntVal = Integer.toString(Integer.MAX_VALUE);
+ String minIntVal = Integer.toString(Integer.MIN_VALUE);
+ checkSum(is,maxIntVal, new String[]{maxIntVal,"0"});
+ checkSum(is,minIntVal, new String[]{maxIntVal,"1"}); // wrap-round check
+
+ is = null; // prevent accidental use below
+
+ LongSum ls = new LongSum();
+ checkInvalidParameterCounts(ls,2);
+ checkSum(ls,"3", new String[]{"1","2"});
+ checkSum(ls,"1", new String[]{"-1","1","1","1","-1","0"});
checkSumNoVar(ls,"3", new String[]{"1","2"});
checkSumNoVar(ls,"1", new String[]{"-1","1","1","1","-1","0"});
- String maxIntVal_1 = Long.toString(1+(long)Integer.MAX_VALUE);
- checkSum(ls,maxIntVal, new String[]{maxIntVal,"0"});
- checkSum(ls,maxIntVal_1, new String[]{maxIntVal,"1"}); // no wrap-round check
- String maxLongVal = Long.toString(Long.MAX_VALUE);
- String minLongVal = Long.toString(Long.MIN_VALUE);
- checkSum(ls,maxLongVal, new String[]{maxLongVal,"0"});
- checkSum(ls,minLongVal, new String[]{maxLongVal,"1"}); // wrap-round check
+ String maxIntVal_1 = Long.toString(1+(long)Integer.MAX_VALUE);
+ checkSum(ls,maxIntVal, new String[]{maxIntVal,"0"});
+ checkSum(ls,maxIntVal_1, new String[]{maxIntVal,"1"}); // no wrap-round check
+ String maxLongVal = Long.toString(Long.MAX_VALUE);
+ String minLongVal = Long.toString(Long.MIN_VALUE);
+ checkSum(ls,maxLongVal, new String[]{maxLongVal,"0"});
+ checkSum(ls,minLongVal, new String[]{maxLongVal,"1"}); // wrap-round check
}
// Perform a sum and check the results
private void checkSum(AbstractFunction func, String value, String [] addends) throws Exception {
- Collection parms = new LinkedList();
- for (int i=0; i< addends.length; i++){
- parms.add(new CompoundVariable(addends[i]));
- }
- parms.add(new CompoundVariable("Result"));
- func.setParameters(parms);
- assertEquals(value,func.execute(null,null));
- assertEquals(value,vars.getObject("Result"));
+ Collection parms = new LinkedList();
+ for (int i=0; i< addends.length; i++){
+ parms.add(new CompoundVariable(addends[i]));
+ }
+ parms.add(new CompoundVariable("Result"));
+ func.setParameters(parms);
+ assertEquals(value,func.execute(null,null));
+ assertEquals(value,vars.getObject("Result"));
}
// Perform a sum and check the results
private void checkSumNoVar(AbstractFunction func, String value, String [] addends) throws Exception {
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestFileRowColContainer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestFileRowColContainer.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestFileRowColContainer.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestFileRowColContainer.java Sun May 10 18:19:28 2009
@@ -30,121 +30,121 @@
*/
public class TestFileRowColContainer {
- public static class Test extends JMeterTestCase {
+ public static class Test extends JMeterTestCase {
- public Test(String a) {
- super(a);
- }
-
- public void testNull() throws Exception {
- try {
- new FileRowColContainer("testfiles/xyzxyz");
- fail("Should not find the file");
- } catch (FileNotFoundException e) {
- }
- }
-
- public void testrowNum() throws Exception {
- FileRowColContainer f = new FileRowColContainer("testfiles/test.csv");
- assertNotNull(f);
- assertEquals("Expected 4 lines", 4, f.getSize());
-
- assertEquals(0, f.nextRow());
- assertEquals(1, f.nextRow());
- assertEquals(2, f.nextRow());
- assertEquals(3, f.nextRow());
- assertEquals(0, f.nextRow());
-
- }
-
- public void testColumns() throws Exception {
- FileRowColContainer f = new FileRowColContainer("testfiles/test.csv");
- assertNotNull(f);
- assertTrue("Not empty", f.getSize() > 0);
-
- int myRow = f.nextRow();
- assertEquals(0, myRow);
- assertEquals("a1", f.getColumn(myRow, 0));
- assertEquals("d1", f.getColumn(myRow, 3));
-
- try {
- f.getColumn(myRow, 4);
- fail("Expected out of bounds");
- } catch (IndexOutOfBoundsException e) {
- }
- myRow = f.nextRow();
- assertEquals(1, myRow);
- assertEquals("b2", f.getColumn(myRow, 1));
- assertEquals("c2", f.getColumn(myRow, 2));
- }
-
- public void testColumnsComma() throws Exception {
- FileRowColContainer f = new FileRowColContainer("testfiles/test.csv", ",");
- assertNotNull(f);
- assertTrue("Not empty", f.getSize() > 0);
-
- int myRow = f.nextRow();
- assertEquals(0, myRow);
- assertEquals("a1", f.getColumn(myRow, 0));
- assertEquals("d1", f.getColumn(myRow, 3));
-
- try {
- f.getColumn(myRow, 4);
- fail("Expected out of bounds");
- } catch (IndexOutOfBoundsException e) {
- }
- myRow = f.nextRow();
- assertEquals(1, myRow);
- assertEquals("b2", f.getColumn(myRow, 1));
- assertEquals("c2", f.getColumn(myRow, 2));
- }
-
- public void testColumnsTab() throws Exception {
- FileRowColContainer f = new FileRowColContainer("testfiles/test.tsv", "\t");
- assertNotNull(f);
- assertTrue("Not empty", f.getSize() > 0);
-
- int myRow = f.nextRow();
- assertEquals(0, myRow);
- assertEquals("a1", f.getColumn(myRow, 0));
- assertEquals("d1", f.getColumn(myRow, 3));
-
- try {
- f.getColumn(myRow, 4);
- fail("Expected out of bounds");
- } catch (IndexOutOfBoundsException e) {
- }
- myRow = f.nextRow();
- assertEquals(1, myRow);
- assertEquals("b2", f.getColumn(myRow, 1));
- assertEquals("c2", f.getColumn(myRow, 2));
- }
-
- public void testEmptyCols() throws Exception {
- FileRowColContainer f = new FileRowColContainer("testfiles/testempty.csv");
- assertNotNull(f);
- assertEquals("Expected 4 lines", 4, f.getSize());
-
- int myRow = f.nextRow();
- assertEquals(0, myRow);
- assertEquals("", f.getColumn(myRow, 0));
- assertEquals("d1", f.getColumn(myRow, 3));
-
- myRow = f.nextRow();
- assertEquals(1, myRow);
- assertEquals("", f.getColumn(myRow, 1));
- assertEquals("c2", f.getColumn(myRow, 2));
-
- myRow = f.nextRow();
- assertEquals(2, myRow);
- assertEquals("b3", f.getColumn(myRow, 1));
- assertEquals("", f.getColumn(myRow, 2));
-
- myRow = f.nextRow();
- assertEquals(3, myRow);
- assertEquals("b4", f.getColumn(myRow, 1));
- assertEquals("c4", f.getColumn(myRow, 2));
- assertEquals("", f.getColumn(myRow, 3));
- }
- }
+ public Test(String a) {
+ super(a);
+ }
+
+ public void testNull() throws Exception {
+ try {
+ new FileRowColContainer("testfiles/xyzxyz");
+ fail("Should not find the file");
+ } catch (FileNotFoundException e) {
+ }
+ }
+
+ public void testrowNum() throws Exception {
+ FileRowColContainer f = new FileRowColContainer("testfiles/test.csv");
+ assertNotNull(f);
+ assertEquals("Expected 4 lines", 4, f.getSize());
+
+ assertEquals(0, f.nextRow());
+ assertEquals(1, f.nextRow());
+ assertEquals(2, f.nextRow());
+ assertEquals(3, f.nextRow());
+ assertEquals(0, f.nextRow());
+
+ }
+
+ public void testColumns() throws Exception {
+ FileRowColContainer f = new FileRowColContainer("testfiles/test.csv");
+ assertNotNull(f);
+ assertTrue("Not empty", f.getSize() > 0);
+
+ int myRow = f.nextRow();
+ assertEquals(0, myRow);
+ assertEquals("a1", f.getColumn(myRow, 0));
+ assertEquals("d1", f.getColumn(myRow, 3));
+
+ try {
+ f.getColumn(myRow, 4);
+ fail("Expected out of bounds");
+ } catch (IndexOutOfBoundsException e) {
+ }
+ myRow = f.nextRow();
+ assertEquals(1, myRow);
+ assertEquals("b2", f.getColumn(myRow, 1));
+ assertEquals("c2", f.getColumn(myRow, 2));
+ }
+
+ public void testColumnsComma() throws Exception {
+ FileRowColContainer f = new FileRowColContainer("testfiles/test.csv", ",");
+ assertNotNull(f);
+ assertTrue("Not empty", f.getSize() > 0);
+
+ int myRow = f.nextRow();
+ assertEquals(0, myRow);
+ assertEquals("a1", f.getColumn(myRow, 0));
+ assertEquals("d1", f.getColumn(myRow, 3));
+
+ try {
+ f.getColumn(myRow, 4);
+ fail("Expected out of bounds");
+ } catch (IndexOutOfBoundsException e) {
+ }
+ myRow = f.nextRow();
+ assertEquals(1, myRow);
+ assertEquals("b2", f.getColumn(myRow, 1));
+ assertEquals("c2", f.getColumn(myRow, 2));
+ }
+
+ public void testColumnsTab() throws Exception {
+ FileRowColContainer f = new FileRowColContainer("testfiles/test.tsv", "\t");
+ assertNotNull(f);
+ assertTrue("Not empty", f.getSize() > 0);
+
+ int myRow = f.nextRow();
+ assertEquals(0, myRow);
+ assertEquals("a1", f.getColumn(myRow, 0));
+ assertEquals("d1", f.getColumn(myRow, 3));
+
+ try {
+ f.getColumn(myRow, 4);
+ fail("Expected out of bounds");
+ } catch (IndexOutOfBoundsException e) {
+ }
+ myRow = f.nextRow();
+ assertEquals(1, myRow);
+ assertEquals("b2", f.getColumn(myRow, 1));
+ assertEquals("c2", f.getColumn(myRow, 2));
+ }
+
+ public void testEmptyCols() throws Exception {
+ FileRowColContainer f = new FileRowColContainer("testfiles/testempty.csv");
+ assertNotNull(f);
+ assertEquals("Expected 4 lines", 4, f.getSize());
+
+ int myRow = f.nextRow();
+ assertEquals(0, myRow);
+ assertEquals("", f.getColumn(myRow, 0));
+ assertEquals("d1", f.getColumn(myRow, 3));
+
+ myRow = f.nextRow();
+ assertEquals(1, myRow);
+ assertEquals("", f.getColumn(myRow, 1));
+ assertEquals("c2", f.getColumn(myRow, 2));
+
+ myRow = f.nextRow();
+ assertEquals(2, myRow);
+ assertEquals("b3", f.getColumn(myRow, 1));
+ assertEquals("", f.getColumn(myRow, 2));
+
+ myRow = f.nextRow();
+ assertEquals(3, myRow);
+ assertEquals("b4", f.getColumn(myRow, 1));
+ assertEquals("c4", f.getColumn(myRow, 2));
+ assertEquals("", f.getColumn(myRow, 3));
+ }
+ }
}
\ No newline at end of file
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestRegexFunction.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestRegexFunction.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestRegexFunction.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestRegexFunction.java Sun May 10 18:19:28 2009
@@ -29,52 +29,52 @@
import org.apache.jmeter.threads.JMeterVariables;
public class TestRegexFunction extends JMeterTestCase {
- private static final String INPUT_VARIABLE_NAME = "INVAR";
+ private static final String INPUT_VARIABLE_NAME = "INVAR";
RegexFunction variable;
- SampleResult result;
+ SampleResult result;
- Collection params;
+ Collection params;
- private JMeterVariables vars;
+ private JMeterVariables vars;
- private JMeterContext jmctx = null;
+ private JMeterContext jmctx = null;
- public TestRegexFunction(String name) {
- super(name);
- }
-
- public void setUp() {
- variable = new RegexFunction();
- result = new SampleResult();
- jmctx = JMeterContextService.getContext();
- String data = "<company-xmlext-query-ret><row>" + "<value field=\"RetCode\">" + "LIS_OK</value><value"
- + " field=\"RetCodeExtension\"></value>" + "<value field=\"alias\"></value><value"
- + " field=\"positioncount\"></value>" + "<value field=\"invalidpincount\">0</value><value"
- + " field=\"pinposition1\">1</value><value" + " field=\"pinpositionvalue1\"></value><value"
- + " field=\"pinposition2\">5</value><value" + " field=\"pinpositionvalue2\"></value><value"
- + " field=\"pinposition3\">6</value><value" + " field=\"pinpositionvalue3\"></value>"
- + "</row></company-xmlext-query-ret>";
- result.setResponseData(data.getBytes());
- vars = new JMeterVariables();
- String data2 = "The quick brown fox jumped over the lazy dog 123 times";
- vars.put(INPUT_VARIABLE_NAME, data2);
- jmctx.setVariables(vars);
- jmctx.setPreviousResult(result);
- }
-
- public void testVariableExtraction() throws Exception {
- params = new LinkedList();
- params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
- params.add(new CompoundVariable("$2$"));
- params.add(new CompoundVariable("2"));
- variable.setParameters(params);
- String match = variable.execute(result, null);
- assertEquals("5", match);
- }
+ public TestRegexFunction(String name) {
+ super(name);
+ }
+
+ public void setUp() {
+ variable = new RegexFunction();
+ result = new SampleResult();
+ jmctx = JMeterContextService.getContext();
+ String data = "<company-xmlext-query-ret><row>" + "<value field=\"RetCode\">" + "LIS_OK</value><value"
+ + " field=\"RetCodeExtension\"></value>" + "<value field=\"alias\"></value><value"
+ + " field=\"positioncount\"></value>" + "<value field=\"invalidpincount\">0</value><value"
+ + " field=\"pinposition1\">1</value><value" + " field=\"pinpositionvalue1\"></value><value"
+ + " field=\"pinposition2\">5</value><value" + " field=\"pinpositionvalue2\"></value><value"
+ + " field=\"pinposition3\">6</value><value" + " field=\"pinpositionvalue3\"></value>"
+ + "</row></company-xmlext-query-ret>";
+ result.setResponseData(data.getBytes());
+ vars = new JMeterVariables();
+ String data2 = "The quick brown fox jumped over the lazy dog 123 times";
+ vars.put(INPUT_VARIABLE_NAME, data2);
+ jmctx.setVariables(vars);
+ jmctx.setPreviousResult(result);
+ }
- // Test with output variable name
+ public void testVariableExtraction() throws Exception {
+ params = new LinkedList();
+ params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+ params.add(new CompoundVariable("$2$"));
+ params.add(new CompoundVariable("2"));
+ variable.setParameters(params);
+ String match = variable.execute(result, null);
+ assertEquals("5", match);
+ }
+
+ // Test with output variable name
public void testVariableExtraction1a() throws Exception {
params = new LinkedList();
params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
@@ -279,78 +279,78 @@
assertEquals("times", vars.getObject("OUTVAR_g2"));
}
- public void testVariableExtraction2() throws Exception {
- params = new LinkedList();
- params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
- params.add(new CompoundVariable("$1$"));
- params.add(new CompoundVariable("3"));
- variable.setParameters(params);
- String match = variable.execute(result, null);
- assertEquals("pinposition3", match);
- }
-
- public void testVariableExtraction5() throws Exception {
- params = new LinkedList();
- params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
- params.add(new CompoundVariable("$1$"));
- params.add(new CompoundVariable("ALL"));
- params.add(new CompoundVariable("_"));
- variable.setParameters(params);
- String match = variable.execute(result, null);
- assertEquals("pinposition1_pinposition2_pinposition3", match);
- }
-
- public void testVariableExtraction6() throws Exception {
- params = new LinkedList();
- params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
- params.add(new CompoundVariable("$2$"));
- params.add(new CompoundVariable("4"));
- params.add(new CompoundVariable(""));
- params.add(new CompoundVariable("default"));
- variable.setParameters(params);
- String match = variable.execute(result, null);
- assertEquals("default", match);
- }
-
- public void testComma() throws Exception {
- params = new LinkedList();
- params.add(new CompoundVariable("<value,? field=\"(pinposition\\d+)\">(\\d+)</value>"));
- params.add(new CompoundVariable("$1$"));
- params.add(new CompoundVariable("3"));
- variable.setParameters(params);
- String match = variable.execute(result, null);
- assertEquals("pinposition3", match);
- }
-
- public void testVariableExtraction3() throws Exception {
- params = new LinkedList();
- params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
- params.add(new CompoundVariable("_$1$"));
- params.add(new CompoundVariable("2"));
- variable.setParameters(params);
- String match = variable.execute(result, null);
- assertEquals("_pinposition2", match);
- }
-
- public void testVariableExtraction4() throws Exception {
- params = new LinkedList();
- params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
- params.add(new CompoundVariable("$2$, "));
- params.add(new CompoundVariable(".333"));
- variable.setParameters(params);
- String match = variable.execute(result, null);
- assertEquals("1, ", match);
- }
-
- public void testDefaultValue() throws Exception {
- params = new LinkedList();
- params.add(new CompoundVariable("<value,, field=\"(pinposition\\d+)\">(\\d+)</value>"));
- params.add(new CompoundVariable("$2$, "));
- params.add(new CompoundVariable(".333"));
- params.add(new CompoundVariable(""));
- params.add(new CompoundVariable("No Value Found"));
- variable.setParameters(params);
- String match = variable.execute(result, null);
- assertEquals("No Value Found", match);
- }
+ public void testVariableExtraction2() throws Exception {
+ params = new LinkedList();
+ params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+ params.add(new CompoundVariable("$1$"));
+ params.add(new CompoundVariable("3"));
+ variable.setParameters(params);
+ String match = variable.execute(result, null);
+ assertEquals("pinposition3", match);
+ }
+
+ public void testVariableExtraction5() throws Exception {
+ params = new LinkedList();
+ params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+ params.add(new CompoundVariable("$1$"));
+ params.add(new CompoundVariable("ALL"));
+ params.add(new CompoundVariable("_"));
+ variable.setParameters(params);
+ String match = variable.execute(result, null);
+ assertEquals("pinposition1_pinposition2_pinposition3", match);
+ }
+
+ public void testVariableExtraction6() throws Exception {
+ params = new LinkedList();
+ params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+ params.add(new CompoundVariable("$2$"));
+ params.add(new CompoundVariable("4"));
+ params.add(new CompoundVariable(""));
+ params.add(new CompoundVariable("default"));
+ variable.setParameters(params);
+ String match = variable.execute(result, null);
+ assertEquals("default", match);
+ }
+
+ public void testComma() throws Exception {
+ params = new LinkedList();
+ params.add(new CompoundVariable("<value,? field=\"(pinposition\\d+)\">(\\d+)</value>"));
+ params.add(new CompoundVariable("$1$"));
+ params.add(new CompoundVariable("3"));
+ variable.setParameters(params);
+ String match = variable.execute(result, null);
+ assertEquals("pinposition3", match);
+ }
+
+ public void testVariableExtraction3() throws Exception {
+ params = new LinkedList();
+ params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+ params.add(new CompoundVariable("_$1$"));
+ params.add(new CompoundVariable("2"));
+ variable.setParameters(params);
+ String match = variable.execute(result, null);
+ assertEquals("_pinposition2", match);
+ }
+
+ public void testVariableExtraction4() throws Exception {
+ params = new LinkedList();
+ params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+ params.add(new CompoundVariable("$2$, "));
+ params.add(new CompoundVariable(".333"));
+ variable.setParameters(params);
+ String match = variable.execute(result, null);
+ assertEquals("1, ", match);
+ }
+
+ public void testDefaultValue() throws Exception {
+ params = new LinkedList();
+ params.add(new CompoundVariable("<value,, field=\"(pinposition\\d+)\">(\\d+)</value>"));
+ params.add(new CompoundVariable("$2$, "));
+ params.add(new CompoundVariable(".333"));
+ params.add(new CompoundVariable(""));
+ params.add(new CompoundVariable("No Value Found"));
+ variable.setParameters(params);
+ String match = variable.execute(result, null);
+ assertEquals("No Value Found", match);
+ }
}
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestTimeFunction.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestTimeFunction.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestTimeFunction.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestTimeFunction.java Sun May 10 18:19:28 2009
@@ -30,31 +30,31 @@
import org.apache.jmeter.threads.JMeterVariables;
public class TestTimeFunction extends JMeterTestCase {
- private Function variable;
+ private Function variable;
- private SampleResult result;
+ private SampleResult result;
- private Collection params;
+ private Collection params;
- private JMeterVariables vars;
+ private JMeterVariables vars;
- private JMeterContext jmctx = null;
+ private JMeterContext jmctx = null;
private String value;
- public TestTimeFunction(String name) {
- super(name);
- }
-
- public void setUp() {
- jmctx = JMeterContextService.getContext();
- vars = new JMeterVariables();
- jmctx.setVariables(vars);
- jmctx.setPreviousResult(result);
+ public TestTimeFunction(String name) {
+ super(name);
+ }
+
+ public void setUp() {
+ jmctx = JMeterContextService.getContext();
+ vars = new JMeterVariables();
+ jmctx.setVariables(vars);
+ jmctx.setPreviousResult(result);
params = new LinkedList();
result = new SampleResult();
variable = new TimeFunction();
- }
+ }
public void testDefault() throws Exception {
variable.setParameters(params);
@@ -105,14 +105,14 @@
}
}
- public void testYMD() throws Exception {
- params.add(new CompoundVariable("YMD"));
- params.add(new CompoundVariable("NAME"));
- variable.setParameters(params);
- value = variable.execute(result, null);
- assertEquals(8,value.length());
+ public void testYMD() throws Exception {
+ params.add(new CompoundVariable("YMD"));
+ params.add(new CompoundVariable("NAME"));
+ variable.setParameters(params);
+ value = variable.execute(result, null);
+ assertEquals(8,value.length());
assertEquals(value,vars.get("NAME"));
- }
+ }
public void testYMDnoV() throws Exception {
params.add(new CompoundVariable("YMD"));
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/PackageTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/PackageTest.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/PackageTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/PackageTest.java Sun May 10 18:19:28 2009
@@ -22,16 +22,16 @@
public class PackageTest extends TestCase {
- public PackageTest(String arg0) {
- super(arg0);
- }
+ public PackageTest(String arg0) {
+ super(arg0);
+ }
- //TODO add tests for SaveGraphics
- public void testSaveGraphics() throws Exception {
- }
-
- //TODO add tests for ReportSaveGraphics
- public void testReportSaveGraphics() throws Exception {
- }
-
+ //TODO add tests for SaveGraphics
+ public void testSaveGraphics() throws Exception {
+ }
+
+ //TODO add tests for ReportSaveGraphics
+ public void testReportSaveGraphics() throws Exception {
+ }
+
}
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestLoad.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestLoad.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestLoad.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestLoad.java Sun May 10 18:19:28 2009
@@ -36,82 +36,82 @@
*/
public class TestLoad extends JMeterTestCase {
- private static final String basedir = new File(System.getProperty("user.dir")).getParent();
- private static final File testfiledir = new File(basedir,"bin/testfiles");
- private static final File demofiledir = new File(basedir,"xdocs/demos");
-
- private static final Set notTestPlan = new HashSet();// not full test plans
-
- static{
- notTestPlan.add("load_bug_list.jmx");// used by TestAnchorModifier
- notTestPlan.add("Load_JMeter_Page.jmx");// used by TestAnchorModifier
- notTestPlan.add("ProxyServerTestPlan.jmx");// used by TestSaveService
- }
-
- private static final FilenameFilter jmxFilter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".jmx");
- }
- };
-
- private final File testFile;
- private final String parent;
-
- public TestLoad(String name) {
- super(name);
- testFile=null;
- parent=null;
- }
-
- public TestLoad(String name, File file, String dir) {
- super(name);
- testFile=file;
- parent=dir;
- }
-
- public static TestSuite suite(){
- TestSuite suite=new TestSuite("Load Test");
- //suite.addTest(new TestLoad("checkGuiPackage"));
- scanFiles(suite,testfiledir);
- scanFiles(suite,demofiledir);
- return suite;
- }
-
- private static void scanFiles(TestSuite suite, File parent) {
- File testFiles[]=parent.listFiles(jmxFilter);
- String dir = parent.getName();
- for (int i=0; i<testFiles.length; i++){
- suite.addTest(new TestLoad("checkTestFile",testFiles[i],dir));
- }
- }
-
- public void checkTestFile() throws Exception{
- HashTree tree = null;
- try {
- tree =getTree(testFile);
- } catch (Exception e) {
- fail(parent+": "+ testFile.getName()+" caused "+e);
- }
- assertTree(tree);
- }
-
- private void assertTree(HashTree tree) throws Exception {
- final Object object = tree.getArray()[0];
- final String name = testFile.getName();
-
- if (! (object instanceof org.apache.jmeter.testelement.TestPlan) && !notTestPlan.contains(name)){
- fail(parent+ ": " +name+" tree should be TestPlan, but is "+object.getClass().getName());
- }
- }
-
- private HashTree getTree(File f) throws Exception {
- FileInputStream fis = new FileInputStream(f);
- HashTree tree = null;
- try {
+ private static final String basedir = new File(System.getProperty("user.dir")).getParent();
+ private static final File testfiledir = new File(basedir,"bin/testfiles");
+ private static final File demofiledir = new File(basedir,"xdocs/demos");
+
+ private static final Set notTestPlan = new HashSet();// not full test plans
+
+ static{
+ notTestPlan.add("load_bug_list.jmx");// used by TestAnchorModifier
+ notTestPlan.add("Load_JMeter_Page.jmx");// used by TestAnchorModifier
+ notTestPlan.add("ProxyServerTestPlan.jmx");// used by TestSaveService
+ }
+
+ private static final FilenameFilter jmxFilter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jmx");
+ }
+ };
+
+ private final File testFile;
+ private final String parent;
+
+ public TestLoad(String name) {
+ super(name);
+ testFile=null;
+ parent=null;
+ }
+
+ public TestLoad(String name, File file, String dir) {
+ super(name);
+ testFile=file;
+ parent=dir;
+ }
+
+ public static TestSuite suite(){
+ TestSuite suite=new TestSuite("Load Test");
+ //suite.addTest(new TestLoad("checkGuiPackage"));
+ scanFiles(suite,testfiledir);
+ scanFiles(suite,demofiledir);
+ return suite;
+ }
+
+ private static void scanFiles(TestSuite suite, File parent) {
+ File testFiles[]=parent.listFiles(jmxFilter);
+ String dir = parent.getName();
+ for (int i=0; i<testFiles.length; i++){
+ suite.addTest(new TestLoad("checkTestFile",testFiles[i],dir));
+ }
+ }
+
+ public void checkTestFile() throws Exception{
+ HashTree tree = null;
+ try {
+ tree =getTree(testFile);
+ } catch (Exception e) {
+ fail(parent+": "+ testFile.getName()+" caused "+e);
+ }
+ assertTree(tree);
+ }
+
+ private void assertTree(HashTree tree) throws Exception {
+ final Object object = tree.getArray()[0];
+ final String name = testFile.getName();
+
+ if (! (object instanceof org.apache.jmeter.testelement.TestPlan) && !notTestPlan.contains(name)){
+ fail(parent+ ": " +name+" tree should be TestPlan, but is "+object.getClass().getName());
+ }
+ }
+
+ private HashTree getTree(File f) throws Exception {
+ FileInputStream fis = new FileInputStream(f);
+ HashTree tree = null;
+ try {
tree = SaveService.loadTree(fis);
- } finally {
- fis.close();
- }
- return tree;
- }
+ } finally {
+ fis.close();
+ }
+ return tree;
+ }
}
\ No newline at end of file
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestSave.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestSave.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestSave.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestSave.java Sun May 10 18:19:28 2009
@@ -24,26 +24,26 @@
import org.apache.jorphan.collections.ListedHashTree;
public class TestSave extends junit.framework.TestCase {
- Save save;
+ Save save;
- public TestSave(String name) {
- super(name);
- }
+ public TestSave(String name) {
+ super(name);
+ }
- public void setUp() {
- save = new Save();
- }
+ public void setUp() {
+ save = new Save();
+ }
- public void testTreeConversion() throws Exception {
- HashTree tree = new ListedHashTree();
- JMeterTreeNode root = new JMeterTreeNode(new Arguments(), null);
- tree.add(root, root);
- tree.getTree(root).add(root, root);
- save.convertSubTree(tree);
- assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
- tree = tree.getTree(tree.getArray()[0]);
- assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
- assertEquals(tree.getTree(tree.getArray()[0]).getArray()[0].getClass().getName(), root.getTestElement()
- .getClass().getName());
- }
+ public void testTreeConversion() throws Exception {
+ HashTree tree = new ListedHashTree();
+ JMeterTreeNode root = new JMeterTreeNode(new Arguments(), null);
+ tree.add(root, root);
+ tree.getTree(root).add(root, root);
+ save.convertSubTree(tree);
+ assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
+ tree = tree.getTree(tree.getArray()[0]);
+ assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
+ assertEquals(tree.getTree(tree.getArray()[0]).getArray()[0].getClass().getName(), root.getTestElement()
+ .getClass().getName());
+ }
}
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java Sun May 10 18:19:28 2009
@@ -22,32 +22,32 @@
public final class TestMenuFactory extends JMeterTestCase {
- public TestMenuFactory() {
- super();
- }
-
- public TestMenuFactory(String name) {
- super(name);
- }
-
- private static void check(String s, int i) throws Exception {
- assertFalse("The number of " + s + " should not be 0", 0 == i);
- }
-
- public void testMenu() throws Exception {
- check("menumap", MenuFactory.menuMap_size());
-
- check("assertions", MenuFactory.assertions_size());
- check("configElements", MenuFactory.configElements_size());
- check("controllers", MenuFactory.controllers_size());
- check("listeners", MenuFactory.listeners_size());
- check("nonTestElements", MenuFactory.nonTestElements_size());
- check("postProcessors", MenuFactory.postProcessors_size());
- check("preProcessors", MenuFactory.preProcessors_size());
- check("samplers", MenuFactory.samplers_size());
- check("timers", MenuFactory.timers_size());
+ public TestMenuFactory() {
+ super();
+ }
+
+ public TestMenuFactory(String name) {
+ super(name);
+ }
+
+ private static void check(String s, int i) throws Exception {
+ assertFalse("The number of " + s + " should not be 0", 0 == i);
+ }
+
+ public void testMenu() throws Exception {
+ check("menumap", MenuFactory.menuMap_size());
+
+ check("assertions", MenuFactory.assertions_size());
+ check("configElements", MenuFactory.configElements_size());
+ check("controllers", MenuFactory.controllers_size());
+ check("listeners", MenuFactory.listeners_size());
+ check("nonTestElements", MenuFactory.nonTestElements_size());
+ check("postProcessors", MenuFactory.postProcessors_size());
+ check("preProcessors", MenuFactory.preProcessors_size());
+ check("samplers", MenuFactory.samplers_size());
+ check("timers", MenuFactory.timers_size());
- check("elementstoskip", MenuFactory.elementsToSkip_size());
+ check("elementstoskip", MenuFactory.elementsToSkip_size());
- }
+ }
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org