Navigation Menu

Skip to content

Commit

Permalink
tests for datastream service
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Feb 12, 2013
1 parent c52a989 commit 2ad6e52
Showing 1 changed file with 12 additions and 2 deletions.
@@ -1,5 +1,6 @@
package org.fcrepo.services;

import org.apache.tika.io.IOUtils;
import org.fcrepo.AbstractTest;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
Expand Down Expand Up @@ -35,14 +36,23 @@ public void testCreateDatastreamNode() throws Exception {
session = repository.login();

assertTrue(session.getRootNode().hasNode("testDatastreamNode"));

System.out.println(session.getNode("/testDatastreamNode").getNode(JCR_CONTENT).getProperty(JCR_DATA).getString());
assertEquals("asdf", session.getNode("/testDatastreamNode").getNode(JCR_CONTENT).getProperty(JCR_DATA).getString());

}

@Test
public void testGetDatastreamContentInputStream() throws Exception {
Session session = repository.login();
InputStream is = new ByteArrayInputStream("asdf".getBytes());

Node n = new DatastreamService().createDatastreamNode(session, "testDatastreamNode", "application/octet-stream", is);

session.save();

session = repository.login();

InputStream contentInputStream = new DatastreamService().getDatastreamContentInputStream(session, "/testDatastreamNode");

assertEquals("asdf", IOUtils.toString(contentInputStream, "UTF-8"));
}
}

0 comments on commit 2ad6e52

Please sign in to comment.