Java Code Examples for org.apache.jmeter.testelement.property.StringProperty

The following examples show how to use org.apache.jmeter.testelement.property.StringProperty. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jmeter-plugins   Source File: JMeterPluginsUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static void collectionPropertyToTableModelRows(CollectionProperty prop, PowerTableModel model, Class[] columnClasses) {
    model.clearData();
    for (int rowN = 0; rowN < prop.size(); rowN++) {
        ArrayList<StringProperty> rowStrings = (ArrayList<StringProperty>) prop.get(rowN).getObjectValue();
        ArrayList<Object> rowObject = new ArrayList<>(rowStrings.size());

        for (int i = 0; i < columnClasses.length && i < rowStrings.size(); i++) {
            rowObject.add(convertToClass(rowStrings.get(i), columnClasses[i]));
        }
        //for now work only if new fields are added at the end...
        //needed for retro compatibility if new fields added
        if (rowObject.size() < columnClasses.length) {
            for (int i = rowObject.size(); i < columnClasses.length; i++) {
                rowObject.add(new Object());
            }
        }
        model.addRow(rowObject.toArray());
    }
    model.fireTableDataChanged();
}
 
Example 2
@Override
public void modifyTestElement(TestElement c) {
    super.modifyTestElement(c);
    c.setProperty(new LongProperty(INTERVAL_PROPERTY, interval));
    c.setProperty(new BooleanProperty(GRAPH_AGGREGATED, isAggregate));
    c.setProperty(new StringProperty(CorrectedResultCollector.INCLUDE_SAMPLE_LABELS, graphPanel.getRowSelectorPanel().getIncludeSampleLabels()));
    c.setProperty(new StringProperty(CorrectedResultCollector.EXCLUDE_SAMPLE_LABELS, graphPanel.getRowSelectorPanel().getExcludeSampleLabels()));
    c.setProperty(new StringProperty(CorrectedResultCollector.START_OFFSET,
            graphPanel.getRowSelectorPanel().getStartOffset()));
    c.setProperty(new StringProperty(CorrectedResultCollector.END_OFFSET,
            graphPanel.getRowSelectorPanel().getEndOffset()));

    c.setProperty(new BooleanProperty(
            CorrectedResultCollector.INCLUDE_REGEX_CHECKBOX_STATE,
            graphPanel.getRowSelectorPanel().isSelectedRegExpInc()));
    c.setProperty(new BooleanProperty(
            CorrectedResultCollector.EXCLUDE_REGEX_CHECKBOX_STATE,
            graphPanel.getRowSelectorPanel().isSelectedRegExpExc()));
}
 
Example 3
Source Project: jmeter-plugins   Source File: MergeResultsGui.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Modifies a given TestElement to mirror the data in the gui components.
 *
 * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
 */
@Override
public void modifyTestElement(TestElement c) {
    super.modifyTestElement(c);
    if (c instanceof ResultCollector) {
        ResultCollector rc = (ResultCollector) c;
        rc.setFilename(getFile());

        rc.setProperty(new StringProperty(
                CorrectedResultCollector.FILENAME, getFile()));
        CollectionProperty rows = JMeterPluginsUtils
                .tableModelRowsToCollectionProperty(tableModel,
                        DATA_PROPERTY);
        rc.setProperty(rows);
        collector = rc;
    }
}
 
Example 4
Source Project: jmeter-plugins   Source File: SynthesisReportGui.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void modifyTestElement(TestElement c) {
    super.modifyTestElement(c);
    c.setProperty(USE_GROUP_NAME, useGroupName.isSelected(), false);
    c.setProperty(SAVE_HEADERS, saveHeaders.isSelected(), true);
    c.setProperty(new StringProperty(
            CorrectedResultCollector.INCLUDE_SAMPLE_LABELS, jPanelFilter
            .getIncludeSampleLabels()));
    c.setProperty(new StringProperty(
            CorrectedResultCollector.EXCLUDE_SAMPLE_LABELS, jPanelFilter
            .getExcludeSampleLabels()));

    c.setProperty(new StringProperty(CorrectedResultCollector.START_OFFSET,
            jPanelFilter.getStartOffset()));
    c.setProperty(new StringProperty(CorrectedResultCollector.END_OFFSET,
            jPanelFilter.getEndOffset()));

    c.setProperty(new BooleanProperty(
            CorrectedResultCollector.INCLUDE_REGEX_CHECKBOX_STATE,
            jPanelFilter.isSelectedRegExpInc()));
    c.setProperty(new BooleanProperty(
            CorrectedResultCollector.EXCLUDE_REGEX_CHECKBOX_STATE,
            jPanelFilter.isSelectedRegExpExc()));
}
 
