Repository: apex-malhar
Updated Branches:
  refs/heads/master d1fb2b604 -> 9b6e11d85


http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/9b6e11d8/library/src/test/java/org/apache/apex/malhar/lib/state/spillable/inmem/InMemorySpillableStateStoreTest.java
----------------------------------------------------------------------
diff --git 
a/library/src/test/java/org/apache/apex/malhar/lib/state/spillable/inmem/InMemorySpillableStateStoreTest.java
 
b/library/src/test/java/org/apache/apex/malhar/lib/state/spillable/inmem/InMemorySpillableStateStoreTest.java
new file mode 100644
index 0000000..769bc0d
--- /dev/null
+++ 
b/library/src/test/java/org/apache/apex/malhar/lib/state/spillable/inmem/InMemorySpillableStateStoreTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.apex.malhar.lib.state.spillable.inmem;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.util.TestUtils;
+
+public class InMemorySpillableStateStoreTest
+{
+  @Test
+  public void simpleStoreTest()
+  {
+    InMemSpillableStateStore store = new InMemSpillableStateStore();
+
+    store.setup(null);
+
+    long windowId = 0L;
+    store.beginWindow(windowId);
+    windowId++;
+
+    Assert.assertEquals(null, store.getSync(0L, TestUtils.getSlice(1)));
+
+    store.put(0L, TestUtils.getSlice(1), TestUtils.getSlice(2));
+    store.put(0L, TestUtils.getSlice(3), TestUtils.getSlice(10));
+    store.put(1L, TestUtils.getSlice(2), TestUtils.getSlice(3));
+    store.put(1L, TestUtils.getSlice(4), TestUtils.getSlice(11));
+
+    Assert.assertEquals(null, store.getSync(0L, TestUtils.getSlice(2)));
+    Assert.assertEquals(null, store.getSync(0L, TestUtils.getSlice(4)));
+    Assert.assertEquals(TestUtils.getSlice(2), store.getSync(0L, 
TestUtils.getSlice(1)));
+    Assert.assertEquals(TestUtils.getSlice(10), store.getSync(0L, 
TestUtils.getSlice(3)));
+
+    Assert.assertEquals(null, store.getSync(1L, TestUtils.getSlice(1)));
+    Assert.assertEquals(null, store.getSync(1L, TestUtils.getSlice(3)));
+    Assert.assertEquals(TestUtils.getSlice(3), store.getSync(1L, 
TestUtils.getSlice(2)));
+    Assert.assertEquals(TestUtils.getSlice(11), store.getSync(1L, 
TestUtils.getSlice(4)));
+
+    store.endWindow();
+
+    store.teardown();
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/9b6e11d8/library/src/test/java/org/apache/apex/malhar/lib/utils/serde/SerdeListSliceTest.java
----------------------------------------------------------------------
diff --git 
a/library/src/test/java/org/apache/apex/malhar/lib/utils/serde/SerdeListSliceTest.java
 
b/library/src/test/java/org/apache/apex/malhar/lib/utils/serde/SerdeListSliceTest.java
new file mode 100644
index 0000000..f7753d2
--- /dev/null
+++ 
b/library/src/test/java/org/apache/apex/malhar/lib/utils/serde/SerdeListSliceTest.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.apex.malhar.lib.utils.serde;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.common.collect.Lists;
+
+import com.datatorrent.netlet.util.Slice;
+
+public class SerdeListSliceTest
+{
+  @Test
+  public void simpleSerdeTest()
+  {
+    SerdeListSlice<String> serdeList = new SerdeListSlice<String>(new 
SerdeStringSlice());
+
+    List<String> stringList = Lists.newArrayList("a", "b", "c");
+
+    Slice slice = serdeList.serialize(stringList);
+
+    List<String> deserializedList = serdeList.deserialize(slice);
+
+    Assert.assertEquals(stringList, deserializedList);
+  }
+}

Reply via email to