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 [3/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/junit/JMeterTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java Sun May 10 18:19:28 2009
@@ -62,470 +62,470 @@
import org.jdom.input.SAXBuilder;
public class JMeterTest extends JMeterTestCase {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggingManager.getLoggerForClass();
- private static Map guiTitles;
+ private static Map guiTitles;
- private static Map guiTags;
+ private static Map guiTags;
- private static Map funcTitles;
+ private static Map funcTitles;
private static Properties nameMap;
private static final Locale TEST_LOCALE = Locale.ENGLISH;
- public JMeterTest(String name) {
- super(name);
- }
-
- /*
- * The suite() method creates separate test suites for each of the types of
- * test. The suitexxx() methods create a list of items to be tested, and
- * create a new test instance for each.
- *
- * Each test type has its own constructor, which saves the item to be tested
- *
- * Note that the suite() method must be static, and the methods to run the
- * tests must be instance methods so that they can pick up the item value
- * 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;
-
- public JMeterTest(String testName, Serializable ser) {
- super(testName);// Save the method name
- serObj = ser;
- }
-
- // Constructor for GUI tests
- private JMeterGUIComponent guiItem;
-
- public JMeterTest(String testName, JMeterGUIComponent gc) {
- super(testName);// Save the method name
- 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
- */
- public static Test suite() throws Exception {
+ public JMeterTest(String name) {
+ super(name);
+ }
+
+ /*
+ * The suite() method creates separate test suites for each of the types of
+ * test. The suitexxx() methods create a list of items to be tested, and
+ * create a new test instance for each.
+ *
+ * Each test type has its own constructor, which saves the item to be tested
+ *
+ * Note that the suite() method must be static, and the methods to run the
+ * tests must be instance methods so that they can pick up the item value
+ * 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;
+
+ public JMeterTest(String testName, Serializable ser) {
+ super(testName);// Save the method name
+ serObj = ser;
+ }
+
+ // Constructor for GUI tests
+ private JMeterGUIComponent guiItem;
+
+ public JMeterTest(String testName, JMeterGUIComponent gc) {
+ super(testName);// Save the method name
+ 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
+ */
+ public static Test suite() throws Exception {
// The Locale used to instantiate the GUI objects
JMeterUtils.setLocale(TEST_LOCALE);
- TestSuite suite = new TestSuite("JMeterTest");
+ TestSuite suite = new TestSuite("JMeterTest");
suite.addTest(new JMeterTest("readAliases"));
- suite.addTest(new JMeterTest("createTitleSet"));
- 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"));
- return suite;
- }
-
- /*
- * Extract titles from component_reference.xml
- */
- public void createTitleSet() throws Exception {
- guiTitles = new HashMap(90);
-
- String compref = "../xdocs/usermanual/component_reference.xml";
- SAXBuilder bldr = new SAXBuilder();
- Document doc;
- doc = bldr.build(compref);
- Element root = doc.getRootElement();
- Element body = root.getChild("body");
- List sections = body.getChildren("section");
- for (int i = 0; i < sections.size(); i++) {
- List components = ((Element) sections.get(i)).getChildren("component");
- for (int j = 0; j < components.size(); j++) {
- Element comp = (Element) components.get(j);
+ suite.addTest(new JMeterTest("createTitleSet"));
+ 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"));
+ return suite;
+ }
+
+ /*
+ * Extract titles from component_reference.xml
+ */
+ public void createTitleSet() throws Exception {
+ guiTitles = new HashMap(90);
+
+ String compref = "../xdocs/usermanual/component_reference.xml";
+ SAXBuilder bldr = new SAXBuilder();
+ Document doc;
+ doc = bldr.build(compref);
+ Element root = doc.getRootElement();
+ Element body = root.getChild("body");
+ List sections = body.getChildren("section");
+ for (int i = 0; i < sections.size(); i++) {
+ List components = ((Element) sections.get(i)).getChildren("component");
+ for (int j = 0; j < components.size(); j++) {
+ Element comp = (Element) components.get(j);
String nm=comp.getAttributeValue("name");
if (!nm.equals("SSL Manager")){// Not a true GUI component
- guiTitles.put(nm.replace(' ','_'), Boolean.FALSE);
+ guiTitles.put(nm.replace(' ','_'), Boolean.FALSE);
}
- }
- }
- // Add titles that don't need to be documented
- //guiTitles.put("Root", Boolean.FALSE);
- guiTitles.put("Example Sampler", Boolean.FALSE);
- }
-
- /*
- * Extract titles from component_reference.xml
- */
- public void createTagSet() throws Exception {
- guiTags = new HashMap(90);
-
- String compref = "../xdocs/usermanual/component_reference.xml";
- SAXBuilder bldr = new SAXBuilder();
- Document doc;
- doc = bldr.build(compref);
- Element root = doc.getRootElement();
- Element body = root.getChild("body");
- List sections = body.getChildren("section");
- for (int i = 0; i < sections.size(); i++) {
- List components = ((Element) sections.get(i)).getChildren("component");
- for (int j = 0; j < components.size(); j++) {
- Element comp = (Element) components.get(j);
- guiTags.put(comp.getAttributeValue("tag"), Boolean.FALSE);
- }
- }
- }
-
- /*
- * 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");
- List sections = section.getChildren("subsection");
- for (int i = 0; i < sections.size(); i++) {
- List components = ((Element) sections.get(i)).getChildren("component");
- for (int j = 0; j < components.size(); j++) {
- Element comp = (Element) components.get(j);
- funcTitles.put(comp.getAttributeValue("name"), Boolean.FALSE);
- }
- }
- }
-
- private int scanprintMap(Map m, String t) {
- Set s = m.keySet();
- int unseen = 0;
- if (s.size() == 0) {
- return 0;
- }
- Iterator i = s.iterator();
- while (i.hasNext()) {
- Object key = i.next();
- if (!m.get(key).equals(Boolean.TRUE)) {
- if (unseen == 0)// first time
- {
- System.out.println("\nNames remaining in " + t + " Map:");
- }
- unseen++;
- System.out.println(key);
- }
- }
- return unseen;
- }
-
- public void checkGuiSet() throws Exception {
- guiTitles.remove("Example Sampler");// We don't mind if this is left over
- guiTitles.remove("Sample_Result_Save_Configuration");// Ditto, not a sampler
- assertEquals("Should not have any names left over", 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
- */
- private static Test suiteGUIComponents() throws Exception {
- TestSuite suite = new TestSuite("GuiComponents");
- Iterator iter = getObjects(JMeterGUIComponent.class).iterator();
- while (iter.hasNext()) {
- JMeterGUIComponent item = (JMeterGUIComponent) iter.next();
- if (item instanceof JMeterTreeNode) {
- System.out.println("INFO: JMeterGUIComponent: skipping all tests " + item.getClass().getName());
- continue;
- }
- if (item instanceof ObsoleteGui){
- continue;
- }
- TestSuite ts = new TestSuite(item.getClass().getName());
- ts.addTest(new JMeterTest("GUIComponents1", item));
- if (item instanceof TestBeanGUI) {
- System.out.println("INFO: JMeterGUIComponent: skipping some tests " + item.getClass().getName());
- } else {
- ts.addTest(new JMeterTest("GUIComponents2", item));
- ts.addTest(new JMeterTest("runGUITitle", item));
- }
- suite.addTest(ts);
- }
- return suite;
- }
-
- /*
- * Test Functions - create the suite of tests
- */
- private static Test suiteFunctions() throws Exception {
- TestSuite suite = new TestSuite("Functions");
- Iterator iter = 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 JMeterTest("runFunction", (Function) item));
- ts.addTest(new JMeterTest("runFunction2", (Function) item));
- suite.addTest(ts);
- }
- return suite;
- }
-
- /*
- * Test GUI elements - create the suite of tests
- */
- private static Test suiteBeanComponents() throws Exception {
- TestSuite suite = new TestSuite("BeanComponents");
- Iterator iter = getObjects(TestBean.class).iterator();
- while (iter.hasNext()) {
- Class c = iter.next().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));
- suite.addTest(ts);
- } catch (IllegalArgumentException e) {
- System.out.println("Cannot create test for " + c.getName() + " " + e);
- e.printStackTrace(System.out);
- }
- }
- return suite;
- }
-
- /*
- * Test GUI elements - run the test
- */
- public void runGUITitle() throws Exception {
- if (guiTitles.size() > 0) {
- String title = guiItem.getDocAnchor();
- boolean ct = guiTitles.containsKey(title);
- if (ct) {
- guiTitles.put(title, Boolean.TRUE);// So we can detect extra entries
+ }
+ }
+ // Add titles that don't need to be documented
+ //guiTitles.put("Root", Boolean.FALSE);
+ guiTitles.put("Example Sampler", Boolean.FALSE);
+ }
+
+ /*
+ * Extract titles from component_reference.xml
+ */
+ public void createTagSet() throws Exception {
+ guiTags = new HashMap(90);
+
+ String compref = "../xdocs/usermanual/component_reference.xml";
+ SAXBuilder bldr = new SAXBuilder();
+ Document doc;
+ doc = bldr.build(compref);
+ Element root = doc.getRootElement();
+ Element body = root.getChild("body");
+ List sections = body.getChildren("section");
+ for (int i = 0; i < sections.size(); i++) {
+ List components = ((Element) sections.get(i)).getChildren("component");
+ for (int j = 0; j < components.size(); j++) {
+ Element comp = (Element) components.get(j);
+ guiTags.put(comp.getAttributeValue("tag"), Boolean.FALSE);
+ }
+ }
+ }
+
+ /*
+ * 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");
+ List sections = section.getChildren("subsection");
+ for (int i = 0; i < sections.size(); i++) {
+ List components = ((Element) sections.get(i)).getChildren("component");
+ for (int j = 0; j < components.size(); j++) {
+ Element comp = (Element) components.get(j);
+ funcTitles.put(comp.getAttributeValue("name"), Boolean.FALSE);
+ }
+ }
+ }
+
+ private int scanprintMap(Map m, String t) {
+ Set s = m.keySet();
+ int unseen = 0;
+ if (s.size() == 0) {
+ return 0;
+ }
+ Iterator i = s.iterator();
+ while (i.hasNext()) {
+ Object key = i.next();
+ if (!m.get(key).equals(Boolean.TRUE)) {
+ if (unseen == 0)// first time
+ {
+ System.out.println("\nNames remaining in " + t + " Map:");
+ }
+ unseen++;
+ System.out.println(key);
+ }
+ }
+ return unseen;
+ }
+
+ public void checkGuiSet() throws Exception {
+ guiTitles.remove("Example Sampler");// We don't mind if this is left over
+ guiTitles.remove("Sample_Result_Save_Configuration");// Ditto, not a sampler
+ assertEquals("Should not have any names left over", 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
+ */
+ private static Test suiteGUIComponents() throws Exception {
+ TestSuite suite = new TestSuite("GuiComponents");
+ Iterator iter = getObjects(JMeterGUIComponent.class).iterator();
+ while (iter.hasNext()) {
+ JMeterGUIComponent item = (JMeterGUIComponent) iter.next();
+ if (item instanceof JMeterTreeNode) {
+ System.out.println("INFO: JMeterGUIComponent: skipping all tests " + item.getClass().getName());
+ continue;
+ }
+ if (item instanceof ObsoleteGui){
+ continue;
+ }
+ TestSuite ts = new TestSuite(item.getClass().getName());
+ ts.addTest(new JMeterTest("GUIComponents1", item));
+ if (item instanceof TestBeanGUI) {
+ System.out.println("INFO: JMeterGUIComponent: skipping some tests " + item.getClass().getName());
+ } else {
+ ts.addTest(new JMeterTest("GUIComponents2", item));
+ ts.addTest(new JMeterTest("runGUITitle", item));
+ }
+ suite.addTest(ts);
+ }
+ return suite;
+ }
+
+ /*
+ * Test Functions - create the suite of tests
+ */
+ private static Test suiteFunctions() throws Exception {
+ TestSuite suite = new TestSuite("Functions");
+ Iterator iter = 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 JMeterTest("runFunction", (Function) item));
+ ts.addTest(new JMeterTest("runFunction2", (Function) item));
+ suite.addTest(ts);
+ }
+ return suite;
+ }
+
+ /*
+ * Test GUI elements - create the suite of tests
+ */
+ private static Test suiteBeanComponents() throws Exception {
+ TestSuite suite = new TestSuite("BeanComponents");
+ Iterator iter = getObjects(TestBean.class).iterator();
+ while (iter.hasNext()) {
+ Class c = iter.next().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));
+ suite.addTest(ts);
+ } catch (IllegalArgumentException e) {
+ System.out.println("Cannot create test for " + c.getName() + " " + e);
+ e.printStackTrace(System.out);
+ }
+ }
+ return suite;
+ }
+
+ /*
+ * Test GUI elements - run the test
+ */
+ public void runGUITitle() throws Exception {
+ if (guiTitles.size() > 0) {
+ String title = guiItem.getDocAnchor();
+ boolean ct = guiTitles.containsKey(title);
+ if (ct) {
+ guiTitles.put(title, Boolean.TRUE);// So we can detect extra entries
}
String name = guiItem.getClass().getName();
- if (// Is this a work in progress or an internal GUI component?
- (title != null && title.length() > 0) // Will be "" for internal components
- && (title.toUpperCase(java.util.Locale.ENGLISH).indexOf("(ALPHA") == -1)
+ if (// Is this a work in progress or an internal GUI component?
+ (title != null && title.length() > 0) // Will be "" for internal components
+ && (title.toUpperCase(java.util.Locale.ENGLISH).indexOf("(ALPHA") == -1)
&& (title.toUpperCase(java.util.Locale.ENGLISH).indexOf("(BETA") == -1)
- && (!title.equals("Example1")) // Skip the example samplers ...
- && (!title.equals("Example2"))
+ && (!title.equals("Example1")) // Skip the example samplers ...
+ && (!title.equals("Example2"))
&& (!name.startsWith("org.apache.jmeter.examples."))
)
{// No, not a work in progress ...
String s = "component_reference.xml needs '" + title + "' anchor for " + name;
- if (!ct) {
- log.warn(s); // Record in log as well
+ if (!ct) {
+ log.warn(s); // Record in log as well
+ }
+ assertTrue(s, ct);
+ }
+ }
+ }
+
+ /*
+ * 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);
- }
- }
- }
-
- /*
- * 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"));
- }
- }
-
- /*
- * Test GUI elements - run for all components
- */
- public void GUIComponents1() throws Exception {
+ 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"));
+ }
+ }
+
+ /*
+ * Test GUI elements - run for all components
+ */
+ public void GUIComponents1() throws Exception {
// We must set the Locale to the same value that was used when the
// GUI objects was instantiated in this class
JMeterUtils.setLocale(TEST_LOCALE);
- String name = guiItem.getClass().getName();
+ String name = guiItem.getClass().getName();
- assertEquals("Name should be same as static label for " + name, guiItem.getStaticLabel(), guiItem.getName());
+ assertEquals("Name should be same as static label for " + name, guiItem.getStaticLabel(), guiItem.getName());
if (name.startsWith("org.apache.jmeter.examples.")){
return;
}
- if (!name.endsWith("TestBeanGUI")) {
- try {
- String label = guiItem.getLabelResource();
- assertTrue(label.length() > 0);
- assertFalse("'" + label + "' should be in resource file for " + name, JMeterUtils.getResString(
- label).startsWith(JMeterUtils.RES_KEY_PFX));
- } catch (UnsupportedOperationException uoe) {
- log.warn("Class has not yet implemented getLabelResource " + name);
- }
- }
+ if (!name.endsWith("TestBeanGUI")) {
+ try {
+ String label = guiItem.getLabelResource();
+ assertTrue(label.length() > 0);
+ assertFalse("'" + label + "' should be in resource file for " + name, JMeterUtils.getResString(
+ label).startsWith(JMeterUtils.RES_KEY_PFX));
+ } catch (UnsupportedOperationException uoe) {
+ log.warn("Class has not yet implemented getLabelResource " + name);
+ }
+ }
checkElementAlias(guiItem);
- }
+ }
- /*
- * Test GUI elements - not run for TestBeanGui items
- */
- public void GUIComponents2() throws Exception {
- String name = guiItem.getClass().getName();
-
- // TODO these assertions should be separate tests
-
- TestElement el = guiItem.createTestElement();
- assertNotNull(name + ".createTestElement should be non-null ", el);
- assertEquals("GUI-CLASS: Failed on " + name, name, el.getPropertyAsString(TestElement.GUI_CLASS));
-
- assertEquals("NAME: Failed on " + name, guiItem.getName(), el.getName());
- assertEquals("TEST-CLASS: Failed on " + name, el.getClass().getName(), el
- .getPropertyAsString(TestElement.TEST_CLASS));
- TestElement el2 = guiItem.createTestElement();
- el.setName("hey, new name!:");
- el.setProperty("NOT", "Shouldn't be here");
- if (!(guiItem instanceof UnsharedComponent)) {
- assertEquals("SHARED: Failed on " + name, "", el2.getPropertyAsString("NOT"));
- }
- log.debug("Saving element: " + el.getClass());
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- SaveService.saveElement(el, bos);
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- bos.close();
- el = (TestElement) SaveService.loadElement(bis);
- bis.close();
+ /*
+ * Test GUI elements - not run for TestBeanGui items
+ */
+ public void GUIComponents2() throws Exception {
+ String name = guiItem.getClass().getName();
+
+ // TODO these assertions should be separate tests
+
+ TestElement el = guiItem.createTestElement();
+ assertNotNull(name + ".createTestElement should be non-null ", el);
+ assertEquals("GUI-CLASS: Failed on " + name, name, el.getPropertyAsString(TestElement.GUI_CLASS));
+
+ assertEquals("NAME: Failed on " + name, guiItem.getName(), el.getName());
+ assertEquals("TEST-CLASS: Failed on " + name, el.getClass().getName(), el
+ .getPropertyAsString(TestElement.TEST_CLASS));
+ TestElement el2 = guiItem.createTestElement();
+ el.setName("hey, new name!:");
+ el.setProperty("NOT", "Shouldn't be here");
+ if (!(guiItem instanceof UnsharedComponent)) {
+ assertEquals("SHARED: Failed on " + name, "", el2.getPropertyAsString("NOT"));
+ }
+ log.debug("Saving element: " + el.getClass());
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ SaveService.saveElement(el, bos);
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ bos.close();
+ el = (TestElement) SaveService.loadElement(bis);
+ bis.close();
assertNotNull("Load element failed on: "+name,el);
- guiItem.configure(el);
- assertEquals("CONFIGURE-TEST: Failed on " + name, el.getName(), guiItem.getName());
- guiItem.modifyTestElement(el2);
- assertEquals("Modify Test: Failed on " + name, "hey, new name!:", el2.getName());
- }
-
- /*
- * Test serializable elements - create the suite of tests
- */
- private static Test suiteSerializableElements() throws Exception {
- TestSuite suite = new TestSuite("SerializableElements");
- Iterator iter = getObjects(Serializable.class).iterator();
- while (iter.hasNext()) {
- Serializable serObj = (Serializable) iter.next();
- if (serObj.getClass().getName().endsWith("_Stub")) {
- continue;
- }
- TestSuite ts = new TestSuite(serObj.getClass().getName());
- ts.addTest(new JMeterTest("runSerialTest", serObj));
- suite.addTest(ts);
- }
- return suite;
- }
-
- /*
- * Test serializable elements - test the object
- */
- public void runSerialTest() throws Exception {
- if (!(serObj instanceof JComponent)) {
- try {
- ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(bytes);
- out.writeObject(serObj);
- out.close();
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()));
- Object readObject = in.readObject();
- in.close();
- assertEquals("deserializing class: " + serObj.getClass().getName(), serObj.getClass(), readObject
- .getClass());
- } catch (Throwable e) {
- fail("serialization of " + serObj.getClass().getName() + " failed: " + e);
- }
- }
- }
-
- /*
- * Test TestElements - create the suite
- */
- private static Test suiteTestElements() throws Exception {
- TestSuite suite = new TestSuite("TestElements");
- Iterator iter = getObjects(TestElement.class).iterator();
- while (iter.hasNext()) {
- TestElement item = (TestElement) iter.next();
- 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();
+ guiItem.configure(el);
+ assertEquals("CONFIGURE-TEST: Failed on " + name, el.getName(), guiItem.getName());
+ guiItem.modifyTestElement(el2);
+ assertEquals("Modify Test: Failed on " + name, "hey, new name!:", el2.getName());
+ }
+
+ /*
+ * Test serializable elements - create the suite of tests
+ */
+ private static Test suiteSerializableElements() throws Exception {
+ TestSuite suite = new TestSuite("SerializableElements");
+ Iterator iter = getObjects(Serializable.class).iterator();
+ while (iter.hasNext()) {
+ Serializable serObj = (Serializable) iter.next();
+ if (serObj.getClass().getName().endsWith("_Stub")) {
+ continue;
+ }
+ TestSuite ts = new TestSuite(serObj.getClass().getName());
+ ts.addTest(new JMeterTest("runSerialTest", serObj));
+ suite.addTest(ts);
+ }
+ return suite;
+ }
+
+ /*
+ * Test serializable elements - test the object
+ */
+ public void runSerialTest() throws Exception {
+ if (!(serObj instanceof JComponent)) {
+ try {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(bytes);
+ out.writeObject(serObj);
+ out.close();
+ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()));
+ Object readObject = in.readObject();
+ in.close();
+ assertEquals("deserializing class: " + serObj.getClass().getName(), serObj.getClass(), readObject
+ .getClass());
+ } catch (Throwable e) {
+ fail("serialization of " + serObj.getClass().getName() + " failed: " + e);
+ }
+ }
+ }
+
+ /*
+ * Test TestElements - create the suite
+ */
+ private static Test suiteTestElements() throws Exception {
+ TestSuite suite = new TestSuite("TestElements");
+ Iterator iter = getObjects(TestElement.class).iterator();
+ while (iter.hasNext()) {
+ TestElement item = (TestElement) iter.next();
+ 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
+ return; // Not a real sampler
}
-
+
checkElementAlias(testItem);
- }
+ }
public void readAliases() throws Exception {
nameMap = SaveService.loadProperties();
assertNotNull("SaveService nameMap (saveservice.properties) should not be null",nameMap);
}
- private void checkElementAlias(Object item) {
+ private void checkElementAlias(Object item) {
String name=item.getClass().getName();
boolean contains = nameMap.values().contains(name);
if (!contains){
@@ -535,103 +535,103 @@
}
private static Collection getObjects(Class extendsClass) throws Exception {
- String exName = extendsClass.getName();
- Object myThis = "";
- Iterator classes = ClassFinder
- .findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { extendsClass }).iterator();
- List objects = new LinkedList();
- String n = "";
- boolean caughtError = true;
- Throwable caught = null;
- try {
- while (classes.hasNext()) {
- n = (String) classes.next();
- // TODO - improve this check
- if (n.endsWith("RemoteJMeterEngineImpl")) {
- continue; // Don't try to instantiate remote server
- }
- Class c = null;
- try {
- c = Class.forName(n);
- try {
- // Try with a parameter-less constructor first
- 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(
- new Object[] { myThis }));
- } catch (NoSuchMethodException f) {
- // no luck. Ignore this class
- System.out.println("WARN: " + exName + ": NoSuchMethodException " + n);
- }
- }
- } catch (NoClassDefFoundError e) {
- // no luck. Ignore this class
- System.out.println("WARN: " + exName + ": NoClassDefFoundError " + n);
- } catch (IllegalAccessException e) {
- caught = e;
- System.out.println("WARN: " + exName + ": IllegalAccessException " + n);
- // We won't test restricted-access classes.
- } catch (HeadlessException e) {
+ String exName = extendsClass.getName();
+ Object myThis = "";
+ Iterator classes = ClassFinder
+ .findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { extendsClass }).iterator();
+ List objects = new LinkedList();
+ String n = "";
+ boolean caughtError = true;
+ Throwable caught = null;
+ try {
+ while (classes.hasNext()) {
+ n = (String) classes.next();
+ // TODO - improve this check
+ if (n.endsWith("RemoteJMeterEngineImpl")) {
+ continue; // Don't try to instantiate remote server
+ }
+ Class c = null;
+ try {
+ c = Class.forName(n);
+ try {
+ // Try with a parameter-less constructor first
+ 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(
+ new Object[] { myThis }));
+ } catch (NoSuchMethodException f) {
+ // no luck. Ignore this class
+ System.out.println("WARN: " + exName + ": NoSuchMethodException " + n);
+ }
+ }
+ } catch (NoClassDefFoundError e) {
+ // no luck. Ignore this class
+ System.out.println("WARN: " + exName + ": NoClassDefFoundError " + n);
+ } catch (IllegalAccessException e) {
+ caught = e;
+ System.out.println("WARN: " + exName + ": IllegalAccessException " + n);
+ // We won't test restricted-access classes.
+ } catch (HeadlessException e) {
+ caught = e;
+ System.out.println("Error creating "+n+" "+e.toString());
+ } catch (Exception e) {
caught = e;
- System.out.println("Error creating "+n+" "+e.toString());
- } catch (Exception e) {
- caught = e;
- if (e instanceof RemoteException) { // not thrown, so need to check here
- System.out.println("WARN: " + "Error creating " + n + " " + e.toString());
- } else {
- throw new Exception("Error creating " + n, e);
- }
- }
- }
- caughtError = false;
- } finally {
- if (caughtError) {
- System.out.println("Last class=" + n);
- System.out.println("objects.size=" + objects.size());
- System.out.println("Last error=" + caught);
- }
- }
-
- if (objects.size() == 0) {
- System.out.println("No classes found that extend " + exName + ". Check the following:");
- System.out.println("Search paths are:");
- String ss[] = JMeterUtils.getSearchPaths();
- for (int i = 0; i < ss.length; i++) {
- System.out.println(ss[i]);
- }
- if (!classPathShown) {// Only dump it once
- System.out.println("Class path is:");
- String cp = System.getProperty("java.class.path");
- String cpe[] = JOrphanUtils.split(cp, java.io.File.pathSeparator);
- for (int i = 0; i < cpe.length; i++) {
- System.out.println(cpe[i]);
- }
- classPathShown = true;
- }
- }
- 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();
- // [sebb] assertEquals(item2,
- // clonedItem.getProperty(item2.getName()));
- assertEquals(item2.getStringValue(), clonedItem.getProperty(item2.getName()).getStringValue());
- assertTrue(item2 != clonedItem.getProperty(item2.getName()));
- }
- }
+ if (e instanceof RemoteException) { // not thrown, so need to check here
+ System.out.println("WARN: " + "Error creating " + n + " " + e.toString());
+ } else {
+ throw new Exception("Error creating " + n, e);
+ }
+ }
+ }
+ caughtError = false;
+ } finally {
+ if (caughtError) {
+ System.out.println("Last class=" + n);
+ System.out.println("objects.size=" + objects.size());
+ System.out.println("Last error=" + caught);
+ }
+ }
+
+ if (objects.size() == 0) {
+ System.out.println("No classes found that extend " + exName + ". Check the following:");
+ System.out.println("Search paths are:");
+ String ss[] = JMeterUtils.getSearchPaths();
+ for (int i = 0; i < ss.length; i++) {
+ System.out.println(ss[i]);
+ }
+ if (!classPathShown) {// Only dump it once
+ System.out.println("Class path is:");
+ String cp = System.getProperty("java.class.path");
+ String cpe[] = JOrphanUtils.split(cp, java.io.File.pathSeparator);
+ for (int i = 0; i < cpe.length; i++) {
+ System.out.println(cpe[i]);
+ }
+ classPathShown = true;
+ }
+ }
+ 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();
+ // [sebb] assertEquals(item2,
+ // clonedItem.getProperty(item2.getName()));
+ assertEquals(item2.getStringValue(), clonedItem.getProperty(item2.getName()).getStringValue());
+ assertTrue(item2 != clonedItem.getProperty(item2.getName()));
+ }
+ }
}
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java Sun May 10 18:19:28 2009
@@ -35,87 +35,87 @@
* Extend JUnit TestCase to provide common setup
*/
public abstract class JMeterTestCase extends TestCase {
- // Used by findTestFile
- private static final String filePrefix;
+ // Used by findTestFile
+ private static final String filePrefix;
- public JMeterTestCase() {
- super();
- }
-
- public JMeterTestCase(String name) {
- super(name);
- }
-
- /*
- * If not running under AllTests.java, make sure that the properties (and
- * log file) are set up correctly.
- *
- * N.B. In order for this to work correctly, the JUnit test must be started
- * in the bin directory, and all the JMeter jars (plus any others needed at
- * run-time) need to be on the classpath.
- *
- */
- static {
- if (JMeterUtils.getJMeterProperties() == null) {
- String file = "testfiles/jmetertest.properties";
- File f = new File(file);
- if (!f.canRead()) {
- System.out.println("Can't find " + file + " - trying bin directory");
- file = "bin/" + file;// JMeterUtils assumes Unix-style
- // separators
- // Also need to set working directory so test files can be found
- System.setProperty("user.dir", System.getProperty("user.dir") + File.separatorChar + "bin");
- System.out.println("Setting user.dir=" + System.getProperty("user.dir"));
- filePrefix = "bin/";
- } else {
- filePrefix = "";
- }
- // Used to be done in initializeProperties
- String home=new File(System.getProperty("user.dir")).getParent();
- System.out.println("Setting JMeterHome: "+home);
- JMeterUtils.setJMeterHome(home);
- JMeterUtils jmu = new JMeterUtils();
- try {
- jmu.initializeProperties(file);
- } catch (MissingResourceException e) {
- System.out.println("** Can't find resources - continuing anyway **");
- }
- logprop("java.version");
+ public JMeterTestCase() {
+ super();
+ }
+
+ public JMeterTestCase(String name) {
+ super(name);
+ }
+
+ /*
+ * If not running under AllTests.java, make sure that the properties (and
+ * log file) are set up correctly.
+ *
+ * N.B. In order for this to work correctly, the JUnit test must be started
+ * in the bin directory, and all the JMeter jars (plus any others needed at
+ * run-time) need to be on the classpath.
+ *
+ */
+ static {
+ if (JMeterUtils.getJMeterProperties() == null) {
+ String file = "testfiles/jmetertest.properties";
+ File f = new File(file);
+ if (!f.canRead()) {
+ System.out.println("Can't find " + file + " - trying bin directory");
+ file = "bin/" + file;// JMeterUtils assumes Unix-style
+ // separators
+ // Also need to set working directory so test files can be found
+ System.setProperty("user.dir", System.getProperty("user.dir") + File.separatorChar + "bin");
+ System.out.println("Setting user.dir=" + System.getProperty("user.dir"));
+ filePrefix = "bin/";
+ } else {
+ filePrefix = "";
+ }
+ // Used to be done in initializeProperties
+ String home=new File(System.getProperty("user.dir")).getParent();
+ System.out.println("Setting JMeterHome: "+home);
+ JMeterUtils.setJMeterHome(home);
+ JMeterUtils jmu = new JMeterUtils();
+ try {
+ jmu.initializeProperties(file);
+ } catch (MissingResourceException e) {
+ System.out.println("** Can't find resources - continuing anyway **");
+ }
+ logprop("java.version");
logprop("java.vm.name");
- logprop("java.vendor");
- logprop("java.home");
- logprop("user.home");
- logprop("user.dir");
- logprop("java.class.version");
- logprop("os.name");
- logprop("os.version");
- logprop("os.arch");
- logprop("java.class.path");
- // String cp = System.getProperty("java.class.path");
- // String cpe[]= JOrphanUtils.split(cp,File.pathSeparator);
- // System.out.println("java.class.path=");
- // for (int i=0;i<cpe.length;i++){
- // System.out.println(cpe[i]);
- // }
- } else {
- filePrefix = "";
- }
- }
-
- private static void logprop(String prop) {
- System.out.println(prop + "=" + System.getProperty(prop));
- }
-
- // Helper method to find a file
- protected static File findTestFile(String file) {
- File f = new File(file);
- if (filePrefix.length() > 0 && !f.isAbsolute()) {
- f = new File(filePrefix + file);// Add the offset
- }
- return f;
- }
+ logprop("java.vendor");
+ logprop("java.home");
+ logprop("user.home");
+ logprop("user.dir");
+ logprop("java.class.version");
+ logprop("os.name");
+ logprop("os.version");
+ logprop("os.arch");
+ logprop("java.class.path");
+ // String cp = System.getProperty("java.class.path");
+ // String cpe[]= JOrphanUtils.split(cp,File.pathSeparator);
+ // System.out.println("java.class.path=");
+ // for (int i=0;i<cpe.length;i++){
+ // System.out.println(cpe[i]);
+ // }
+ } else {
+ filePrefix = "";
+ }
+ }
+
+ private static void logprop(String prop) {
+ System.out.println(prop + "=" + System.getProperty(prop));
+ }
+
+ // Helper method to find a file
+ protected static File findTestFile(String file) {
+ File f = new File(file);
+ if (filePrefix.length() > 0 && !f.isAbsolute()) {
+ f = new File(filePrefix + file);// Add the offset
+ }
+ return f;
+ }
- protected static final Logger testLog = LoggingManager.getLoggerForClass();
+ protected static final Logger testLog = LoggingManager.getLoggerForClass();
protected void checkInvalidParameterCounts(AbstractFunction func, int minimum)
throws Exception {
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/junit/stubs/TestSampler.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/junit/stubs/TestSampler.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/junit/stubs/TestSampler.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/junit/stubs/TestSampler.java Sun May 10 18:19:28 2009
@@ -30,44 +30,44 @@
public class TestSampler extends AbstractSampler {
- private long wait = 0;
+ private long wait = 0;
- private long samples = 0; // number of samples taken
+ private long samples = 0; // number of samples taken
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.samplers.Sampler#sample(org.apache.jmeter.samplers.Entry)
- */
- public SampleResult sample(Entry e) {
- if (wait > 0) {
- try {
- Thread.sleep(wait);
- } catch (InterruptedException e1) {
- // ignore
- }
- }
- samples++;
- return null;
- }
-
- public TestSampler(String name, long wait) {
- setName(name);
- this.wait = wait;
- }
-
- public TestSampler(String name) {
- setName(name);
- }
-
- public TestSampler() {
- }
-
- public String toString() {
- return getName();
- }
-
- public long getSamples() {
- return samples;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.samplers.Sampler#sample(org.apache.jmeter.samplers.Entry)
+ */
+ public SampleResult sample(Entry e) {
+ if (wait > 0) {
+ try {
+ Thread.sleep(wait);
+ } catch (InterruptedException e1) {
+ // ignore
+ }
+ }
+ samples++;
+ return null;
+ }
+
+ public TestSampler(String name, long wait) {
+ setName(name);
+ this.wait = wait;
+ }
+
+ public TestSampler(String name) {
+ setName(name);
+ }
+
+ public TestSampler() {
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ public long getSamples() {
+ return samples;
+ }
}
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/monitor/model/TestObjectFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/monitor/model/TestObjectFactory.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/monitor/model/TestObjectFactory.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/monitor/model/TestObjectFactory.java Sun May 10 18:19:28 2009
@@ -26,53 +26,53 @@
public void testSomething() throws Exception{
}
- /**
- * Basic method for testing the class
- *
- * @param args
- */
- public static void main(String[] args) {
- if (args != null && args.length == 2) {
- String file = null;
- // int count = 1;
- if (args[0] != null) {
- file = args[0];
- }
- if (args[1] != null) {
- // count = Integer.parseInt(args[1]);
- }
- try {
- ObjectFactory of = ObjectFactory.getInstance();
- java.io.File infile = new java.io.File(file);
- java.io.FileInputStream fis = new java.io.FileInputStream(infile);
- java.io.InputStreamReader isr = new java.io.InputStreamReader(fis);
- StringBuffer buf = new StringBuffer();
- java.io.BufferedReader br = new java.io.BufferedReader(isr);
- String line = null;
- while ((line = br.readLine()) != null) {
- buf.append(line);
- }
- System.out.println("contents: ");
- System.out.println(buf.toString());
- System.out.println("----------------------");
- Status st = of.parseBytes(buf.toString().getBytes());
- if (st == null) {
- System.out.println("parse failed");
- } else {
- System.out.println("parse successful:");
- System.out.println(st.getJvm().getMemory().getFree());
- System.out.println(st.getJvm().getMemory().getTotal());
- System.out.println(st.getJvm().getMemory().getMax());
- System.out.println("connector size: " + st.getConnector().size());
- Connector conn = (Connector) st.getConnector().get(0);
- System.out.println("conn: " + conn.getThreadInfo().getMaxThreads());
- }
- } catch (java.io.FileNotFoundException e) {
- e.printStackTrace();
- } catch (java.io.IOException e) {
- e.printStackTrace();
- }
- } else {
- }
- }
+ /**
+ * Basic method for testing the class
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ if (args != null && args.length == 2) {
+ String file = null;
+ // int count = 1;
+ if (args[0] != null) {
+ file = args[0];
+ }
+ if (args[1] != null) {
+ // count = Integer.parseInt(args[1]);
+ }
+ try {
+ ObjectFactory of = ObjectFactory.getInstance();
+ java.io.File infile = new java.io.File(file);
+ java.io.FileInputStream fis = new java.io.FileInputStream(infile);
+ java.io.InputStreamReader isr = new java.io.InputStreamReader(fis);
+ StringBuffer buf = new StringBuffer();
+ java.io.BufferedReader br = new java.io.BufferedReader(isr);
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ buf.append(line);
+ }
+ System.out.println("contents: ");
+ System.out.println(buf.toString());
+ System.out.println("----------------------");
+ Status st = of.parseBytes(buf.toString().getBytes());
+ if (st == null) {
+ System.out.println("parse failed");
+ } else {
+ System.out.println("parse successful:");
+ System.out.println(st.getJvm().getMemory().getFree());
+ System.out.println(st.getJvm().getMemory().getTotal());
+ System.out.println(st.getJvm().getMemory().getMax());
+ System.out.println("connector size: " + st.getConnector().size());
+ Connector conn = (Connector) st.getConnector().get(0);
+ System.out.println("conn: " + conn.getThreadInfo().getMaxThreads());
+ }
+ } catch (java.io.FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (java.io.IOException e) {
+ e.printStackTrace();
+ }
+ } else {
+ }
+ }
}
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/monitor/model/benchmark/ParseBenchmark.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/monitor/model/benchmark/ParseBenchmark.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/monitor/model/benchmark/ParseBenchmark.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/monitor/model/benchmark/ParseBenchmark.java Sun May 10 18:19:28 2009
@@ -18,81 +18,81 @@
public class ParseBenchmark {
- /**
- *
- */
- public ParseBenchmark() {
- super();
- }
-
- public static void main(String[] args) {
- if (args.length == 3) {
- int parser = 0;
- String file = null;
- int loops = 1000;
- if (args[0] != null) {
- if (!args[0].equals("jaxb")) {
- parser = 1;
- }
- }
- if (args[1] != null) {
- file = args[1];
- }
- if (args[2] != null) {
- loops = Integer.parseInt(args[2]);
- }
-
- java.io.File infile = new java.io.File(file);
- java.io.FileInputStream fis = null;
- java.io.InputStreamReader isr = null;
- StringBuffer buf = new StringBuffer();
- try {
- fis = new java.io.FileInputStream(infile);
- isr = new java.io.InputStreamReader(fis);
- java.io.BufferedReader br = new java.io.BufferedReader(isr);
- String line = null;
- while ((line = br.readLine()) != null) {
- buf.append(line);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- long start = 0;
- long end = 0;
- String contents = buf.toString().trim();
- System.out.println("start test: " + loops + " iterations");
- System.out.println("content:");
- System.out.println(contents);
-
- if (parser == 0) {
- /**
- * try { JAXBContext jxbc = new
- * org.apache.jorphan.tomcat.manager.ObjectFactory();
- * Unmarshaller mar = jxbc.createUnmarshaller();
- *
- * start = System.currentTimeMillis(); for (int idx=0; idx <
- * loops; idx++){ StreamSource ss = new StreamSource( new
- * ByteArrayInputStream(contents.getBytes())); Object ld =
- * mar.unmarshal(ss); } end = System.currentTimeMillis();
- * System.out.println("elapsed Time: " + (end - start)); } catch
- * (JAXBException e){ }
- */
- } else {
- org.apache.jmeter.monitor.model.ObjectFactory of = org.apache.jmeter.monitor.model.ObjectFactory
- .getInstance();
- start = System.currentTimeMillis();
- for (int idx = 0; idx < loops; idx++) {
- // NOTUSED org.apache.jmeter.monitor.model.Status st =
- of.parseBytes(contents.getBytes());
- }
- end = System.currentTimeMillis();
- System.out.println("elapsed Time: " + (end - start));
- }
-
- } else {
- System.out.println("missing paramters:");
- System.out.println("parser file iterations");
- System.out.println("example: jaxb status.xml 1000");
- }
- }
+ /**
+ *
+ */
+ public ParseBenchmark() {
+ super();
+ }
+
+ public static void main(String[] args) {
+ if (args.length == 3) {
+ int parser = 0;
+ String file = null;
+ int loops = 1000;
+ if (args[0] != null) {
+ if (!args[0].equals("jaxb")) {
+ parser = 1;
+ }
+ }
+ if (args[1] != null) {
+ file = args[1];
+ }
+ if (args[2] != null) {
+ loops = Integer.parseInt(args[2]);
+ }
+
+ java.io.File infile = new java.io.File(file);
+ java.io.FileInputStream fis = null;
+ java.io.InputStreamReader isr = null;
+ StringBuffer buf = new StringBuffer();
+ try {
+ fis = new java.io.FileInputStream(infile);
+ isr = new java.io.InputStreamReader(fis);
+ java.io.BufferedReader br = new java.io.BufferedReader(isr);
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ buf.append(line);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ long start = 0;
+ long end = 0;
+ String contents = buf.toString().trim();
+ System.out.println("start test: " + loops + " iterations");
+ System.out.println("content:");
+ System.out.println(contents);
+
+ if (parser == 0) {
+ /**
+ * try { JAXBContext jxbc = new
+ * org.apache.jorphan.tomcat.manager.ObjectFactory();
+ * Unmarshaller mar = jxbc.createUnmarshaller();
+ *
+ * start = System.currentTimeMillis(); for (int idx=0; idx <
+ * loops; idx++){ StreamSource ss = new StreamSource( new
+ * ByteArrayInputStream(contents.getBytes())); Object ld =
+ * mar.unmarshal(ss); } end = System.currentTimeMillis();
+ * System.out.println("elapsed Time: " + (end - start)); } catch
+ * (JAXBException e){ }
+ */
+ } else {
+ org.apache.jmeter.monitor.model.ObjectFactory of = org.apache.jmeter.monitor.model.ObjectFactory
+ .getInstance();
+ start = System.currentTimeMillis();
+ for (int idx = 0; idx < loops; idx++) {
+ // NOTUSED org.apache.jmeter.monitor.model.Status st =
+ of.parseBytes(contents.getBytes());
+ }
+ end = System.currentTimeMillis();
+ System.out.println("elapsed Time: " + (end - start));
+ }
+
+ } else {
+ System.out.println("missing paramters:");
+ System.out.println("parser file iterations");
+ System.out.println("example: jaxb status.xml 1000");
+ }
+ }
}
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java Sun May 10 18:19:28 2009
@@ -27,55 +27,55 @@
public class MultipartUrlConfigTest extends TestCase {
- public MultipartUrlConfigTest(String name) {
- super(name);
- }
+ public MultipartUrlConfigTest(String name) {
+ super(name);
+ }
- public void testConstructors() {
- MultipartUrlConfig muc = new MultipartUrlConfig();
- assertEquals(0, muc.getArguments().getArgumentCount());
- assertEquals(0, muc.getHTTPFileArgs().getHTTPFileArgCount());
- muc = new MultipartUrlConfig("boundary");
- assertEquals(0, muc.getArguments().getArgumentCount());
- assertEquals(0, muc.getHTTPFileArgs().getHTTPFileArgCount());
- assertEquals("boundary", muc.getBoundary());
- }
+ public void testConstructors() {
+ MultipartUrlConfig muc = new MultipartUrlConfig();
+ assertEquals(0, muc.getArguments().getArgumentCount());
+ assertEquals(0, muc.getHTTPFileArgs().getHTTPFileArgCount());
+ muc = new MultipartUrlConfig("boundary");
+ assertEquals(0, muc.getArguments().getArgumentCount());
+ assertEquals(0, muc.getHTTPFileArgs().getHTTPFileArgCount());
+ assertEquals("boundary", muc.getBoundary());
+ }
- public void testParseArguments() {
- String queryString
- = "Content-Disposition: form-data; name=\"aa\"\n"
- + "Content-Type: text/plain; charset=ISO-8859-1\n"
- + "Content-Transfer-Encoding: 8bit\n"
- + "\n"
- + "aa\n"
- + "--7d159c1302d0y0\n"
- + "Content-Disposition: form-data; name=\"xx\"\n"
- + "Content-Type: text/plain; charset=ISO-8859-1\n"
- + "Content-Transfer-Encoding: 8bit\n"
- + "\n"
- + "xx\n"
- + "--7d159c1302d0y0\n"
- + "Content-Disposition: form-data; name=\"param1\"; filename=\"file1\"\n"
- + "Content-Type: text/plain\n"
- + "Content-Transfer-Encoding: binary\n"
- + "\n"
- + "file content\n"
- + "\n";
- MultipartUrlConfig muc = new MultipartUrlConfig("7d159c1302d0y0");
- muc.parseArguments(queryString);
- HTTPFileArgs files = muc.getHTTPFileArgs();
- assertEquals(1, files.getHTTPFileArgCount());
- HTTPFileArg file = (HTTPFileArg) files.iterator().next().getObjectValue();
- assertEquals("file1", file.getPath());
- assertEquals("param1", file.getParamName());
- assertEquals("text/plain", file.getMimeType());
- Arguments args = muc.getArguments();
- assertEquals(2, args.getArgumentCount());
- Argument arg = args.getArgument(0);
- assertEquals("aa", arg.getName());
- assertEquals("aa", arg.getValue());
- arg = args.getArgument(1);
- assertEquals("xx", arg.getName());
- assertEquals("xx", arg.getValue());
- }
+ public void testParseArguments() {
+ String queryString
+ = "Content-Disposition: form-data; name=\"aa\"\n"
+ + "Content-Type: text/plain; charset=ISO-8859-1\n"
+ + "Content-Transfer-Encoding: 8bit\n"
+ + "\n"
+ + "aa\n"
+ + "--7d159c1302d0y0\n"
+ + "Content-Disposition: form-data; name=\"xx\"\n"
+ + "Content-Type: text/plain; charset=ISO-8859-1\n"
+ + "Content-Transfer-Encoding: 8bit\n"
+ + "\n"
+ + "xx\n"
+ + "--7d159c1302d0y0\n"
+ + "Content-Disposition: form-data; name=\"param1\"; filename=\"file1\"\n"
+ + "Content-Type: text/plain\n"
+ + "Content-Transfer-Encoding: binary\n"
+ + "\n"
+ + "file content\n"
+ + "\n";
+ MultipartUrlConfig muc = new MultipartUrlConfig("7d159c1302d0y0");
+ muc.parseArguments(queryString);
+ HTTPFileArgs files = muc.getHTTPFileArgs();
+ assertEquals(1, files.getHTTPFileArgCount());
+ HTTPFileArg file = (HTTPFileArg) files.iterator().next().getObjectValue();
+ assertEquals("file1", file.getPath());
+ assertEquals("param1", file.getParamName());
+ assertEquals("text/plain", file.getMimeType());
+ Arguments args = muc.getArguments();
+ assertEquals(2, args.getArgumentCount());
+ Argument arg = args.getArgument(0);
+ assertEquals("aa", arg.getName());
+ assertEquals("aa", arg.getValue());
+ arg = args.getArgument(1);
+ assertEquals("xx", arg.getName());
+ assertEquals("xx", arg.getValue());
+ }
}
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/UrlConfigTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/UrlConfigTest.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/UrlConfigTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/UrlConfigTest.java Sun May 10 18:19:28 2009
@@ -27,47 +27,47 @@
import org.apache.jmeter.testelement.property.TestElementProperty;
public class UrlConfigTest extends JMeterTestCase {
- HTTPSamplerBase config;
+ HTTPSamplerBase config;
- HTTPSamplerBase defaultConfig;
+ HTTPSamplerBase defaultConfig;
- HTTPSamplerBase partialConfig;
+ HTTPSamplerBase partialConfig;
- public UrlConfigTest(String name) {
- super(name);
- }
-
- protected void setUp() {
- Arguments args = new Arguments();
- args.addArgument("username", "mstover");
- args.addArgument("password", "pass");
- args.addArgument("action", "login");
- config = new HTTPNullSampler();
- config.setName("Full Config");
- config.setProperty(HTTPSamplerBase.DOMAIN, "www.lazer.com");
- config.setProperty(HTTPSamplerBase.PATH, "login.jsp");
- config.setProperty(HTTPSamplerBase.METHOD, HTTPSamplerBase.POST);
- config.setProperty(new TestElementProperty(HTTPSamplerBase.ARGUMENTS, args));
- defaultConfig = new HTTPNullSampler();
- defaultConfig.setName("default");
- defaultConfig.setProperty(HTTPSamplerBase.DOMAIN, "www.xerox.com");
- defaultConfig.setProperty(HTTPSamplerBase.PATH, "default.html");
- partialConfig = new HTTPNullSampler();
- partialConfig.setProperty(HTTPSamplerBase.PATH, "main.jsp");
- partialConfig.setProperty(HTTPSamplerBase.METHOD, HTTPSamplerBase.GET);
- }
-
- public void testSimpleConfig() {
- assertTrue(config.getName().equals("Full Config"));
- assertEquals(config.getDomain(), "www.lazer.com");
- }
-
- public void testOverRide() {
- JMeterProperty jmp = partialConfig.getProperty(HTTPSamplerBase.DOMAIN);
- assertTrue(jmp instanceof NullProperty);
- assertTrue(new NullProperty(HTTPSamplerBase.DOMAIN).equals(jmp));
- partialConfig.addTestElement(defaultConfig);
- assertEquals(partialConfig.getPropertyAsString(HTTPSamplerBase.DOMAIN), "www.xerox.com");
- assertEquals(partialConfig.getPropertyAsString(HTTPSamplerBase.PATH), "main.jsp");
- }
+ public UrlConfigTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() {
+ Arguments args = new Arguments();
+ args.addArgument("username", "mstover");
+ args.addArgument("password", "pass");
+ args.addArgument("action", "login");
+ config = new HTTPNullSampler();
+ config.setName("Full Config");
+ config.setProperty(HTTPSamplerBase.DOMAIN, "www.lazer.com");
+ config.setProperty(HTTPSamplerBase.PATH, "login.jsp");
+ config.setProperty(HTTPSamplerBase.METHOD, HTTPSamplerBase.POST);
+ config.setProperty(new TestElementProperty(HTTPSamplerBase.ARGUMENTS, args));
+ defaultConfig = new HTTPNullSampler();
+ defaultConfig.setName("default");
+ defaultConfig.setProperty(HTTPSamplerBase.DOMAIN, "www.xerox.com");
+ defaultConfig.setProperty(HTTPSamplerBase.PATH, "default.html");
+ partialConfig = new HTTPNullSampler();
+ partialConfig.setProperty(HTTPSamplerBase.PATH, "main.jsp");
+ partialConfig.setProperty(HTTPSamplerBase.METHOD, HTTPSamplerBase.GET);
+ }
+
+ public void testSimpleConfig() {
+ assertTrue(config.getName().equals("Full Config"));
+ assertEquals(config.getDomain(), "www.lazer.com");
+ }
+
+ public void testOverRide() {
+ JMeterProperty jmp = partialConfig.getProperty(HTTPSamplerBase.DOMAIN);
+ assertTrue(jmp instanceof NullProperty);
+ assertTrue(new NullProperty(HTTPSamplerBase.DOMAIN).equals(jmp));
+ partialConfig.addTestElement(defaultConfig);
+ assertEquals(partialConfig.getPropertyAsString(HTTPSamplerBase.DOMAIN), "www.xerox.com");
+ assertEquals(partialConfig.getPropertyAsString(HTTPSamplerBase.PATH), "main.jsp");
+ }
}
\ No newline at end of file
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java Sun May 10 18:19:28 2009
@@ -24,57 +24,57 @@
import org.apache.jmeter.testelement.property.CollectionProperty;
public class TestAuthManager extends JMeterTestCase {
- public TestAuthManager(String name) {
- super(name);
- }
+ public TestAuthManager(String name) {
+ super(name);
+ }
- public void testHttp() throws Exception {
- assertTrue(AuthManager.isSupportedProtocol(new URL("http:")));
- }
+ public void testHttp() throws Exception {
+ assertTrue(AuthManager.isSupportedProtocol(new URL("http:")));
+ }
- public void testHttps() throws Exception {
- assertTrue(AuthManager.isSupportedProtocol(new URL("https:")));
- }
+ public void testHttps() throws Exception {
+ assertTrue(AuthManager.isSupportedProtocol(new URL("https:")));
+ }
- public void testFile() throws Exception {
- AuthManager am = new AuthManager();
- CollectionProperty ao = am.getAuthObjects();
- assertEquals(0, ao.size());
- am.addFile("testfiles/TestAuth.txt");
- assertEquals(9, ao.size());
- Authorization at;
- at = am.getAuthForURL(new URL("http://a.b.c/"));
- assertEquals("login", at.getUser());
- assertEquals("password", at.getPass());
- at = am.getAuthForURL(new URL("http://a.b.c:80/")); // same as above
- assertEquals("login", at.getUser());
- assertEquals("password", at.getPass());
- at = am.getAuthForURL(new URL("http://a.b.c:443/"));// not same
- assertNull(at);
- at = am.getAuthForURL(new URL("http://a.b.c/1"));
- assertEquals("login1", at.getUser());
- assertEquals("password1", at.getPass());
- assertEquals("", at.getDomain());
- assertEquals("", at.getRealm());
- at = am.getAuthForURL(new URL("http://d.e.f/"));
- assertEquals("user", at.getUser());
- assertEquals("pass", at.getPass());
- assertEquals("domain", at.getDomain());
- assertEquals("realm", at.getRealm());
- at = am.getAuthForURL(new URL("https://j.k.l/"));
- assertEquals("jkl", at.getUser());
- assertEquals("pass", at.getPass());
- at = am.getAuthForURL(new URL("https://j.k.l:443/"));
- assertEquals("jkl", at.getUser());
- assertEquals("pass", at.getPass());
- at = am.getAuthForURL(new URL("https://l.m.n/"));
- assertEquals("lmn443", at.getUser());
- assertEquals("pass", at.getPass());
- at = am.getAuthForURL(new URL("https://l.m.n:443/"));
- assertEquals("lmn443", at.getUser());
- assertEquals("pass", at.getPass());
- at = am.getAuthForURL(new URL("https://l.m.n:8443/"));
- assertEquals("lmn8443", at.getUser());
- assertEquals("pass", at.getPass());
- }
+ public void testFile() throws Exception {
+ AuthManager am = new AuthManager();
+ CollectionProperty ao = am.getAuthObjects();
+ assertEquals(0, ao.size());
+ am.addFile("testfiles/TestAuth.txt");
+ assertEquals(9, ao.size());
+ Authorization at;
+ at = am.getAuthForURL(new URL("http://a.b.c/"));
+ assertEquals("login", at.getUser());
+ assertEquals("password", at.getPass());
+ at = am.getAuthForURL(new URL("http://a.b.c:80/")); // same as above
+ assertEquals("login", at.getUser());
+ assertEquals("password", at.getPass());
+ at = am.getAuthForURL(new URL("http://a.b.c:443/"));// not same
+ assertNull(at);
+ at = am.getAuthForURL(new URL("http://a.b.c/1"));
+ assertEquals("login1", at.getUser());
+ assertEquals("password1", at.getPass());
+ assertEquals("", at.getDomain());
+ assertEquals("", at.getRealm());
+ at = am.getAuthForURL(new URL("http://d.e.f/"));
+ assertEquals("user", at.getUser());
+ assertEquals("pass", at.getPass());
+ assertEquals("domain", at.getDomain());
+ assertEquals("realm", at.getRealm());
+ at = am.getAuthForURL(new URL("https://j.k.l/"));
+ assertEquals("jkl", at.getUser());
+ assertEquals("pass", at.getPass());
+ at = am.getAuthForURL(new URL("https://j.k.l:443/"));
+ assertEquals("jkl", at.getUser());
+ assertEquals("pass", at.getPass());
+ at = am.getAuthForURL(new URL("https://l.m.n/"));
+ assertEquals("lmn443", at.getUser());
+ assertEquals("pass", at.getPass());
+ at = am.getAuthForURL(new URL("https://l.m.n:443/"));
+ assertEquals("lmn443", at.getUser());
+ assertEquals("pass", at.getPass());
+ at = am.getAuthForURL(new URL("https://l.m.n:8443/"));
+ assertEquals("lmn8443", at.getUser());
+ assertEquals("pass", at.getPass());
+ }
}
Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java Sun May 10 18:19:28 2009
@@ -196,45 +196,45 @@
}
- /** Tests missing cookie path for a trivial URL fetch from the domain
- * Note that this fails prior to a fix for BUG 38256
- */
- public void testMissingPath0() throws Exception {
- URL url = new URL("http://d.e.f/goo.html");
- man.addCookieFromHeader("test=moo", url);
- String s = man.getCookieHeaderForURL(new URL("http://d.e.f/"));
- assertNotNull(s);
- assertEquals("test=moo", s);
- }
-
- /** Tests missing cookie path for a non-trivial URL fetch from the
- * domain. Note that this fails prior to a fix for BUG 38256
- */
- public void testMissingPath1() throws Exception {
- URL url = new URL("http://d.e.f/moo.html");
- man.addCookieFromHeader("test=moo", url);
- String s = man.getCookieHeaderForURL(new URL("http://d.e.f/goo.html"));
- assertNotNull(s);
- assertEquals("test=moo", s);
- }
-
- /** Tests explicit root path with a trivial URL fetch from the domain */
- public void testRootPath0() throws Exception {
- URL url = new URL("http://d.e.f/goo.html");
- man.addCookieFromHeader("test=moo;path=/", url);
- String s = man.getCookieHeaderForURL(new URL("http://d.e.f/"));
- assertNotNull(s);
- assertEquals("test=moo", s);
- }
-
- /** Tests explicit root path with a non-trivial URL fetch from the domain */
- public void testRootPath1() throws Exception {
- URL url = new URL("http://d.e.f/moo.html");
- man.addCookieFromHeader("test=moo;path=/", url);
- String s = man.getCookieHeaderForURL(new URL("http://d.e.f/goo.html"));
- assertNotNull(s);
- assertEquals("test=moo", s);
- }
+ /** Tests missing cookie path for a trivial URL fetch from the domain
+ * Note that this fails prior to a fix for BUG 38256
+ */
+ public void testMissingPath0() throws Exception {
+ URL url = new URL("http://d.e.f/goo.html");
+ man.addCookieFromHeader("test=moo", url);
+ String s = man.getCookieHeaderForURL(new URL("http://d.e.f/"));
+ assertNotNull(s);
+ assertEquals("test=moo", s);
+ }
+
+ /** Tests missing cookie path for a non-trivial URL fetch from the
+ * domain. Note that this fails prior to a fix for BUG 38256
+ */
+ public void testMissingPath1() throws Exception {
+ URL url = new URL("http://d.e.f/moo.html");
+ man.addCookieFromHeader("test=moo", url);
+ String s = man.getCookieHeaderForURL(new URL("http://d.e.f/goo.html"));
+ assertNotNull(s);
+ assertEquals("test=moo", s);
+ }
+
+ /** Tests explicit root path with a trivial URL fetch from the domain */
+ public void testRootPath0() throws Exception {
+ URL url = new URL("http://d.e.f/goo.html");
+ man.addCookieFromHeader("test=moo;path=/", url);
+ String s = man.getCookieHeaderForURL(new URL("http://d.e.f/"));
+ assertNotNull(s);
+ assertEquals("test=moo", s);
+ }
+
+ /** Tests explicit root path with a non-trivial URL fetch from the domain */
+ public void testRootPath1() throws Exception {
+ URL url = new URL("http://d.e.f/moo.html");
+ man.addCookieFromHeader("test=moo;path=/", url);
+ String s = man.getCookieHeaderForURL(new URL("http://d.e.f/goo.html"));
+ assertNotNull(s);
+ assertEquals("test=moo", s);
+ }
// Test cookie matching
public void testCookieMatching() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org