Java Code Examples for org.apache.jmeter.config.Arguments#addArgument()

The following examples show how to use org.apache.jmeter.config.Arguments#addArgument() . 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: SetVariablesActionTest.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testSample() throws InvalidVariableException {

    System.out.println("next");
    Arguments args = new Arguments();
    args.addArgument("var2", "${var1}");
    args.addArgument("var3", "${var2}");


    instance.setUserDefinedVariables(args);

    ValueReplacer replacer = new ValueReplacer();
    replacer.replaceValues(instance);
    args.setRunningVersion(true);

    instance.sample(null);

    JMeterVariables vars = JMeterContextService.getContext().getVariables();
    assertEquals("${var2}", vars.get("var3"));
    assertEquals("val1", vars.get("var2"));
    instance.sample(null);
    assertEquals("val1", vars.get("var3"));
}
 
Example 2
Source File: SetVariablesActionGuiTest.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testGui() throws Exception {
    SetVariablesActionGui gui = new SetVariablesActionGui();

    SetVariablesAction element1 = (SetVariablesAction) gui.createTestElement();
    SetVariablesAction element2 = (SetVariablesAction) gui.createTestElement();

    Arguments args = new Arguments();
    args.addArgument("var1", "val0");
    element1.setUserDefinedVariables(args);

    gui.configure(element1);
    gui.modifyTestElement(element2);

    assertEquals(element1.getUserDefinedVariablesAsProperty().getObjectValue().toString(),
            element2.getUserDefinedVariablesAsProperty().getObjectValue().toString());

    gui.clearGui();
    gui.modifyTestElement(element2);

    assertEquals("", element2.getUserDefinedVariablesAsProperty().getObjectValue().toString());
}
 
Example 3
Source File: JmxRawBodyBuilder.java    From postman2jmx with MIT License 6 votes vote down vote up
@Override
public HTTPSamplerProxy buildJmxBody(PostmanItem postmanItem)  {

    HTTPSamplerProxy httpSamplerProxy = JmxHTTPSamplerProxy.newInstance(postmanItem);

    if ("post".equalsIgnoreCase(httpSamplerProxy.getMethod())) {
        httpSamplerProxy.setPostBodyRaw(true);
        Arguments arguments = new Arguments();
        PostmanRawBody raw = postmanItem.getRequest().getBody().getRaw();

        if (raw.getValue() != null && !raw.getValue().isEmpty()) {
            HTTPArgument argument = new HTTPArgument();
            argument.setEnabled(true);
            argument.setAlwaysEncoded(false);
            argument.setMetaData("=");
            argument.setValue(raw.getValue());
            arguments.addArgument(argument);
        }
        httpSamplerProxy.setArguments(arguments);
    }

    return httpSamplerProxy;
}
 
Example 4
Source File: BlazemeterBackendListenerClientTest.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testFlow() throws Exception {
    StatusNotifierCallbackTest.StatusNotifierCallbackImpl notifier = new StatusNotifierCallbackTest.StatusNotifierCallbackImpl();
    BlazeMeterBackendListenerClient client = new BLCEmul();
    final Arguments arguments = new Arguments();
    arguments.addArgument(BlazeMeterUploader.SHARE_TEST, Boolean.toString(false));
    arguments.addArgument(BlazeMeterUploader.PROJECT, "project");
    arguments.addArgument(BlazeMeterUploader.TITLE, "title");
    client.setupTest(new BackendListenerContext(arguments));
    client.setInformer(notifier);
    client.initiateOnline();
    assertNotNull(client.getApiClient());

    client.handleSampleResults(BlazemeterAPIClientTest.generateResults(), null);

    client.teardownTest(null);

    String output = notifier.getBuffer().toString();
    assertTrue(output.contains("No BlazeMeter API key provided, will upload anonymously"));
}
 
Example 5
Source File: ParameterizedControllerTest.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testNext() throws InvalidVariableException {

    System.out.println("next");
    Arguments args = new Arguments();
    args.addArgument("var2", "${var1}");
    args.addArgument("var3", "${var2}");


    instance.setUserDefinedVariables(args);

    ValueReplacer replacer = new ValueReplacer();
    replacer.replaceValues(instance);
    args.setRunningVersion(true);

    instance.next();

    JMeterVariables vars = JMeterContextService.getContext().getVariables();
    assertEquals("${var2}", vars.get("var3"));
    assertEquals("val1", vars.get("var2"));
    instance.next();
    assertEquals("val1", vars.get("var3"));
}
 
