fix checking atomicLong in IgniteClientDataStructuresTest#testAtomicLong. - Fixes
@@ -24,6 +24,7 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteAtomicLong;
import org.apache.ignite.IgniteAtomicSequence;
import org.apache.ignite.IgniteCountDownLatch;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLock;
import org.apache.ignite.IgniteQueue;
import org.apache.ignite.IgniteSemaphore;
@@ -162,8 +163,43 @@ public abstract class IgniteClientDataStructuresAbstractTest extends GridCommonA
assertEquals(3L, cntr.get());
}
- assertNull(creator.atomicLong("long1", 1L, false));
- assertNull(other.atomicLong("long1", 1L, false));
+ assertAtomicLongClosedCorrect(creator.atomicLong("long1", 1L, false));
+ assertAtomicLongClosedCorrect(other.atomicLong("long1", 1L, false));
+ }
+
+ /**
+ * It is possible 3 variants:
+ * * input value is null, because it already delete.
+ * * input value is not null, but call 'get' method causes IllegalStateException because IgniteAtomicLong marked as delete.
+ * * input value is not null, but call 'get' method causes IgniteException
+ * because IgniteAtomicLong have not marked as delete yet but already removed from cache.
+ */
+ private void assertAtomicLongClosedCorrect(IgniteAtomicLong atomicLong) {
+ if (atomicLong == null)
+ assertNull(atomicLong);
+ else {
+ try {
+ atomicLong.get();
+
+ fail("Always should be exception because atomicLong was closed");
+ }
+ catch (IllegalStateException e) {
+ String expectedMessage = "Sequence was removed from cache";
+
+ assertTrue(
+ String.format("Exception should start with '%s' but was '%s'", expectedMessage, e.getMessage()),
+ e.getMessage().startsWith(expectedMessage)
+ );
+ }
+ catch (IgniteException e){
+ String expectedMessage = "Failed to find atomic long:";
+
+ assertTrue(
+ String.format("Exception should start with '%s' but was '%s'", expectedMessage, e.getMessage()),
+ e.getMessage().startsWith(expectedMessage)
+ );
+ }
+ }
}
/**
