@@ -47,7 +47,7 @@ public void testStartBasicHttpServer() throws Exception {
4747 httpServer .initialize (httpServiceProvider );
4848 assertTrue (httpServer .startServer (0 ));
4949 int port = httpServer .getListeningPort ();
50- HttpResponse httpResponse = sendGet (getUrl (port , HttpRouter .HEARTBEAT ));
50+ HttpResponse httpResponse = send (getUrl (port , HttpRouter .HEARTBEAT ), HttpServer . Method . GET );
5151 assertEquals (HttpServer .StatusCode .OK .getValue (), httpResponse .responseCode );
5252 assertEquals (HeartbeatService .HEARTBEAT .trim (), httpResponse .responseBody .trim ());
5353 httpServer .stopServer ();
@@ -60,17 +60,33 @@ public void testStartMetricsServiceOnRouterPath() throws Exception {
6060 httpServer .initialize (httpServiceProvider );
6161 assertTrue (httpServer .startServer (0 ));
6262 int port = httpServer .getListeningPort ();
63- HttpResponse httpResponse = sendGet (getUrl (port , HttpRouter .METRICS ));
63+ HttpResponse httpResponse = send (getUrl (port , HttpRouter .METRICS ), HttpServer . Method . GET );
6464 assertEquals (HttpServer .StatusCode .OK .getValue (), httpResponse .responseCode );
6565 httpServer .stopServer ();
6666 }
6767
68- // HTTP GET request
69- private HttpResponse sendGet (String url ) throws IOException {
68+ @ Test
69+ public void testHttpMethods () throws Exception {
70+ VertxHttpServer httpServer = new VertxHttpServer ();
71+ HttpServiceProvider httpServiceProvider = NullHttpServiceProvider .getInstance ();
72+ httpServer .initialize (httpServiceProvider );
73+ assertTrue (httpServer .startServer (0 ));
74+ int port = httpServer .getListeningPort ();
75+ HttpResponse httpResponse = send (getUrl (port , HttpRouter .GC ), HttpServer .Method .GET );
76+ assertEquals (HttpServer .StatusCode .OK .getValue (), httpResponse .responseCode );
77+ httpResponse = send (getUrl (port , HttpRouter .GC ), HttpServer .Method .POST );
78+ assertEquals (HttpServer .StatusCode .OK .getValue (), httpResponse .responseCode );
79+ httpResponse = send (getUrl (port , HttpRouter .GC ), HttpServer .Method .PUT );
80+ assertEquals (HttpServer .StatusCode .OK .getValue (), httpResponse .responseCode );
81+ httpServer .stopServer ();
82+ }
83+
84+ // HTTP request
85+ private HttpResponse send (String url , HttpServer .Method method ) throws IOException {
7086 URL obj = new URL (url );
7187 HttpURLConnection con = (HttpURLConnection ) obj .openConnection ();
7288 // optional, default is GET
73- con .setRequestMethod ("GET" );
89+ con .setRequestMethod (method . toString () );
7490 int responseCode = con .getResponseCode ();
7591 StringBuilder response = new StringBuilder ();
7692 BufferedReader in = null ;
0 commit comments