org.apache.jmeter.protocol.http.control.HeaderManager Java Examples

The following examples show how to use org.apache.jmeter.protocol.http.control.HeaderManager. 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: FeedbackSessionSubmitLNPTest.java    From teammates with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected ListedHashTree getLnpTestPlan() {
    ListedHashTree testPlan = new ListedHashTree(JMeterElements.testPlan());
    HashTree threadGroup = testPlan.add(
            JMeterElements.threadGroup(NUMBER_OF_USER_ACCOUNTS, RAMP_UP_PERIOD, 1));
    threadGroup.add(JMeterElements.csvDataSet(getPathToTestDataFile(getCsvConfigPath())));
    threadGroup.add(JMeterElements.cookieManager());
    threadGroup.add(JMeterElements.defaultSampler());
    threadGroup.add(JMeterElements.onceOnlyController())
            .add(JMeterElements.loginSampler())
            .add(JMeterElements.csrfExtractor("csrfToken"));

    HeaderManager headerManager = JMeterElements.headerManager(getRequestHeaders());
    threadGroup.add(headerManager);

    for (int i = 1; i <= NUMBER_OF_QUESTIONS; i++) {
        String body = "{\"questionType\": \"TEXT\","
                + "\"recipientIdentifier\": \"${studentEmail}\","
                + "\"responseDetails\": {\"answer\": \"<p>test</p>\", \"questionType\": \"TEXT\"}}";
        String path = "webapi/response?questionid=${question" + i + "id}"
                + "&intent=STUDENT_SUBMISSION";
        threadGroup.add(JMeterElements.httpSampler(path, POST, body));
    }

    return testPlan;
}
 
Example #3
Source File: InstructorStudentEnrollmentLNPTest.java    From teammates with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected ListedHashTree getLnpTestPlan() {
    ListedHashTree testPlan = new ListedHashTree(JMeterElements.testPlan());
    HashTree threadGroup = testPlan.add(
            JMeterElements.threadGroup(NUM_INSTRUCTORS, RAMP_UP_PERIOD, 1));

    threadGroup.add(JMeterElements.csvDataSet(getPathToTestDataFile(getCsvConfigPath())));
    threadGroup.add(JMeterElements.cookieManager());
    threadGroup.add(JMeterElements.defaultSampler());

    threadGroup.add(JMeterElements.onceOnlyController())
            .add(JMeterElements.loginSampler())
            .add(JMeterElements.csrfExtractor("csrfToken"));

    // Add HTTP sampler for test endpoint
    HeaderManager headerManager = JMeterElements.headerManager(getRequestHeaders());
    threadGroup.add(JMeterElements.httpSampler(getTestEndpoint(), PUT, "${enrollData}"))
            .add(headerManager);

    return testPlan;
}
 
Example #4
Source File: JmxHeaderManager.java    From postman2jmx with MIT License 5 votes vote down vote up
public static HeaderManager newInstance(String name, List<PostmanHeader> headers) {
    HeaderManager headerManager = new HeaderManager();
    headerManager.setProperty(TestElement.GUI_CLASS, HeaderPanel.class.getName());
    headerManager.setProperty(TestElement.TEST_CLASS, HeaderManager.class.getName());
    headerManager.setEnabled(true);
    headerManager.setName(name);

    for (PostmanHeader header : headers) {

        headerManager.add(new Header(header.getKey(), header.getValue()));
    }

    return headerManager;
}
 
Example #5
Source File: WebSocketAbstractSampler.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void addTestElement(TestElement el) {
	if (el instanceof HeaderManager) {
		setHeaderManager((HeaderManager) el);
	} else if (el instanceof CookieManager) {
		setCookieManager((CookieManager) el);
	} else {
		super.addTestElement(el);
	}
}
 
Example #6
Source File: WebSocketAbstractSampler.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
public void setHeaderManager(HeaderManager value) {
	HeaderManager mgr = getHeaderManager();
	if (mgr != null) {
		value = mgr.merge(value, true);
		if (log.isDebugEnabled()) {
			log.debug("Existing HeaderManager '" + mgr.getName() + "' merged with '" + value.getName() + "'");
			for (int i = 0; i < value.getHeaders().size(); i++) {
				log.debug("    " + value.getHeader(i).getName() + "=" + value.getHeader(i).getValue());
			}
		}
	}
	setProperty(new TestElementProperty(HEADER_MANAGER, value));
}
 
Example #7
Source File: HTTP2Sampler.java    From jmeter-http2-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void addTestElement(TestElement el) {
    if (el instanceof HeaderManager) {
        HeaderManager value = (HeaderManager) el;
        HeaderManager currentHeaderManager = getHeaderManager();
        if (currentHeaderManager != null) {
            value = currentHeaderManager.merge(value, true);
        }
        setProperty(new TestElementProperty(HTTPSamplerBase.HEADER_MANAGER, value));
    } else {
        super.addTestElement(el);
    }
}
 
Example #8
Source File: HTTP2Sampler.java    From jmeter-http2-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public SampleResult sample(Entry e)
{
    log.debug("sample()");

    // Load test elements
    HeaderManager headerManager = (HeaderManager)getProperty(HTTPSamplerBase.HEADER_MANAGER).getObjectValue();

    // Send H2 request
    NettyHttp2Client client = new NettyHttp2Client(getMethod(), getDomain(), getPort(), getPath(), headerManager);
    SampleResult res = client.request();
    res.setSampleLabel(getName());

    return res;
}
 
Example #9
Source File: NettyHttp2Client.java    From jmeter-http2-plugin with Apache License 2.0 5 votes vote down vote up
public NettyHttp2Client(String method, String host, int port, String path, HeaderManager headerManager) {
    this.method = method;
    this.host = host;
    this.port = port;
    this.path = path;
    this.headerManager = headerManager;
}
 
Example #10
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 #11
Source File: WebSocketSampler.java    From JMeter-WebSocketSampler with Apache License 2.0 5 votes vote down vote up
public void addTestElement(TestElement el) {
    if (el instanceof HeaderManager) {
        headerManager = (HeaderManager) el;
    } else {
        super.addTestElement(el);
    }
}
 
Example #12
Source File: WebSocketAbstractSampler.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
private HeaderManager getHeaderManager() {
	HeaderManager headerManager = (HeaderManager) getProperty(this.HEADER_MANAGER).getObjectValue();
    return headerManager;
}
 
Example #13
Source File: HTTP2Sampler.java    From jmeter-http2-plugin with Apache License 2.0 4 votes vote down vote up
private HeaderManager getHeaderManager() {
    return (HeaderManager)getProperty(HTTPSamplerBase.HEADER_MANAGER).getObjectValue();
}