Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More whitespace and static import cleanup
  • Loading branch information
ajs6f committed Oct 21, 2013
1 parent d546a4b commit b63c416
Show file tree
Hide file tree
Showing 15 changed files with 268 additions and 286 deletions.
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.fcrepo.integration.kernel;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -49,67 +50,63 @@ public class DatastreamIT extends AbstractIT {

@Test
public void testCreatedDate() throws RepositoryException, IOException,
InvalidChecksumException {
InvalidChecksumException {
Session session = repo.login();
objectService.createObject(session, "/testDatastreamObject");
datastreamService
.createDatastreamNode(session,
"/testDatastreamObject/testDatastreamNode1",
"application/octet-stream",
new ByteArrayInputStream("asdf".getBytes()));
datastreamService.createDatastreamNode(session,
"/testDatastreamObject/testDatastreamNode1",
"application/octet-stream", new ByteArrayInputStream("asdf"
.getBytes()));
session.save();
session.logout();
session = repo.login();
final Datastream ds =
datastreamService
.getDatastream(session,
"/testDatastreamObject/testDatastreamNode1");
datastreamService.getDatastream(session,
"/testDatastreamObject/testDatastreamNode1");
assertNotNull("Couldn't find created date on datastream!", ds
.getCreatedDate());
.getCreatedDate());
}

@Test
public void testDatastreamContent()
throws IOException, RepositoryException, InvalidChecksumException {
public void testDatastreamContent() throws IOException,
RepositoryException,
InvalidChecksumException {
final Session session = repo.login();
objectService.createObject(session, "/testDatastreamObject");
datastreamService
.createDatastreamNode(session,
"/testDatastreamObject/testDatastreamNode1",
"application/octet-stream",
new ByteArrayInputStream("asdf".getBytes()));
datastreamService.createDatastreamNode(session,
"/testDatastreamObject/testDatastreamNode1",
"application/octet-stream", new ByteArrayInputStream("asdf"
.getBytes()));

session.save();

final Datastream ds =
datastreamService
.getDatastream(session,
"/testDatastreamObject/testDatastreamNode1");
datastreamService.getDatastream(session,
"/testDatastreamObject/testDatastreamNode1");
final String contentString = IOUtils.toString(ds.getContent(), "ASCII");

assertEquals("asdf", contentString);

}

@Test
public void testDatastreamContentDigestAndLength()
throws IOException, RepositoryException, InvalidChecksumException {
public void testDatastreamContentDigestAndLength() throws IOException,
RepositoryException,
InvalidChecksumException {
final Session session = repo.login();
objectService.createObject(session, "/testDatastreamObject");
datastreamService
.createDatastreamNode(session,
"/testDatastreamObject/testDatastreamNode2",
"application/octet-stream",
new ByteArrayInputStream("asdf".getBytes()));
datastreamService.createDatastreamNode(session,
"/testDatastreamObject/testDatastreamNode2",
"application/octet-stream", new ByteArrayInputStream("asdf"
.getBytes()));

session.save();

final Datastream ds =
datastreamService
.getDatastream(session,
"/testDatastreamObject/testDatastreamNode2");
datastreamService.getDatastream(session,
"/testDatastreamObject/testDatastreamNode2");
assertEquals("urn:sha1:3da541559918a808c2402bba5012f6c60b27661c", ds
.getContentDigest().toString());
.getContentDigest().toString());
assertEquals(4L, ds.getContentSize());

final String contentString = IOUtils.toString(ds.getContent(), "ASCII");
Expand All @@ -118,28 +115,27 @@ public void testDatastreamContentDigestAndLength()
}

@Test
public void testModifyDatastreamContentDigestAndLength()
throws IOException, RepositoryException, InvalidChecksumException {
public void
testModifyDatastreamContentDigestAndLength() throws IOException,
RepositoryException,
InvalidChecksumException {
final Session session = repo.login();
objectService.createObject(session, "/testDatastreamObject");
datastreamService
.createDatastreamNode(session,
"/testDatastreamObject/testDatastreamNode3",
"application/octet-stream",
new ByteArrayInputStream("asdf".getBytes()));
datastreamService.createDatastreamNode(session,
"/testDatastreamObject/testDatastreamNode3",
"application/octet-stream", new ByteArrayInputStream("asdf"
.getBytes()));

session.save();

final Datastream ds =
datastreamService
.getDatastream(session,
"/testDatastreamObject/testDatastreamNode3");

datastreamService.getDatastream(session,
"/testDatastreamObject/testDatastreamNode3");

ds.setContent(new ByteArrayInputStream("0123456789".getBytes()));

assertEquals("urn:sha1:87acec17cd9dcd20a716cc2cf67417b71c8a7016", ds
.getContentDigest().toString());
.getContentDigest().toString());
assertEquals(10L, ds.getContentSize());

final String contentString = IOUtils.toString(ds.getContent(), "ASCII");
Expand All @@ -148,26 +144,24 @@ public void testModifyDatastreamContentDigestAndLength()
}

@Test
public void testDatastreamContentWithChecksum()
throws IOException, RepositoryException, InvalidChecksumException {
public void testDatastreamContentWithChecksum() throws IOException,
RepositoryException,
InvalidChecksumException {
final Session session = repo.login();
objectService.createObject(session, "/testDatastreamObject");
datastreamService
.createDatastreamNode(session,
"/testDatastreamObject/testDatastreamNode4",
"application/octet-stream",
new ByteArrayInputStream("asdf".getBytes()),
ContentDigest.asURI("SHA-1",
"3da541559918a808c2402bba5012f6c60b27661c"));
datastreamService.createDatastreamNode(session,
"/testDatastreamObject/testDatastreamNode4",
"application/octet-stream", new ByteArrayInputStream("asdf"
.getBytes()), ContentDigest.asURI("SHA-1",
"3da541559918a808c2402bba5012f6c60b27661c"));

session.save();

final Datastream ds =
datastreamService
.getDatastream(session,
"/testDatastreamObject/testDatastreamNode4");
datastreamService.getDatastream(session,
"/testDatastreamObject/testDatastreamNode4");
assertEquals("urn:sha1:3da541559918a808c2402bba5012f6c60b27661c", ds
.getContentDigest().toString());
.getContentDigest().toString());

final String contentString = IOUtils.toString(ds.getContent(), "ASCII");

Expand Down
Expand Up @@ -15,7 +15,10 @@
*/
package org.fcrepo.integration.kernel;

import static com.hp.hpl.jena.update.UpdateAction.parseExecute;
import static java.util.regex.Pattern.compile;
import static org.fcrepo.kernel.RdfLexicon.RELATIONS_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.RESTAPI_NAMESPACE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand All @@ -37,7 +40,6 @@
import org.springframework.test.context.ContextConfiguration;

import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.update.UpdateAction;

@ContextConfiguration({"/spring-test/repo.xml"})
public class FedoraObjectIT extends AbstractIT {
Expand Down Expand Up @@ -84,23 +86,20 @@ public void testObjectGraph() throws Exception {
objectService.createObject(session, "/graphObject");
final Dataset graphStore = object.getPropertiesDataset(new DefaultGraphSubjects(session));

final String graphSubject =
RdfLexicon.RESTAPI_NAMESPACE + "/graphObject";
final String graphSubject = RESTAPI_NAMESPACE + "/graphObject";

assertFalse("Graph store should not contain JCR prefixes",
compile("jcr").matcher(graphStore.toString()).find());
assertFalse("Graph store should contain our fcrepo prefix",
compile("fcrepo")
.matcher(graphStore.toString()).find());

UpdateAction
.parseExecute("PREFIX dc: <http://purl.org/dc/terms/>\n" +
parseExecute("PREFIX dc: <http://purl.org/dc/terms/>\n" +
"INSERT { <http://example/egbook> dc:title " +
"\"This is an example of an update that will be " +
"ignored\" } WHERE {}", graphStore);

UpdateAction
.parseExecute("PREFIX dc: <http://purl.org/dc/terms/>\n" +
parseExecute("PREFIX dc: <http://purl.org/dc/terms/>\n" +
"INSERT { <" + graphSubject + "> dc:title " +
"\"This is an example title\" } WHERE {}",
graphStore);
Expand All @@ -111,8 +110,7 @@ public void testObjectGraph() throws Exception {
.getString().equals("This is an example title"));


UpdateAction
.parseExecute("PREFIX myurn: <info:myurn/>\n" +
parseExecute("PREFIX myurn: <info:myurn/>\n" +
"INSERT { <" + graphSubject + "> myurn:info " +
"\"This is some example data\";" +
"myurn:info \"And so it this\" } WHERE {}",
Expand All @@ -127,29 +125,26 @@ public void testObjectGraph() throws Exception {
assertEquals("And so it this", values[1].getString());


UpdateAction
.parseExecute("PREFIX fedora-rels-ext: <"
+ RdfLexicon.RELATIONS_NAMESPACE + ">\n" +
"INSERT { <" + graphSubject + "> fedora-rels-ext:" +
"isPartOf <" + graphSubject + "> } WHERE {}", graphStore);
parseExecute("PREFIX fedora-rels-ext: <"
+ RELATIONS_NAMESPACE + ">\n" + "INSERT { <" + graphSubject
+ "> fedora-rels-ext:" + "isPartOf <" + graphSubject
+ "> } WHERE {}", graphStore);
assertTrue(object.getNode().getProperty("fedorarelsext:isPartOf")
.getValues()[0].getString(),
object.getNode().getProperty("fedorarelsext:isPartOf")
.getValues()[0].getString()
.equals(object.getNode().getIdentifier()));


UpdateAction
.parseExecute("PREFIX dc: <http://purl.org/dc/terms/>\n" +
parseExecute("PREFIX dc: <http://purl.org/dc/terms/>\n" +
"DELETE { <" + graphSubject + "> dc:title " +
"\"This is an example title\" } WHERE {}",
graphStore);

assertFalse("Found unexpected dc:title",
object.getNode().hasProperty("dc:title"));

UpdateAction
.parseExecute("PREFIX fedora-rels-ext: <" +
parseExecute("PREFIX fedora-rels-ext: <" +
RdfLexicon.RELATIONS_NAMESPACE + ">\n" +
"DELETE { <" + graphSubject + "> " +
"fedora-rels-ext:isPartOf <" + graphSubject + "> " +
Expand Down

0 comments on commit b63c416

Please sign in to comment.