public void testCreateList() throws IOException { URI dir = store.createList("dir", tmp); assertTrue(new File(dir).isDirectory()); }
public void testListAcceptableFiles() throws IOException { URI dir = store.createList("dir", tmp); final File text = File.createTempFile("test", ".txt", new File(dir)); final File xml = File.createTempFile("test", ".xml", new File(dir)); final File json = File.createTempFile("test", ".json", new File(dir)); final File zip = File.createTempFile("test", ".zip", new File(dir)); assertEquals(4, store.listAcceptableFiles(new File(dir), "*/*").length); assertEquals(Collections.singletonList(text), Arrays.asList(store.listAcceptableFiles(new File(dir), "text/plain"))); assertEquals(Collections.singletonList(xml), Arrays.asList(store.listAcceptableFiles(new File(dir), "application/xml"))); assertEquals(Collections.singletonList(json), Arrays.asList(store.listAcceptableFiles(new File(dir), "application/json"))); assertEquals(Collections.singletonList(zip), Arrays.asList(store.listAcceptableFiles(new File(dir), "application/zip"))); zip.delete(); json.delete(); xml.delete(); text.delete(); new File(dir).delete(); }
public void testListEachEntry() throws IOException { URI dir = store.createList("dir", tmp); final File text = File.createTempFile("test", ".txt", new File(dir)); final File xml = File.createTempFile("test", ".xml", new File(dir)); store.listEachEntry("dir", tmp, "text/plain", new DataInfo() { public void list(URI id, String media, long lastModified) throws IOException { assertEquals("text/plain", media); assertEquals(text.getAbsolutePath(), new File(id).getAbsolutePath()); } }); store.listEachEntry("dir", tmp, "application/xml", new DataInfo() { public void list(URI id, String media, long lastModified) throws IOException { assertEquals("application/xml", media); assertEquals(xml.getAbsolutePath(), new File(id).getAbsolutePath()); } }); store.deleteEntry(text.getPath(), tmp); store.deleteEntry(xml.getPath(), tmp); store.deleteEntry(dir.getPath(), tmp); }