use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class HttpRequestWrapperTest method testRequestBasics.
@Test
public void testRequestBasics() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, "/stuff");
final HttpRequestWrapper httpRequestWrapper = new HttpRequestWrapper(request);
Assertions.assertEquals(Method.GET.name(), httpRequestWrapper.getMethod());
Assertions.assertEquals("/stuff", httpRequestWrapper.getPath());
Assertions.assertNull(httpRequestWrapper.getAuthority());
Assertions.assertEquals(new URI("/stuff"), httpRequestWrapper.getUri());
httpRequestWrapper.setPath("/another-stuff");
Assertions.assertEquals("/another-stuff", httpRequestWrapper.getPath());
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class HttpRequestWrapperTest method testRequestWithUserInfo.
@Test
public void testRequestWithUserInfo() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, new URI("https://user:pwd@host:9443/stuff?param=value"));
final HttpRequestWrapper httpRequestWrapper = new HttpRequestWrapper(request);
Assertions.assertEquals(Method.GET.name(), httpRequestWrapper.getMethod());
Assertions.assertEquals("/stuff?param=value", httpRequestWrapper.getPath());
Assertions.assertEquals(new URIAuthority("user:pwd", "host", 9443), httpRequestWrapper.getAuthority());
Assertions.assertEquals("https", httpRequestWrapper.getScheme());
Assertions.assertEquals(new URI("https://host:9443/stuff?param=value"), httpRequestWrapper.getUri());
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class HttpRequestWrapperTest method testRequestWithAuthorityRelativePath.
@Test
public void testRequestWithAuthorityRelativePath() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, new HttpHost("http", "somehost", -1), "stuff");
final HttpRequestWrapper httpRequestWrapper = new HttpRequestWrapper(request);
Assertions.assertEquals(Method.GET.name(), httpRequestWrapper.getMethod());
Assertions.assertEquals("stuff", httpRequestWrapper.getPath());
Assertions.assertEquals("stuff", httpRequestWrapper.getRequestUri());
Assertions.assertEquals(new URIAuthority("somehost"), httpRequestWrapper.getAuthority());
Assertions.assertEquals(new URI("http://somehost/stuff"), httpRequestWrapper.getUri());
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class HttpRequestWrapperTest method testRequestWithNoPath.
@Test
public void testRequestWithNoPath() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, new URI("http://host"));
final HttpRequestWrapper httpRequestWrapper = new HttpRequestWrapper(request);
Assertions.assertEquals(Method.GET.name(), httpRequestWrapper.getMethod());
Assertions.assertEquals("/", httpRequestWrapper.getPath());
Assertions.assertEquals(new URIAuthority("host"), httpRequestWrapper.getAuthority());
Assertions.assertEquals("http", httpRequestWrapper.getScheme());
Assertions.assertEquals(new URI("http://host/"), httpRequestWrapper.getUri());
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class HttpRequestWrapperTest method testDefaultRequestConstructors.
@Test
public void testDefaultRequestConstructors() {
final HttpRequest request1 = new BasicHttpRequest("WHATEVER", "/");
final HttpRequestWrapper httpRequestWrapper = new HttpRequestWrapper(request1);
Assertions.assertEquals("WHATEVER", httpRequestWrapper.getMethod());
Assertions.assertEquals("/", httpRequestWrapper.getPath());
final HttpRequest request2 = new BasicHttpRequest(Method.GET, "/");
final HttpRequestWrapper httpRequestWrapper2 = new HttpRequestWrapper(request2);
Assertions.assertEquals(Method.GET.name(), httpRequestWrapper2.getMethod());
Assertions.assertEquals("/", httpRequestWrapper2.getPath());
Assertions.assertThrows(NullPointerException.class, () -> new BasicHttpRequest(Method.GET, (URI) null));
}
Aggregations