Example 6
Source File: JMeterInfluxDBBackendListenerClient.java    From JMeter-InfluxDB-Writer with Apache License 2.0 6 votes vote down vote up
@Override
public Arguments getDefaultParameters() {
	Arguments arguments = new Arguments();
	arguments.addArgument(KEY_TEST_NAME, "Test");
	arguments.addArgument(KEY_NODE_NAME, "Test-Node");
	arguments.addArgument(KEY_RUN_ID, "R001");
	arguments.addArgument(InfluxDBConfig.KEY_INFLUX_DB_HOST, "localhost");
	arguments.addArgument(InfluxDBConfig.KEY_INFLUX_DB_PORT, Integer.toString(InfluxDBConfig.DEFAULT_PORT));
	arguments.addArgument(InfluxDBConfig.KEY_INFLUX_DB_USER, "");
	arguments.addArgument(InfluxDBConfig.KEY_INFLUX_DB_PASSWORD, "");
	arguments.addArgument(InfluxDBConfig.KEY_INFLUX_DB_DATABASE, InfluxDBConfig.DEFAULT_DATABASE);
	arguments.addArgument(InfluxDBConfig.KEY_RETENTION_POLICY, InfluxDBConfig.DEFAULT_RETENTION_POLICY);
	arguments.addArgument(KEY_SAMPLERS_LIST, ".*");
	arguments.addArgument(KEY_USE_REGEX_FOR_SAMPLER_LIST, "true");
	arguments.addArgument(KEY_RECORD_SUB_SAMPLES, "true");
	return arguments;
}
 
Example 7
Source File: BlurSamplerClient.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public Arguments getDefaultParameters() {
  Arguments arguments = new Arguments();
  arguments.addArgument("ZooKeeperConnection", "localhost",
      "The ZooKeeper connection string to the Blur cluster you want to test.");
  arguments.addArgument("Table", "test");
  return arguments;
}
 
Example 8
Source File: JMeterTest.java    From learning-hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public Arguments getDefaultParameters() {
	Arguments params = new Arguments();
	params.addArgument("putOrget", "put");
	params.addArgument("keyNumLength", "5");
	params.addArgument("valueLength", "1000");
	params.addArgument("cf", "cf");
	params.addArgument("qualifier", "a");
	params.addArgument("tableName","test");
	params.addArgument("autoFlush","false");
	params.addArgument("writeBufferSize","2097152");
	params.addArgument("writeToWAL","true");
	params.addArgument("poolSize","500");
	return params;
}
 
Example 9
Source File: SetVariablesActionTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetUserDefinedVariables() {
    System.out.println("setUserDefinedVariables");
    Arguments vars = new Arguments();
    vars.addArgument("var1", "val0");
    instance.setUserDefinedVariables(vars);
    JMeterProperty property = instance.getUserDefinedVariablesAsProperty();
    Arguments args = (Arguments) property.getObjectValue();
    assertEquals("val0", args.getArgumentsAsMap().get("var1"));
}
 
Example 10
Source File: LicenseActivateCheckDeactivate.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public Arguments getDefaultParameters() {
	Arguments args = new Arguments();
	args.addArgument("LicenseID", "89U1jiKrhD5IG1yNU0O2CinG");
	args.addArgument("HardwareCode", "TestHW");
	args.addArgument("InstallCode", "TestInstall");
	args.addArgument("WaitSeconds", "5");
	args.addArgument("IntervalSeconds", "30");
	return args;
}
 
Example 11
Source File: JMeterInfluxDBImportFileClient.java    From JMeter-InfluxDB-Writer with Apache License 2.0 5 votes vote down vote up
@Override
public Arguments getDefaultParameters() {
	Arguments arguments = new Arguments();
	arguments.addArgument(KEY_TEST_NAME, "Test");
	arguments.addArgument(KEY_FILE_PATH, "influxDBExport.txt");
	arguments.addArgument(KEY_SAMPLERS_LIST, ".*");
	arguments.addArgument(KEY_USE_REGEX_FOR_SAMPLER_LIST, "true");
	return arguments;
}
 
Example 12
Source File: LicenseCheck.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public Arguments getDefaultParameters() {
	Arguments args = new Arguments();
	args.addArgument("LicenseID", "89U1jiKrhD5IG1yNU0O2CinG");
	args.addArgument("HardwareCode", "TestHW");
	args.addArgument("InstallCode", "TestInstall");
	args.addArgument("IntervalSeconds", "30");
	return args;
}
 
