You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2016/02/15 20:54:41 UTC
svn commit: r1730601 - in /jmeter/trunk/test/src/org/apache:
jmeter/functions/ jmeter/junit/ jmeter/report/core/ jmeter/testbeans/gui/
jmeter/testelement/ jorphan/exec/
Author: pmouawad
Date: Mon Feb 15 19:54:40 2016
New Revision: 1730601
URL: http://svn.apache.org/viewvc?rev=1730601&view=rev
Log:
move more tests into their own classes
Patch by Benoit Wiart
#resolve #125
Added:
jmeter/trunk/test/src/org/apache/jmeter/functions/CSVReadFunctionTest.java (with props)
jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java (with props)
jmeter/trunk/test/src/org/apache/jmeter/functions/SplitFunctionTest.java (with props)
jmeter/trunk/test/src/org/apache/jmeter/testelement/TestElementTest.java (with props)
Modified:
jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java
jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java
jmeter/trunk/test/src/org/apache/jmeter/report/core/TestCsvSampleWriter.java
jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java
jmeter/trunk/test/src/org/apache/jmeter/testelement/PackageTest.java
jmeter/trunk/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java
Added: jmeter/trunk/test/src/org/apache/jmeter/functions/CSVReadFunctionTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/functions/CSVReadFunctionTest.java?rev=1730601&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/functions/CSVReadFunctionTest.java (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/functions/CSVReadFunctionTest.java Mon Feb 15 19:54:40 2016
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.functions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.apache.jmeter.engine.util.CompoundVariable;
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+import org.junit.Test;
+
+public class CSVReadFunctionTest extends JMeterTestCase {
+
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ // Create the CSVRead function and set its parameters.
+ private static CSVRead setCSVReadParams(String p1, String p2) throws Exception {
+ CSVRead cr = new CSVRead();
+ Collection<CompoundVariable> parms = new LinkedList<>();
+ if (p1 != null) {
+ parms.add(new CompoundVariable(p1));
+ }
+ if (p2 != null) {
+ parms.add(new CompoundVariable(p2));
+ }
+ cr.setParameters(parms);
+ return cr;
+ }
+
+ @Test
+ public void testCSVParamsFail() 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) {
+ }
+ }
+
+ @Test
+ public void testCSVNoFile() throws Exception {
+ String s;
+
+ CSVRead cr1 = setCSVReadParams("xtestfiles/test.csv", "1");
+ log.info("Expecting file not found");
+ s = cr1.execute(null, null);
+ assertEquals("", s);
+
+ CSVRead cr2 = setCSVReadParams("xtestfiles/test.csv", "next");
+ log.info("Expecting no entry for file");
+ s = cr2.execute(null, null);
+ assertEquals("", s);
+
+ CSVRead cr3 = setCSVReadParams("xtestfiles/test.csv", "*ABC");
+ log.info("Expecting file not found");
+ s = cr3.execute(null, null);
+ assertEquals("", s);
+
+ CSVRead cr4 = setCSVReadParams("*ABC", "1");
+ log.info("Expecting cannot open file");
+ s = cr4.execute(null, null);
+ assertEquals("", s);
+ }
+
+ @Test
+ public void testCSValias() throws Exception {
+ CSVRead cr1 = setCSVReadParams("testfiles/test.csv", "*A");
+ CSVRead cr2 = setCSVReadParams("*A", "1");
+ CSVRead cr3 = setCSVReadParams("*A", "next");
+
+ CSVRead cr4 = setCSVReadParams("testfiles/test.csv", "*B");
+ CSVRead cr5 = setCSVReadParams("*B", "2");
+ CSVRead 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);
+ }
+
+ // Check blank lines are treated as EOF
+ @Test
+ 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);
+ }
+ }
+
+ @Test
+ public void CSVRun() throws Exception {
+ CSVRead cr1 = setCSVReadParams("testfiles/test.csv", "1");
+ CSVRead cr2 = setCSVReadParams("testfiles/test.csv", "2");
+ CSVRead cr3 = setCSVReadParams("testfiles/test.csv", "3");
+ CSVRead cr4 = setCSVReadParams("testfiles/test.csv", "next");
+ CSVRead cr5 = setCSVReadParams("", "0");
+ CSVRead cr6 = setCSVReadParams("", "next");
+
+ 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));
+
+ }
+}
Propchange: jmeter/trunk/test/src/org/apache/jmeter/functions/CSVReadFunctionTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java?rev=1730601&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java Mon Feb 15 19:54:40 2016
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.functions;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.jmeter.engine.util.CompoundVariable;
+import org.apache.jmeter.junit.JMeterTest;
+import org.apache.jmeter.junit.JMeterTestCaseJUnit3;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class ComponentReferenceFunctionTest extends JMeterTestCaseJUnit3 {
+
+ private static final Logger LOG = LoggingManager.getLoggerForClass();
+
+ private static Map<String, Boolean> funcTitles;
+
+ // Constructor for Function tests
+ private Function funcItem;
+
+ public ComponentReferenceFunctionTest(String name) {
+ super(name);
+ }
+
+ public ComponentReferenceFunctionTest(String testName, Function fi) {
+ super(testName);// Save the method name
+ funcItem = fi;
+ }
+
+ /*
+ * Test Functions - create the suite of tests
+ */
+ private static Test suiteFunctions() throws Exception {
+ TestSuite suite = new TestSuite("Functions");
+ Iterator<Object> iter = JMeterTest.getObjects(Function.class).iterator();
+ while (iter.hasNext()) {
+ Object item = iter.next();
+ if (item.getClass().equals(CompoundVariable.class)) {
+ continue;
+ }
+ TestSuite ts = new TestSuite(item.getClass().getName());
+ ts.addTest(new ComponentReferenceFunctionTest("runFunction", (Function) item));
+ ts.addTest(new ComponentReferenceFunctionTest("runFunction2", (Function) item));
+ suite.addTest(ts);
+ }
+ return suite;
+ }
+
+ /*
+ * Extract titles from functions.xml
+ */
+ public void createFunctionSet() throws Exception {
+ funcTitles = new HashMap<>(20);
+
+ String compref = "../xdocs/usermanual/functions.xml";
+ SAXBuilder bldr = new SAXBuilder();
+ Document doc = bldr.build(compref);
+ Element root = doc.getRootElement();
+ Element body = root.getChild("body");
+ Element section = body.getChild("section");
+ @SuppressWarnings("unchecked")
+ List<Element> sections = section.getChildren("subsection");
+ for (int i = 0; i < sections.size(); i++) {
+ @SuppressWarnings("unchecked")
+ List<Element> components = sections.get(i).getChildren("component");
+ for (int j = 0; j < components.size(); j++) {
+ Element comp = components.get(j);
+ funcTitles.put(comp.getAttributeValue("name"), Boolean.FALSE);
+ String tag = comp.getAttributeValue("tag");
+ if (tag != null){
+ funcTitles.put(tag, Boolean.FALSE);
+ }
+ }
+ }
+ }
+
+ public void checkFunctionSet() throws Exception {
+ assertEquals("Should not have any names left over", 0, JMeterTest.scanprintMap(funcTitles, "Function"));
+ }
+
+ /*
+ * run the function test
+ */
+ public void runFunction() throws Exception {
+ if (funcTitles.size() > 0) {
+ String title = funcItem.getReferenceKey();
+ boolean ct = funcTitles.containsKey(title);
+ if (ct) {
+ funcTitles.put(title, Boolean.TRUE);// For detecting extra entries
+ }
+ if (// Is this a work in progress ?
+ title.indexOf("(ALPHA") == -1 && title.indexOf("(EXPERIMENTAL") == -1) {// No, not a
+ // work in progress
+ // ...
+ String s = "function.xml needs '" + title + "' entry for " + funcItem.getClass().getName();
+ if (!ct) {
+ LOG.warn(s); // Record in log as well
+ }
+ assertTrue(s, ct);
+ }
+ }
+ }
+
+ /*
+ * Check that function descriptions are OK
+ */
+ public void runFunction2() throws Exception {
+ Iterator<?> i = funcItem.getArgumentDesc().iterator();
+ while (i.hasNext()) {
+ Object o = i.next();
+ assertTrue("Description must be a String", o instanceof String);
+ assertFalse("Description must not start with [refkey", ((String) o).startsWith("[refkey"));
+ }
+ }
+
+ /*
+ * Use a suite to allow the tests to be generated at run-time
+ */
+ public static Test suite() throws Exception {
+ TestSuite suite = new TestSuite("ComponentReferenceFunctionTest");
+ suite.addTest(new ComponentReferenceFunctionTest("createFunctionSet"));
+ suite.addTest(suiteFunctions());
+ suite.addTest(new ComponentReferenceFunctionTest("checkFunctionSet"));
+ return suite;
+ }
+}
Propchange: jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java?rev=1730601&r1=1730600&r2=1730601&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java Mon Feb 15 19:54:40 2016
@@ -16,14 +16,6 @@
*
*/
-/*
- * Package to test functions
- *
- * Functions are created and parameters set up in one thread.
- *
- * They are then tested in another thread, or two threads running in parallel
- *
- */
package org.apache.jmeter.functions;
import static org.apache.jmeter.functions.FunctionTestHelper.makeParams;
@@ -53,11 +45,6 @@ public class PackageTest extends JMeterT
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);
}
@@ -77,21 +64,6 @@ public class PackageTest extends JMeterT
}
- // 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<CompoundVariable> 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();
@@ -99,8 +71,6 @@ public class PackageTest extends JMeterT
return bsh;
}
-
-
public static Test suite() throws Exception {
TestSuite allsuites = new TestSuite("Function PackageTest");
@@ -113,27 +83,14 @@ public class PackageTest extends JMeterT
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"));
+ allsuites.addTest(new PackageTest("CSVSetup"));
TestSuite par = new ActiveTestSuite("Parallel");
par.addTest(new PackageTest("CSVThread1"));
par.addTest(new PackageTest("CSVThread2"));
allsuites.addTest(par);
- 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"));
@@ -244,117 +201,31 @@ public class PackageTest extends JMeterT
}
- public void splitTest1() throws Exception {
- String src = "";
-
- try {
- splitParams("a,b,c", null, null);
- fail("Expected InvalidVariableException (wrong number of parameters)");
- } catch (InvalidVariableException e) {
- // OK
- }
- src = "a,b,c";
- SplitFunction split;
- 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"));
- 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"));
- assertNull(vars.get("VAR_3"));
-
- src = "a,,c,";
- vars.put("VAR", src);
- split = splitParams("${VAR}", "VAR5", null);
- assertEquals(src, split.execute());
- assertEquals("4", vars.get("VAR5_n"));
- assertEquals("a", vars.get("VAR5_1"));
- assertEquals("?", vars.get("VAR5_2"));
- assertEquals("c", vars.get("VAR5_3"));
- assertEquals("?", vars.get("VAR5_4"));
- assertNull(vars.get("VAR5_5"));
- }
-
-
-
// Function objects to be tested
- private static CSVRead cr1, cr2, cr3, cr4, cr5, cr6;
+ private static CSVRead cr1, cr4;
// 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();
+ private static final Baton BATON = new Baton();
public void CSVThread1() throws Exception {
Thread.currentThread().setName("One");
- synchronized (baton) {
+ synchronized (BATON) {
assertEquals("b1", cr1.execute(null, null));
@@ -362,7 +233,7 @@ public class PackageTest extends JMeterT
assertEquals("b2", cr1.execute(null, null));
- baton.pass();
+ BATON.pass();
assertEquals("", cr4.execute(null, null));
@@ -370,26 +241,26 @@ public class PackageTest extends JMeterT
assertEquals("", cr4.execute(null, null));
- baton.pass();
+ BATON.pass();
assertEquals("b3", cr1.execute(null, null));
assertEquals("", cr4.execute(null, null));
- baton.done();
+ BATON.done();
}
}
public void CSVThread2() throws Exception {
Thread.currentThread().setName("Two");
Thread.sleep(500);// Allow other thread to start
- synchronized (baton) {
+ synchronized (BATON) {
assertEquals("b3", cr1.execute(null, null));
assertEquals("", cr4.execute(null, null));
- baton.pass();
+ BATON.pass();
assertEquals("b1", cr1.execute(null, null));
@@ -397,157 +268,22 @@ public class PackageTest extends JMeterT
assertEquals("b2", cr1.execute(null, null));
- baton.pass();
+ BATON.pass();
assertEquals("", cr4.execute(null, null));
assertEquals("b4", cr1.execute(null, null));
- baton.done();
+ 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
@@ -653,28 +389,28 @@ public class PackageTest extends JMeterT
public void XPathThread1() throws Exception {
Thread.currentThread().setName("XPathOne");
- synchronized (baton) {
+ synchronized (BATON) {
assertEquals("u1",sxp1.execute());
assertEquals("u2",sxp1.execute());
- baton.pass();
+ BATON.pass();
assertEquals("u5",sxp1.execute());
- baton.pass();
+ BATON.pass();
assertEquals("u2",sxp1.execute());
- baton.done();
+ BATON.done();
}
}
public void XPathThread2() throws Exception {
Thread.currentThread().setName("XPathTwo");
Thread.sleep(500);
- synchronized (baton) {
+ synchronized (BATON) {
assertEquals("u3",sxp2.execute());
assertEquals("u4",sxp2.execute());
- baton.pass();
+ BATON.pass();
assertEquals("u1",sxp2.execute());
- baton.pass();
+ BATON.pass();
assertEquals("u3",sxp2.execute());
- baton.done();
+ BATON.done();
}
}
Added: jmeter/trunk/test/src/org/apache/jmeter/functions/SplitFunctionTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/functions/SplitFunctionTest.java?rev=1730601&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/functions/SplitFunctionTest.java (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/functions/SplitFunctionTest.java Mon Feb 15 19:54:40 2016
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.functions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.apache.jmeter.engine.util.CompoundVariable;
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.threads.JMeterContext;
+import org.apache.jmeter.threads.JMeterContextService;
+import org.apache.jmeter.threads.JMeterVariables;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SplitFunctionTest extends JMeterTestCase {
+
+ private JMeterContext jmctx = null;
+ private JMeterVariables vars = null;
+
+ @Before
+ public void setUp() {
+ jmctx = JMeterContextService.getContext();
+ jmctx.setVariables(new JMeterVariables());
+ vars = jmctx.getVariables();
+ }
+
+ @Test
+ public void splitTest1() throws Exception {
+ String src = "";
+
+ try {
+ splitParams("a,b,c", null, null);
+ fail("Expected InvalidVariableException (wrong number of parameters)");
+ } catch (InvalidVariableException e) {
+ // OK
+ }
+ src = "a,b,c";
+ SplitFunction split;
+ 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"));
+ 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"));
+ assertNull(vars.get("VAR_3"));
+
+ src = "a,,c,";
+ vars.put("VAR", src);
+ split = splitParams("${VAR}", "VAR5", null);
+ assertEquals(src, split.execute());
+ assertEquals("4", vars.get("VAR5_n"));
+ assertEquals("a", vars.get("VAR5_1"));
+ assertEquals("?", vars.get("VAR5_2"));
+ assertEquals("c", vars.get("VAR5_3"));
+ assertEquals("?", vars.get("VAR5_4"));
+ assertNull(vars.get("VAR5_5"));
+ }
+
+ // 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<CompoundVariable> 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;
+ }
+
+}
Propchange: jmeter/trunk/test/src/org/apache/jmeter/functions/SplitFunctionTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java?rev=1730601&r1=1730600&r2=1730601&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java Mon Feb 15 19:54:40 2016
@@ -38,8 +38,6 @@ import java.util.Properties;
import java.util.Set;
import org.apache.jmeter.config.gui.ObsoleteGui;
-import org.apache.jmeter.engine.util.CompoundVariable;
-import org.apache.jmeter.functions.Function;
import org.apache.jmeter.gui.JMeterGUIComponent;
import org.apache.jmeter.gui.UnsharedComponent;
import org.apache.jmeter.gui.tree.JMeterTreeNode;
@@ -47,8 +45,6 @@ import org.apache.jmeter.save.SaveServic
import org.apache.jmeter.testbeans.TestBean;
import org.apache.jmeter.testbeans.gui.TestBeanGUI;
import org.apache.jmeter.testelement.TestElement;
-import org.apache.jmeter.testelement.property.JMeterProperty;
-import org.apache.jmeter.testelement.property.PropertyIterator;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.reflect.ClassFinder;
@@ -68,8 +64,6 @@ public class JMeterTest extends JMeterTe
private static Map<String, Boolean> guiTags;
- private static Map<String, Boolean> funcTitles;
-
private static Properties nameMap;
private static final Locale TEST_LOCALE = Locale.ENGLISH;
@@ -92,14 +86,7 @@ public class JMeterTest extends JMeterTe
* which was saved by the constructor.
*
*/
- // Constructor for TestElement tests
- private TestElement testItem;
-
- public JMeterTest(String testName, TestElement te) {
- super(testName);// Save the method name
- testItem = te;
- }
-
+
// Constructor for Serializable tests
private Serializable serObj;
@@ -116,16 +103,8 @@ public class JMeterTest extends JMeterTe
guiItem = gc;
}
- // Constructor for Function tests
- private Function funcItem;
-
private static volatile boolean classPathShown = false;// Only show classpath once
- public JMeterTest(String testName, Function fi) {
- super(testName);// Save the method name
- funcItem = fi;
- }
-
/*
* Use a suite to allow the tests to be generated at run-time
*/
@@ -147,12 +126,8 @@ public class JMeterTest extends JMeterTe
suite.addTest(new JMeterTest("createTagSet"));
suite.addTest(suiteGUIComponents());
suite.addTest(suiteSerializableElements());
- suite.addTest(suiteTestElements());
suite.addTest(suiteBeanComponents());
- suite.addTest(new JMeterTest("createFunctionSet"));
- suite.addTest(suiteFunctions());
suite.addTest(new JMeterTest("checkGuiSet"));
- suite.addTest(new JMeterTest("checkFunctionSet"));
suite.addTest(new JMeterTest("resetLocale")); // revert
return suite;
@@ -172,8 +147,7 @@ public class JMeterTest extends JMeterTe
String compref = "../xdocs/usermanual/component_reference.xml";
SAXBuilder bldr = new SAXBuilder();
- Document doc;
- doc = bldr.build(compref);
+ Document doc = bldr.build(compref);
Element root = doc.getRootElement();
Element body = root.getChild("body");
@SuppressWarnings("unchecked")
@@ -189,7 +163,6 @@ public class JMeterTest extends JMeterTe
}
}
// Add titles that don't need to be documented
- //guiTitles.put("Root", Boolean.FALSE);
guiTitles.put("Example Sampler", Boolean.FALSE);
}
@@ -201,8 +174,7 @@ public class JMeterTest extends JMeterTe
String compref = "../xdocs/usermanual/component_reference.xml";
SAXBuilder bldr = new SAXBuilder();
- Document doc;
- doc = bldr.build(compref);
+ Document doc = bldr.build(compref);
Element root = doc.getRootElement();
Element body = root.getChild("body");
@SuppressWarnings("unchecked")
@@ -216,40 +188,14 @@ public class JMeterTest extends JMeterTe
}
}
- /*
- * Extract titles from functions.xml
- */
- public void createFunctionSet() throws Exception {
- funcTitles = new HashMap<>(20);
-
- String compref = "../xdocs/usermanual/functions.xml";
- SAXBuilder bldr = new SAXBuilder();
- Document doc;
- doc = bldr.build(compref);
- Element root = doc.getRootElement();
- Element body = root.getChild("body");
- Element section = body.getChild("section");
- @SuppressWarnings("unchecked")
- List<Element> subSections = section.getChildren("subsection");
- for (Element subSection : subSections) {
- @SuppressWarnings("unchecked")
- List<Element> components = subSection.getChildren("component");
- for (Element comp : components) {
- funcTitles.put(comp.getAttributeValue("name"), Boolean.FALSE);
- String tag = comp.getAttributeValue("tag");
- if (tag != null) {
- funcTitles.put(tag, Boolean.FALSE);
- }
- }
- }
- }
- private int scanprintMap(Map<String, Boolean> m, String t) {
+ public static int scanprintMap(Map<String, Boolean> m, String t) {
Set<String> s = m.keySet();
- int unseen = 0;
- if (s.size() == 0) {
+ if (s.isEmpty()) {
return 0;
}
+
+ int unseen = 0;
for (String key : s) {
if (!m.get(key).equals(Boolean.TRUE)) {
if (unseen == 0)// first time
@@ -269,9 +215,7 @@ public class JMeterTest extends JMeterTe
assertEquals("Should not have any names left over, check name of components in EN (default) Locale, which must match name attribute of component", 0, scanprintMap(guiTitles, "GUI"));
}
- public void checkFunctionSet() throws Exception {
- assertEquals("Should not have any names left over", 0, scanprintMap(funcTitles, "Function"));
- }
+
/*
* Test GUI elements - create the suite of tests
@@ -300,22 +244,6 @@ public class JMeterTest extends JMeterTe
return suite;
}
- /*
- * Test Functions - create the suite of tests
- */
- private static Test suiteFunctions() throws Exception {
- TestSuite suite = new TestSuite("Functions");
- for (Object item : getObjects(Function.class)) {
- if (item.getClass().equals(CompoundVariable.class)) {
- continue;
- }
- TestSuite ts = new TestSuite(item.getClass().getName());
- ts.addTest(new JMeterTest("runFunction", (Function) item));
- ts.addTest(new JMeterTest("runFunction2", (Function) item));
- suite.addTest(ts);
- }
- return suite;
- }
/*
* Test GUI elements - create the suite of tests
@@ -326,7 +254,6 @@ public class JMeterTest extends JMeterTe
Class<? extends Object> c = o.getClass();
try {
JMeterGUIComponent item = new TestBeanGUI(c);
- // JMeterGUIComponent item = (JMeterGUIComponent) iter.next();
TestSuite ts = new TestSuite(item.getClass().getName());
ts.addTest(new JMeterTest("GUIComponents2", item));
ts.addTest(new JMeterTest("runGUITitle", item));
@@ -366,44 +293,7 @@ public class JMeterTest extends JMeterTe
}
}
- /*
- * run the function test
- */
- public void runFunction() throws Exception {
- if (funcTitles.size() > 0) {
- String title = funcItem.getReferenceKey();
- boolean ct = funcTitles.containsKey(title);
- if (ct) {
- funcTitles.put(title, Boolean.TRUE);// For detecting extra entries
- }
- if (// Is this a work in progress ?
- title.indexOf("(ALPHA") == -1 && title.indexOf("(EXPERIMENTAL") == -1) {// No,
- // not
- // a
- // work
- // in
- // progress
- // ...
- String s = "function.xml needs '" + title + "' entry for " + funcItem.getClass().getName();
- if (!ct) {
- log.warn(s); // Record in log as well
- }
- assertTrue(s, ct);
- }
- }
- }
-
- /*
- * Check that function descriptions are OK
- */
- public void runFunction2() throws Exception {
- for (Object o : funcItem.getArgumentDesc()) {
- assertTrue("Description must be a String", o instanceof String);
- assertFalse("Description must not start with [refkey", ((String) o).startsWith("[refkey"));
- }
- }
-
/*
* Test GUI elements - run for all components
*/
@@ -501,39 +391,9 @@ public class JMeterTest extends JMeterTe
}
}
- /*
- * Test TestElements - create the suite
- */
- private static Test suiteTestElements() throws Exception {
- TestSuite suite = new TestSuite("TestElements");
- for (Object o : getObjects(TestElement.class)) {
- TestElement item = (TestElement) o;
- TestSuite ts = new TestSuite(item.getClass().getName());
- ts.addTest(new JMeterTest("runTestElement", item));
- suite.addTest(ts);
- }
- return suite;
- }
-
- /*
- * Test TestElements - implement the test case
- */
- public void runTestElement() throws Exception {
- checkElementCloning(testItem);
- String name = testItem.getClass().getName();
- assertTrue(name + " must implement Serializable", testItem instanceof Serializable);
- if (name.startsWith("org.apache.jmeter.examples.")){
- return;
- }
- if (name.equals("org.apache.jmeter.control.TransactionSampler")){
- return; // Not a real sampler
- }
-
- checkElementAlias(testItem);
- }
public void readAliases() throws Exception {
- nameMap = SaveService.loadProperties();
+ nameMap = SaveService.loadProperties();
assertNotNull("SaveService nameMap (saveservice.properties) should not be null",nameMap);
}
@@ -541,12 +401,11 @@ public class JMeterTest extends JMeterTe
String name=item.getClass().getName();
boolean contains = nameMap.values().contains(name);
if (!contains){
- //System.out.println(name.substring(name.lastIndexOf('.')+1)+"="+name);
fail("SaveService nameMap (saveservice.properties) should contain "+name);
}
}
- private static Collection<Object> getObjects(Class<?> extendsClass) throws Exception {
+ public static Collection<Object> getObjects(Class<?> extendsClass) throws Exception {
String exName = extendsClass.getName();
Object myThis = "";
Iterator<String> classes = ClassFinder
@@ -570,7 +429,6 @@ public class JMeterTest extends JMeterTe
objects.add(c.newInstance());
} catch (InstantiationException e) {
caught = e;
- // System.out.println(e.toString());
try {
// Events often have this constructor
objects.add(c.getConstructor(new Class[] { Object.class }).newInstance(
@@ -608,7 +466,7 @@ public class JMeterTest extends JMeterTe
}
}
- if (objects.size() == 0) {
+ if (objects.isEmpty()) {
System.out.println("No classes found that extend " + exName + ". Check the following:");
System.out.println("Search paths are:");
String ss[] = JMeterUtils.getSearchPaths();
@@ -627,21 +485,5 @@ public class JMeterTest extends JMeterTe
}
return objects;
}
-
- private static void cloneTesting(TestElement item, TestElement clonedItem) {
- assertTrue(item != clonedItem);
- assertEquals("CLONE-SAME-CLASS: testing " + item.getClass().getName(), item.getClass().getName(), clonedItem
- .getClass().getName());
- }
-
- private static void checkElementCloning(TestElement item) {
- TestElement clonedItem = (TestElement) item.clone();
- cloneTesting(item, clonedItem);
- PropertyIterator iter2 = item.propertyIterator();
- while (iter2.hasNext()) {
- JMeterProperty item2 = iter2.next();
- assertEquals(item2.getStringValue(), clonedItem.getProperty(item2.getName()).getStringValue());
- assertTrue(item2 != clonedItem.getProperty(item2.getName()));
- }
- }
+
}
Modified: jmeter/trunk/test/src/org/apache/jmeter/report/core/TestCsvSampleWriter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/report/core/TestCsvSampleWriter.java?rev=1730601&r1=1730600&r2=1730601&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/report/core/TestCsvSampleWriter.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/report/core/TestCsvSampleWriter.java Mon Feb 15 19:54:40 2016
@@ -36,16 +36,11 @@ public class TestCsvSampleWriter {
SampleMetadata metadata = new SampleMetadata(',', "a", "b");
- @Test
+ @Test(expected=NullPointerException.class)
public void testCsvSampleWriterConstructorWithNull() throws Exception {
- try {
- CsvSampleWriter dummy = new CsvSampleWriter(null);
- dummy.close(); // We should never get here, but it would be a
- // writer, so close it
- fail("NPE expected");
- } catch (NullPointerException e) {
- // OK, we should land here
- }
+ CsvSampleWriter dummy = new CsvSampleWriter(null);
+ dummy.close(); // We should never get here, but it would be a
+ // writer, so close it
}
@Test
Modified: jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java?rev=1730601&r1=1730600&r2=1730601&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java Mon Feb 15 19:54:40 2016
@@ -163,11 +163,11 @@ public final class PackageTest extends J
public static Test suite() throws Exception {
TestSuite suite = new TestSuite("Bean Resource Test Suite");
- List<String> testBaeanclassNames = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { TestBean.class });
+ List<String> testBeanClassNames = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { TestBean.class });
boolean errorDetected = false;
JMeterUtils.setLocale(defaultLocale);
- for (String className : testBaeanclassNames) {
+ for (String className : testBeanClassNames) {
Class<?> testBeanClass = Class.forName(className);
ResourceBundle defaultBundle = null;
try {
Modified: jmeter/trunk/test/src/org/apache/jmeter/testelement/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/testelement/PackageTest.java?rev=1730601&r1=1730600&r2=1730601&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/testelement/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/testelement/PackageTest.java Mon Feb 15 19:54:40 2016
@@ -16,10 +16,6 @@
*
*/
-/*
- * Created on Jul 16, 2003
- *
- */
package org.apache.jmeter.testelement;
import static org.junit.Assert.assertEquals;
@@ -36,12 +32,15 @@ import org.apache.jmeter.testelement.pro
import org.apache.jmeter.testelement.property.NullProperty;
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.testelement.property.TestElementProperty;
+import org.junit.Ignore;
import org.junit.Test;
public class PackageTest {
- // Test needs to run in this package in order to give access to AbstractTestElement.addProperty()
- public void DISABLEDtestBug50799() throws Exception {
+ // Test needs to run in this package in order to give access to AbstractTestElement.addProperty()
+ @Ignore
+ @Test
+ public void testBug50799() throws Exception {
HeaderManager headerManager = new HeaderManager();
headerManager.add(new Header("1stLevelTestHeader", "testValue1"));
HeaderManager headerManager2 = new HeaderManager();
Added: jmeter/trunk/test/src/org/apache/jmeter/testelement/TestElementTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/testelement/TestElementTest.java?rev=1730601&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/testelement/TestElementTest.java (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/testelement/TestElementTest.java Mon Feb 15 19:54:40 2016
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.testelement;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.jmeter.junit.JMeterTest;
+import org.apache.jmeter.junit.JMeterTestCaseJUnit3;
+import org.apache.jmeter.save.SaveService;
+import org.apache.jmeter.testelement.property.JMeterProperty;
+import org.apache.jmeter.testelement.property.PropertyIterator;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class TestElementTest extends JMeterTestCaseJUnit3 {
+
+ private TestElement testItem;
+
+ public TestElementTest(String testName, TestElement te) {
+ super(testName);// Save the method name
+ testItem = te;
+ }
+
+ /*
+ * Test TestElements - create the suite
+ */
+ public static Test suite() throws Exception {
+ TestSuite suite = new TestSuite("TestElements");
+ Iterator<Object> iter = JMeterTest.getObjects(TestElement.class).iterator();
+ while (iter.hasNext()) {
+ TestElement item = (TestElement) iter.next();
+ TestSuite ts = new TestSuite(item.getClass().getName());
+ ts.addTest(new TestElementTest("runTestElement", item));
+ suite.addTest(ts);
+ }
+ return suite;
+ }
+
+ /*
+ * Test TestElements - implement the test case
+ */
+ public void runTestElement() throws Exception {
+ checkElementCloning(testItem);
+ String name = testItem.getClass().getName();
+ assertTrue(name + " must implement Serializable", testItem instanceof Serializable);
+ if (name.startsWith("org.apache.jmeter.examples.")){
+ return;
+ }
+ if (name.equals("org.apache.jmeter.control.TransactionSampler")){
+ return; // Not a real sampler
+ }
+
+ checkElementAlias(testItem);
+ }
+
+ private static void checkElementCloning(TestElement item) {
+ TestElement clonedItem = (TestElement) item.clone();
+ cloneTesting(item, clonedItem);
+ PropertyIterator iter2 = item.propertyIterator();
+ while (iter2.hasNext()) {
+ JMeterProperty item2 = iter2.next();
+ assertEquals(item2.getStringValue(), clonedItem.getProperty(item2.getName()).getStringValue());
+ assertTrue(item2 != clonedItem.getProperty(item2.getName()));
+ }
+ }
+
+ private static void cloneTesting(TestElement item, TestElement clonedItem) {
+ assertTrue(item != clonedItem);
+ assertEquals("CLONE-SAME-CLASS: testing " + item.getClass().getName(), item.getClass().getName(), clonedItem
+ .getClass().getName());
+ }
+
+ private void checkElementAlias(Object item) throws IOException {
+ //FIXME do it only once
+ Properties nameMap = SaveService.loadProperties();
+ assertNotNull("SaveService nameMap (saveservice.properties) should not be null",nameMap);
+
+ String name = item.getClass().getName();
+ boolean contains = nameMap.values().contains(name);
+ if (!contains){
+ fail("SaveService nameMap (saveservice.properties) should contain "+name);
+ }
+ }
+}
Propchange: jmeter/trunk/test/src/org/apache/jmeter/testelement/TestElementTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jmeter/trunk/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java?rev=1730601&r1=1730600&r2=1730601&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java Mon Feb 15 19:54:40 2016
@@ -47,9 +47,7 @@ public class TestKeyToolUtils {
if (status == 0 || status ==1) {
fail("Unexpected status " + status);
}
-// System.out.println("testCheckKeytool:status="+status);
} catch (IOException expected) {
-// System.out.println("testCheckKeytool:Exception="+e);
}
}
}