Skip to content

Commit

Permalink
Cleaning Java compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Dec 1, 2013
1 parent 7201d56 commit dd2d0ee
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 63 deletions.
Expand Up @@ -18,25 +18,20 @@

import static com.hp.hpl.jena.graph.NodeFactory.createURI;
import static com.hp.hpl.jena.graph.Triple.create;
import static com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel;
import static org.fcrepo.http.commons.test.util.TestHelpers.setField;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Map;

import javax.jcr.NamespaceRegistry;
import javax.jcr.RepositoryException;
Expand All @@ -54,7 +49,6 @@
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.rdf.model.Model;

public class StreamingBaseHtmlProviderTest {

Expand Down Expand Up @@ -109,7 +103,7 @@ public void testWriteTo() throws WebApplicationException,
}

// check that the BaseHtmlProvider gets a dataset with namespace prefixes set
ArgumentCaptor<Dataset> argument = ArgumentCaptor.forClass(Dataset.class);
final ArgumentCaptor<Dataset> argument = ArgumentCaptor.forClass(Dataset.class);
verify(mockBaseHtmlProvider).writeTo(argument.capture(),
eq(RdfStream.class),
eq((Type)null),
Expand Down
Expand Up @@ -97,21 +97,22 @@ public void releaseConnection() throws JMSException {
@Test
public void testAtomStream() throws RepositoryException,
InterruptedException {
Session session = repository.login();
final Session session = repository.login();
session.getRootNode().addNode("test1").addMixin(FEDORA_OBJECT);
session.save();

waitForEntry(1);
session.logout();

if (entries.isEmpty()) fail("Waited a second, got no messages");
if (entries.isEmpty()) {
fail("Waited a second, got no messages");
}

String title = null;
String path = null;
for (Entry entry : entries) {
List<Category> categories = copyOf(entry.getCategories("xsd:string"));
String p = null;
for (Category cat : categories) {
for (final Entry entry : entries) {
final List<Category> categories = copyOf(entry.getCategories("xsd:string"));
for (final Category cat : categories) {
if (cat.getLabel().equals("fedora-types:pid")) {
logger.debug("Found Category with term: " + cat.getTerm());
path = cat.getTerm();
Expand All @@ -122,28 +123,29 @@ public void testAtomStream() throws RepositoryException,
assertEquals("Got wrong pid!", "test1", path);
assertEquals("Got wrong method!", "ingest", title);
}


@Test
public void testAtomStreamNodePath() throws RepositoryException,
InterruptedException {
final int minEntriesSize = 2;
Session session = repository.login();
final Session session = repository.login();
session.getRootNode().addNode("test1/sigma").addMixin(FEDORA_OBJECT);
session.save();

waitForEntry(minEntriesSize);
session.logout();

if (entries.isEmpty())
if (entries.isEmpty()) {
fail("Waited a second, got no messages");
}

String path = null;
assertEquals("Entries size not 2", entries.size(), 2);
for (Entry entry : entries) {
List<Category> categories = copyOf(entry.getCategories("xsd:string"));
for (final Entry entry : entries) {
final List<Category> categories = copyOf(entry.getCategories("xsd:string"));
String p = null;
for (Category cat : categories) {
for (final Category cat : categories) {
if (cat.getLabel().equals("path")) {
logger.debug("Found Category with term: " + cat.getTerm());
p = cat.getTerm();
Expand All @@ -153,30 +155,32 @@ public void testAtomStreamNodePath() throws RepositoryException,
path = p;
}
}
assertEquals("Got wrong path!", "/test1/sigma", path);
assertEquals("Got wrong path!", "/test1/sigma", path);
}

@Test
public void testDatastreamTerm() throws RepositoryException,
InterruptedException {
logger.trace("BEGIN: testDatastreamTerm()");
Session session = repository.login();
final Session session = repository.login();
final Node object = session.getRootNode().addNode("testDatastreamTerm");
object.addMixin(FEDORA_OBJECT);
session.save();
logger.trace("testDatastreamTerm called session.save()");

waitForEntry(1);
if (entries.isEmpty()) fail("Waited a second, got no messages");
if (entries.isEmpty()) {
fail("Waited a second, got no messages");
}

String path = null;
for (Entry entry : entries) {
List<Category> categories = copyOf(entry.getCategories("xsd:string"));
for (final Entry entry : entries) {
final List<Category> categories = copyOf(entry.getCategories("xsd:string"));

logger.trace("Matched {} categories with scheme xsd:string",
categories
.size());
for (Category cat : categories) {
for (final Category cat : categories) {
if (cat.getLabel().equals("fedora-types:pid")) {
logger.debug("Found Category with term: " + cat.getTerm());
path = cat.getTerm();
Expand All @@ -195,16 +199,18 @@ public void testDatastreamTerm() throws RepositoryException,
logger.trace("testDatastreamTerm called session.logout()");

waitForEntry(2);
if (entries.isEmpty()) fail("Waited a second, got no messages");
if (entries.isEmpty()) {
fail("Waited a second, got no messages");
}

path = null;
for (Entry entry : entries) {
List<Category> categories = copyOf(entry.getCategories("xsd:string"));
for (final Entry entry : entries) {
final List<Category> categories = copyOf(entry.getCategories("xsd:string"));

logger.trace("Matched {} categories with scheme xsd:string",
categories
.size());
for (Category cat : categories) {
for (final Category cat : categories) {
if (cat.getLabel().equals("fedora-types:dsID")) {
logger.debug("Found Category with term: " + cat.getTerm());
path = cat.getTerm();
Expand All @@ -217,20 +223,20 @@ public void testDatastreamTerm() throws RepositoryException,
}

@Override
public void onMessage(Message message) {
public void onMessage(final Message message) {
logger.debug("Received JMS message: " + message.toString());

TextMessage tMessage = (TextMessage) message;
final TextMessage tMessage = (TextMessage) message;
try {
if (LegacyMethod.canParse(message)) {
LegacyMethod legacy = new LegacyMethod(tMessage.getText());
Entry entry = legacy.getEntry();
final LegacyMethod legacy = new LegacyMethod(tMessage.getText());
final Entry entry = legacy.getEntry();
entries.add(entry);
logger.debug("Parsed Entry: {}", entry.toString());
} else {
logger.warn("Could not parse message: {}", message);
}
} catch (Exception e) {
} catch (final Exception e) {
logger.error("Exception receiving message: {}", e);
fail(e.getMessage());
}
Expand All @@ -239,7 +245,7 @@ public void onMessage(Message message) {
}
}

private void waitForEntry(int size) throws InterruptedException {
private void waitForEntry(final int size) throws InterruptedException {
for (int i = 0; i < 5; i++) {
if (entries.size() < size) { // must not have rec'vd event yet
synchronized (this) {
Expand Down
12 changes: 0 additions & 12 deletions fcrepo-kernel/src/main/java/org/fcrepo/kernel/rdf/JcrRdfTools.java
Expand Up @@ -53,7 +53,6 @@
import org.fcrepo.kernel.rdf.impl.VersionsRdfContext;
import org.fcrepo.kernel.rdf.impl.WorkspaceRdfContext;
import org.fcrepo.kernel.services.LowLevelStorageService;
import org.fcrepo.kernel.services.functions.GetClusterConfiguration;
import org.fcrepo.kernel.utils.FixityResult;
import org.fcrepo.kernel.utils.iterators.RdfStream;
import org.modeshape.jcr.api.NamespaceRegistry;
Expand Down Expand Up @@ -93,9 +92,6 @@ public class JcrRdfTools {
public static BiMap<String, String> rdfNamespacesToJcrNamespaces =
jcrNamespacesToRDFNamespaces.inverse();

private static GetClusterConfiguration getClusterConfiguration =
new GetClusterConfiguration();

private LowLevelStorageService llstore;

private final GraphSubjects graphSubjects;
Expand Down Expand Up @@ -579,14 +575,6 @@ public String getPropertyNameFromPredicate(final NamespaceRegistry namespaceRegi

}

/**
* Set the function used to get the cluster configuration for Infinispan
*/
public static void setGetClusterConfiguration(
final GetClusterConfiguration newClusterConfiguration) {
getClusterConfiguration = newClusterConfiguration;
}

/**
* Set the Low-level storage server implementation
*/
Expand Down
Expand Up @@ -24,11 +24,6 @@
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createProperty;
import static javax.jcr.PropertyType.BINARY;
import static javax.jcr.query.Query.JCR_SQL2;
import static org.fcrepo.jcr.FedoraJcrTypes.CONTENT_SIZE;
import static org.fcrepo.jcr.FedoraJcrTypes.FEDORA_BINARY;
import static org.fcrepo.jcr.FedoraJcrTypes.FEDORA_DATASTREAM;
import static org.fcrepo.jcr.FedoraJcrTypes.FEDORA_OBJECT;
import static org.fcrepo.jcr.FedoraJcrTypes.FEDORA_RESOURCE;
import static org.fcrepo.kernel.rdf.JcrRdfTools.getRDFNamespaceForJcrNamespace;
import static org.modeshape.jcr.api.JcrConstants.JCR_DATA;
import static org.modeshape.jcr.api.JcrConstants.JCR_PATH;
Expand Down Expand Up @@ -121,9 +116,9 @@ public boolean apply(final Node node) {
checkArgument(node != null, "null cannot be a Fedora object!");
try {
if (node.getPrimaryNodeType().getName().equals(FROZEN_NODE)) {
PropertyIterator it = node.getProperties(FROZEN_MIXIN_TYPES);
final PropertyIterator it = node.getProperties(FROZEN_MIXIN_TYPES);
while (it.hasNext()) {
for (Value v : it.nextProperty().getValues()) {
for (final Value v : it.nextProperty().getValues()) {
if (v.getString().equals(FEDORA_RESOURCE)) {
return true;
}
Expand Down
Expand Up @@ -47,7 +47,6 @@
import static org.fcrepo.kernel.RdfLexicon.RESTAPI_NAMESPACE;
import static org.fcrepo.kernel.rdf.JcrRdfTools.getJcrNamespaceForRDFNamespace;
import static org.fcrepo.kernel.rdf.JcrRdfTools.getRDFNamespaceForJcrNamespace;
import static org.fcrepo.kernel.rdf.JcrRdfTools.setGetClusterConfiguration;
import static org.fcrepo.kernel.utils.FixityResult.FixityState.BAD_CHECKSUM;
import static org.fcrepo.kernel.utils.FixityResult.FixityState.BAD_SIZE;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -102,7 +101,6 @@
import org.fcrepo.kernel.rdf.JcrRdfTools;
import org.fcrepo.kernel.rdf.impl.DefaultGraphSubjects;
import org.fcrepo.kernel.services.LowLevelStorageService;
import org.fcrepo.kernel.services.functions.GetClusterConfiguration;
import org.fcrepo.kernel.testutilities.TestPropertyIterator;
import org.junit.Before;
import org.junit.Ignore;
Expand All @@ -115,7 +113,6 @@
import com.codahale.metrics.Counter;
import com.codahale.metrics.MetricRegistry;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Iterators;
import com.hp.hpl.jena.rdf.model.Model;
Expand Down Expand Up @@ -220,9 +217,6 @@ public final void testGetPropertiesModel() throws RepositoryException,
mockCounter

));
when(mockGetClusterConfiguration.apply(mockRepository)).thenReturn(
ImmutableMap.of("a", "b"));
setGetClusterConfiguration(mockGetClusterConfiguration);

when(mockNode.getPath()).thenReturn("/");
when(mockNode.getPrimaryNodeType()).thenReturn(mockNodeType);
Expand Down Expand Up @@ -736,9 +730,6 @@ private void logRDF(final Model rdf) throws IOException {
@Mock
private Counter mockCounter;

@Mock
private GetClusterConfiguration mockGetClusterConfiguration;

@Mock
private NodeTypeManager mockNodeTypeManager;

Expand Down

0 comments on commit dd2d0ee

Please sign in to comment.