org.apache.jmeter.testelement.TestElement Java Examples

The following examples show how to use org.apache.jmeter.testelement.TestElement. 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: JMeterRecorder.java    From jsflight with Apache License 2.0 6 votes vote down vote up
private List<TestElement> extractAppropriateTestElements(RecordingController recordingController)
{
    List<TestElement> samples = new ArrayList<>();

    for (TestElement sample; (sample = recordingController.next()) != null;)
    {
        // skip unknown nasty requests
        if (sample instanceof HTTPSamplerBase)
        {
            HTTPSamplerBase http = (HTTPSamplerBase)sample;
            if (http.getArguments().getArgumentCount() > 0
                    && http.getArguments().getArgument(0).getValue().startsWith("0Q0O0M0K0I0"))
            {
                continue;
            }
        }
        samples.add(sample);
    }

    Collections.sort(samples, (o1, o2) -> {
        String num1 = o1.getName().split(" ")[0];
        String num2 = o2.getName().split(" ")[0];
        return ((Integer)Integer.parseInt(num1)).compareTo(Integer.parseInt(num2));
    });
    return samples;
}
 
Example #2
Source File: SubSamplerUI.java    From mqtt-jmeter with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(TestElement element) {
	super.configure(element);
	SubSampler sampler = (SubSampler) element;

	if(sampler.getQOS().trim().indexOf(JMETER_VARIABLE_PREFIX) == -1){
		this.qosChoice.setSelectedIndex(Integer.parseInt(sampler.getQOS()));	
	} else {
		this.qosChoice.setText(sampler.getQOS());
	}
	
	this.topicNames.setText(sampler.getTopics());
	this.timestamp.setSelected(sampler.isAddTimestamp());
	this.debugResponse.setSelected(sampler.isDebugResponse());
	this.sampleOnCondition.setText(sampler.getSampleCondition());

	if(SAMPLE_ON_CONDITION_OPTION1.equalsIgnoreCase(sampleOnCondition.getText())) {
		this.sampleConditionValue.setText(sampler.getSampleElapsedTime());
	} else if(SAMPLE_ON_CONDITION_OPTION2.equalsIgnoreCase(sampleOnCondition.getText())) {
		this.sampleConditionValue.setText(sampler.getSampleCount());
	}
}
 
Example #3
Source File: ParallelHTTPSamplerGui.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(TestElement tg) {
    super.configure(tg);
    ParallelHTTPSampler utg = (ParallelHTTPSampler) tg;
    JMeterProperty threadValues = utg.getData();
    if (threadValues instanceof NullProperty) {
        log.warn("Received null property instead of collection");
        return;
    }

    CollectionProperty columns = (CollectionProperty) threadValues;

    tableModel.removeTableModelListener(this);
    JMeterPluginsUtils.collectionPropertyToTableModelRows(columns, tableModel);
    tableModel.addTableModelListener(this);
    buttons.checkDeleteButtonStatus();
    updateUI();
}
 
Example #4
Source File: BlazemeterUploaderGuiTest.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
public void displayGUI() throws InterruptedException {
    if (!GraphicsEnvironment.isHeadless()) {
        BlazeMeterUploaderGui obj = new BlazeMeterUploaderGui();
        TestElement te = obj.createTestElement();
        obj.configure(te);
        obj.clearGui();
        obj.modifyTestElement(te);

        JFrame frame = new JFrame(obj.getStaticLabel());
        frame.setPreferredSize(new Dimension(800, 600));
        frame.getContentPane().add(obj, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);

        while (frame.isVisible()) {
            Thread.sleep(1000);
        }
    }
}
 
Example #5
Source File: MQTTSubscriberGui.java    From mqtt-jmeter 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 s) {
    SubscriberSampler sampler = (SubscriberSampler) s;
    this.configureTestElement(sampler);
    sampler.setBrokerUrl(brokerUrlField.getText());
    sampler.setClientId(clientId.getText());
    sampler.setTopicName(mqttDestination.getText());
    sampler.setCleanSession(cleanSession.isSelected());
    sampler.setKeepAlive(mqttKeepAlive.getText());
    sampler.setUsername(mqttUser.getText());
    sampler.setPassword(mqttPwd.getText());
    sampler.setQOS(typeQoSValue.getText());
    sampler.setClientType(typeClientValue.getText());

}
 
