Commit 173ad1d6 authored by Gerrit Hübbers's avatar Gerrit Hübbers 🃏
Browse files

Add test for content resolving file protocol

parent 61cc65a5
......@@ -7,6 +7,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
......@@ -49,6 +50,7 @@ import com.j256.simplemagic.ContentInfo;
import com.j256.simplemagic.ContentInfoUtil;
import com.j256.simplemagic.ContentType;
public class ContentResolverTest {
private final static Logger LOG = LoggerFactory.getLogger(ContentResolverTest.class);
......@@ -627,6 +629,25 @@ public class ContentResolverTest {
assertEquals(expected, result);
}
@Test
public void resolveContentFromFileProtocol() throws IOException {
URL fileUrl = getClass().getClassLoader().getResource("Bundeskabinett_PDF.pdf");
File file = new File( fileUrl.getFile() );
LOG.info("file.absolutePath ={}", file.getAbsolutePath() );
LOG.info("file.canonicalPath={}", file.getCanonicalPath() );
String fileURIString = file.toURI().toString();
LOG.info("fileURIString ={}", fileURIString );
Metadatum metadatum = new SimpleMetadatum("dc.identifier.url", fileURIString);
Set<Metadatum> metadata = ImmutableSet.of(metadatum);
InputStream actual = ContentResolver.resolveContentInputStream(metadata);
InputStream expected = getClass().getResourceAsStream("/Bundeskabinett_PDF.pdf");
assertTrue( IOUtils.contentEquals(expected, actual) );
}
public static String unrootDomainName(String url) {
try {
String result;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment