[TEST][Monitoring] Also set StreamInput version

Sets the StreamInput's version so that it properly deserializes the
incoming message.

Original commit: elastic/x-pack-elasticsearch@e783fbcecc
This commit is contained in:
Chris Earle 2018-03-16 14:46:12 -04:00
parent ff725afe01
commit d19ad8b3d1
1 changed files with 4 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import org.elasticsearch.Version;
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -103,7 +104,9 @@ public class MonitoringFeatureSetTests extends ESTestCase {
BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(serializedVersion);
monitoringUsage.writeTo(out);
XPackFeatureSet.Usage serializedUsage = new MonitoringFeatureSetUsage(out.bytes().streamInput());
StreamInput in = out.bytes().streamInput();
in.setVersion(serializedVersion);
XPackFeatureSet.Usage serializedUsage = new MonitoringFeatureSetUsage(in);
for (XPackFeatureSet.Usage usage : Arrays.asList(monitoringUsage, serializedUsage)) {
assertThat(usage.name(), is(featureSet.name()));
assertThat(usage.enabled(), is(featureSet.enabled()));