@Test public void testInputStreamBasedConstructor() { ByteArrayInputStream baos = new ByteArrayInputStream("Some Content".getBytes()); file = new DownloadFileImpl(baos, "somefile.txt", "text/plain"); assertEquals("It Set the File Name", "somefile.txt", file.getFileName()); assertEquals("It Set the content type", "text/plain", file.getContentType()); assertSame("It Wrappend the bytes", baos, file.getInputStream()); }
@Test public void testFileBasedConstructor() throws IOException { File f = File.createTempFile("temptest", "txt"); file = new DownloadFileImpl(f, "text/plain"); assertEquals("It Set the File Name", f.getName(), file.getFileName()); assertEquals("It Set the content type", "text/plain", file.getContentType()); assertEquals( "It Was a File Input Stream", FileInputStream.class, file.getInputStream().getClass()); }