@Test public void testSimpleSourceUpload() throws Exception { Assume.assumeTrue(Network.isAppAlive()); String id = UUID.randomUUID().toString(); Source source = makeSource(id); client.put(source); Source fromServer = client.get(Source.class, id); Assert.assertEquals(id, fromServer.sourceInfo.dataSetInfo.uuid); }
@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); }