Example 13
Source File: SetVariablesActionTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetUserDefinedVariablesAsProperty() {
    System.out.println("getUserDefinedVariablesAsProperty");
    Arguments vars = new Arguments();
    vars.addArgument("key", "value");
    instance.setUserDefinedVariables(vars);
    JMeterProperty result = instance.getUserDefinedVariablesAsProperty();
    assertNotNull(result);
}
 
Example 14
Source File: LicenseActivateCheckDeactivate.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public Arguments getDefaultParameters() {
	Arguments args = new Arguments();
	args.addArgument("LicenseID", "89U1jiKrhD5IG1yNU0O2CinG");
	args.addArgument("HardwareCode", "TestHW");
	args.addArgument("InstallCode", "TestInstall");
	args.addArgument("WaitSeconds", "5");
	args.addArgument("IntervalSeconds", "30");
	return args;
}
 
Example 15
Source File: BlazeMeterUploader.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private Arguments createArguments() {
    final Arguments arguments = new Arguments();
    arguments.addArgument(SHARE_TEST, Boolean.toString(isShareTest()));
    arguments.addArgument(PROJECT, getProject());
    arguments.addArgument(TITLE, getTitle());
    arguments.addArgument(UPLOAD_TOKEN, getUploadToken());
    return arguments;
}
 
Example 16
Source File: LoadosophiaUploader.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private Arguments createArguments() {
    final Arguments arguments = new Arguments();
    arguments.addArgument(PROJECT, getProject());
    arguments.addArgument(TITLE, getTitle());
    arguments.addArgument(COLOR, getColorFlag());
    arguments.addArgument(UPLOAD_TOKEN, getUploadToken());
    arguments.addArgument(USE_ONLINE, Boolean.toString(isUseOnline()));
    arguments.addArgument(STORE_DIR, getStoreDir());
    arguments.addArgument(FILE_NAME, fileName);
    return arguments;
}
 
Example 17
Source File: WeEventProducer.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
@Override
public Arguments getDefaultParameters() {
    Arguments arguments = new Arguments();
    arguments.addArgument("topic", this.topic);
    arguments.addArgument("size", String.valueOf(this.size));
    arguments.addArgument("groupId", this.groupId);
    arguments.addArgument("format", this.format);
    arguments.addArgument("url", this.defaultUrl);
    return arguments;
}
 
Example 18
Source File: PepperBoxSamplerTest.java    From pepper-box with Apache License 2.0 4 votes vote down vote up
@Test
public void serializedSamplerTest() throws IOException {

    PepperBoxKafkaSampler sampler = new PepperBoxKafkaSampler();
    Arguments arguments = sampler.getDefaultParameters();
    arguments.removeArgument(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG);
    arguments.removeArgument(ProducerKeys.KAFKA_TOPIC_CONFIG);
    arguments.removeArgument(ProducerKeys.ZOOKEEPER_SERVERS);
    arguments.removeArgument(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG);
    arguments.addArgument(ProducerKeys.KAFKA_TOPIC_CONFIG, TOPIC);
    arguments.addArgument(ProducerKeys.ZOOKEEPER_SERVERS, ZKHOST + ":" + zkServer.port());
    arguments.addArgument(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, BROKERHOST + ":" + BROKERPORT);
    arguments.addArgument(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "com.gslab.pepper.input.serialized.ObjectSerializer");

    jmcx = new JavaSamplerContext(arguments);
    sampler.setupTest(jmcx);

    List<FieldExpressionMapping> fieldExpressionMappings = TestInputUtils.getFieldExpressionMappings();
    SerializedConfigElement serializedConfigElement = new SerializedConfigElement();
    serializedConfigElement.setClassName("com.gslab.pepper.test.Message");
    serializedConfigElement.setObjProperties(fieldExpressionMappings);
    serializedConfigElement.setPlaceHolder(PropsKeys.MSG_PLACEHOLDER);
    serializedConfigElement.iterationStart(null);

    Message msgSent = (Message) JMeterContextService.getContext().getVariables().getObject(PropsKeys.MSG_PLACEHOLDER);
    sampler.runTest(jmcx);

    Properties consumerProps = new Properties();
    consumerProps.setProperty("bootstrap.servers", BROKERHOST + ":" + BROKERPORT);
    consumerProps.setProperty("group.id", "group0");
    consumerProps.setProperty("client.id", "consumer0");
    consumerProps.setProperty("key.deserializer","org.apache.kafka.common.serialization.StringDeserializer");
    consumerProps.setProperty("value.deserializer", "com.gslab.pepper.input.serialized.ObjectDeserializer");
    consumerProps.put("auto.offset.reset", "earliest");
    KafkaConsumer<String, Message> consumer = new KafkaConsumer<>(consumerProps);
    consumer.subscribe(Arrays.asList(TOPIC));
    ConsumerRecords<String, Message> records = consumer.poll(30000);
    Assert.assertEquals(1, records.count());
    for (ConsumerRecord<String, Message> record : records){
        Assert.assertEquals("Failed to validate produced message", msgSent.getMessageBody(), record.value().getMessageBody());
    }

    sampler.teardownTest(jmcx);

}
 
