org.apache.jmeter.config.ConfigTestElement Java Examples

The following examples show how to use org.apache.jmeter.config.ConfigTestElement. 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: DubboDefaultConfigGui.java    From jmeter-plugins-for-apache-dubbo with Apache License 2.0 5 votes vote down vote up
@Override
public TestElement createTestElement() {
    log.debug("创建sample对象");
    //创建sample对象
    ConfigTestElement config = new ConfigTestElement();
    modifyTestElement(config);
    return config;
}
 
Example #2
Source File: TestCompilerParallel.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private void addSamplePackage(Sampler sampler, SamplePackage samplePackage) {
    if (sampler instanceof AbstractTestElement) {
        knownElements.add((AbstractTestElement) sampler);
    }

    for (Assertion assertion : samplePackage.getAssertions()) {
        if (assertion instanceof AbstractTestElement) {
            knownElements.add((AbstractTestElement) assertion);
        }
    }

    for (ConfigTestElement config : samplePackage.getConfigs()) {
        knownElements.add(config);
    }

    for (PostProcessor postProcessor : samplePackage.getPostProcessors()) {
        if (postProcessor instanceof AbstractTestElement) {
            knownElements.add((AbstractTestElement) postProcessor);
        }
    }

    for (PreProcessor preProcessor : samplePackage.getPreProcessors()) {
        if (preProcessor instanceof AbstractTestElement) {
            knownElements.add((AbstractTestElement) preProcessor);
        }
    }

    for (Timer timer : samplePackage.getTimers()) {
        if (timer instanceof AbstractTestElement) {
            knownElements.add((AbstractTestElement) timer);
        }
    }
}
 
Example #3
Source File: ParallelSamplerTest.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private HashTree createTestTree(ConfigTestElement configTestElement) {
    HashTree hashTree = new HashTree();

    LoopController loopController = new LoopController();

    HashTree loopNode = new HashTree();
    loopNode.add(loopController, configTestElement);

    hashTree.add(loopNode);
    return hashTree;
}
 
Example #4
Source File: CustomTreeClonerTest.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private HashTree createTestTree(ThroughputController controller, ConfigTestElement configTestElement) {
    HashTree controllerNode = new HashTree();
    controllerNode.add(controller, configTestElement);


    LoopController loopController = new LoopController();
    HashTree loopNode = new HashTree();
    loopNode.add(loopController, controllerNode);

    HashTree hashTree = new HashTree();
    hashTree.add(loopNode);
    return hashTree;
}
 
Example #5
Source File: WebSocketConnectionConfigGui.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(TestElement element) {
    super.configure(element);
    if (element instanceof ConfigTestElement) {
    	ConfigTestElement configTestElement = (ConfigTestElement) element;
        webSocketConnectionConfigPanel.setServer(configTestElement.getPropertyAsString("WebSocketConnectionConfig.Server"));
        webSocketConnectionConfigPanel.setPort(configTestElement.getPropertyAsString("WebSocketConnectionConfig.Port"));
        webSocketConnectionConfigPanel.setConnectionTimeout(configTestElement.getPropertyAsString("WebSocketConnectionConfig.ConnectionTimeout"));
        webSocketConnectionConfigPanel.setProtocol(configTestElement.getPropertyAsString("WebSocketConnectionConfig.Protocol"));
        webSocketConnectionConfigPanel.setPath(configTestElement.getPropertyAsString("WebSocketConnectionConfig.Path"));
        webSocketConnectionConfigPanel.setTopic(configTestElement.getPropertyAsString("WebSocketConnectionConfig.Topic"));
        webSocketConnectionConfigPanel.setContentEncoding(configTestElement.getPropertyAsString("WebSocketConnectionConfig.Encoding"));
        webSocketConnectionConfigPanel.setImplementation(configTestElement.getPropertyAsString("WebSocketConnectionConfig.Implementation"));
        webSocketConnectionConfigPanel.setCloseConnectionPattern(configTestElement.getPropertyAsString("WebSocketConnectionConfig.CloseConnectionPattern"));
        webSocketConnectionConfigPanel.setProtocolWSMQTTComboBox(configTestElement.getPropertyAsString("WebSocketConnectionConfig.ProtocolWSMQTTComboBox"));
        webSocketConnectionConfigPanel.setLogLevel(configTestElement.getPropertyAsString("WebSocketConnectionConfig.LogLevel"));
       
        Arguments queryStringParameters = (Arguments) configTestElement.getProperty("WebSocketConnectionConfig.HTTPRequest.ARGUMENTS").getObjectValue();
        if (queryStringParameters != null) {
            webSocketConnectionConfigPanel.getAttributePanel().configure(queryStringParameters);
        }
        
        Arguments queryStringPatterns = (Arguments) configTestElement.getProperty("WebSocketConnectionConfig.ResponsePatterns.ARGUMENTS").getObjectValue();
        if (queryStringPatterns != null) {
            webSocketConnectionConfigPanel.getPatternsPanel().configure(queryStringPatterns);
        }
    }
}
 
Example #6
Source File: WebSocketConnectionConfigGui.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public TestElement createTestElement() {
	ConfigTestElement config = new ConfigTestElement();
	config.setName(this.getName());
	config.setProperty(TestElement.GUI_CLASS, this.getClass().getName());
	config.setProperty(TestElement.TEST_CLASS, config.getClass().getName());
    modifyTestElement(config);
    return config;
}
 
