Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fcrepo-http-commons tests pass, now for fcrepo-http-api
- Loading branch information
Showing
10 changed files
with
110 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<html> | ||
<head> | ||
<title></title> | ||
</head> | ||
<body> | ||
<div> | ||
<span>TEMPLATE</span> | ||
</div> | ||
|
||
</body> | ||
</html> |
62 changes: 41 additions & 21 deletions
62
fcrepo-http-commons/src/test/java/org/fcrepo/responses/GraphStreamingOutputTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,55 @@ | ||
|
||
package org.fcrepo.responses; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.spy; | ||
import static org.mockito.Mockito.verify; | ||
import static com.hp.hpl.jena.graph.Node.createURI; | ||
import static org.fcrepo.http.RDFMediaType.NTRIPLES_TYPE; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
|
||
import javax.jcr.RepositoryException; | ||
import javax.ws.rs.WebApplicationException; | ||
|
||
import org.fcrepo.http.RDFMediaType; | ||
import org.fcrepo.responses.GraphStreamingOutput; | ||
import org.junit.Test; | ||
|
||
import com.hp.hpl.jena.rdf.model.Model; | ||
import com.hp.hpl.jena.sparql.modify.GraphStoreNull; | ||
import org.slf4j.Logger; | ||
|
||
import com.hp.hpl.jena.graph.Graph; | ||
import com.hp.hpl.jena.graph.Triple; | ||
import com.hp.hpl.jena.mem.GraphMem; | ||
import com.hp.hpl.jena.rdf.model.ModelFactory; | ||
import com.hp.hpl.jena.sparql.core.DatasetImpl; | ||
import com.hp.hpl.jena.sparql.modify.GraphStoreBasic; | ||
import com.hp.hpl.jena.update.GraphStore; | ||
|
||
public class GraphStreamingOutputTest { | ||
|
||
@Test | ||
public void testStuff() throws WebApplicationException, IOException, RepositoryException { | ||
GraphStore graph = new GraphStoreNull(); | ||
|
||
final Model model = spy(graph.toDataset().getDefaultModel()); | ||
|
||
GraphStreamingOutput test = | ||
new GraphStreamingOutput(graph, RDFMediaType.NTRIPLES_TYPE); | ||
OutputStream mockOut = mock(OutputStream.class); | ||
test.write(mockOut); | ||
verify(model.write(mockOut, "N-TRIPLES")); | ||
} | ||
private static final Logger logger = | ||
getLogger(GraphStreamingOutputTest.class); | ||
|
||
@Test | ||
public void testStuff() throws WebApplicationException, IOException, | ||
RepositoryException { | ||
final GraphStore graphStore = | ||
new GraphStoreBasic(new DatasetImpl(ModelFactory | ||
.createDefaultModel())); | ||
final Graph g = new GraphMem(); | ||
g.add(new Triple(createURI("test:subject"), | ||
createURI("test:predicate"), createURI("test:object"))); | ||
graphStore.setDefaultGraph(g); | ||
final GraphStreamingOutput test = | ||
new GraphStreamingOutput(graphStore, NTRIPLES_TYPE); | ||
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) { | ||
test.write(out); | ||
final String serialized = out.toString(); | ||
logger.debug("Created serialized RDF: \n {}", serialized); | ||
assertTrue("Couldn't find test subject!", serialized | ||
.contains("test:subject")); | ||
assertTrue("Couldn't find test predicate!", serialized | ||
.contains("test:predicate")); | ||
assertTrue("Couldn't find test object!", serialized | ||
.contains("test:object")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE configuration> | ||
<configuration> | ||
<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> | ||
<logger name="org.modeshape" additivity="false" level="WARN"> | ||
<appender-ref ref="STDOUT"/> | ||
</logger> | ||
<logger name="org.apache.http.client" additivity="false" level="DEBUG"> | ||
<appender-ref ref="STDOUT"/> | ||
</logger> | ||
<root additivity="false" level="INFO"> | ||
<appender-ref ref="STDOUT"/> | ||
</root> | ||
</configuration> |