summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/action/ingest
diff options
context:
space:
mode:
authorSimon Willnauer <simon.willnauer@elasticsearch.com>2016-07-01 16:09:31 +0200
committerGitHub <noreply@github.com>2016-07-01 16:09:31 +0200
commit5c8164a5618b4ac8f9b7a3530c68771925c96896 (patch)
tree142cc9555797ca308e5ca1182068df091456eea7 /core/src/test/java/org/elasticsearch/action/ingest
parent42addb5692ffdad4a553f4c9be2a6806a3063c36 (diff)
Clean up BytesReference (#19196)
BytesReference should be a really simple interface, yet it has a gazillion ways to achieve the same this. Methods like `#hasArray`, `#toBytesArray`, `#copyBytesArray` `#toBytesRef` `#bytes` are all really duplicates. This change simplifies the interface dramatically and makes implementations of it much simpler. All array access has been removed and is streamlined through a single `#toBytesRef` method. Utility methods to materialize a compact byte array has been added too for convenience.
Diffstat (limited to 'core/src/test/java/org/elasticsearch/action/ingest')
-rw-r--r--core/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentSimpleResultTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/ingest/WritePipelineResponseTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java2
5 files changed, 6 insertions, 6 deletions
diff --git a/core/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentSimpleResultTests.java b/core/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentSimpleResultTests.java
index 323a8c0aaa..544e2932b4 100644
--- a/core/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentSimpleResultTests.java
+++ b/core/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentSimpleResultTests.java
@@ -45,7 +45,7 @@ public class SimulateDocumentSimpleResultTests extends ESTestCase {
BytesStreamOutput out = new BytesStreamOutput();
simulateDocumentBaseResult.writeTo(out);
- StreamInput streamInput = StreamInput.wrap(out.bytes());
+ StreamInput streamInput = out.bytes().streamInput();
SimulateDocumentBaseResult otherSimulateDocumentBaseResult = new SimulateDocumentBaseResult(streamInput);
if (isFailure) {
diff --git a/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java b/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java
index 1376ca4280..576e8e0172 100644
--- a/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java
+++ b/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java
@@ -73,7 +73,7 @@ public class SimulatePipelineResponseTests extends ESTestCase {
SimulatePipelineResponse response = new SimulatePipelineResponse(randomAsciiOfLengthBetween(1, 10), isVerbose, results);
BytesStreamOutput out = new BytesStreamOutput();
response.writeTo(out);
- StreamInput streamInput = StreamInput.wrap(out.bytes());
+ StreamInput streamInput = out.bytes().streamInput();
SimulatePipelineResponse otherResponse = new SimulatePipelineResponse();
otherResponse.readFrom(streamInput);
diff --git a/core/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java b/core/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java
index f612f36c9d..ccf3a67494 100644
--- a/core/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java
+++ b/core/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java
@@ -48,7 +48,7 @@ public class SimulateProcessorResultTests extends ESTestCase {
BytesStreamOutput out = new BytesStreamOutput();
simulateProcessorResult.writeTo(out);
- StreamInput streamInput = StreamInput.wrap(out.bytes());
+ StreamInput streamInput = out.bytes().streamInput();
SimulateProcessorResult otherSimulateProcessorResult = new SimulateProcessorResult(streamInput);
assertThat(otherSimulateProcessorResult.getProcessorTag(), equalTo(simulateProcessorResult.getProcessorTag()));
if (isFailure) {
diff --git a/core/src/test/java/org/elasticsearch/action/ingest/WritePipelineResponseTests.java b/core/src/test/java/org/elasticsearch/action/ingest/WritePipelineResponseTests.java
index 3f252c3707..00327603ba 100644
--- a/core/src/test/java/org/elasticsearch/action/ingest/WritePipelineResponseTests.java
+++ b/core/src/test/java/org/elasticsearch/action/ingest/WritePipelineResponseTests.java
@@ -35,7 +35,7 @@ public class WritePipelineResponseTests extends ESTestCase {
response = new WritePipelineResponse(isAcknowledged);
BytesStreamOutput out = new BytesStreamOutput();
response.writeTo(out);
- StreamInput streamInput = StreamInput.wrap(out.bytes());
+ StreamInput streamInput = out.bytes().streamInput();
WritePipelineResponse otherResponse = new WritePipelineResponse();
otherResponse.readFrom(streamInput);
@@ -46,7 +46,7 @@ public class WritePipelineResponseTests extends ESTestCase {
WritePipelineResponse response = new WritePipelineResponse();
BytesStreamOutput out = new BytesStreamOutput();
response.writeTo(out);
- StreamInput streamInput = StreamInput.wrap(out.bytes());
+ StreamInput streamInput = out.bytes().streamInput();
WritePipelineResponse otherResponse = new WritePipelineResponse();
otherResponse.readFrom(streamInput);
diff --git a/core/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java b/core/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java
index a7ce842913..b4908846e9 100644
--- a/core/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java
+++ b/core/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java
@@ -112,7 +112,7 @@ public class WriteableIngestDocumentTests extends ESTestCase {
BytesStreamOutput out = new BytesStreamOutput();
writeableIngestDocument.writeTo(out);
- StreamInput streamInput = StreamInput.wrap(out.bytes());
+ StreamInput streamInput = out.bytes().streamInput();
WriteableIngestDocument otherWriteableIngestDocument = new WriteableIngestDocument(streamInput);
assertIngestDocument(otherWriteableIngestDocument.getIngestDocument(), writeableIngestDocument.getIngestDocument());
}