Search in sources :

Example 31 with Binary

use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.

the class TestSwift method testNullMime.

@Test
@Ignore
public void testNullMime() throws IOException {
    Map<String, String> meta = new HashMap<String, String>();
    meta.put("aap", "noot");
    URL u = new URL("https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png");
    Binary b = new Binary(u, true);
    osi.store(b);
// osi.set("test/factory",null, b, meta);
}
Also used : HashMap(java.util.HashMap) Binary(com.dexels.navajo.document.types.Binary) URL(java.net.URL) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 32 with Binary

use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.

the class TestBinary method testBinaryFromURL.

@Test
public void testBinaryFromURL() throws IOException {
    URL u = new URL("https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png");
    Binary b = new Binary(u, false);
    Assert.assertTrue("", b.getLength() > 2000);
}
Also used : Binary(com.dexels.navajo.document.types.Binary) URL(java.net.URL) Test(org.junit.Test)

Example 33 with Binary

use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.

the class TestBinary method testNonLazyBinary.

@Test
public void testNonLazyBinary() {
    Binary b1 = new Binary(getClass().getResourceAsStream("binary1.txt"));
    Assert.assertEquals(7, b1.getData().length);
}
Also used : Binary(com.dexels.navajo.document.types.Binary) Test(org.junit.Test)

Example 34 with Binary

use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.

the class TestBinary method testUnresolvedBinary.

@Test
public void testUnresolvedBinary() throws IOException {
    URL u = new URL("https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png");
    Binary b = new Binary(u, true);
    Assert.assertFalse(b.isResolved());
    Assert.assertTrue("", b.getData().length > 2000);
    Assert.assertTrue(b.isResolved());
}
Also used : Binary(com.dexels.navajo.document.types.Binary) URL(java.net.URL) Test(org.junit.Test)

Example 35 with Binary

use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.

the class TestBinary method testMimeDetection1.

@Test
// Ignore until we find a proper fix for this problem...
@Ignore
public void testMimeDetection1() throws IOException {
    // File-based test - no sandbox mode
    NavajoFactory.getInstance().setSandboxMode(false);
    URL url = this.getClass().getResource("doc1.doc");
    Binary binaryx = new Binary(new File(url.getFile()));
    Assert.assertEquals("application/msword", binaryx.guessContentType());
}
Also used : Binary(com.dexels.navajo.document.types.Binary) File(java.io.File) URL(java.net.URL) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Binary (com.dexels.navajo.document.types.Binary)139 Test (org.junit.Test)38 IOException (java.io.IOException)32 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)26 File (java.io.File)25 Ignore (org.junit.Ignore)17 Property (com.dexels.navajo.document.Property)16 URL (java.net.URL)16 UserException (com.dexels.navajo.script.api.UserException)14 OutputStream (java.io.OutputStream)13 FileOutputStream (java.io.FileOutputStream)12 Navajo (com.dexels.navajo.document.Navajo)11 MappableException (com.dexels.navajo.script.api.MappableException)11 FileInputStream (java.io.FileInputStream)9 InputStream (java.io.InputStream)9 Message (com.dexels.navajo.document.Message)8 StringWriter (java.io.StringWriter)8 OutputStreamWriter (java.io.OutputStreamWriter)7 NavajoException (com.dexels.navajo.document.NavajoException)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6