package com.hamishrickerby.http_server;

import junit.framework.TestCase;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by rickerbh on 16/08/2016.
 */
public class DirectoryListingResponseTest extends TestCase {
    List<String> listing = new ArrayList<String>(Arrays.asList("test.html", "ihniwid.jpg"));

    public void testEnsureDirectoryListingTextMatchesFiles() {
        String responseText = getDirectoryListing();
        assertTrue(responseText.contains("/"));
        assertTrue(responseText.contains(listing.get(0)));
        assertTrue(responseText.contains(listing.get(1)));
    }

    private String getDirectoryListing() {
        DirectoryListingResponse response = new DirectoryListingResponse(new Request("GET / HTTP/1.1"));
        response.setRootPath("./src/test/resources");
        return new String(response.body());
    }

    public void testEnsureDirectoryListingHasHTMLLinks() {
        String responseText = getDirectoryListing();
        assertTrue(responseText.contains("<a href=\"/" + listing.get(0) + "\">" + listing.get(0) + "</a>"));
        assertTrue(responseText.contains("<a href=\"/" + listing.get(1) + "\">" + listing.get(1) + "</a>"));
    }
}

@@ -673,17 +673,39 @@
 yListing
-(
+ForPath(String location
 ) %7B%0A    
@@ -790,17 +790,32 @@
 st(%22GET 
-/
+%22 + location + %22
  HTTP/1.
@@ -921,24 +921,122 @@
 ());%0A    %7D%0A%0A
+    private String getDirectoryListing() %7B%0A        return getDirectoryListingForPath(%22/%22);%0A    %7D%0A%0A
     public v

Make directory listing test helper more generic