package peergos.server.tests;
import org.junit.Assert;
import org.junit.Test;
import peergos.server.net.FileHandler;
import peergos.server.net.StaticHandler;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
public class FileHandlerTests {
static final Path TEST_ROOT = Paths.get("test", "resources", "static_handler");
@Test
public void test_read() throws IOException {
FileHandler fileHandler = new FileHandler(TEST_ROOT, false);
for (String path : Arrays.asList("something.txt", "/something.txt")) {
StaticHandler.Asset asset = fileHandler.getAsset(path);
Assert.assertEquals(new String(asset.data), "The thing!");
}
StaticHandler.Asset hello = fileHandler.getAsset("test/hello.txt");
Assert.assertEquals(new String(hello.data), "Hello, Peergos!");
}
}