use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testFFParsing.
@Test
public void testFFParsing() {
String cmdLine = "curl 'http://jmeter.apache.org/' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:63.0) Gecko/20100101 Firefox/63.0' " + "-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' " + "-H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'DNT: 1' " + "-H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("http://jmeter.apache.org/", request.getUrl());
assertEquals(5, request.getHeaders().size());
assertTrue(request.isCompressed());
assertEquals("GET", request.getMethod());
String resParser = "Request [compressed=true, url=http://jmeter.apache.org/, method=GET, headers=[(User-Agent,Mozilla/5.0 " + "(Macintosh; Intel Mac OS X 10.11; rv:63.0) Gecko/20100101 Firefox/63.0), (Accept,text/html,application/xhtml+xml," + "application/xml;q=0.9,*/*;q=0.8), (Accept-Language,en-US,en;q=0.5), (DNT,1), " + "(Upgrade-Insecure-Requests,1)]]";
assertEquals(resParser, request.toString(), "The method 'toString' should get all parameters correctly");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testFormWithEmptyValue.
@Test
public void testFormWithEmptyValue() {
String cmdLine = "curl 'https://example.invalid' -F 'test=\"\"' ";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
List<Pair<String, ArgumentHolder>> res = request.getFormData();
assertTrue(res.contains(Pair.of("test", StringArgumentHolder.of(""))), "With method 'parser', we should post form data: " + request.getFormData());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testDuplicatedKeyInData.
@Test
public void testDuplicatedKeyInData() {
String cmdLine = "curl 'https://example.invalid' " + "-H 'cache-control: no-cache' --data 'name=one' --data 'name=two' ";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("name=one&name=two", request.getPostData());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testNullCommand.
@Test
public void testNullCommand() {
String cmdLine = "";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("Request [compressed=false, url=null, method=GET, headers=[]]", request.toString(), "The method 'translateCommandline' should return 'null' when command is empty, ");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testProxyUser.
@Test
public void testProxyUser() {
String cmdLine = "curl 'http://jmeter.apache.org/' --proxy '201.36.208.19:3128' -U 'aa:bb'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("aa", request.getProxyServer().get("username"));
assertEquals("bb", request.getProxyServer().get("password"));
}
Aggregations