use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class ParseCurlCommandActionTest method testCreateCookieManager.
@Test
public void testCreateCookieManager(@TempDir Path tempDir) throws Exception {
ParseCurlCommandAction p = new ParseCurlCommandAction();
CookieManager cookieManager = new CookieManager();
BasicCurlParser basicCurlParser = new BasicCurlParser();
Request request = basicCurlParser.parse("curl 'http://jmeter.apache.org/' -b 'name=Tom'");
Method method = getMethodFor("createCookieManager", CookieManager.class, Request.class);
method.invoke(p, cookieManager, request);
assertEquals("jmeter.apache.org", cookieManager.get(0).getDomain(), "the domain of cookie should be set in cookieManager");
assertEquals("/", cookieManager.get(0).getPath(), "the path of cookie should be set in cookieManager");
assertEquals("name", cookieManager.get(0).getName(), "the name of cookie should be set in cookieManager");
assertEquals("Tom", cookieManager.get(0).getValue(), "the password of cookie should be set in cookieManager");
cookieManager = new CookieManager();
String filepath = tempDir.resolve("test.txt").toAbsolutePath().toString();
assertTrue(tempDir.resolve("test.txt").toFile().createNewFile());
request = basicCurlParser.parse("curl 'http://jmeter.apache.org/' -b '" + filepath + "'");
method.invoke(p, cookieManager, request);
request = basicCurlParser.parse("curl 'http://jmeter.apache.org/' -b 'test1.txt'");
try {
method.invoke(p, cookieManager, request);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof IllegalArgumentException) {
assertTrue(cause.getMessage().contains("File test1.txt doesn't exist"));
}
}
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class ParseCurlCommandActionTest method testDnsServer.
@Test
public void testDnsServer() throws Exception {
ParseCurlCommandAction p = new ParseCurlCommandAction();
DNSCacheManager dnsCacheManager = new DNSCacheManager();
BasicCurlParser basicCurlParser = new BasicCurlParser();
Request request = basicCurlParser.parse("curl 'http://jmeter.apache.org/' --dns-servers '0.0.0.0'");
Method method = getMethodFor("createDnsServer", Request.class, DNSCacheManager.class);
method.invoke(p, request, dnsCacheManager);
assertEquals("0.0.0.0", dnsCacheManager.getServers().get(0).getStringValue(), "the dns server should be set in DNSCacheManager");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testSetRequestMethodOnData.
@Test
public void testSetRequestMethodOnData() {
String cmdLine = "curl -X PUT -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());
assertEquals("PUT", request.getMethod());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testNoproxy.
@Test
public void testNoproxy() {
String cmdLine = "curl 'http://jmeter.apache.org/' --noproxy 'localhost'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("localhost", request.getNoproxy());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testDoubleQuote.
@Test
public void testDoubleQuote() {
String cmdLine = "curl \"http://jmeter.apache.org/\"";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("http://jmeter.apache.org/", request.getUrl());
}
Aggregations