use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testBackslashAtLineEnding.
@Test
public void testBackslashAtLineEnding() {
String cmdLine = "curl \\\n-d 'hey' http://jmeter.apache.org/";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("http://jmeter.apache.org/", request.getUrl());
assertEquals("hey", request.getPostData());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testCapath.
@Test
public void testCapath() {
String cmdLine = "curl 'http://jmeter.apache.org/' --capath 'test.pem' ";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("capath", request.getCaCert(), "With method 'parser',the cacert need to show a warning'");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testCookie.
@Test
public void testCookie() {
String cmdLine = "curl -X POST \"https://api.imgur.com/3/upload\" -b 'name=Tom;password=123456'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
Cookie c1 = new Cookie();
c1.setDomain("api.imgur.com");
c1.setName("name");
c1.setValue("Tom");
c1.setPath("/3/upload");
Cookie c2 = new Cookie();
c2.setDomain("api.imgur.com");
c2.setName("password");
c2.setValue("123456");
c2.setPath("/3/upload");
assertTrue(request.getCookies("https://api.imgur.com/3/upload").contains(c1), "With method 'parser', the cookie should be set in CookieManager");
assertTrue(request.getCookies("https://api.imgur.com/3/upload").contains(c2), "With method 'parser', the cookie should be set in CookieManager");
assertEquals(2, request.getCookies("https://api.imgur.com/3/upload").size(), "With method 'parser', the cookie should be set in CookieManager");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testProxyDefaultPort.
@Test
public void testProxyDefaultPort() {
String cmdLine = "curl 'http://jmeter.apache.org/' -x 'https://example.com'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("1080", request.getProxyServer().get("port"), "With method 'parser',the default port of proxy should be 1080");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class ParseCurlCommandActionTest method testCreateProxyServer.
@Test
public void testCreateProxyServer() throws Exception {
ParseCurlCommandAction p = new ParseCurlCommandAction();
HTTPSamplerProxy httpSampler = (HTTPSamplerProxy) HTTPSamplerFactory.newInstance(HTTPSamplerFactory.DEFAULT_CLASSNAME);
httpSampler.setProperty(TestElement.GUI_CLASS, HttpTestSampleGui.class.getName());
httpSampler.setProperty(TestElement.NAME, "HTTP Request");
BasicCurlParser basicCurlParser = new BasicCurlParser();
Request request = basicCurlParser.parse("curl 'http://jmeter.apache.org/' -x 'https://aa:bb@example.com:8042'");
Method method = getMethodFor("createProxyServer", Request.class, HTTPSamplerProxy.class);
method.invoke(p, request, httpSampler);
assertEquals("example.com", httpSampler.getProxyHost(), "proxy host should be set in httpsampler");
assertEquals("aa", httpSampler.getProxyUser(), "proxy user should be set in httpsampler");
assertEquals("bb", httpSampler.getProxyPass(), "proxy pass should be set in httpsampler");
assertEquals("https", httpSampler.getProxyScheme(), "proxy scheme should be set in httpsampler");
assertEquals("example.com", httpSampler.getProxyHost(), "proxy host should be set in httpsampler");
assertEquals(8042, httpSampler.getProxyPortInt(), "The command line should be parsed in turn");
}
Aggregations