Search in sources :

Example 1 with BytesStreamInput

use of org.elasticsearch.common.io.stream.BytesStreamInput in project geocluster-facet by zenobase.

the class GeoClusterTests method testReadFromWriteTo.

@Test
public void testReadFromWriteTo() throws IOException {
    GeoCluster expected = new GeoCluster(42, DENVER, COLORADO);
    BytesStreamOutput out = new BytesStreamOutput();
    expected.writeTo(out);
    BytesStreamInput in = new BytesStreamInput(out.bytes());
    GeoCluster actual = GeoCluster.readFrom(in);
    assertThat("Center", actual.center(), closeTo(DENVER));
    assertThat("Bounds", actual.bounds(), equalTo(COLORADO));
}
Also used : BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) BytesStreamInput(org.elasticsearch.common.io.stream.BytesStreamInput) Test(org.testng.annotations.Test)

Example 2 with BytesStreamInput

use of org.elasticsearch.common.io.stream.BytesStreamInput in project geocluster-facet by zenobase.

the class GeoPointsTests method testReadFromWriteTo.

@Test
public void testReadFromWriteTo() throws IOException {
    BytesStreamOutput out = new BytesStreamOutput();
    GeoPoints.writeTo(LAS_VEGAS, out);
    BytesStreamInput in = new BytesStreamInput(out.bytes());
    GeoPoint point = GeoPoints.readFrom(in);
    assertThat("Latitude", point.lat(), equalTo(LAS_VEGAS.lat()));
    assertThat("Longitude", point.lon(), equalTo(LAS_VEGAS.lon()));
}
Also used : GeoPoint(org.elasticsearch.common.geo.GeoPoint) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) BytesStreamInput(org.elasticsearch.common.io.stream.BytesStreamInput) Test(org.testng.annotations.Test)

Example 3 with BytesStreamInput

use of org.elasticsearch.common.io.stream.BytesStreamInput in project geocluster-facet by zenobase.

the class GeoClusterTests method testReadFromWriteToSingleton.

@Test
public void testReadFromWriteToSingleton() throws IOException {
    GeoCluster expected = new GeoCluster(DENVER);
    BytesStreamOutput out = new BytesStreamOutput();
    expected.writeTo(out);
    BytesStreamInput in = new BytesStreamInput(out.bytes());
    GeoCluster actual = GeoCluster.readFrom(in);
    assertThat("Center", actual.center(), closeTo(DENVER));
    assertThat("Bounds", actual.bounds(), equalTo(new GeoBoundingBox(DENVER)));
}
Also used : BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) BytesStreamInput(org.elasticsearch.common.io.stream.BytesStreamInput) Test(org.testng.annotations.Test)

Aggregations

BytesStreamInput (org.elasticsearch.common.io.stream.BytesStreamInput)3 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)3 Test (org.testng.annotations.Test)3 GeoPoint (org.elasticsearch.common.geo.GeoPoint)1