@Test public void testSourceWithFileUpload() throws Exception { Assume.assumeTrue(Network.isAppAlive()); String id = UUID.randomUUID().toString(); Source source = makeSource(id); Path tempFile = Files.createTempFile("soda_upload_test", ".txt"); byte[] content = "Test file content".getBytes(); Files.write(tempFile, content); File file = tempFile.toFile(); addFileLink(source, file); client.put(source, file); InputStream is = client.getExternalDocument(id, file.getName()); byte[] contentFromServer = new byte[content.length]; is.read(contentFromServer); is.close(); Assert.assertArrayEquals(content, contentFromServer); }
@Test(expected = DataStoreException.class) public void testNoFile() throws Exception { Assume.assumeTrue(Network.isAppAlive()); client.getExternalDocument(UUID.randomUUID().toString(), "no_such_file.txt"); }