package examples.routing;

import com.vtence.molecule.WebServer;
import com.vtence.molecule.support.http.DeprecatedHttpRequest;
import com.vtence.molecule.support.http.DeprecatedHttpResponse;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;

public class RoutingTest {

    RoutingExample routing = new RoutingExample();
    WebServer server = WebServer.create(9999);

    DeprecatedHttpRequest request = new DeprecatedHttpRequest(9999);
    DeprecatedHttpResponse response;

    @Before
    public void startServer() throws IOException {
        routing.run(server);
    }

    @After
    public void stopServer() throws IOException {
        server.stop();
    }

    @Test
    public void mappingRoutesToUrls() throws IOException {
        response = request.get("/");
        response.assertHasStatusCode(200);
        response.assertContentEqualTo("Welcome!");
    }

    @Test
    public void restrictingARouteToASpecificVerb() throws IOException {
        response = request.followRedirects(false).withParameter("username", "Vincent").post("/login");
        response.assertHasStatusCode(303);
    }

    @Test
    public void bindingDynamicRequestParametersToPath() throws IOException {
        response = request.get("/hello/Vincent");
        response.assertHasStatusCode(200);
        response.assertHasContentType("text/html");
        response.assertContentEqualTo("<html><body><h3>Hello, Vincent</h3></body></html>");
    }

    @Test
    public void requestingAnUndefinedRoute() throws IOException {
        response = request.get("/nowhere");
        response.assertHasStatusCode(404);
    }
}
@@ -85,39 +85,63 @@
 olecule.
-support.http.Deprecated
+test.HtmlForm;%0Aimport com.vtence.molecule.test.
 HttpRequ
@@ -176,31 +176,13 @@
 ule.
-support.http.Deprecated
+test.
 Http
@@ -293,16 +293,87 @@
 ption;%0A%0A
+import static com.vtence.molecule.test.HttpResponseAssert.assertThat;%0A%0A
 public c
@@ -491,34 +491,24 @@
 9999);%0A%0A    
-Deprecated
 HttpRequest 
@@ -521,26 +521,16 @@
 t = new 
-Deprecated
 HttpRequ
@@ -548,18 +548,8 @@
     
-Deprecated
 Http
@@ -876,80 +876,76 @@
     
-response.assertHasStatusCode(200);%0A        response.assertContentEqualTo
+assertThat(response).isOK()%0A                            .hasBodyText
 (%22We
@@ -1074,44 +1074,31 @@
 est.
-followRedirects(false).withParameter
+body(new HtmlForm().set
 (%22us
@@ -1116,16 +1116,17 @@
 incent%22)
+)
 .post(%22/
@@ -1142,32 +1142,38 @@
         
-response.assertH
+assertThat(response).h
 asStatus
@@ -1339,67 +1339,66 @@
     
-response.assertHasStatusCode(200);%0A        response.assertH
+assertThat(response).isOK()%0A                            .h
 asCo
@@ -1419,17 +1419,16 @@
 t/html%22)
-;
 %0A       
@@ -1432,37 +1432,40 @@
     
-response.assertContentEqualTo
+                    .hasBodyText
 (%22%3Ch
@@ -1654,24 +1654,30 @@
     
-response.assertH
+assertThat(response).h
 asSt

Use lite http client in routing example