jsalvata 2004/02/09 14:50:52
Modified: src/core/org/apache/jmeter/resources messages.properties
xdocs/usermanual component_reference.xml
Added: src/components/org/apache/jmeter/control
RandomOrderController.java
src/components/org/apache/jmeter/control/gui
RandomOrderControllerGui.java
Log:
Adding RandomOrderController by Mike Verdone.
Revision Changes Path
1.1
jakarta-jmeter/src/components/org/apache/jmeter/control/RandomOrderController.java
Index: RandomOrderController.java
===================================================================
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed 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.
*
* @author Mike Verdone
* @version $Id: RandomOrderController.java,v 1.1 2004/02/09 22:50:52 jsalvata Exp $
*/
package org.apache.jmeter.control;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import junit.framework.TestSuite;
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.junit.stubs.TestSampler;
import org.apache.jmeter.testelement.TestElement;
/**
* A controller that runs its children each at most once, but in a random order.
*/
public class RandomOrderController
extends GenericController
implements Serializable
{
/**
* Create a new RandomOrderController.
*/
public RandomOrderController()
{
}
/**
* @see GenericController#initialize()
*/
public void initialize()
{
super.initialize();
this.reorder();
}
/**
* @see GenericController#reInitialize()
*/
public void reInitialize()
{
super.reInitialize();
this.reorder();
}
/**
* Replace the subControllersAndSamplers list with a reordered ArrayList.
*/
private void reorder()
{
int numElements = this.subControllersAndSamplers.size();
// Create a new list containing numElements null elements.
List reordered = new ArrayList(this.subControllersAndSamplers.size());
for (int i = 0; i < numElements; i++)
{
reordered.add(null);
}
// Insert the subControllersAndSamplers into random list positions.
for (Iterator i = this.subControllersAndSamplers.iterator();
i.hasNext(); )
{
int idx = (int)Math.floor(Math.random() * reordered.size());
while (true)
{
if (idx == numElements)
{
idx = 0;
}
if (reordered.get(idx) == null)
{
reordered.set(idx, i.next());
break;
}
idx++;
}
}
// Replace subControllersAndSamplers with reordered copy.
this.subControllersAndSamplers = reordered;
}
public static class Test extends JMeterTestCase
{
public Test(String name)
{
super(name);
}
public void testRandomOrder()
{
testLog.debug("Testing RandomOrderController");
RandomOrderController roc = new RandomOrderController();
roc.addTestElement(new TestSampler("zero"));
roc.addTestElement(new TestSampler("one"));
roc.addTestElement(new TestSampler("two"));
roc.addTestElement(new TestSampler("three"));
TestElement sampler = null;
List usedSamplers = new ArrayList();
roc.initialize();
while ((sampler = roc.next()) != null)
{
String samplerName = sampler.getPropertyAsString(TestSampler.NAME);
if (usedSamplers.contains(samplerName))
{
assertTrue("Duplicate sampler returned from next()", false);
}
usedSamplers.add(samplerName);
}
assertTrue("All samplers were returned",
usedSamplers.size() == 4);
}
public void testRandomOrderNoElements()
{
RandomOrderController roc = new RandomOrderController();
TestElement sampler = null;
List usedSamplers = new ArrayList();
roc.initialize();
assertTrue(roc.next() == null);
}
public void testRandomOrderOneElement()
{
RandomOrderController roc = new RandomOrderController();
roc.addTestElement(new TestSampler("zero"));
TestElement sampler = null;
List usedSamplers = new ArrayList();
roc.initialize();
while ((sampler = roc.next()) != null)
{
String samplerName = sampler.getPropertyAsString(TestSampler.NAME);
if (usedSamplers.contains(samplerName))
{
assertTrue("Duplicate sampler returned from next()", false);
}
usedSamplers.add(samplerName);
}
assertTrue("All samplers were returned",
usedSamplers.size() == 1);
}
}
public static void main(String args[])
{
junit.textui.TestRunner.run(suite());
}
public static TestSuite suite()
{
TestSuite suite = new TestSuite();
suite.addTest(new Test("testRandomOrderController"));
return suite;
}
}
1.99 +1 -0
jakarta-jmeter/src/core/org/apache/jmeter/resources/messages.properties
Index: messages.properties
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/resources/messages.properties,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- messages.properties 9 Feb 2004 01:09:18 -0000 1.98
+++ messages.properties 9 Feb 2004 22:50:52 -0000 1.99
@@ -308,6 +308,7 @@
proxy_usekeepalive=Set Keep-Alive
ramp_up=Ramp-Up Period (in seconds)\:
random_control_title=Random Controller
+random_order_control_title=Random Order Controller
read_response_message=Read response is not checked. To see the response, please
check the box in the sampler.
read_response_note=If read response is unchecked, the sampler will not read the
response
read_response_note2=or set the SampleResult. This improves performance, but it means
1.1
jakarta-jmeter/src/components/org/apache/jmeter/control/gui/RandomOrderControllerGui.java
Index: RandomOrderControllerGui.java
===================================================================
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed 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.
*
* @author Mike Verdone
* @version $Id: RandomOrderControllerGui.java,v 1.1 2004/02/09 22:50:52 jsalvata
Exp $
*/
package org.apache.jmeter.control.gui;
import org.apache.jmeter.control.RandomOrderController;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
/**
* GUI for RandomOrderController.
*/
public class RandomOrderControllerGui extends LogicControllerGui
{
/* (non-Javadoc)
* @see org.apache.jmeter.gui.JMeterGUIComponent#getStaticLabel()
*/
public String getStaticLabel()
{
return JMeterUtils.getResString("random_order_control_title");
}
/* (non-Javadoc)
* @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
*/
public TestElement createTestElement()
{
RandomOrderController ic = new RandomOrderController();
modifyTestElement(ic);
return ic;
}
/* (non-Javadoc)
* @see
org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(org.apache.jmeter.testelement.TestElement)
*/
public void modifyTestElement(TestElement ic)
{
configureTestElement(ic);
}
}
1.80 +11 -1 jakarta-jmeter/xdocs/usermanual/component_reference.xml
Index: component_reference.xml
===================================================================
RCS file: /home/cvs/jakarta-jmeter/xdocs/usermanual/component_reference.xml,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- component_reference.xml 7 Feb 2004 13:10:16 -0000 1.79
+++ component_reference.xml 9 Feb 2004 22:50:52 -0000 1.80
@@ -756,6 +756,16 @@
<property name="Condition" required="yes">Javascript code that returns "true"
or "false"</property>
</properties>
</component>
+
+<component name="Random Order Controller" index="14.2.10" screenshot="">
+ <description>
+ <p>The Random Order Controller is much like a Simple Controller in
that it will execute each child
+ element at most once, but the order of execution of the nodes will be
random.</p>
+ </description>
+<properties>
+ <property name="Name" required="No">Descriptive name for this controller that
is shown in the tree.</property>
+</properties>
+</component>
</section>
<section name="14.3 Listeners" anchor="listeners">
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]