Search in sources :

Example 1 with TestCaseOptions

use of alluxio.rest.TestCaseOptions in project alluxio by Alluxio.

the class FileSystemClientRestApiTest method writeFile.

private void writeFile(AlluxioURI path, byte[] input) throws Exception {
    String result = new TestCase(mHostname, mPort, PATHS_PREFIX + path.toString() + "/" + PathsRestServiceHandler.CREATE_FILE, NO_PARAMS, HttpMethod.POST, null, TestCaseOptions.defaults().setBody(CreateFileOptions.defaults())).call();
    Integer id = new ObjectMapper().readValue(result, Integer.TYPE);
    TestCaseOptions options = TestCaseOptions.defaults();
    long expected = 0;
    if (input != null) {
        options.setInputStream(new ByteArrayInputStream(input));
        expected = input.length;
    }
    new TestCase(mHostname, mPort, STREAMS_PREFIX + id.toString() + "/" + StreamsRestServiceHandler.WRITE, NO_PARAMS, HttpMethod.POST, expected, options).run();
    new TestCase(mHostname, mPort, STREAMS_PREFIX + id.toString() + "/" + StreamsRestServiceHandler.CLOSE, NO_PARAMS, HttpMethod.POST, null).run();
}
Also used : TestCaseOptions(alluxio.rest.TestCaseOptions) TestCase(alluxio.rest.TestCase) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

TestCase (alluxio.rest.TestCase)1 TestCaseOptions (alluxio.rest.TestCaseOptions)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1