Search in sources :

Example 21 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RangeTest method byteStringSerializationTest.

@Test
public void byteStringSerializationTest() throws IOException, ClassNotFoundException {
    ByteStringRange expected = ByteStringRange.create("a", "z");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(expected);
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
    ByteStringRange actual = (ByteStringRange) ois.readObject();
    assertThat(actual).isEqualTo(expected);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 22 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RangeTest method byteStringOfStringTest.

@Test
public void byteStringOfStringTest() {
    ByteStringRange range = ByteStringRange.create("a", "b");
    assertThat(range.getStartBound()).isEqualTo(BoundType.CLOSED);
    assertThat(range.getStart()).isEqualTo(ByteString.copyFromUtf8("a"));
    assertThat(range.getEndBound()).isEqualTo(BoundType.OPEN);
    assertThat(range.getEnd()).isEqualTo(ByteString.copyFromUtf8("b"));
}
Also used : ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) Test(org.junit.Test)

Aggregations

ByteStringRange (com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange)22 Test (org.junit.Test)20 RowSet (com.google.bigtable.v2.RowSet)10 RowRange (com.google.bigtable.v2.RowRange)1 RowKeyWrapper (com.google.cloud.bigtable.hbase.util.RowKeyWrapper)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ByteString (com.google.protobuf.ByteString)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1