Skip to content

Commit

Permalink
fixed typo in test
Browse files Browse the repository at this point in the history
  • Loading branch information
fasseg committed May 17, 2013
1 parent 73a7415 commit 64ee8dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Expand Up @@ -9,7 +9,6 @@
import static org.fcrepo.http.RDFMediaType.N3_ALT1;
import static org.fcrepo.http.RDFMediaType.N3_ALT2;
import static org.fcrepo.http.RDFMediaType.NTRIPLES;
import static org.fcrepo.http.RDFMediaType.POSSIBLE_RDF_VARIANTS;
import static org.fcrepo.http.RDFMediaType.RDF_JSON;
import static org.fcrepo.http.RDFMediaType.RDF_XML;
import static org.fcrepo.http.RDFMediaType.TURTLE;
Expand All @@ -35,8 +34,8 @@
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.core.Variant;

import org.fcrepo.AbstractResource;
import org.fcrepo.jaxb.search.FieldSearchResult;
Expand Down Expand Up @@ -75,14 +74,14 @@ public String searchForm() throws RepositoryException {
@POST
@Timed
@Produces({N3, N3_ALT1, N3_ALT2, TURTLE, RDF_XML, RDF_JSON, NTRIPLES})
public StreamingOutput searchSubmitRdf(@FormParam("terms") final String terms,
public Response searchSubmitRdf(@FormParam("terms") final String terms,
@FormParam("offSet") @DefaultValue("0") final String offSet,
@FormParam("maxResults") final String maxResults, @Context final Request request) throws RepositoryException{

final Session session = getAuthenticatedSession();
try{
/* select the best response type */
final Variant bestPossibleResponse = request.selectVariant(POSSIBLE_RDF_VARIANTS);
// /* select the best response type */
// final Variant bestPossibleResponse = request.selectVariant(POSSIBLE_RDF_VARIANTS);

/* construct the query from the user's search terms */
final Query query = getQuery(session.getWorkspace().getQueryManager(), session.getValueFactory(), terms);
Expand All @@ -103,20 +102,21 @@ public StreamingOutput searchSubmitRdf(@FormParam("terms") final String terms,
model.add(objRes, model.createProperty("info:fedora/fedora-system:def/search#matchesSearchTerm"), terms);
model.add(searchResult, model.createProperty("info:fedora/fedora-system:def/search#hasResult"), objRes);
}
model.write(System.out,"RDF/JSON");

return new StreamingOutput() {
/* create a StreamingOutput that writes the model to the response stream */
final StreamingOutput rdfStream = new StreamingOutput() {
@Override
public void write(OutputStream output) throws IOException,
WebApplicationException {
try{
model.write(output,"RDF/JSON");
searchResult.getModel().write(output);
output.flush();
}finally{
output.close();
}
}
};
return Response.ok(rdfStream).build();
}finally{
session.logout();
}
Expand Down
Expand Up @@ -39,7 +39,7 @@ public void testSearchSubmit() throws Exception {
}

@Test
public void testSearchSubmitRdfXML() throws Exception {
public void testSearchSubmitRdfJSON() throws Exception {
final HttpPost method = new HttpPost(serverAddress + "fcr:search");
method.setHeader("Accept", "application/rdf+json");
final List<BasicNameValuePair> list = new ArrayList<>();
Expand All @@ -50,9 +50,9 @@ public void testSearchSubmitRdfXML() throws Exception {
method.setEntity(formEntity);

HttpResponse resp = execute(method);
assertEquals(200, resp.getStatusLine().getStatusCode());
String json = IOUtils.toString(resp.getEntity().getContent());
logger.debug("RDF/XML Response for FieldSearch:\n",json);
assertEquals("Server returned\n" + json, 200, resp.getStatusLine().getStatusCode());
logger.debug("RDF/XML Response for FieldSearch:\n" + json);

method.releaseConnection();
fail("implement a test");
Expand Down

0 comments on commit 64ee8dd

Please sign in to comment.