Example #6
Source File: UDPSamplerGui.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(TestElement element) {
    super.configure(element);

    if (element instanceof UDPSampler) {
        UDPSampler sampler = (UDPSampler) element;
        hostName.setText(sampler.getHostName());
        port.setText(sampler.getPort());
        timeout.setText(sampler.getTimeout());
        waitResponse.setSelected(sampler.isWaitResponse());
        closeChannel.setSelected(sampler.isCloseChannel());
        messageEncodeClass.setText(sampler.getEncoderClass());
        requestData.setText(sampler.getRequestData());
        bindAddress.setText(sampler.getBindAddress());
        bindPort.setText(sampler.getBindPort());
    }
}
 
Example #7
Source File: BotServiceConfigDefaultsGui.java    From BotServiceStressToolkit with MIT License 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 config) {
	config.clear();
	configureTestElement(config);

	log.debug("modifyTestElement(%s)", config.toString());

	if (config instanceof BotServiceConfig) {
		log.info("config is instanceof " + BotServiceConfig.class);
		config.setProperty(BotServiceConfig.BOT_URL, botUrlTextField.getText());
		config.setProperty(BotServiceConfig.CALLBACK_URL, callbackUrlTextField.getText());
		config.setProperty(BotServiceConfig.CHANNEL_ID, channelIdTextField.getText());
		config.setProperty(BotServiceConfig.CALLBACK_SERVER_HOST, callbackServerHostTextField.getText());
		config.setProperty(BotServiceConfig.CALLBACK_SERVER_PORT, callbackServerPortTextField.getText());
		config.setProperty(BotServiceConfig.FROM_MEMBER_ID, fromMemberTextField.getText());
		config.setProperty(BotServiceConfig.RECIPIENT_MEMBER_ID, recipientMemberTextField.getText());
		config.setProperty(BotServiceConfig.GEN_RANDOM_ID_PER_THREAD, genRandomIdPerThreadCheckbox.isSelected());
		config.setProperty(BotServiceConfig.RESPONSE_TIMEOUT, Integer.parseInt(responseTimeoutTextField.getText()));
	} else {
		log.info("config is not instanceof " + config);
	}
}
 
Example #8
Source File: RandomCSVDataSetConfigGui.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(TestElement element) {
    super.configure(element);

    if (element instanceof RandomCSVDataSetConfig) {
        RandomCSVDataSetConfig randomCSV = (RandomCSVDataSetConfig) element;

        filenameField.setText(randomCSV.getFilename());
        fileEncodingField.setText(randomCSV.getFileEncoding());
        delimiterField.setText(randomCSV.getDelimiter());
        variableNamesField.setText(randomCSV.getVariableNames());

        isRandomOrderCheckBox.setSelected(randomCSV.isRandomOrder());
        isIgnoreFirstLineCheckBox.setSelected(randomCSV.isIgnoreFirstLine());
        isRewindOnTheEndCheckBox.setSelected(randomCSV.isRewindOnTheEndOfList());
        isIndependentListCheckBox.setSelected(randomCSV.isIndependentListPerThread());

    }
}
 
Example #9
Source File: PrometheusMetricsConfigGui.java    From jmeter-prometheus-plugin with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void configure(TestElement ele) {
	super.configure(ele);
	
	if(ele instanceof CollectorElement<?>) {
		try {
			this.table.populateTable((CollectorElement<BaseCollectorConfig>) ele);
		} catch(Exception e) {
			log.error("didn't modify test element because {}:{}", e.getClass(), e.getMessage());
		}
	}
	
	this.setName(ele.getName());
	this.setComment(ele.getComment());
}
 
Example #10
Source File: WeightedSwitchControllerGui.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(TestElement element) {
    // from model to GUI
    super.configure(element);
    log.debug("Props: " + this.isShowing() + " " + isVisible() + " " + isEnabled() + " " + isFocusOwner());
    GuiPackage gp = GuiPackage.getInstance();

    if (gp != null && element instanceof WeightedSwitchController) {
        WeightedSwitchController wsc = (WeightedSwitchController) element;
        CollectionProperty oldData = wsc.getData();

        grid.getModel().clearData();
        isRandomChoiceCheckBox.setSelected(wsc.isRandomChoice());
        if (isShowing()) {
            fillGridFromTree(wsc, oldData);
        } else {
            JMeterPluginsUtils.collectionPropertyToTableModelRows(oldData, grid.getModel());
        }
    }
}
 
