Search in sources :

Example 1 with DataOutputStreamOutput

use of org.elasticsearch.common.io.stream.DataOutputStreamOutput in project elasticsearch by elastic.

the class ScriptExceptionTests method testRoundTrip.

/** ensure we can round trip in serialization */
public void testRoundTrip() throws IOException {
    ScriptException e = new ScriptException("messageData", new Exception("causeData"), Arrays.asList("stack1", "stack2"), "sourceData", "langData");
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    StreamOutput output = new DataOutputStreamOutput(new DataOutputStream(bytes));
    e.writeTo(output);
    output.close();
    StreamInput input = new InputStreamStreamInput(new ByteArrayInputStream(bytes.toByteArray()));
    ScriptException e2 = new ScriptException(input);
    input.close();
    assertEquals(e.getMessage(), e2.getMessage());
    assertEquals(e.getScriptStack(), e2.getScriptStack());
    assertEquals(e.getScript(), e2.getScript());
    assertEquals(e.getLang(), e2.getLang());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) InputStreamStreamInput(org.elasticsearch.common.io.stream.InputStreamStreamInput) StreamInput(org.elasticsearch.common.io.stream.StreamInput) DataOutputStreamOutput(org.elasticsearch.common.io.stream.DataOutputStreamOutput) ByteArrayOutputStream(java.io.ByteArrayOutputStream) StreamOutput(org.elasticsearch.common.io.stream.StreamOutput) DataOutputStreamOutput(org.elasticsearch.common.io.stream.DataOutputStreamOutput) IOException(java.io.IOException) InputStreamStreamInput(org.elasticsearch.common.io.stream.InputStreamStreamInput)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 IOException (java.io.IOException)1 DataOutputStreamOutput (org.elasticsearch.common.io.stream.DataOutputStreamOutput)1 InputStreamStreamInput (org.elasticsearch.common.io.stream.InputStreamStreamInput)1 StreamInput (org.elasticsearch.common.io.stream.StreamInput)1 StreamOutput (org.elasticsearch.common.io.stream.StreamOutput)1