Skip to content
Permalink
Browse files

Merge pull request #93 from futures/SourceCleanup

Code cleanup
  • Loading branch information...
cbeer committed Jul 4, 2013
2 parents 94857ea + b7765cb commit 6ddee904ba1349d367243e6be0131f5a19262730
Showing with 700 additions and 558 deletions.
  1. +1 −0 fcrepo-http-api/src/main/java/org/fcrepo/api/repository/FedoraRepositoryExport.java
  2. +3 −3 fcrepo-http-api/src/main/java/org/fcrepo/api/repository/FedoraRepositoryTransactions.java
  3. +0 −1 fcrepo-http-api/src/test/java/org/fcrepo/api/FedoraExportTest.java
  4. +6 −5 fcrepo-http-api/src/test/java/org/fcrepo/api/FedoraFieldSearchTest.java
  5. +11 −11 fcrepo-http-api/src/test/java/org/fcrepo/api/FedoraTransactionsTest.java
  6. +3 −3 fcrepo-http-api/src/test/java/org/fcrepo/api/FedoraUnnamedObjectsTest.java
  7. +51 −43 fcrepo-http-api/src/test/java/org/fcrepo/api/FedoraVersionsTest.java
  8. +13 −15 fcrepo-http-api/src/test/java/org/fcrepo/integration/api/FedoraDatastreamsIT.java
  9. +2 −2 fcrepo-http-api/src/test/java/org/fcrepo/integration/api/FedoraHtmlIT.java
  10. +31 −32 fcrepo-http-api/src/test/java/org/fcrepo/integration/api/FedoraNodesIT.java
  11. +7 −7 fcrepo-http-api/src/test/java/org/fcrepo/integration/api/FedoraWorkspacesIT.java
  12. +22 −21 fcrepo-http-api/src/test/java/org/fcrepo/url/HttpApiResourcesTest.java
  13. +2 −2 fcrepo-http-commons/src/main/java/org/fcrepo/api/rdf/QuadOrdering.java
  14. +5 −5 fcrepo-http-commons/src/main/java/org/fcrepo/exceptionhandlers/InvalidChecksumExceptionMapper.java
  15. +2 −2 ...po-http-commons/src/main/java/org/fcrepo/exceptionhandlers/TransactionMissingExceptionMapper.java
  16. +5 −5 ...o-http-commons/src/test/java/org/fcrepo/exceptionhandlers/InvalidChecksumExceptionMapperTest.java
  17. +20 −14 fcrepo-http-commons/src/test/java/org/fcrepo/responses/RdfSerializationUtilsTest.java
  18. +21 −26 fcrepo-http-commons/src/test/java/org/fcrepo/test/util/ContainerWrapper.java
  19. +1 −1 fcrepo-kernel/src/main/java/org/fcrepo/Datastream.java
  20. +2 −2 fcrepo-kernel/src/main/java/org/fcrepo/RdfLexicon.java
  21. +3 −2 fcrepo-kernel/src/main/java/org/fcrepo/TxAwareSession.java
  22. +4 −4 fcrepo-kernel/src/main/java/org/fcrepo/identifiers/UUIDPathMinter.java
  23. +1 −1 fcrepo-kernel/src/main/java/org/fcrepo/services/DatastreamService.java
  24. +1 −1 fcrepo-kernel/src/main/java/org/fcrepo/services/LowLevelStorageService.java
  25. +1 −1 fcrepo-kernel/src/main/java/org/fcrepo/services/NodeService.java
  26. +7 −6 fcrepo-kernel/src/main/java/org/fcrepo/services/RepositoryService.java
  27. +1 −1 fcrepo-kernel/src/main/java/org/fcrepo/services/ServiceHelpers.java
  28. +2 −2 fcrepo-kernel/src/main/java/org/fcrepo/services/TransactionService.java
  29. +2 −2 fcrepo-kernel/src/main/java/org/fcrepo/spring/ModeShapeRepositoryFactoryBean.java
  30. +6 −5 fcrepo-kernel/src/main/java/org/fcrepo/utils/NamespaceChangedStatementListener.java
  31. +2 −0 fcrepo-kernel/src/main/java/org/fcrepo/utils/NamespaceTools.java
  32. +1 −1 fcrepo-kernel/src/main/java/org/fcrepo/utils/infinispan/StoreChunkOutputStream.java
  33. +1 −1 fcrepo-kernel/src/test/java/org/fcrepo/TransactionTest.java
  34. +2 −2 fcrepo-kernel/src/test/java/org/fcrepo/identifiers/UUIDPathMinterTest.java
  35. +1 −1 fcrepo-kernel/src/test/java/org/fcrepo/integration/FedoraObjectIT.java
  36. +88 −53 fcrepo-kernel/src/test/java/org/fcrepo/services/DatastreamServiceTest.java
  37. +22 −25 fcrepo-kernel/src/test/java/org/fcrepo/services/RepositoryServiceTest.java
  38. +19 −17 fcrepo-kernel/src/test/java/org/fcrepo/services/TransactionServiceTest.java
  39. +18 −15 fcrepo-kernel/src/test/java/org/fcrepo/services/functions/CacheLocalTransformTest.java
  40. +1 −1 fcrepo-kernel/src/test/java/org/fcrepo/services/functions/GetClusterConfigurationTest.java
  41. +0 −1 fcrepo-kernel/src/test/java/org/fcrepo/spring/ModeShapeRepositoryFactoryBeanTest.java
  42. +298 −206 fcrepo-kernel/src/test/java/org/fcrepo/utils/JcrRdfToolsTest.java
  43. +10 −9 fcrepo-kernel/src/test/java/org/fcrepo/utils/NamespaceChangedStatementListenerTest.java
  44. +1 −1 fcrepo-kernel/src/test/java/org/fcrepo/utils/TestHelpers.java
