Skip to content

Commit

Permalink
feat: add WhileControllerSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
vlsi committed Jun 15, 2023
1 parent 9c56e2c commit f2332f7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.jmeter.engine.event.LoopIterationEvent;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.testelement.property.JMeterProperty;
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.testelement.schema.PropertiesAccessor;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterThread;
import org.apache.jmeter.threads.JMeterVariables;
Expand All @@ -36,14 +36,22 @@ public class WhileController extends GenericController implements Serializable,

private static final long serialVersionUID = 233L;

private static final String CONDITION = "WhileController.condition"; // $NON-NLS-1$

private boolean breakLoop;

public WhileController() {
super();
}

@Override
public WhileControllerSchema getSchema() {
return WhileControllerSchema.INSTANCE;
}

@Override
public PropertiesAccessor<? extends WhileController, ? extends WhileControllerSchema> getProps() {
return new PropertiesAccessor<>(this, getSchema());
}

/**
* Evaluate the condition, which can be:
* blank or LAST = was the last sampler OK?
Expand Down Expand Up @@ -130,14 +138,14 @@ protected void resetLoopCount() {
*/
public void setCondition(String string) {
log.debug("setCondition({})", string);
setProperty(new StringProperty(CONDITION, string));
set(getSchema().getCondition(), string);
}

/**
* @return the condition
*/
public String getCondition() {
JMeterProperty prop=getProperty(CONDITION);
JMeterProperty prop=getProperty(getSchema().getCondition().getName());
prop.recoverRunningVersion(this);
return prop.getStringValue();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.control

import org.apache.jmeter.testelement.schema.StringPropertyDescriptor
import org.apiguardian.api.API

/**
* Lists properties of a [WhileController].
* @since 5.6
*/
@API(status = API.Status.EXPERIMENTAL, since = "5.6")
public abstract class WhileControllerSchema : GenericControllerSchema() {
public companion object INSTANCE : WhileControllerSchema()

public val condition: StringPropertyDescriptor<WhileControllerSchema>
by string("WhileController.condition")
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class DslPrinterTraverserTest {
+org.apache.jmeter.reporters.Summariser::class
org.apache.jmeter.control.WhileController::class {
setProperty("WhileController.condition", "while \"condition\" \${'$'} ")
props {
it[condition] = "while \"condition\" \$ "
}
org.apache.jmeter.control.IfController::class {
setProperty("IfController.condition", "\${'$'}{__P(abc, def)}")
Expand Down

0 comments on commit f2332f7

Please sign in to comment.