Skip to content

Commit

Permalink
More minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed May 8, 2013
1 parent 89f3a22 commit d14cb8a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 48 deletions.
Expand Up @@ -58,15 +58,18 @@ public void tearDown() {

}

@SuppressWarnings("unchecked")
@Test
public void testIngestAndMint() throws RepositoryException, IOException, InvalidChecksumException {
UUIDPidMinter mockMint = mock(UUIDPidMinter.class);
public void testIngestAndMint() throws RepositoryException, IOException,
InvalidChecksumException {
final UUIDPidMinter mockMint = mock(UUIDPidMinter.class);
testObj.setPidMinter(mockMint);
testObj.ingestAndMint(createPathList("objects", "fcr:new"));
verify(mockMint).mintPid();
verify(mockObjects).createObject(
any(List.class), any(String.class),
eq(FedoraJcrTypes.FEDORA_OBJECT), isNull(String.class), isNull(String.class), isNull(MediaType.class), isNull(InputStream.class));
verify(mockObjects).createObject(any(List.class), any(String.class),
eq(FedoraJcrTypes.FEDORA_OBJECT), isNull(String.class),
isNull(String.class), isNull(MediaType.class),
isNull(InputStream.class));
}

}
Expand Up @@ -10,9 +10,9 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.fcrepo.Datastream;
import org.fcrepo.utils.LowLevelCacheEntry;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
Expand Down Expand Up @@ -70,9 +70,9 @@ public class DatastreamProfile {

@XmlElement
public URI dsChecksum;
@XmlElement
public DSStores dsStores;

@XmlElement
public DSStores dsStores;

public static enum DatastreamControlGroup {
M, E, R
Expand All @@ -92,28 +92,29 @@ public static String convertDateToXSDString(final long date) {
final DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
return fmt.print(dt);
}

/**
* adds the datastream store information to the datastream profile output.
*
* datastream profile output in fcrepo4 no longer matches output from
* fcrepo3.x
*
*/
public static class DSStores {

@XmlElement(name = "dsStore")
public List<String> storeIdentifiers ;
public static class DSStores {

public DSStores(){
this.storeIdentifiers = new ArrayList();
}
@XmlElement(name = "dsStore")
public List<String> storeIdentifiers;

public DSStores() {
this.storeIdentifiers = new ArrayList<String>();
}

public DSStores(Datastream datastream, Set cacheEntries) {
this.storeIdentifiers = new ArrayList();
for (Iterator it = cacheEntries.iterator(); it.hasNext();) {
LowLevelCacheEntry cacheEntry = (LowLevelCacheEntry) it.next();
storeIdentifiers.add(cacheEntry.getExternalIdentifier());
public DSStores(final Datastream datastream, final Set cacheEntries) {
this.storeIdentifiers = new ArrayList<String>();
for (final Iterator it = cacheEntries.iterator(); it.hasNext();) {
final LowLevelCacheEntry cacheEntry =
(LowLevelCacheEntry) it.next();
storeIdentifiers.add(cacheEntry.getExternalIdentifier());
}
}
}
Expand Down
@@ -1,3 +1,4 @@

package org.fcrepo.test.util;

import java.util.ArrayList;
Expand All @@ -9,18 +10,22 @@
import com.sun.jersey.api.uri.UriComponent;
import com.sun.jersey.core.util.MultivaluedMapImpl;


public class PathSegmentImpl implements PathSegment {
private static final PathSegment EMPTY_PATH_SEGMENT = new PathSegmentImpl("", false);

// private static final PathSegment EMPTY_PATH_SEGMENT = new PathSegmentImpl("", false);
private final String path;

private final MultivaluedMap<String, String> matrixParameters;

PathSegmentImpl(String path, boolean decode) {
PathSegmentImpl(final String path, final boolean decode) {
this(path, decode, new MultivaluedMapImpl());
}

PathSegmentImpl(String path, boolean decode, MultivaluedMap<String, String> matrixParameters) {
this.path = (decode) ? UriComponent.decode(path, UriComponent.Type.PATH_SEGMENT) : path;
PathSegmentImpl(final String path, final boolean decode,
final MultivaluedMap<String, String> matrixParameters) {
this.path =
(decode) ? UriComponent.decode(path,
UriComponent.Type.PATH_SEGMENT) : path;
this.matrixParameters = matrixParameters;
}

Expand All @@ -33,10 +38,13 @@ public String getPath() {
public MultivaluedMap<String, String> getMatrixParameters() {
return matrixParameters;
}

public static List<PathSegment> createPathList(String...strings) {
ArrayList<PathSegment> result = new ArrayList<PathSegment>(strings.length);
for (String string: strings) result.add(new PathSegmentImpl(string, false));

public static List<PathSegment> createPathList(final String... strings) {
final ArrayList<PathSegment> result =
new ArrayList<PathSegment>(strings.length);
for (final String string : strings) {
result.add(new PathSegmentImpl(string, false));
}
return result;
}
}
@@ -1,42 +1,28 @@
package org.fcrepo.test.util;

import static org.fcrepo.utils.FedoraJcrTypes.CONTENT_SIZE;
import static org.fcrepo.utils.FedoraJcrTypes.DIGEST_ALGORITHM;
import static org.fcrepo.utils.FedoraJcrTypes.DIGEST_VALUE;
import static org.fcrepo.utils.FedoraJcrTypes.FEDORA_OWNED;
import static org.fcrepo.utils.FedoraJcrTypes.FEDORA_OWNERID;
import static org.fcrepo.utils.FedoraJcrTypes.JCR_CREATED;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.modeshape.jcr.api.JcrConstants.JCR_DATA;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Principal;
import java.security.SecureRandom;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.Map.Entry;

import javax.jcr.Binary;
import javax.jcr.LoginException;
import javax.jcr.NamespaceRegistry;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
import javax.jcr.ValueFactory;
import javax.jcr.Workspace;
import javax.jcr.nodetype.NodeType;
Expand All @@ -59,8 +45,6 @@
import org.fcrepo.session.SessionFactory;
import org.fcrepo.utils.ContentDigest;
import org.fcrepo.utils.DatastreamIterator;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.modeshape.jcr.api.Repository;
import org.modeshape.jcr.api.query.QueryManager;

Expand Down

0 comments on commit d14cb8a

Please sign in to comment.