Example 5
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * set methodArgs
 * @param methodArgs the methodArgs to set
 */
public static final void setMethodArgs(List<MethodArgument> methodArgs, TestElement element) {
    int size = methodArgs == null ? 0 : methodArgs.size();
    element.setProperty(new IntegerProperty(FIELD_DUBBO_METHOD_ARGS_SIZE, size));
    if (size > 0) {
        for (int i = 1; i <= methodArgs.size(); i++) {
            element.setProperty(new StringProperty(FIELD_DUBBO_METHOD_ARGS + "_PARAM_TYPE" + i, methodArgs.get(i-1).getParamType()));
            element.setProperty(new StringProperty(FIELD_DUBBO_METHOD_ARGS + "_PARAM_VALUE" + i, methodArgs.get(i-1).getParamValue()));
        }
    }
}
 
Example 6
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * set attachmentArgs
 * @param methodArgs the attachmentArgs to set
 */
public static final void setAttachmentArgs(List<MethodArgument> methodArgs, TestElement element) {
    int size = methodArgs == null ? 0 : methodArgs.size();
    element.setProperty(new IntegerProperty(FIELD_DUBBO_ATTACHMENT_ARGS_SIZE, size));
    if (size > 0) {
        for (int i = 1; i <= methodArgs.size(); i++) {
            element.setProperty(new StringProperty(FIELD_DUBBO_ATTACHMENT_ARGS + "_KEY" + i, methodArgs.get(i-1).getParamType()));
            element.setProperty(new StringProperty(FIELD_DUBBO_ATTACHMENT_ARGS + "_VALUE" + i, methodArgs.get(i-1).getParamValue()));
        }
    }
}
 
Example 7
Source Project: jmeter-plugins   Source File: MergeResultsGuiTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigure_NullProperty() {
    System.out.println("configure");
    TestElement el = new ResultCollector();
    el.setProperty(new StringProperty(MergeResultsGui.FILENAME,
            "fusionRes.csv"));
    MergeResultsGui instance = new MergeResultsGui();
    instance.configure(el);
}
 
Example 8
Source Project: jmeter-plugins   Source File: MergeResultsGuiTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigure() {
    System.out.println("configure");
    TestElement el = new ResultCollector();
    el.setProperty(new StringProperty(MergeResultsGui.FILENAME,
            "fusionRes.csv"));
    MergeResultsGui instance = new MergeResultsGui();
    instance.modifyTestElement(el);
    instance.configure(el);
}
 
Example 9
private CollectionProperty getRow(int i, int i1, int i2) {
    CollectionProperty row = new CollectionProperty();
    row.addProperty(new StringProperty("", String.valueOf(i)));
    row.addProperty(new StringProperty("", String.valueOf(i1)));
    row.addProperty(new StringProperty("", String.valueOf(i2)));
    return row;
}
 
Example 10
Source Project: JMeter-WebSocketSampler   Source File: WebSocketSampler.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setComment(String comment) {
    setProperty(new StringProperty(TestElement.COMMENTS, comment));
}
 
Example 11
Source Project: jmeter-plugins   Source File: JMeterPluginsUtils.java    License: Apache License 2.0 4 votes vote down vote up
private static Object convertToClass(StringProperty value, Class aClass) {
    if (Boolean.class.equals(aClass)) {
        return Boolean.valueOf(value.getStringValue());
    }
    return value;
}
 
Example 12
Source Project: jmeter-plugins   Source File: JMeterVariableEvaluator.java    License: Apache License 2.0 4 votes vote down vote up
public double getDouble(JMeterProperty jMeterProperty) {
    String strval = evaluate(jMeterProperty.getStringValue());

    return (new StringProperty("", strval)).getDoubleValue();
}
 
