Esempio n. 1
0
 @Test
 @SuppressWarnings("unchecked")
 public void testDirectoryResourceReifyShouldRetunNullForFiles() throws IOException {
   File file = File.createTempFile("fileresourcetest", ".tmp");
   file.deleteOnExit();
   FileResource<?> fileResource = resourceFactory.create(FileResource.class, file);
   Assert.assertNotNull(fileResource);
   Assert.assertNull(fileResource.reify(DirectoryResource.class));
 }
Esempio n. 2
0
 @Test
 public void testAppendableOutputStream() throws IOException {
   File file = File.createTempFile("fileresourcetest", ".tmp");
   file.deleteOnExit();
   FileResource<?> fileResource = resourceFactory.create(file).reify(FileResource.class);
   Assert.assertNotNull(fileResource);
   Assert.assertNull(fileResource.reify(DirectoryResource.class));
   try (OutputStream os = fileResource.getResourceOutputStream(false)) {
     os.write("HELLO".getBytes());
     os.flush();
   }
   Assert.assertEquals("HELLO", fileResource.getContents());
   try (OutputStream os = fileResource.getResourceOutputStream(true)) {
     os.write(" WORLD".getBytes());
     os.flush();
   }
   Assert.assertEquals("HELLO WORLD", fileResource.getContents());
   try (OutputStream os = fileResource.getResourceOutputStream()) {
     os.write("GOODBYE".getBytes());
     os.flush();
   }
   Assert.assertEquals("GOODBYE", fileResource.getContents());
 }