Example #7
Source File: WebSocketConnectionConfigGui.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyTestElement(TestElement te) {
    configureTestElement(te);
    if (te instanceof ConfigTestElement) {
    	ConfigTestElement configTestElement = (ConfigTestElement) te;
    	configTestElement.setProperty("WebSocketConnectionConfig.Server", webSocketConnectionConfigPanel.getServer());
    	configTestElement.setProperty("WebSocketConnectionConfig.Port", webSocketConnectionConfigPanel.getPort());
    	configTestElement.setProperty("WebSocketConnectionConfig.ConnectionTimeout", webSocketConnectionConfigPanel.getConnectionTimeout());
    	configTestElement.setProperty("WebSocketConnectionConfig.Protocol", webSocketConnectionConfigPanel.getProtocolSelected());
    	configTestElement.setProperty("WebSocketConnectionConfig.Path", webSocketConnectionConfigPanel.getPath());
    	configTestElement.setProperty("WebSocketConnectionConfig.Topic", webSocketConnectionConfigPanel.getTopic());
    	configTestElement.setProperty("WebSocketConnectionConfig.Encoding", webSocketConnectionConfigPanel.getContentEncoding());
    	configTestElement.setProperty("WebSocketConnectionConfig.Implementation", webSocketConnectionConfigPanel.getImplementation());
        configTestElement.setProperty("WebSocketConnectionConfig.CloseConnectionPattern", webSocketConnectionConfigPanel.getCloseConnectionPattern());
        configTestElement.setProperty("WebSocketConnectionConfig.ProtocolWSMQTTComboBox", webSocketConnectionConfigPanel.getProtocolWSMQTTComboBox());
        configTestElement.setProperty("WebSocketConnectionConfig.LogLevel", webSocketConnectionConfigPanel.getLogLevel());
        
        
        HTTPArgumentsPanel queryStringParameters = webSocketConnectionConfigPanel.getAttributePanel();
        if (queryStringParameters != null) {
        	configTestElement.setProperty(new TestElementProperty("WebSocketConnectionConfig.HTTPRequest.ARGUMENTS", (Arguments)queryStringParameters.createTestElement()));
        }
        
        ArgumentsPanel queryStringPatterns = webSocketConnectionConfigPanel.getPatternsPanel();
        if (queryStringPatterns != null) {
        	configTestElement.setProperty(new TestElementProperty("WebSocketConnectionConfig.ResponsePatterns.ARGUMENTS", (Arguments)queryStringPatterns.createTestElement()));
        }
    }
}
 
Example #8
Source File: JMeterProxyControl.java    From jsflight with Apache License 2.0 5 votes vote down vote up
/**
 * Remove from the sampler all values which match the one provided by the
 * first configuration in the given collection which provides a value for
 * that property.
 *
 * @param sampler        Sampler to remove values from.
 * @param configurations ConfigTestElements in descending priority.
 */
private void removeValuesFromSampler(HTTPSamplerBase sampler, Collection<ConfigTestElement> configurations)
{
    for (PropertyIterator props = sampler.propertyIterator(); props.hasNext();)
    {
        JMeterProperty prop = props.next();
        String name = prop.getName();
        String value = prop.getStringValue();

        // There's a few properties which are excluded from this processing:
        if (name.equals(TestElement.ENABLED) || name.equals(TestElement.GUI_CLASS) || name.equals(TestElement.NAME)
                || name.equals(TestElement.TEST_CLASS))
        {
            continue; // go on with next property.
        }

        for (ConfigTestElement config : configurations)
        {
            String configValue = config.getPropertyAsString(name);

            if (configValue != null && configValue.length() > 0)
            {
                if (configValue.equals(value))
                {
                    sampler.setProperty(name, ""); // $NON-NLS-1$
                }
                // Property was found in a config element. Whether or not
                // it matched the value in the sampler, we're done with
                // this property -- don't look at lower-priority configs:
                break;
            }
        }
    }
}
 
Example #9
Source File: WebSocketSendSampler.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
private ConfigTestElement getConfigTestElement() {
ConfigTestElement connectionConfig = (ConfigTestElement) getProperty(this.CONNECT_CONFIG).getObjectValue();
      return connectionConfig;
  }
 
Example #10
Source File: CassandraSampler.java    From jmeter-cassandra with Apache License 2.0 4 votes vote down vote up
/**
 * @see org.apache.jmeter.samplers.AbstractSampler#applies(org.apache.jmeter.config.ConfigTestElement)
 */
@Override
public boolean applies(ConfigTestElement configElement) {
    String guiClass = configElement.getProperty(TestElement.GUI_CLASS).getStringValue();
    return APPLIABLE_CONFIG_CLASSES.contains(guiClass);
}
 
Example #11
Source File: JMeterElements.java    From teammates with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Overloaded method that returns a HTTP Request Defaults element that listens to the server at "localhost:8080".
 */
public static ConfigTestElement defaultSampler() {
    return defaultSampler("localhost", "8080");
}
 
Example #12
Source File: WebSocketSampler.java    From jmeter-websocket with Apache License 2.0 4 votes vote down vote up
/**
 * @see org.apache.jmeter.samplers.AbstractSampler#applies(org.apache.jmeter.config.ConfigTestElement)
 */
@Override
public boolean applies(ConfigTestElement configElement) {
    String guiClass = configElement.getProperty(TestElement.GUI_CLASS).getStringValue();
    return APPLIABLE_CONFIG_CLASSES.contains(guiClass);
}