예제 #1
0
 public static String get(final MockHTable table, final byte[] key) throws IOException {
   Get get = new Get(key);
   Result result = null;
   result = table.get(get);
   Assert.assertEquals(1, result.size());
   return Bytes.toString(result.getValue(SYNC_COLUMN_FAMILY, SYNC_COLUMN_QUALIFIER));
 }
예제 #2
0
  public static void put(final MockHTable table, final byte[] key, final String value)
      throws IOException {
    List<Put> puts = new ArrayList<Put>();
    Put put = new Put(key);
    put.add(SYNC_COLUMN_FAMILY, SYNC_COLUMN_QUALIFIER, Bytes.toBytes(value));

    puts.add(put);
    table.put(puts);
  }
예제 #3
0
  @Test
  public void testResetValue() {
    final String value1 = "val1";
    final String value2 = "val2";
    final byte[] key = Bytes.toBytes("key");

    MockHTable table = MockHTable.create(TEST_TABLE_NAME);

    try {
      put(table, key, value1);
      Assert.assertEquals(value1, get(table, key));
      put(table, key, value2);
      Assert.assertEquals(value2, get(table, key));
    } catch (IOException e) {
      throw new HBaseRuntimeException("Could not get from HBase!", e);
    }
  }