Java Code Examples for org.apache.jmeter.testelement.property.JMeterProperty#getObjectValue()

The following examples show how to use org.apache.jmeter.testelement.property.JMeterProperty#getObjectValue() . 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: WebSocketAbstractSampler.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
protected void setConnectionHeaders(ClientUpgradeRequest request, HeaderManager headerManager, CacheManager cacheManager) {
    if (headerManager != null) {
        CollectionProperty headers = headerManager.getHeaders();
        PropertyIterator p = headers.iterator();
        if (headers != null) {
        	while (p.hasNext()){
        		JMeterProperty jMeterProperty = p.next();
        		org.apache.jmeter.protocol.http.control.Header header
                = (org.apache.jmeter.protocol.http.control.Header)
                        jMeterProperty.getObjectValue();
                String n = header.getName();
                if (! HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)){
                    String v = header.getValue();
            		request.setHeader(n, v);
                }
        	}
        }
    }
    if (cacheManager != null){
    }
}
 
Example 2
Source File: JMeterRecorder.java    From jsflight with Apache License 2.0 5 votes vote down vote up
private List<TestElement> findAndRemoveHeaderManagers(TestElement element) {
    List<TestElement> descendants = new ArrayList<>();

    for (PropertyIterator iter = element.propertyIterator(); iter.hasNext();)
    {
        JMeterProperty property = iter.next();
        if (property.getObjectValue() instanceof HeaderManager)
        {
            descendants.add((HeaderManager)property.getObjectValue());
            iter.remove();
        }
    }
    return descendants;
}
 
Example 3
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 4
Source File: ParallelHTTPSampler.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
@Override
protected HTTPSampleResult sample(java.net.URL u, String method, boolean areFollowingRedirect, int depth) {
    if (depth < 1) {
        JMeterProperty data = getData();
        StringBuilder body = new StringBuilder();
        StringBuilder req = new StringBuilder();
        if (!(data instanceof NullProperty)) {
            CollectionProperty rows = (CollectionProperty) data;

            for (JMeterProperty row : rows) {
                ArrayList<Object> curProp = (ArrayList<Object>) row.getObjectValue();
                req.append(curProp.get(0)).append("\n");
                body.append("<iframe src='").append(curProp.get(0)).append("'></iframe>\n");
            }
        }

        HTTPSampleResult res = new HTTPSampleResult();
        res.setSamplerData(req.toString());
        res.setRequestHeaders("\n");
        res.setHTTPMethod("GET");
        try {
            res.setURL(new URL("http://parallel-urls-list"));
        } catch (MalformedURLException e) {
            log.warn("Failed to set empty url", e);
        }

        res.setSuccessful(true);
        res.setResponseData(body.toString(), res.getDataEncodingWithDefault());
        res.setContentType("text/html");
        res.sampleStart();
        downloadPageResources(res, res, depth);
        if (res.getEndTime() == 0L) {
            res.sampleEnd();
        }
        return res;
    } else {
        if (impl == null) {
            impl = HCAccessor.getInstance(this);
        }

        return HCAccessor.sample(impl, u, method, areFollowingRedirect, depth);
    }
}
 
Example 5
Source File: PrometheusListener.java    From jmeter-prometheus-plugin with Apache License 2.0 4 votes vote down vote up
@Override
protected void makeNewCollectors() {
	// this.clearCollectors();
	if (this.registry == null) {
		log.warn("Collector registry has not yet been initialized, doing it now");
		registry = JMeterCollectorRegistry.getInstance();
	}
	this.updaters = new ArrayList<AbstractUpdater>();

	CollectionProperty collectorDefs = this.getCollectorConfigs();

	for (JMeterProperty collectorDef : collectorDefs) {

		try {
			ListenerCollectorConfig config = (ListenerCollectorConfig) collectorDef.getObjectValue();
			log.debug("Creating collector from configuration: " + config);
			Collector collector = this.registry.getOrCreateAndRegister(config);
			AbstractUpdater updater = null;

			switch (config.getMeasuringAsEnum()) {
			case CountTotal:
			case FailureTotal:
			case SuccessTotal:
			case SuccessRatio:
				updater = new CountTypeUpdater(config);
				break;
			case ResponseSize:
			case ResponseTime:
			case Latency:
			case IdleTime:
			case ConnectTime:
				updater = new AggregatedTypeUpdater(config);
				break;
			default:
				// hope our IDEs are telling us to use all possible enums!
				log.error(config.getMeasuringAsEnum() + " triggered default case, which means there's "
						+ "no functionality for this and is likely a bug");
				break;
			}

			this.collectors.put(config, collector);
			this.updaters.add(updater);
			log.debug("added " + config.getMetricName() + " to list of collectors");

		} catch (Exception e) {
			log.error("Didn't create new collector because of error, ", e);
		}

	}

}