Bug 55334 - Adding Include Controller to test plan (made of Include Controllers) without saving TestPlan leads to included code not being taken into account until save

Bugzilla Id: 55334

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1509647 13f79535-47bb-0310-9956-ffa450edef68

Former-commit-id: 90d52dfecb
This commit is contained in:
Philippe Mouawad 2013-08-02 12:02:03 +00:00
parent d2a50a6cb4
commit e465c0028a
2 changed files with 26 additions and 16 deletions

View File

@ -842,16 +842,7 @@ public class JMeter implements JMeterPlugin {
TestElement item = (TestElement) o;
if (item.isEnabled()) {
if (item instanceof ReplaceableController) {
ReplaceableController rc;
// TODO this bit of code needs to be tidied up
// Unfortunately ModuleController is in components, not core
if (item.getClass().getName().equals("org.apache.jmeter.control.ModuleController")){ // Bug 47165
rc = (ReplaceableController) item;
} else {
// HACK: force the controller to load its tree
rc = (ReplaceableController) item.clone();
}
ReplaceableController rc = ensureReplaceableControllerIsLoaded(item);
HashTree subTree = tree.getTree(item);
if (subTree != null) {
@ -861,9 +852,7 @@ public class JMeter implements JMeterPlugin {
tree.replace(item, rc);
tree.set(rc, replacementTree);
}
} else { // null subTree
convertSubTree(tree.getTree(item));
}
}
} else { // not Replaceable Controller
convertSubTree(tree.getTree(item));
}
@ -876,10 +865,11 @@ public class JMeter implements JMeterPlugin {
// Replacement only needs to occur when starting the engine
// @see StandardJMeterEngine.run()
if (item.getUserObject() instanceof ReplaceableController) {
ReplaceableController rc =
(ReplaceableController) item.getTestElement();
HashTree subTree = tree.getTree(item);
TestElement controllerAsItem = item.getTestElement();
ReplaceableController rc = ensureReplaceableControllerIsLoaded(controllerAsItem);
HashTree subTree = tree.getTree(item);
if (subTree != null) {
HashTree replacementTree = rc.getReplacementSubTree();
if (replacementTree != null) {
@ -900,6 +890,25 @@ public class JMeter implements JMeterPlugin {
}
}
/**
* Ensures the {@link ReplaceableController} is loaded
* @param item {@link TestElement}
* @return {@link ReplaceableController} loaded
*/
private static ReplaceableController ensureReplaceableControllerIsLoaded(
TestElement item) {
ReplaceableController rc;
// TODO this bit of code needs to be tidied up
// Unfortunately ModuleController is in components, not core
if (item.getClass().getName().equals("org.apache.jmeter.control.ModuleController")){ // Bug 47165
rc = (ReplaceableController) item;
} else {
// HACK: force the controller to load its tree
rc = (ReplaceableController) item.clone();
}
return rc;
}
private JMeterEngine doRemoteInit(String hostName, HashTree testTree) {
JMeterEngine engine = null;
try {

View File

@ -238,6 +238,7 @@ Previously the default was 1, which could cause unexpected additional traffic.
<li><bugzilla>54985</bugzilla> - Make Transaction Controller set Response Code of Generated Parent Sampler to response code of first failing child in case of failure of one of its children</li>
<li><bugzilla>54950</bugzilla> - ModuleController : Changes to referenced Module are not taken into account if changes occur after first run and referenced node is disabled</li>
<li><bugzilla>55201</bugzilla> - ForEach controller excludes start index and includes end index (clarified documentation)</li>
<li><bugzilla>55334</bugzilla> - Adding Include Controller to test plan (made of Include Controllers) without saving TestPlan leads to included code not being taken into account until save</li>
</ul>
<h3>Listeners</h3>