Move TestBSONDecorator.java

Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/279faf05
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/279faf05
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/279faf05

Branch: refs/heads/master
Commit: 279faf0538a9483395ed9369b5e91ff671c01694
Parents: 7eb2792
Author: Damien Raude-Morvan <dam...@dictanova.com>
Authored: Sat May 24 23:56:41 2014 +0200
Committer: Damien Raude-Morvan <dam...@dictanova.com>
Committed: Sat May 24 23:56:41 2014 +0200

----------------------------------------------------------------------
 .../apache/gora/mongodb/TestBSONDecorator.java  | 96 --------------------
 .../gora/mongodb/utils/TestBSONDecorator.java   | 95 +++++++++++++++++++
 2 files changed, 95 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/gora/blob/279faf05/gora-mongodb/src/test/java/org/apache/gora/mongodb/TestBSONDecorator.java
----------------------------------------------------------------------
diff --git 
a/gora-mongodb/src/test/java/org/apache/gora/mongodb/TestBSONDecorator.java 
b/gora-mongodb/src/test/java/org/apache/gora/mongodb/TestBSONDecorator.java
deleted file mode 100644
index dec4c5d..0000000
--- a/gora-mongodb/src/test/java/org/apache/gora/mongodb/TestBSONDecorator.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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.gora.mongodb;
-
-import static org.junit.Assert.*;
-
-import java.nio.ByteBuffer;
-
-import org.apache.gora.mongodb.utils.BSONDecorator;
-import org.junit.Test;
-
-import com.mongodb.BasicDBObject;
-import com.mongodb.BasicDBObjectBuilder;
-import com.mongodb.DBObject;
-
-public class TestBSONDecorator {
-
-  @Test
-  public void testContainsField() {
-    // Init the object used for testing
-    DBObject dbo1 = BasicDBObjectBuilder
-        .start()
-        .add("root0", "value")
-        .add("root1", new BasicDBObject("leaf1", 1))
-        .add("root2",
-            new BasicDBObject("parent1", new BasicDBObject("leaf2", "test")))
-        .get();
-    BSONDecorator dboc = new BSONDecorator(dbo1);
-
-    // Root level field, does exist
-    assertTrue(dboc.containsField("root0"));
-    // Root level field, does not exist
-    assertFalse(dboc.containsField("doestNotExist"));
-
-    // 1-deep level field, does exist
-    assertTrue(dboc.containsField("root1.leaf1"));
-    // 1-deep level field, parent does not exist
-    assertFalse(dboc.containsField("doesNotExist.leaf2"));
-    // 1-deep level field, leaf does not exist
-    assertFalse(dboc.containsField("root1.doestNotExist"));
-
-    // 3-deep level field, does exist
-    assertTrue(dboc.containsField("root2.parent1.leaf2"));
-    // 3-deep level field, leaf does not exist
-    assertFalse(dboc.containsField("root2.parent1.doestNotExist"));
-    // 3-deep level field, first parent does not exist
-    assertFalse(dboc.containsField("doesNotExist.parent1.leaf2"));
-    // 3-deep level field, intermediate parent does not exist
-    assertFalse(dboc.containsField("root2.doesNotExist.leaf2"));
-  }
-
-  @Test
-  public void testBinaryField() {
-    // Init the object used for testing
-    DBObject dbo1 = BasicDBObjectBuilder
-        .start()
-        .add("root0", "value")
-        .add("root1", new BasicDBObject("leaf1", "abcdefgh".getBytes()))
-        .add(
-            "root2",
-            new BasicDBObject("parent1", new BasicDBObject("leaf2", "test"
-                .getBytes())))
-        .add("root3", ByteBuffer.wrap("test2".getBytes())).get();
-    BSONDecorator dboc = new BSONDecorator(dbo1);
-
-    // Access first bytes field
-    assertTrue(dboc.containsField("root1.leaf1"));
-    assertArrayEquals("abcdefgh".getBytes(), dboc.getBytes("root1.leaf1")
-        .array());
-
-    // Access second bytes field
-    assertTrue(dboc.containsField("root2.parent1.leaf2"));
-    assertArrayEquals("test".getBytes(), dboc.getBytes("root2.parent1.leaf2")
-        .array());
-
-    // Access third bytes field
-    assertTrue(dboc.containsField("root3"));
-    assertArrayEquals("test2".getBytes(), dboc.getBytes("root3").array());
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/gora/blob/279faf05/gora-mongodb/src/test/java/org/apache/gora/mongodb/utils/TestBSONDecorator.java
----------------------------------------------------------------------
diff --git 
a/gora-mongodb/src/test/java/org/apache/gora/mongodb/utils/TestBSONDecorator.java
 
b/gora-mongodb/src/test/java/org/apache/gora/mongodb/utils/TestBSONDecorator.java
new file mode 100644
index 0000000..c25a9ae
--- /dev/null
+++ 
b/gora-mongodb/src/test/java/org/apache/gora/mongodb/utils/TestBSONDecorator.java
@@ -0,0 +1,95 @@
+/**
+ * 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.gora.mongodb.utils;
+
+import static org.junit.Assert.*;
+
+import java.nio.ByteBuffer;
+
+import org.junit.Test;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.BasicDBObjectBuilder;
+import com.mongodb.DBObject;
+
+public class TestBSONDecorator {
+
+  @Test
+  public void testContainsField() {
+    // Init the object used for testing
+    DBObject dbo1 = BasicDBObjectBuilder
+        .start()
+        .add("root0", "value")
+        .add("root1", new BasicDBObject("leaf1", 1))
+        .add("root2",
+            new BasicDBObject("parent1", new BasicDBObject("leaf2", "test")))
+        .get();
+    BSONDecorator dboc = new BSONDecorator(dbo1);
+
+    // Root level field, does exist
+    assertTrue(dboc.containsField("root0"));
+    // Root level field, does not exist
+    assertFalse(dboc.containsField("doestNotExist"));
+
+    // 1-deep level field, does exist
+    assertTrue(dboc.containsField("root1.leaf1"));
+    // 1-deep level field, parent does not exist
+    assertFalse(dboc.containsField("doesNotExist.leaf2"));
+    // 1-deep level field, leaf does not exist
+    assertFalse(dboc.containsField("root1.doestNotExist"));
+
+    // 3-deep level field, does exist
+    assertTrue(dboc.containsField("root2.parent1.leaf2"));
+    // 3-deep level field, leaf does not exist
+    assertFalse(dboc.containsField("root2.parent1.doestNotExist"));
+    // 3-deep level field, first parent does not exist
+    assertFalse(dboc.containsField("doesNotExist.parent1.leaf2"));
+    // 3-deep level field, intermediate parent does not exist
+    assertFalse(dboc.containsField("root2.doesNotExist.leaf2"));
+  }
+
+  @Test
+  public void testBinaryField() {
+    // Init the object used for testing
+    DBObject dbo1 = BasicDBObjectBuilder
+        .start()
+        .add("root0", "value")
+        .add("root1", new BasicDBObject("leaf1", "abcdefgh".getBytes()))
+        .add(
+            "root2",
+            new BasicDBObject("parent1", new BasicDBObject("leaf2", "test"
+                .getBytes())))
+        .add("root3", ByteBuffer.wrap("test2".getBytes())).get();
+    BSONDecorator dboc = new BSONDecorator(dbo1);
+
+    // Access first bytes field
+    assertTrue(dboc.containsField("root1.leaf1"));
+    assertArrayEquals("abcdefgh".getBytes(), dboc.getBytes("root1.leaf1")
+        .array());
+
+    // Access second bytes field
+    assertTrue(dboc.containsField("root2.parent1.leaf2"));
+    assertArrayEquals("test".getBytes(), dboc.getBytes("root2.parent1.leaf2")
+        .array());
+
+    // Access third bytes field
+    assertTrue(dboc.containsField("root3"));
+    assertArrayEquals("test2".getBytes(), dboc.getBytes("root3").array());
+  }
+
+}

Reply via email to