/*
 * Javalin - https://javalin.io
 * Copyright 2017 David Åse
 * Licensed under Apache 2.0: https://github.com/tipsy/javalin/blob/master/LICENSE
 *
 */

package io.javalin;

import io.javalin.util.SimpleHttpClient;
import java.io.IOException;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

/**
 * Created by enchanting on 03.08.17.
 */
public class TestIgnoreTrailingSlashes {

    private SimpleHttpClient simpleHttpClient = new SimpleHttpClient();

    @Test
    public void dontIgnoreTrailingSlashes() throws IOException {
        Javalin app = Javalin.create()
            .dontIgnoreTrailingSlashes()
            .start()
            .get("/hello", ctx -> ctx.result("Hello, slash!"));
        assertThat(simpleHttpClient.http_GET("http://localhost:7000/hello").getBody(), is("Hello, slash!"));
        assertThat(simpleHttpClient.http_GET("http://localhost:7000/hello/").getBody(), is("Not found"));
        app.stop();
    }

    @Test
    public void ignoreTrailingSlashes() throws IOException {
        Javalin app = Javalin.create()
            .start()
            .get("/hello", ctx -> ctx.result("Hello, slash!"));
        assertThat(simpleHttpClient.http_GET("http://localhost:7000/hello").getBody(), is("Hello, slash!"));
        assertThat(simpleHttpClient.http_GET("http://localhost:7000/hello/").getBody(), is("Hello, slash!"));
        app.stop();
    }

}

@@ -621,32 +621,53 @@
 avalin.create()%0A
+            .port(0)%0A
             .don
@@ -691,16 +691,16 @@
 ashes()%0A
-
         
@@ -831,36 +831,50 @@
 ttp://localhost:
-7000
+%22 + app.port() + %22
 /hello%22).getBody
@@ -954,36 +954,50 @@
 ttp://localhost:
-7000
+%22 + app.port() + %22
 /hello/%22).getBod
@@ -1148,32 +1148,53 @@
 avalin.create()%0A
+            .port(0)%0A
             .sta
@@ -1321,28 +1321,42 @@
 //localhost:
-7000
+%22 + app.port() + %22
 /hello%22).get
@@ -1452,12 +1452,26 @@
 ost:
-7000
+%22 + app.port() + %22
 /hel

Use random port in trailing slash test