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

The following examples show how to use org.apache.jmeter.testelement.property.StringProperty. 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 File: SynthesisReportGui.java    From jmeter-plugins with 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 #2
Source File: MergeResultsGui.java    From jmeter-plugins with 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 #3
Source File: AbstractGraphPanelVisualizer.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: JMeterPluginsUtils.java    From jmeter-plugins with 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 #5
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 File: FreeFormArrivalsThreadStarterTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
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 #8
Source File: MergeResultsGuiTest.java    From jmeter-plugins with 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
Source File: MergeResultsGuiTest.java    From jmeter-plugins with 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 #10
Source File: WebSocketSamplerTest.java    From jmeter-websocket with 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 #11
Source File: WebSocketSampler.java    From JMeter-WebSocketSampler with Apache License 2.0 4 votes vote down vote up
@Override
public void setComment(String comment) {
    setProperty(new StringProperty(TestElement.COMMENTS, comment));
}
 
Example #12
Source File: JMeterPluginsUtils.java    From jmeter-plugins with 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 #13
Source File: JMeterVariableEvaluator.java    From jmeter-plugins with 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 #14
Source File: ConcurrencyThreadGroupTest.java    From jmeter-plugins with 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 #15
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with Apache License 2.0 2 votes vote down vote up
/**
 * set connections
 * @param connections the connections to set
 */
public static final void setConnections(String connections, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_CONNECTIONS, StringUtils.trimAllWhitespace(connections)));
}
 
Example #16
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with Apache License 2.0 2 votes vote down vote up
/**
 * set method
 * @param method the method to set
 */
public static final void setMethod(String method, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_METHOD, StringUtils.trimAllWhitespace(method)));
}
 
Example #17
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with Apache License 2.0 2 votes vote down vote up
/**
 * set interfaceName
 * @param interfaceName the interfaceName to set
 */
public static final void setInterfaceName(String interfaceName, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_INTERFACE, StringUtils.trimAllWhitespace(interfaceName)));
}
 
Example #18
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with Apache License 2.0 2 votes vote down vote up
/**
 * set async
 * @param async the async to set
 */
public static final void setAsync(String async, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_ASYNC, StringUtils.trimAllWhitespace(async)));
}
 
Example #19
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with Apache License 2.0 2 votes vote down vote up
/**
 * set loadbalance
 * @param loadbalance the loadbalance to set
 */
public static final void setLoadbalance(String loadbalance, TestElement element) {
    element.setProperty(new StringProperty(FIELD_DUBBO_LOADBALANCE, StringUtils.trimAllWhitespace(loadbalance)));
}
 
Example #20
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 #21
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 #22
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 #23
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 #24
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 #25
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 #26
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 #27
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 #28
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 #29
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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 #30
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with 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)));
}