Example 13
Source Project: jmeter-plugins   Source File: ConcurrencyThreadGroupTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testStartNextLoop() throws Exception {
    JMeterContextService.getContext().setVariables(new JMeterVariables());

    TestSampleListener listener = new TestSampleListener();

    DebugSampler beforeSampler = new DebugSamplerExt();
    beforeSampler.setName("Before Test Action sampler");

    TestAction testAction = new TestAction();
    testAction.setAction(TestAction.RESTART_NEXT_LOOP);

    DebugSampler afterSampler = new DebugSamplerExt();
    afterSampler.setName("After Test Action sampler");


    ConcurrencyThreadGroup ctg = new ConcurrencyThreadGroup();
    ctg.setProperty(new StringProperty(AbstractThreadGroup.ON_SAMPLE_ERROR, AbstractThreadGroup.ON_SAMPLE_ERROR_CONTINUE));
    ctg.setRampUp("0");
    ctg.setTargetLevel("1");
    ctg.setSteps("0");
    ctg.setHold("5"); // TODO: increase this value for debugging
    ctg.setIterationsLimit("10");
    ctg.setUnit("S");

    ListedHashTree hashTree = new ListedHashTree();
    hashTree.add(ctg);
    hashTree.add(ctg, beforeSampler);
    hashTree.add(ctg, testAction);
    hashTree.add(ctg, afterSampler);
    hashTree.add(ctg, listener);

    TestCompiler compiler = new TestCompiler(hashTree);
    hashTree.traverse(compiler);

    ListenerNotifier notifier = new ListenerNotifier();

    ctg.start(1, notifier, hashTree, new StandardJMeterEngine());

    ctg.waitThreadsStopped();

    for (SampleEvent event : listener.events) {
        assertEquals("Before Test Action sampler", event.getResult().getSampleLabel());
    }
}
 
Example 14
Source Project: jmeter-websocket   Source File: WebSocketSamplerTest.java    License: Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    JMeterUtils.setJMeterHome("src/test/resources/");
    JMeterUtils.loadJMeterProperties("src/test/resources/jmeter.properties");
    JMeterUtils.setProperty("saveservice_properties", "saveservice.properties");
    JMeterUtils.setProperty("search_paths", "ApacheJMeter_functions-2.9.jar");
    JMeterUtils.setLocale(Locale.JAPAN);
    
    JMeterEngine engine = new StandardJMeterEngine();
    HashTree config = new ListedHashTree();
    TestPlan testPlan = new TestPlan("websocket test");
    testPlan.setFunctionalMode(false);
    testPlan.setSerialized(false);
    testPlan.setProperty(new BooleanProperty(TestElement.ENABLED, true));
    testPlan.setUserDefinedVariables(new Arguments());

    ThreadGroup threadGroup = new ThreadGroup();
    threadGroup.setNumThreads(300);
    threadGroup.setRampUp(20);
    threadGroup.setDelay(0);
    threadGroup.setDuration(0);
    threadGroup.setProperty(new StringProperty(ThreadGroup.ON_SAMPLE_ERROR, "continue"));
    threadGroup.setScheduler(false);
    threadGroup.setName("Group1");
    threadGroup.setProperty(new BooleanProperty(TestElement.ENABLED, true));

    LoopController controller = new LoopController();
    controller.setLoops(10);
    controller.setContinueForever(false);
    controller.setProperty(new BooleanProperty(TestElement.ENABLED, true));
    threadGroup.setProperty(new TestElementProperty(ThreadGroup.MAIN_CONTROLLER, controller));

    CSVDataSet csvDataSet = new CSVDataSet();
    csvDataSet.setProperty(new StringProperty("filename", "src/test/resources/users.csv"));
    csvDataSet.setProperty(new StringProperty("variableNames", "USER_NAME"));
    csvDataSet.setProperty(new StringProperty("delimiter", ","));
    csvDataSet.setProperty(new StringProperty("shareMode", "shareMode.all"));
    csvDataSet.setProperty("quoted", false);
    csvDataSet.setProperty("recycle", true);
    csvDataSet.setProperty("stopThread", false);

    WebSocketSampler sampler = new WebSocketSampler();
    sampler.setName("WebSocket Test");
    sampler.setProperty(new BooleanProperty(TestElement.ENABLED, true));
    sampler.addNonEncodedArgument("name", "${USER_NAME}", "=");
    sampler.setContentEncoding("UTF-8");
    sampler.setProtocol("ws");
    sampler.setDomain("localhost");
    sampler.setPort(9090);
    sampler.setPath("/", "UTF-8");
    sampler.setSendMessage("${__RandomString(50,ABCDEFGHIJKLMNOPQRSTUVWXYZ)}");
    sampler.setRecvMessage("\"name\":\"${USER_NAME}\"");

    OnceOnlyController onceOnlyController = new OnceOnlyController();

    Summariser summariser = new Summariser();

    HashTree tpConfig = config.add(testPlan);
    HashTree tgConfig = tpConfig.add(threadGroup);
    HashTree oocConfig = tgConfig.add(onceOnlyController);
    oocConfig.add(csvDataSet);

    UniformRandomTimer randomTimer = new UniformRandomTimer();
    randomTimer.setRange(3000);
    HashTree samplerConfig = tgConfig.add(sampler);
    samplerConfig.add(summariser);
    tgConfig.add(randomTimer);

    engine.configure(config);
    engine.runTest();
}
 
