public void testInfoEntry() throws IOException { File file = File.createTempFile("test", ".txt"); FileWriter writer = new FileWriter(file); try { writer.write("read content"); } finally { writer.close(); } String uri = file.toURI().toASCIIString(); store.readEntry(uri, uri, "*/*", null, new DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException { assertEquals("text/plain", media); } }); store.deleteEntry(file.getPath(), tmp); }
public void testReadEntry() throws IOException { File file = File.createTempFile("test", ".txt"); FileWriter writer = new FileWriter(file); try { writer.write("read content"); } finally { writer.close(); } String uri = file.toURI().toASCIIString(); store.readEntry(uri, uri, "*/*", null, new DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException { byte[] buf = new byte[1024]; assertEquals("read content", new String(buf, 0, content.read(buf))); } }); store.deleteEntry(file.getPath(), tmp); }
public void testWriteFile() throws IOException { store.writeEntry("file.txt", tmp, "text/plain", new DataWriter() { public void store(OutputStream content) throws IOException { content.write("content".getBytes()); } }); store.readEntry("file.txt", tmp, "text/plain", null, new DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException { byte[] buf = new byte[1024]; assertEquals("content", new String(buf, 0, content.read(buf))); } }); store.deleteEntry("file.txt", tmp); }
public void testWriteDirectory() throws IOException { URI file = store.writeEntry("dir/", tmp, "text/plain", new DataWriter() { public void store(OutputStream content) throws IOException { content.write("content".getBytes()); } }); store.infoEntry(file.getPath(), tmp, "text/plain", new DataInfo() { public void list(URI id, String media, long lastModified) throws IOException { assertEquals("text/plain", media); } }); store.readEntry(file.getPath(), tmp, "text/plain", null, new DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException { byte[] buf = new byte[1024]; assertEquals("content", new String(buf, 0, content.read(buf))); } }); store.deleteEntry(file.getPath(), tmp); store.deleteEntry("dir", tmp); }