@@ -18,6 +18,7 @@

import javax.jcr.Session;
import javax.ws.rs.Path;

import org.fcrepo.api.FedoraImport;
import org.fcrepo.session.InjectedSession;
import org.springframework.context.annotation.Scope;
@@ -16,14 +16,14 @@

package org.fcrepo.api.repository;

import javax.jcr.Session;
import javax.ws.rs.Path;

import org.fcrepo.api.FedoraTransactions;
import org.fcrepo.session.InjectedSession;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.jcr.Session;
import javax.ws.rs.Path;

/**
* This stub is a hack to mount the functionality of FedoraTransactions at the
* root of this webapp. Without it, the globbing from FedoraNodes would own this
@@ -27,7 +27,6 @@
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;

import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.ws.rs.core.StreamingOutput;

@@ -16,6 +16,8 @@

package org.fcrepo.api;

import static com.hp.hpl.jena.query.DatasetFactory.createMem;
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -42,7 +44,6 @@
import org.junit.Before;
import org.junit.Test;

import com.hp.hpl.jena.query.DatasetFactory;
import com.hp.hpl.jena.rdf.model.ResourceFactory;

public class FedoraFieldSearchTest {
@@ -71,9 +72,10 @@ public void tearDown() {

}

@SuppressWarnings("unchecked")
@Test
public void testFieldSearch() throws RepositoryException,
URISyntaxException {
URISyntaxException {

final Request mockRequest = mock(Request.class);

@@ -87,10 +89,9 @@ public void testFieldSearch() throws RepositoryException,
mockNodeService
.searchRepository(
any(GraphSubjects.class),
eq(ResourceFactory
.createResource("http://localhost/fcrepo/path/to/query/endpoint")),
eq(createResource("http://localhost/fcrepo/path/to/query/endpoint")),
eq(mockSession), eq("ZZZ"), eq(0), eq(0L)))
.thenReturn(DatasetFactory.create());
.thenReturn(createMem());
final UriBuilder mockUriBuilder = mock(UriBuilder.class);

when(mockUriBuilder.path(FedoraFieldSearch.class)).thenReturn(
@@ -16,24 +16,24 @@

package org.fcrepo.api;

import org.fcrepo.Transaction;
import org.fcrepo.TxAwareSession;
import org.fcrepo.services.TransactionService;
import org.fcrepo.test.util.TestHelpers;
import org.junit.Before;
import org.junit.Test;

import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.ws.rs.core.Response;

import static org.fcrepo.test.util.PathSegmentImpl.createPathList;
import static org.fcrepo.test.util.TestHelpers.mockSession;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.ws.rs.core.Response;

import org.fcrepo.Transaction;
import org.fcrepo.TxAwareSession;
import org.fcrepo.services.TransactionService;
import org.fcrepo.test.util.TestHelpers;
import org.junit.Before;
import org.junit.Test;

public class FedoraTransactionsTest {

FedoraTransactions testObj;
@@ -24,6 +24,9 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.io.IOException;
import java.net.URISyntaxException;

import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -40,9 +43,6 @@
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.net.URISyntaxException;

public class FedoraUnnamedObjectsTest {

FedoraUnnamedObjects testObj;
@@ -16,46 +16,42 @@

package org.fcrepo.api;


import static org.junit.Assert.*;
import static org.fcrepo.http.RDFMediaType.POSSIBLE_RDF_VARIANTS;
import static org.fcrepo.test.util.PathSegmentImpl.createPathList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.io.IOException;

import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Variant;

import static org.fcrepo.http.RDFMediaType.POSSIBLE_RDF_VARIANTS;

import javax.jcr.Session;

import org.fcrepo.FedoraResource;
import org.fcrepo.api.rdf.HttpGraphSubjects;

import org.fcrepo.services.NodeService;
import org.fcrepo.test.util.TestHelpers;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

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

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;


public class FedoraVersionsTest {

FedoraVersions testObj;

NodeService mockNodes;

Session mockSession;

@Before
@@ -70,46 +66,58 @@ public void setUp() throws Exception {
}

@Test
public void testGetVersionList () throws RepositoryException {
String pid = "FedoraVersioningTest";
public void testGetVersionList() throws RepositoryException {
final String pid = "FedoraVersioningTest";

final FedoraResource mockResource = mock(FedoraResource.class);
final Request mockRequest = mock(Request.class);
final Variant mockVariant = mock(Variant.class);
final Variant mockVariant = mock(Variant.class);
final Dataset mockDataset = mock(Dataset.class);

when(mockRequest.selectVariant(POSSIBLE_RDF_VARIANTS)).thenReturn(mockVariant);
when(mockNodes.getObject(any(Session.class), anyString())).thenReturn(mockResource);
when(mockResource.getVersionDataset(any(HttpGraphSubjects.class))).thenReturn(mockDataset);
when(mockVariant.getMediaType()).thenReturn(new MediaType("text","turtle"));

final Response response= testObj.getVersionList(createPathList(pid), mockRequest, TestHelpers.getUriInfoImpl());
when(mockRequest.selectVariant(POSSIBLE_RDF_VARIANTS)).thenReturn(
mockVariant);
when(mockNodes.getObject(any(Session.class), anyString())).thenReturn(
mockResource);
when(mockResource.getVersionDataset(any(HttpGraphSubjects.class)))
.thenReturn(mockDataset);
when(mockVariant.getMediaType()).thenReturn(
new MediaType("text", "turtle"));

final Response response =
testObj.getVersionList(createPathList(pid), mockRequest,
TestHelpers.getUriInfoImpl());
assertNotNull(response);
assertEquals(200, response.getStatus());
}

@Test
public void testAddVersionLabel () throws RepositoryException {
String pid = "FedoraVersioningTest";
String versionLabel = "FedoraVersioningTest1/fcr:versions/v0.0.1";
@Test
public void testAddVersionLabel() throws RepositoryException {
final String pid = "FedoraVersioningTest";
final String versionLabel = "FedoraVersioningTest1/fcr:versions/v0.0.1";

final FedoraResource mockResource = mock(FedoraResource.class);
when(mockNodes.getObject(any(Session.class), anyString())).thenReturn(mockResource);
final FedoraResource mockResource = mock(FedoraResource.class);
when(mockNodes.getObject(any(Session.class), anyString())).thenReturn(
mockResource);

final Response response = testObj.addVersionLabel(createPathList(pid), versionLabel);
verify(mockResource).addVersionLabel(anyString());
assertNotNull(response);
final Response response =
testObj.addVersionLabel(createPathList(pid), versionLabel);
verify(mockResource).addVersionLabel(anyString());
assertNotNull(response);
}

@Test
public void testGetVersion () throws RepositoryException, IOException {
String pid = "FedoraVersioningTest";
String versionLabel = "v0.0.1";
@Test
public void testGetVersion() throws RepositoryException, IOException {
final String pid = "FedoraVersioningTest";
final String versionLabel = "v0.0.1";

final FedoraResource mockResource = mock(FedoraResource.class);
when(mockNodes.getObject(any(Session.class),any(String.class), any(String.class))).thenReturn(mockResource);
Dataset ds = testObj.getVersion(createPathList(pid), versionLabel, TestHelpers.getUriInfoImpl());
verify(mockResource).getPropertiesDataset(any(HttpGraphSubjects.class), anyLong(), anyInt());
final FedoraResource mockResource = mock(FedoraResource.class);
when(
mockNodes.getObject(any(Session.class), any(String.class),
any(String.class))).thenReturn(mockResource);
testObj.getVersion(createPathList(pid), versionLabel, TestHelpers
.getUriInfoImpl());
verify(mockResource).getPropertiesDataset(any(HttpGraphSubjects.class),
anyLong(), anyInt());
}

}
@@ -16,9 +16,12 @@

package org.fcrepo.integration.api;

import static com.hp.hpl.jena.graph.Node.ANY;
import static com.hp.hpl.jena.graph.NodeFactory.createURI;
import static java.util.regex.Pattern.DOTALL;
import static java.util.regex.Pattern.compile;
import static junit.framework.TestCase.assertFalse;
import static org.fcrepo.test.util.TestHelpers.parseTriples;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

@@ -63,12 +66,10 @@ public void testMultipleDatastreams() throws Exception {
final String subjectURI =
serverAddress + "objects/FedoraDatastreamsTest7";

assertTrue("Didn't find the first datastream! ", result.contains(
Node.ANY, Node.createURI(subjectURI), Node.ANY, Node
.createURI(subjectURI + "/ds1")));
assertTrue("Didn't find the second datastream! ", result.contains(
Node.ANY, Node.createURI(subjectURI), Node.ANY, Node
.createURI(subjectURI + "/ds2")));
assertTrue("Didn't find the first datastream! ", result.contains(ANY,
createURI(subjectURI), ANY, createURI(subjectURI + "/ds1")));
assertTrue("Didn't find the second datastream! ", result.contains(ANY,
createURI(subjectURI), ANY, createURI(subjectURI + "/ds2")));
}

@Test
@@ -105,16 +106,13 @@ public void testModifyMultipleDatastreams() throws Exception {
final String subjectURI =
serverAddress + "objects/FedoraDatastreamsTest8";
final GraphStore result =
TestHelpers.parseTriples(response.getEntity().getContent());
assertTrue("Didn't find the first datastream! ", result.contains(
Node.ANY, Node.createURI(subjectURI), Node.ANY, Node
.createURI(subjectURI + "/ds1")));
assertTrue("Didn't find the second datastream! ", result.contains(
Node.ANY, Node.createURI(subjectURI), Node.ANY, Node
.createURI(subjectURI + "/ds2")));
parseTriples(response.getEntity().getContent());
assertTrue("Didn't find the first datastream! ", result.contains(ANY,
createURI(subjectURI), ANY, createURI(subjectURI + "/ds1")));
assertTrue("Didn't find the second datastream! ", result.contains(ANY,
createURI(subjectURI), ANY, createURI(subjectURI + "/ds2")));
assertFalse("Found the deleted datastream! ", result.contains(Node.ANY,
Node.createURI(subjectURI), Node.ANY, Node
.createURI(subjectURI + "/ds_void")));
createURI(subjectURI), ANY, createURI(subjectURI + "/ds_void")));

}

@@ -16,13 +16,13 @@

package org.fcrepo.integration.api;

import static org.junit.Assert.assertEquals;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class FedoraHtmlIT extends AbstractResourceIT {

@Test
Oops, something went wrong.

0 comments on commit 6ddee90

Please sign in to comment.
You can’t perform that action at this time.