Example #11
Source File: JMeterRecorder.java    From jsflight with Apache License 2.0 6 votes vote down vote up
public void saveScenario(OutputStream outStream, int recordingIndex) throws IOException
{
    LOG.info("Start {} scenario saving", recordingIndex);
    LOG.info("Cloning template tree");
    HashTree hashTree = (HashTree)mainHashTreeTemplate.clone();
    LOG.info("Searching for main nodes and trees");
    findMainNodesAndTrees(hashTree);

    RecordingController recordingController = recordingControllers.get(recordingIndex);
    HashTree recordingControllerSubTree = transactionControllerSubTree.add(recordingController);

    LOG.info("Extracting test elements");
    List<TestElement> samples = extractAppropriateTestElements(recordingController);

    LOG.info("Placing test elements");
    placeAndProcessTestElements(recordingControllerSubTree, samples);
    LOG.info("Saving into out stream");
    SaveService.saveTree(hashTree, outStream);
}
 
Example #12
Source File: VariableThroughputTimerGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 *
 */
@Test
public void testCreateTestElement() {
    System.out.println("createTestElement");
    VariableThroughputTimerGui instance = new VariableThroughputTimerGui();
    TestElement result = instance.createTestElement();
    assertTrue(result instanceof VariableThroughputTimer);
}
 
Example #13
Source File: Constants.java    From jmeter-plugins-for-apache-dubbo with Apache License 2.0 5 votes vote down vote up
/**
 * get attachmentArgs
 * @return the attachmentArgs
 */
public static final List<MethodArgument> getAttachmentArgs(TestElement element) {
    int paramsSize = element.getPropertyAsInt(FIELD_DUBBO_ATTACHMENT_ARGS_SIZE, 0);
    List<MethodArgument> list = new ArrayList<MethodArgument>();
    for (int i = 1; i <= paramsSize; i++) {
        String paramType = element.getPropertyAsString(FIELD_DUBBO_ATTACHMENT_ARGS + "_KEY" + i);
        String paramValue = element.getPropertyAsString(FIELD_DUBBO_ATTACHMENT_ARGS + "_VALUE" + i);
        MethodArgument args = new MethodArgument(paramType, paramValue);
        list.add(args);
    }
    return list;
}
 
Example #14
Source File: AutoStopGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test of modifyTestElement method, of class AutoStopGui.
 */
@Test
public void testModifyTestElement() {
    System.out.println("modifyTestElement");
    TestElement te = new AutoStop();
    AutoStopGui instance = new AutoStopGui();
    instance.modifyTestElement(te);
}
 
Example #15
Source File: JSONPathExtractorGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test of modifyTestElement method, of class JSONPathExtractorGui.
 */
@Test
public void testModifyTestElement() {
    System.out.println("modifyTestElement");
    TestElement element = new JSONPathExtractor();
    JSONPathExtractorGui instance = new JSONPathExtractorGui();
    instance.modifyTestElement(element);
    // TODO review the generated test code and remove the default call to fail.

}
 
Example #16
Source File: UltimateThreadGroupGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 *
 */
@Test
public void testCreateTestElement() {
    System.out.println("createTestElement");
    UltimateThreadGroupGui instance = new UltimateThreadGroupGui();
    TestElement result = instance.createTestElement();
    assertTrue(result instanceof UltimateThreadGroup);
}
 
Example #17
Source File: LoadosophiaUploaderGui.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyTestElement(TestElement te) {
    super.configureTestElement(te);
    if (te instanceof LoadosophiaUploader) {
        LoadosophiaUploader fw = (LoadosophiaUploader) te;
        fw.setProject(projectKey.getText());
        fw.setUploadToken(uploadToken.getText());
        fw.setStoreDir(storeDir.getText());
        fw.setColorFlag(indexToColor(colorFlag.getSelectedIndex()));
        fw.setTitle(testTitle.getText());
        fw.setUseOnline(useOnline.isSelected());
        fw.setGui(this);
    }
}
 
