use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testData.
@Test
public void testData() {
String cmdLine = "curl 'https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_submit/action_page.php' " + "-H 'cache-control: no-cache' --data 'name=test' ";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("name=test", request.getPostData());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testChromeParsingNotCompressed.
@Test
public void testChromeParsingNotCompressed() {
String cmdLine = "curl 'https://jmeter.apache.org/' -H 'Proxy-Connection: keep-alive' " + "-H 'Proxy-Authorization: Basic XXXXXXXXX/' -H 'Upgrade-Insecure-Requests: 1' " + "-H 'User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/70.0.3538.102 Mobile Safari/537.36' " + "-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' " + "-H 'Accept-Encoding: gzip, deflate' " + "-H 'Accept-Language: en-US,en;q=0.9,fr;q=0.8'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("https://jmeter.apache.org/", request.getUrl());
assertEquals(7, request.getHeaders().size());
assertFalse(request.isCompressed());
assertEquals("GET", request.getMethod());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testMethodPut.
@Test
public void testMethodPut() {
String cmdLine = "curl -X 'PUT' 'https://jmeter.apache.org/test' " + "-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:63.0) Gecko/20100101 Firefox/63.0' -H 'Accept: */*' " + "-H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: https://www.example.com/' " + "-H 'content-type: application/json;charset=UTF-8' -H 'Origin: https://www.example.com' " + "-H 'DNT: 1' -H 'Connection: keep-alive' -H 'TE: Trailers'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("PUT", request.getMethod());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testProxy.
@Test
public void testProxy() {
String cmdLine = "curl 'http://jmeter.apache.org/' -x 'https://aa:bb@example.com:8042'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("example.com", request.getProxyServer().get("servername"), "With method 'parser',the host of proxy should be 'examole.com'");
assertEquals("8042", request.getProxyServer().get("port"), "With method 'parser',the port of proxy should be 8042");
assertEquals("https", request.getProxyServer().get("scheme"), "With method 'parser',the scheme of proxy should be https");
assertEquals("aa", request.getProxyServer().get("username"), "With method 'parser',the username of proxy should be aa");
assertEquals("bb", request.getProxyServer().get("password"), "With method 'parser',the password of proxy should be aa");
}
Aggregations