Search in sources :

Example 31 with BasicCurlParser

use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.

the class BasicCurlParserTest method testReferer.

@Test
public void testReferer() {
    String cmdLine = "curl 'http://jmeter.apache.org/' --referer 'www.baidu.com'";
    BasicCurlParser basicCurlParser = new BasicCurlParser();
    BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
    assertTrue(request.getHeaders().contains(Pair.of("Referer", "www.baidu.com")));
}
Also used : BasicCurlParser(org.apache.jmeter.protocol.http.curl.BasicCurlParser) Test(org.junit.jupiter.api.Test)

Example 32 with BasicCurlParser

use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.

the class BasicCurlParserTest method testCertStatus.

@Test
public void testCertStatus() {
    String cmdLine = "curl 'http://jmeter.apache.org/'  --cert-status ";
    BasicCurlParser basicCurlParser = new BasicCurlParser();
    BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
    assertEquals("cert-status", request.getCaCert(), "With method 'parser',the cacert need to show a warning' ");
}
Also used : BasicCurlParser(org.apache.jmeter.protocol.http.curl.BasicCurlParser) Test(org.junit.jupiter.api.Test)

Example 33 with BasicCurlParser

use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.

the class BasicCurlParserTest method testDataUrlEncodeOneParameterWithoutName.

@Test
public void testDataUrlEncodeOneParameterWithoutName() {
    String cmdLine = "curl 'https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_submit/action_page.php' " + "-H 'cache-control: no-cache' --data-urlencode 'é' ";
    BasicCurlParser basicCurlParser = new BasicCurlParser();
    BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
    assertEquals("%C3%A9", request.getPostData(), "With method 'parser',the parameters need to be encoded' ");
}
Also used : BasicCurlParser(org.apache.jmeter.protocol.http.curl.BasicCurlParser) Test(org.junit.jupiter.api.Test)

Example 34 with BasicCurlParser

use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.

the class BasicCurlParserTest method testAuthMechanismIsBasic.

@Test
public void testAuthMechanismIsBasic() {
    String cmdLine = "curl 'http://jmeter.apache.org/' -u 'arun:12345' --basic";
    BasicCurlParser basicCurlParser = new BasicCurlParser();
    BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
    assertEquals("BASIC", request.getAuthorization().getMechanism().toString());
}
Also used : BasicCurlParser(org.apache.jmeter.protocol.http.curl.BasicCurlParser) Test(org.junit.jupiter.api.Test)

Example 35 with BasicCurlParser

use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.

the class BasicCurlParserTest method testGet.

@Test
public void testGet() {
    String cmdLine = "curl -X POST  \"https://api.imgur.com/3/upload\" " + " -H 'Authorization: Client-ID fb52f2bfa714a36' --data   " + "'name=aaa%&lname=bbb' -G";
    BasicCurlParser basicCurlParser = new BasicCurlParser();
    BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
    assertEquals("https://api.imgur.com/3/upload?name=aaa%&lname=bbb", request.getUrl(), "With method 'parser', it should put the post data in the url");
    assertEquals("GET", request.getMethod(), "With method 'parser',the method should be 'GET'");
}
Also used : BasicCurlParser(org.apache.jmeter.protocol.http.curl.BasicCurlParser) Test(org.junit.jupiter.api.Test)

Aggregations

BasicCurlParser (org.apache.jmeter.protocol.http.curl.BasicCurlParser)84 Test (org.junit.jupiter.api.Test)81 Request (org.apache.jmeter.protocol.http.curl.BasicCurlParser.Request)20 ParseCurlCommandAction (org.apache.jmeter.protocol.http.gui.action.ParseCurlCommandAction)19 Method (java.lang.reflect.Method)16 Pair (org.apache.commons.lang3.tuple.Pair)8 HTTPSamplerProxy (org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy)6 DNSCacheManager (org.apache.jmeter.protocol.http.control.DNSCacheManager)4 AuthManager (org.apache.jmeter.protocol.http.control.AuthManager)3 HttpTestSampleGui (org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Authorization (org.apache.jmeter.protocol.http.control.Authorization)2 Cookie (org.apache.jmeter.protocol.http.control.Cookie)2 CookieManager (org.apache.jmeter.protocol.http.control.CookieManager)2 TestPlan (org.apache.jmeter.testelement.TestPlan)2 ThreadGroup (org.apache.jmeter.threads.ThreadGroup)2 HashTree (org.apache.jorphan.collections.HashTree)2 Field (java.lang.reflect.Field)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1