use of org.apache.http.client.methods.HttpTrace in project vespa by vespa-engine.
the class JDiscHttpServletTest method requireThatServerRespondsToAllMethods.
@Test
public void requireThatServerRespondsToAllMethods() throws Exception {
final TestDriver driver = TestDrivers.newInstance(newEchoHandler());
final URI uri = driver.client().newUri("/status.html");
driver.client().execute(new HttpGet(uri)).expectStatusCode(is(OK));
driver.client().execute(new HttpPost(uri)).expectStatusCode(is(OK));
driver.client().execute(new HttpHead(uri)).expectStatusCode(is(OK));
driver.client().execute(new HttpPut(uri)).expectStatusCode(is(OK));
driver.client().execute(new HttpDelete(uri)).expectStatusCode(is(OK));
driver.client().execute(new HttpOptions(uri)).expectStatusCode(is(OK));
driver.client().execute(new HttpTrace(uri)).expectStatusCode(is(OK));
driver.client().execute(new HttpPatch(uri)).expectStatusCode(is(OK));
assertThat(driver.close(), is(true));
}
use of org.apache.http.client.methods.HttpTrace in project nanohttpd by NanoHttpd.
the class SSLServerSocketFactoryTest method testSSLConnection.
@Test
public void testSSLConnection() throws ClientProtocolException, IOException {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpTrace httphead = new HttpTrace("https://localhost:9043/index.html");
HttpResponse response = httpclient.execute(httphead);
HttpEntity entity = response.getEntity();
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
Assert.assertEquals(9043, this.testServer.getListeningPort());
Assert.assertTrue(this.testServer.isAlive());
}
use of org.apache.http.client.methods.HttpTrace in project nanohttpd by NanoHttpd.
the class TestNanoFileUpLoad method testNormalRequest.
@Test
public void testNormalRequest() throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpTrace httphead = new HttpTrace("http://localhost:8192/index.html");
CloseableHttpResponse response = httpclient.execute(httphead);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
response.close();
}
use of org.apache.http.client.methods.HttpTrace in project nanohttpd by NanoHttpd.
the class HttpSSLServerTest method testSSLConnection.
@Test
public void testSSLConnection() throws ClientProtocolException, IOException {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpTrace httphead = new HttpTrace("https://localhost:9043/index.html");
HttpResponse response = httpclient.execute(httphead);
HttpEntity entity = response.getEntity();
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
Assert.assertEquals(9043, this.testServer.getListeningPort());
Assert.assertTrue(this.testServer.isAlive());
}
use of org.apache.http.client.methods.HttpTrace in project nanohttpd by NanoHttpd.
the class TestNanolets method staticFiles.
@Test
public void staticFiles() throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpTrace httphead = new HttpTrace("http://localhost:9090/browse/blabla.html");
CloseableHttpResponse response = httpclient.execute(httphead);
HttpEntity entity = response.getEntity();
String string = new String(readContents(entity), "UTF-8");
Assert.assertEquals("<html><body><h3>just a page</h3></body></html>", string);
response.close();
httphead = new HttpTrace("http://localhost:9090/browse/dir/blabla.html");
response = httpclient.execute(httphead);
entity = response.getEntity();
string = new String(readContents(entity), "UTF-8");
Assert.assertEquals("<html><body><h3>just an other page</h3></body></html>", string);
response.close();
httphead = new HttpTrace("http://localhost:9090/browse/dir/nanohttpd_logo.png");
response = httpclient.execute(httphead);
entity = response.getEntity();
Assert.assertEquals("image/png", entity.getContentType().getValue());
response.close();
httphead = new HttpTrace("http://localhost:9090/browse/dir/xxx.html");
response = httpclient.execute(httphead);
entity = response.getEntity();
string = new String(readContents(entity), "UTF-8");
Assert.assertEquals("<html><body><h3>Error 404: the requested page doesn't exist.</h3></body></html>", string);
response.close();
httphead = new HttpTrace("http://localhost:9090/browse/dir/");
response = httpclient.execute(httphead);
entity = response.getEntity();
string = new String(readContents(entity), "UTF-8");
Assert.assertEquals("<html><body><h3>just an index page</h3></body></html>", string);
response.close();
httphead = new HttpTrace("http://localhost:9090/browse/exception.html");
response = httpclient.execute(httphead);
Assert.assertEquals(Status.REQUEST_TIMEOUT.getRequestStatus(), response.getStatusLine().getStatusCode());
entity = response.getEntity();
string = new String(readContents(entity), "UTF-8");
Assert.assertEquals("", string);
response.close();
}
Aggregations