use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testFormWithQuotedNotFilename.
@Test
public void testFormWithQuotedNotFilename() {
// The quotes will be removed later by the consumer, which is ParseCurlCommandAction
String cmdLine = "curl 'https://www.exaple.invalid/' " + "--form 'image=\"@/some/file.jpg\"'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
List<Pair<String, ArgumentHolder>> res = request.getFormData();
assertTrue(res.contains(Pair.of("image", StringArgumentHolder.of("@/some/file.jpg"))), "With method 'form', we should post form data");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testMaxTime.
@Test
public void testMaxTime() {
String cmdLine = "curl 'http://jmeter.apache.org/' -m '2'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("2000.0", String.valueOf(request.getMaxTime()));
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testConnectMax.
@Test
public void testConnectMax() {
String cmdLine = "curl 'http://jmeter.apache.org/' -H 'Connection: keep-alive' " + "-H 'Upgrade-Insecure-Requests: 1' --connect-timeout '2'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("2000.0", String.valueOf(request.getConnectTimeout()), "With method 'parser' request should contain 'connect-timeout=2'");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testDataReadFromFile.
@Test
public void testDataReadFromFile() throws IOException {
String encoding = StandardCharsets.UTF_8.name();
FileUtils.writeStringToFile(tempFile, "name=test" + System.lineSeparator(), encoding, true);
String pathname = tempFile.getAbsolutePath();
String cmdLine = "curl 'https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_submit/action_page.php' " + "-H 'cache-control: no-cache' --data '@" + pathname + "' ";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("name=test", request.getPostData(), "With method 'parser',the parameters need to reserve '\n' and '\r' ");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testProxyUriIncorrectFormat.
@Test
public void testProxyUriIncorrectFormat() {
String cmdLine = "curl 'http://jmeter.apache.org/' -x 'https://xxxx.xxx?xxx=xxx|xxxx|'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
assertThrows(IllegalArgumentException.class, () -> basicCurlParser.parse(cmdLine), "The method 'translateCommandline shouldn't run when the uri of proxy is not in the correct format");
}
Aggregations