State machine implementations for various distributed primitives based on latest Copycat APIs

Change-Id: I622cc196aa1cdf072a5a0b100a5ffaaf71b07900
diff --git a/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixLongTest.java b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixLongTest.java
new file mode 100644
index 0000000..d38400d
--- /dev/null
+++ b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixLongTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.primitives.resources.impl;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import io.atomix.Atomix;
+import io.atomix.resource.ResourceType;
+import io.atomix.variables.DistributedLong;
+
+/**
+ * Unit tests for {@link AtomixCounter}.
+ */
+public class AtomixLongTest extends AtomixTestBase {
+
+    @Override
+    protected ResourceType resourceType() {
+        return new ResourceType(DistributedLong.class);
+    }
+
+    @Test
+    public void testBasicOperations() throws Throwable {
+        basicOperationsTest(1);
+        clearTests();
+        basicOperationsTest(2);
+        clearTests();
+        basicOperationsTest(3);
+        clearTests();
+    }
+
+    protected void basicOperationsTest(int clusterSize) throws Throwable {
+        createCopycatServers(clusterSize);
+        Atomix atomix = createAtomixClient();
+        AtomixCounter along = new AtomixCounter("test-long", atomix.getLong("test-long").join());
+        assertEquals(0, along.get().join().longValue());
+        assertEquals(1, along.incrementAndGet().join().longValue());
+        along.set(100).join();
+        assertEquals(100, along.get().join().longValue());
+        assertEquals(100, along.getAndAdd(10).join().longValue());
+        assertEquals(110, along.get().join().longValue());
+        assertFalse(along.compareAndSet(109, 111).join());
+        assertTrue(along.compareAndSet(110, 111).join());
+        assertEquals(100, along.addAndGet(-11).join().longValue());
+        assertEquals(100, along.getAndIncrement().join().longValue());
+        assertEquals(101, along.get().join().longValue());
+    }
+}