Example 15
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set Registry Protocol
 * @param registryProtocol the protocol to set
 */
public static final void setRegistryProtocol(String registryProtocol, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_REGISTRY_PROTOCOL, StringUtils.trimAllWhitespace(registryProtocol)));
}
 
Example 16
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set Registry Group
 * @param registryGroup the group to set
 */
public static final void setRegistryGroup(String registryGroup, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_REGISTRY_GROUP, StringUtils.trimAllWhitespace(registryGroup)));
}
 
Example 17
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set Registry username
 * @param username the username to set
 */
public static final void setRegistryUserName(String username, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_REGISTRY_USER_NAME, StringUtils.trimAllWhitespace(username)));
}
 
Example 18
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set Registry password
 * @param password the password to set
 */
public static final void setRegistryPassword(String password, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_REGISTRY_PASSWORD, StringUtils.trimAllWhitespace(password)));
}
 
Example 19
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set Registry timeout
 * @param timeout the group to set
 */
public static final void setRegistryTimeout(String timeout, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_REGISTRY_TIMEOUT, StringUtils.trimAllWhitespace(timeout)));
}
 
Example 20
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set ConfigCenter protocol
 * @param protocol the protocol to set
 */
public static final void setConfigCenterProtocol(String protocol, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_PROTOCOL, StringUtils.trimAllWhitespace(protocol)));
}
 
Example 21
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set ConfigCenter group
 * @param group the group to set
 */
public static final void setConfigCenterGroup(String group, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_GROUP, StringUtils.trimAllWhitespace(group)));
}
 
Example 22
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set ConfigCenter namespace
 * @param namespace the namespace to set
 */
public static final void setConfigCenterNamespace(String namespace, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_NAMESPACE, StringUtils.trimAllWhitespace(namespace)));
}
 
Example 23
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set ConfigCenter username
 * @param username the username to set
 */
public static final void setConfigCenterUserName(String username, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_USER_NAME, StringUtils.trimAllWhitespace(username)));
}
 
Example 24
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set ConfigCenter password
 * @param password the password to set
 */
public static final void setConfigCenterPassword(String password, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_PASSWORD, StringUtils.trimAllWhitespace(password)));
}
 
Example 25
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set ConfigCenter namespace
 * @param address the address to set
 */
public static final void setConfigCenterAddress(String address, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_ADDRESS, StringUtils.trimAllWhitespace(address)));
}
 
Example 26
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set ConfigCenter namespace
 * @param timeout the timeout to set
 */
public static final void setConfigCenterTimeout(String timeout, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_CONFIG_CENTER_TIMEOUT, StringUtils.trimAllWhitespace(timeout)));
}
 
Example 27
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set RPC protocol
 * @param rpcProtocol the protocol to set
 */
public static final void setRpcProtocol(String rpcProtocol, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_RPC_PROTOCOL, StringUtils.trimAllWhitespace(rpcProtocol)));
}
 
Example 28
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set address
 * @param address the address to set
 */
public static final void setAddress(String address, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_ADDRESS, StringUtils.trimAllWhitespace(address)));
}
 
Example 29
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set timeout
 * @param timeout the timeout to set
 */
public static final void setTimeout(String timeout, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_TIMEOUT, StringUtils.trimAllWhitespace(timeout)));
}
 
Example 30
Source Project: jmeter-plugins-for-apache-dubbo   Source File: Constants.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * set version
 * @param version the version to set
 */
public static final void setVersion(String version, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_VERSION, StringUtils.trimAllWhitespace(version)));
}