List of usage examples for org.apache.commons.io.input NullInputStream NullInputStream
public NullInputStream(long size, boolean markSupported, boolean throwEofException)
From source file:com.fizzed.blaze.util.Streamables.java
static public StreamableInput nullInput() { return new StreamableInput(new NullInputStream(0, true, true), "<null>", null, null); }
From source file:org.fcrepo.client.ConnectionManagementTest.java
/** * Uses the FcrepoClient to connect to supplied {@code uri} using the supplied {@code method}. * This method invokes the supplied {@code responseHandler} on the {@code FcrepoResponse}. * * @param client the FcrepoClient used to invoke the request * @param uri the request URI to connect to * @param method the HTTP method corresponding to the FcrepoClient method invoked * @param responseHandler invoked on the {@code FcrepoResponse}, may be {@code null} *///from w ww. j a v a2s . c o m private void connect(final FcrepoClient client, final MockHttpExpectations.Uris uri, final HttpMethods method, final Consumer<FcrepoResponse> responseHandler) { final NullInputStream nullIn = new NullInputStream(1, true, false); FcrepoResponse response = null; try { switch (method) { case OPTIONS: response = client.options(uri.asUri()).perform(); break; case DELETE: response = client.delete(uri.asUri()).perform(); break; case GET: response = client.get(uri.asUri()).accept(TEXT_TURTLE).perform(); break; case HEAD: response = client.head(uri.asUri()).perform(); break; case PATCH: response = client.patch(uri.asUri()).perform(); break; case POST: response = client.post(uri.asUri()).body(nullIn, TEXT_TURTLE).perform(); break; case PUT: response = client.put(uri.asUri()).body(nullIn, TEXT_TURTLE).perform(); break; case MOVE: response = client.move(uri.asUri(), uri.asUri()).perform(); break; case COPY: response = client.copy(uri.asUri(), uri.asUri()).perform(); break; default: fail("Unknown HTTP method: " + method.name()); } if (uri.statusCode >= HttpStatus.SC_INTERNAL_SERVER_ERROR) { fail("Expected a FcrepoOperationFailedException to be thrown for HTTP method " + method.name()); } } catch (FcrepoOperationFailedException e) { assertEquals("Expected request for " + uri.asUri() + " to return a " + uri.statusCode + ". " + "Was: " + e.getStatusCode() + " Method:" + method, uri.statusCode, e.getStatusCode()); } finally { if (responseHandler != null) { responseHandler.accept(response); } } }