Example #18
Source File: JSONPathExtractorGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyTestElement(TestElement element) {
    super.configureTestElement(element);
    if (element instanceof JSONPathExtractor) {
        JSONPathExtractor extractor = (JSONPathExtractor) element;
        extractor.setVar(variableNameTextField.getText());
        extractor.setJsonPath(jsonPathTextField.getText());
        extractor.setDefaultValue(defaultValTextField.getText());
        extractor.setSrcVariableName(srcVariableName.getText());
        extractor.setSubject(group.getSelection().getActionCommand());
        if (inputFormatGroup.getSelection() != null) {
            extractor.setInputFormat(inputFormatGroup.getSelection().getActionCommand());
        }
    }
}
 
Example #19
Source File: ParameterizedControllerGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateTestElement() {
    System.out.println("createTestElement");
    TestElement expResult = new ParameterizedController();
    TestElement result = instance.createTestElement();
    assertEquals(expResult.getClass(), result.getClass());
}
 
Example #20
Source File: AbstractMonitoringVisualizerTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateTestElement() {
    System.out.println("createTestElement");
    AbstractMonitoringVisualizer instance = new AbstractMonitoringVisualizerImpl();
    TestElement result = instance.createTestElement();
    assertTrue(result instanceof MonitoringResultsCollector);
}
 
Example #21
Source File: UDPSamplerGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testModifyTestElement() {
    System.out.println("modifyTestElement");
    TestElement sampler = new UDPSampler();
    UDPSamplerGui instance = new UDPSamplerGui();
    instance.modifyTestElement(sampler);
}
 
Example #22
Source File: ThroughputVsThreadsGuiTest.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();
    ThroughputVsThreadsGui instance = new ThroughputVsThreadsGui();
    instance.configure(el);
}
 
Example #23
Source File: BotServiceSecurityConfigDefaultsGui.java    From BotServiceStressToolkit with MIT License 5 votes vote down vote up
@Override
public void configure(TestElement el) {
	super.configure(el);

	log.debug("configure(%s)", el.toString());

	if (el instanceof BotServiceSecurityConfig) {
		appIdTextField.setText(el.getPropertyAsString(BotServiceSecurityConfig.APP_ID));
		clientSecretTextField.setText(el.getPropertyAsString(BotServiceSecurityConfig.CLIENT_SECRET));
	} else {
		log.debug("el is not instanceof: " + el);
	}
}
 
Example #24
Source File: HTTP2SamplerGui.java    From jmeter-http2-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public TestElement createTestElement() {
    HTTP2Sampler sampler = new HTTP2Sampler();

    modifyTestElement(sampler);

    return sampler;
}
 
Example #25
Source File: JMXMonGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(TestElement te) {
    super.configure(te);
    JMXMonCollector dmte = (JMXMonCollector) te;
    JMeterProperty jmxmonValues = dmte.getSamplerSettings();
    if (!(jmxmonValues instanceof NullProperty)) {
        JMeterPluginsUtils.collectionPropertyToTableModelRows((CollectionProperty) jmxmonValues, tableModel, columnClasses);
    } else {
        log.warn("Received null property instead of collection");
    }
}
 
Example #26
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 #27
Source File: DbMonGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyTestElement(TestElement te) {
    super.modifyTestElement(te);
    if (grid.isEditing()) {
        grid.getCellEditor().stopCellEditing();
    }

    if (te instanceof DbMonCollector) {
        DbMonCollector dmte = (DbMonCollector) te;
        CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, DbMonCollector.DATA_PROPERTY);
        dmte.setData(rows);
    }
    super.configureTestElement(te);
}
 
Example #28
Source File: JMXMonGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyTestElement(TestElement te) {
    super.modifyTestElement(te);
    if (grid.isEditing()) {
        grid.getCellEditor().stopCellEditing();
    }

    if (te instanceof JMXMonCollector) {
        JMXMonCollector dmte = (JMXMonCollector) te;
        CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, JMXMonCollector.DATA_PROPERTY);
        dmte.setData(rows);
    }
    super.configureTestElement(te);
}
 
Example #29
Source File: HttpSimpleTableControlGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateTestElement() {
    System.out.println("createTestElement");
    HttpSimpleTableControlGui instance = new HttpSimpleTableControlGui();
    TestElement result = instance.createTestElement();
    assertNotNull(result);
}
 
Example #30
Source File: TimesVsThreadsGuiTest.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();
   TimesVsThreadsGui instance = new TimesVsThreadsGui();
   instance.configure(el);
}