Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
Make unit test for ModelTripleHandler pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Jul 10, 2013
1 parent 7799f00 commit 4fd8400
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 8 deletions.
28 changes: 28 additions & 0 deletions pom.xml
Expand Up @@ -34,12 +34,21 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<repositories>
Expand All @@ -52,4 +61,23 @@
</repository>
</repositories>

<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

</project>
Expand Up @@ -4,8 +4,6 @@
import static org.slf4j.LoggerFactory.getLogger;

import java.net.URISyntaxException;
import java.util.Set;

import org.apache.any23.extractor.ExtractionContext;
import org.apache.any23.writer.TripleHandler;
import org.apache.any23.writer.TripleHandlerException;
Expand All @@ -20,9 +18,9 @@
import com.hp.hpl.jena.rdf.model.Statement;

/**
* Utility class to produce a set of triples from a stream of triples produced
* Utility class to produce a {@link Model} from a stream of triples produced
* by Any23 parsing. Most of {@link TripleHandler}'s methods are unimplemented,
* because this class expects to produce nothing other than a {@link Set} of the
* because this class expects to produce nothing other than a {@link Model} of the
* triples emitted into it.
*
* @author ajs6f
Expand All @@ -35,7 +33,7 @@ public class ModelTripleHandler implements TripleHandler, AutoCloseable {
*/
protected Model model = createDefaultModel();

private static final Logger logger = getLogger(ModelTripleHandler.class);
private static final Logger LOGGER = getLogger(ModelTripleHandler.class);

/*
* (non-Javadoc)
Expand All @@ -53,7 +51,7 @@ public void receiveTriple(final Resource s, final URI p, final Value o,
model.createProperty(p.getNamespace(), p.getLocalName()),
objectNode(o));
model.add(triple);
logger.debug("Added triple: {}", triple.asTriple().toString());
LOGGER.debug("Added triple: {}", triple.asTriple().toString());
}

/**
Expand Down
Expand Up @@ -95,7 +95,7 @@ public void testOneTripleWithLiteral() throws IOException,
.contains(
model.createResource("info:fedora/uva-lib:1038847"),
model.createProperty("http://fedora.lib.virginia.edu/relationships#testPredicateWithLiteral"),
model.createResource("literal value")));
model.createLiteral("literal value")));
logger.info("Found appropriate triple.");
close();
}
Expand All @@ -122,7 +122,7 @@ public void testOneTripleWithRelativeUri() throws IOException,
.contains(
model.createResource("info:fedora/uva-lib:1038847"),
model.createProperty("http://fedora.lib.virginia.edu/relationships#testPredicateWithLiteral"),
model.createResource("/relative/uri/")));
model.createLiteral("/relative/uri/")));
logger.info("Found appropriate triple.");
close();
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/resources/logback-test.xml
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="5 seconds">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%p %d{HH:mm:ss.SSS} \(%c{0}\) %m%n</pattern>
</encoder>
</appender>
<logger name="org.fcrepo" additivity="false" level="DEBUG">
<appender-ref ref="STDOUT"/>
</logger>
<root additivity="false" level="WARN">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
10 changes: 10 additions & 0 deletions src/test/resources/rdf.xml
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:fedora-model="info:fedora/fedora-system:def/model#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:uva="http://fedora.lib.virginia.edu/relationships#">
<rdf:Description rdf:about="info:fedora/uva-lib:1038847">
<uva:testPredicate rdf:resource="info:test/resource"/>
<uva:testPredicateWithLiteral>literal value</uva:testPredicateWithLiteral>
<uva:testPredicateWithLiteral>/relative/uri/</uva:testPredicateWithLiteral>
</rdf:Description>
</rdf:RDF>

0 comments on commit 4fd8400

Please sign in to comment.