package com.tomkp.moxy;

import com.google.common.io.Resources;
import com.tomkp.moxy.annotations.Moxy;
import com.tomkp.moxy.junit.MoxyRunner;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;

import static org.junit.Assert.assertEquals;

@RunWith(MoxyRunner.class)
public class FileResponseTests {


    @Test
    @Moxy(file = {"hello.xml"})
    public void fileResponse() throws Exception {
        assertEquals("<hello>Moxy</hello>", readUrl());
    }


    @Test
    @Moxy(file = {"hello.xml", "goodbye.xml"})
    public void fileResponses() throws Exception {
        assertEquals("<hello>Moxy</hello>", readUrl());
        assertEquals("<goodbye>Moxy</goodbye>", readUrl());
    }


    private String readUrl() throws IOException {
        return Resources.toString(new URL("http://localhost:9001"), Charset.forName("UTF-8"));
    }

}

@@ -769,24 +769,210 @@
 ));%0A    %7D%0A%0A%0A
+    @Test%0A    @Moxy(file = %7B%22/scripts/absolute.xml%22%7D)%0A    public void absolutePathFileResponse() throws Exception %7B%0A        assertEquals(%22%3Cabsolute%3EMoxy%3C/absolute%3E%22, readUrl());%0A    %7D%0A%0A%0A
     private 

test absolute paths