Example 19
Source File: PepperBoxSamplerTest.java    From pepper-box with Apache License 2.0 4 votes vote down vote up
@Test
public void plainTextKeyedMessageSamplerTest() throws IOException {

    PepperBoxKafkaSampler sampler = new PepperBoxKafkaSampler();
    Arguments arguments = sampler.getDefaultParameters();
    arguments.removeArgument(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG);
    arguments.removeArgument(ProducerKeys.KAFKA_TOPIC_CONFIG);
    arguments.removeArgument(ProducerKeys.ZOOKEEPER_SERVERS);
    arguments.removeArgument(PropsKeys.KEYED_MESSAGE_KEY);
    arguments.addArgument(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, BROKERHOST + ":" + BROKERPORT);
    arguments.addArgument(ProducerKeys.ZOOKEEPER_SERVERS, ZKHOST + ":" + zkServer.port());
    arguments.addArgument(ProducerKeys.KAFKA_TOPIC_CONFIG, TOPIC);
    arguments.addArgument(PropsKeys.KEYED_MESSAGE_KEY,"YES");

    jmcx = new JavaSamplerContext(arguments);
    sampler.setupTest(jmcx);

    PlainTextConfigElement keyConfigElement = new PlainTextConfigElement();
    keyConfigElement.setJsonSchema(TestInputUtils.testKeySchema);
    keyConfigElement.setPlaceHolder(PropsKeys.MSG_KEY_PLACEHOLDER);
    keyConfigElement.iterationStart(null);

    PlainTextConfigElement valueConfigElement = new PlainTextConfigElement();
    valueConfigElement.setJsonSchema(TestInputUtils.testSchema);
    valueConfigElement.setPlaceHolder(PropsKeys.MSG_PLACEHOLDER);
    valueConfigElement.iterationStart(null);

    Object keySent = JMeterContextService.getContext().getVariables().getObject(PropsKeys.MSG_KEY_PLACEHOLDER);
    Object valueSent = JMeterContextService.getContext().getVariables().getObject(PropsKeys.MSG_PLACEHOLDER);
    sampler.runTest(jmcx);

    Properties consumerProps = new Properties();
    consumerProps.setProperty("bootstrap.servers", BROKERHOST + ":" + BROKERPORT);
    consumerProps.setProperty("group.id", "group0");
    consumerProps.setProperty("client.id", "consumer0");
    consumerProps.setProperty("key.deserializer","org.apache.kafka.common.serialization.StringDeserializer");
    consumerProps.setProperty("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
    consumerProps.put("auto.offset.reset", "earliest");
    KafkaConsumer<String, String> consumer = new KafkaConsumer<>(consumerProps);
    consumer.subscribe(Arrays.asList(TOPIC));
    ConsumerRecords<String, String> records = consumer.poll(30000);
    Assert.assertEquals(1, records.count());
    for (ConsumerRecord<String, String> record : records){
        Assert.assertEquals("Failed to validate key of produced message", keySent.toString(), record.key());
        Assert.assertEquals("Failed to validate value of produced message", valueSent.toString(), record.value());
    }

    sampler.teardownTest(jmcx);
}
 
Example 20
Source File: MultiTopicHCSClient.java    From hedera-mirror-node with Apache License 2.0 4 votes vote down vote up
@Override
public Arguments getDefaultParameters() {
    Arguments defaultParameters = new Arguments();
    defaultParameters.addArgument("propertiesBase", "hedera.mirror.test.performance");
    return defaultParameters;
}