Further changes to the test class and the formatting. And getValues method returns a taggedvaluepointable
Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/18a301e9 Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/18a301e9 Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/18a301e9 Branch: refs/heads/master Commit: 18a301e982f6f20be310708fa31b1021608515a5 Parents: 6527a28 Author: riyafa <[email protected]> Authored: Tue May 17 12:53:58 2016 +0530 Committer: riyafa <[email protected]> Committed: Tue May 17 12:53:58 2016 +0530 ---------------------------------------------------------------------- .../accessors/jsonItem/ObjectPointable.java | 4 +-- .../vxquery/datamodel/values/ValueTag.java | 2 +- .../datamodel/AbstractPointableTest.java | 2 +- .../vxquery/datamodel/ObjectByteTest.java | 28 ++++++++++---------- 4 files changed, 18 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/vxquery/blob/18a301e9/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java index 27c2d20..b8cf83b 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java @@ -61,7 +61,7 @@ public class ObjectPointable extends AbstractPointable { } private static int getKeyLength(byte[] b, int s) { - return UTF8StringPointable.getUTFLength(b,s+1) + 3; + return UTF8StringPointable.getUTFLength(b, s + 1) + 3; } private static int getSlotArrayOffset(int start) { @@ -95,7 +95,7 @@ public class ObjectPointable extends AbstractPointable { } } - public void getValue(TaggedValuePointable key, IPointable pointer) { + public void getValue(TaggedValuePointable key, TaggedValuePointable pointer) { int dataAreaOffset = getDataAreaOffset(bytes, start); int entryCount = getEntryCount(); int s, l; http://git-wip-us.apache.org/repos/asf/vxquery/blob/18a301e9/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java index 7827fe1..c464bc5 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java @@ -82,7 +82,7 @@ public class ValueTag { public static final int COMMENT_NODE_TAG = 105; public static final int PI_NODE_TAG = 106; public static final int NODE_TREE_TAG = 107; - public static final int OBJECT_TAG=109; + public static final int OBJECT_TAG = 109; public static boolean isAtomic(int tag) { return tag < 100; http://git-wip-us.apache.org/repos/asf/vxquery/blob/18a301e9/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java index 9c2a68b..d186c10 100644 --- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java +++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java @@ -30,7 +30,7 @@ public class AbstractPointableTest { int start = abvsInput.getLength(); if (value instanceof java.lang.Integer) { writeInteger((Integer) value, abvsInput.getDataOutput()); - }else if (value instanceof java.lang.Long) { + } else if (value instanceof java.lang.Long) { writeLong((Long) value, abvsInput.getDataOutput()); } else if (value instanceof java.lang.Double) { writeDouble((Double) value, abvsInput.getDataOutput()); http://git-wip-us.apache.org/repos/asf/vxquery/blob/18a301e9/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java index 197cd82..2b2e676 100644 --- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java +++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java @@ -22,7 +22,6 @@ import org.apache.vxquery.datamodel.accessors.TaggedValuePointable; import org.apache.vxquery.datamodel.accessors.jsonItem.ObjectPointable; import org.apache.vxquery.datamodel.builders.jsonItem.ObjectBuilder; import org.apache.vxquery.datamodel.values.ValueTag; -import org.apache.vxquery.datamodel.values.XDMConstants; import org.apache.vxquery.exceptions.SystemException; import org.apache.vxquery.runtime.functions.util.FunctionHelper; import org.junit.Test; @@ -50,7 +49,7 @@ public class ObjectByteTest extends AbstractPointableTest { ob.reset(abvsResult); ob.finish(); } catch (IOException e) { - Assert.fail("Test failed to write the sequence pointable."); + Assert.fail("Test failed to write the Object pointable."); } tvp.set(abvsResult); @@ -60,7 +59,7 @@ public class ObjectByteTest extends AbstractPointableTest { } tvp.getValue(op); if (op.getEntryCount() != 0) { - Assert.fail("Sequence size is incorrect. Expected: 0 Got: " + op.getEntryCount()); + Assert.fail("Object size is incorrect. Expected: 0 Got: " + op.getEntryCount()); } } @@ -85,6 +84,9 @@ public class ObjectByteTest extends AbstractPointableTest { } tvp.getValue(op); + if (op.getEntryCount() != 1) { + Assert.fail("Object size is incorrect. Expected: 1 Got: " + op.getEntryCount()); + } try { op.getKeys(tvp); } catch (SystemException e) { @@ -95,7 +97,7 @@ public class ObjectByteTest extends AbstractPointableTest { Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag()); } if (!FunctionHelper.arraysEqual(tvp, tvp1)) { - Assert.fail("Key is incorrect."); + Assert.fail("Key is incorrect. Expected: id"); } op.getValue(tvp1, tvp); @@ -142,39 +144,37 @@ public class ObjectByteTest extends AbstractPointableTest { } if (tvp.getTag() != ValueTag.SEQUENCE_TAG) { - Assert.fail("Sequence tag is incorrect. Expected: " + ValueTag.SEQUENCE_TAG + " Got: " + tvp.getTag()); + Assert.fail("Object tag is incorrect. Expected: " + ValueTag.SEQUENCE_TAG + " Got: " + tvp.getTag()); } tvp.getValue(sp); if (sp.getEntryCount() != 3) { - Assert.fail("Sequence size is incorrect. Expected: 3 Got: " + sp.getEntryCount()); + Assert.fail("Object size is incorrect. Expected: 3 Got: " + sp.getEntryCount()); } sp.getEntry(0, tvp); if (!FunctionHelper.arraysEqual(tvp, tvp1)) { - Assert.fail("Sequence item one is incorrect. Expected: " + ValueTag.XS_LONG_TAG + " Got: " + tvp.getTag()); + Assert.fail("Object key one is incorrect. Expected: name"); } sp.getEntry(1, tvp); if (!FunctionHelper.arraysEqual(tvp, tvp3)) { - Assert.fail( - "Sequence item two is incorrect. Expected: " + ValueTag.XS_DOUBLE_TAG + " Got: " + tvp.getTag()); + Assert.fail("Object key two is incorrect. Expected: price"); } sp.getEntry(2, tvp); if (!FunctionHelper.arraysEqual(tvp, tvp5)) { - Assert.fail( - "Sequence item three is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag()); + Assert.fail("Object key three is incorrect. Expected: properties"); } //Test values op.getValue(tvp1, tvp); if (!FunctionHelper.arraysEqual(tvp, tvp2)) { - Assert.fail("Value is incorrect for the given key."); + Assert.fail("Value is incorrect for the given key. Expected: A green door"); } op.getValue(tvp3, tvp); if (!FunctionHelper.arraysEqual(tvp, tvp4)) { - Assert.fail("Value is incorrect for the given key."); + Assert.fail("Value is incorrect for the given key. Expected: 12.5"); } op.getValue(tvp5, tvp); if (!FunctionHelper.arraysEqual(tvp, tvp6)) { - Assert.fail("Value is incorrect for the given key."); + Assert.fail("Value is incorrect for the given key. Expected: 100"); } }
