From 0c7ab9be97e2c9ace54c05e3fa7c494e4987b4d6 Mon Sep 17 00:00:00 2001 From: Johan Zeeck Date: Tue, 5 Aug 2014 13:42:02 +0200 Subject: [PATCH] added fix for the change with optionals --- test/storage/TestHBaseStore.java | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/storage/TestHBaseStore.java b/test/storage/TestHBaseStore.java index 8199e53c30..d6fdd19fa2 100644 --- a/test/storage/TestHBaseStore.java +++ b/test/storage/TestHBaseStore.java @@ -189,7 +189,7 @@ public void allocateUIDUnableToIncrementMaxId() throws Exception { @Test // Test the creation of an ID with a race condition. - public void getOrCreateIdAssignIdWithRaceCondition() { + public void getOrCreateIdAssignIdWithRaceCondition() throws Exception{ // Simulate a race between client A and client B. // A does a Get and sees that there's no ID for this name. // B does a Get and sees that there's no ID too, and B actually goes @@ -211,17 +211,18 @@ public void getOrCreateIdAssignIdWithRaceCondition() { .thenReturn(Deferred.fromResult(false)); // For simplicity return an empty ArrayList, then the call back should return // null + final byte[] value = {'1','2','3'}; + ArrayList al = new ArrayList(); + al.add(new KeyValue(new byte[] {'h', 'o', 's', 't'}, new byte[] {}, + new byte[] {}, value)); when(client.get(any(GetRequest.class))) - .thenReturn(Deferred.fromResult(new ArrayList())); - - try { - byte[] uid = tsdb_store.allocateUID(foo_array, UniqueId.UniqueIdType.METRIC, - UniqueId.UniqueIdType.METRIC.width).joinUninterruptibly(); - if (null != uid) - fail("Should have received null but received uid = " + uid); - } catch (Exception e) { - fail("Received unexpected exception = " + e); - } + .thenReturn(Deferred.fromResult(al)); + + + byte[] uid = tsdb_store.allocateUID(foo_array, UniqueId.UniqueIdType.METRIC, + UniqueId.UniqueIdType.METRIC.width).joinUninterruptibly(); + assertEquals(value,uid); + // Verify the order of execution too. final InOrder order = inOrder(client); order.verify(client, times(1)).atomicIncrement(incrementForRow(MAX_UID));