BUG 2325 : Value type of byte[] not recognized by the NormalizedNodeSerializer 28/12528/4
authorMoiz Raja <moraja@cisco.com>
Wed, 5 Nov 2014 19:09:06 +0000 (11:09 -0800)
committerMoiz Raja <moraja@cisco.com>
Wed, 5 Nov 2014 19:55:07 +0000 (11:55 -0800)
Change-Id: I16eab6cdbf7712624f2c1fafb5bf41107b6ae379
Signed-off-by: Moiz Raja <moraja@cisco.com>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueType.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java
opendaylight/md-sal/sal-clustering-commons/src/main/resources/Common.proto
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/NormalizedNodeSerializerTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueTypeTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java
opendaylight/md-sal/sal-clustering-commons/src/test/resources/odl-datastore-test.yang

index 6a843f57c7718fb76911e90649b7194e3b6db0bb..aac45e18b5d7c420eeae0f6d47b62fdee6cb3078 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
 
+import com.google.protobuf.ByteString;
 import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
 import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
@@ -28,16 +29,18 @@ public class ValueSerializer {
                 InstanceIdentifierUtils.toSerializable((YangInstanceIdentifier) value, context));
         } else if(value instanceof Set) {
             Set set = (Set) value;
-            if(!set.isEmpty()){
-                for(Object o : set){
-                    if(o instanceof String){
+            if (!set.isEmpty()) {
+                for (Object o : set) {
+                    if (o instanceof String) {
                         builder.addBitsValue(o.toString());
                     } else {
                         throw new IllegalArgumentException("Expected value type to be Bits but was : " +
-                            value.toString());
+                                value.toString());
                     }
                 }
             }
+        } else if(value instanceof byte[]){
+            builder.setBytesValue(ByteString.copyFrom((byte[]) value));
         } else {
             builder.setValue(value.toString());
         }
@@ -57,6 +60,8 @@ public class ValueSerializer {
                     node.getInstanceIdentifierValue(), context);
         } else if(node.getIntValueType() == ValueType.BITS_TYPE.ordinal()){
             return new HashSet(node.getBitsValueList());
+        } else if(node.getIntValueType() == ValueType.BINARY_TYPE.ordinal()){
+            return node.getBytesValue().toByteArray();
         }
         return deSerializeBasicTypes(node.getIntValueType(), node.getValue());
     }
index 49db8967a685914924eb4e90d5914ecdbc1b43a8..6c884734e298a54dea541fe4973404365db41573 100644 (file)
@@ -29,7 +29,8 @@ public enum ValueType {
     YANG_IDENTIFIER_TYPE,
     STRING_TYPE,
     BIG_INTEGER_TYPE,
-    BIG_DECIMAL_TYPE;
+    BIG_DECIMAL_TYPE,
+    BINARY_TYPE;
 
     private static Map<Class, ValueType> types = new HashMap<>();
 
@@ -45,6 +46,7 @@ public enum ValueType {
         types.put(Short.class,SHORT_TYPE);
         types.put(BigInteger.class, BIG_INTEGER_TYPE);
         types.put(BigDecimal.class, BIG_DECIMAL_TYPE);
+        types.put(byte[].class, BINARY_TYPE);
     }
 
     public static final ValueType getSerializableType(Object node){
index e7f2c361aeb0615c52ff44002ee1b35451396b46..8285009d359fd56ff6d6ed797d3473e7440b7d60 100644 (file)
@@ -5410,6 +5410,16 @@ public final class NormalizedNodeMessages {
      */
     com.google.protobuf.ByteString
         getCodeBytes(int index);
+
+    // optional bytes bytesValue = 13;
+    /**
+     * <code>optional bytes bytesValue = 13;</code>
+     */
+    boolean hasBytesValue();
+    /**
+     * <code>optional bytes bytesValue = 13;</code>
+     */
+    com.google.protobuf.ByteString getBytesValue();
   }
   /**
    * Protobuf type {@code org.opendaylight.controller.mdsal.Node}
@@ -5550,6 +5560,11 @@ public final class NormalizedNodeMessages {
               code_.add(input.readBytes());
               break;
             }
+            case 106: {
+              bitField0_ |= 0x00000100;
+              bytesValue_ = input.readBytes();
+              break;
+            }
           }
         }
       } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -6070,6 +6085,22 @@ public final class NormalizedNodeMessages {
       return code_.getByteString(index);
     }
 
+    // optional bytes bytesValue = 13;
+    public static final int BYTESVALUE_FIELD_NUMBER = 13;
+    private com.google.protobuf.ByteString bytesValue_;
+    /**
+     * <code>optional bytes bytesValue = 13;</code>
+     */
+    public boolean hasBytesValue() {
+      return ((bitField0_ & 0x00000100) == 0x00000100);
+    }
+    /**
+     * <code>optional bytes bytesValue = 13;</code>
+     */
+    public com.google.protobuf.ByteString getBytesValue() {
+      return bytesValue_;
+    }
+
     private void initFields() {
       path_ = "";
       type_ = "";
@@ -6083,6 +6114,7 @@ public final class NormalizedNodeMessages {
       instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance();
       bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY;
       code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+      bytesValue_ = com.google.protobuf.ByteString.EMPTY;
     }
     private byte memoizedIsInitialized = -1;
     public final boolean isInitialized() {
@@ -6156,6 +6188,9 @@ public final class NormalizedNodeMessages {
       for (int i = 0; i < code_.size(); i++) {
         output.writeBytes(12, code_.getByteString(i));
       }
+      if (((bitField0_ & 0x00000100) == 0x00000100)) {
+        output.writeBytes(13, bytesValue_);
+      }
       getUnknownFields().writeTo(output);
     }
 
@@ -6223,6 +6258,10 @@ public final class NormalizedNodeMessages {
         size += dataSize;
         size += 1 * getCodeList().size();
       }
+      if (((bitField0_ & 0x00000100) == 0x00000100)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeBytesSize(13, bytesValue_);
+      }
       size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
       return size;
@@ -6383,6 +6422,8 @@ public final class NormalizedNodeMessages {
         bitField0_ = (bitField0_ & ~0x00000400);
         code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
         bitField0_ = (bitField0_ & ~0x00000800);
+        bytesValue_ = com.google.protobuf.ByteString.EMPTY;
+        bitField0_ = (bitField0_ & ~0x00001000);
         return this;
       }
 
@@ -6481,6 +6522,10 @@ public final class NormalizedNodeMessages {
           bitField0_ = (bitField0_ & ~0x00000800);
         }
         result.code_ = code_;
+        if (((from_bitField0_ & 0x00001000) == 0x00001000)) {
+          to_bitField0_ |= 0x00000100;
+        }
+        result.bytesValue_ = bytesValue_;
         result.bitField0_ = to_bitField0_;
         onBuilt();
         return result;
@@ -6601,6 +6646,9 @@ public final class NormalizedNodeMessages {
           }
           onChanged();
         }
+        if (other.hasBytesValue()) {
+          setBytesValue(other.getBytesValue());
+        }
         this.mergeUnknownFields(other.getUnknownFields());
         return this;
       }
@@ -8110,6 +8158,42 @@ public final class NormalizedNodeMessages {
         return this;
       }
 
+      // optional bytes bytesValue = 13;
+      private com.google.protobuf.ByteString bytesValue_ = com.google.protobuf.ByteString.EMPTY;
+      /**
+       * <code>optional bytes bytesValue = 13;</code>
+       */
+      public boolean hasBytesValue() {
+        return ((bitField0_ & 0x00001000) == 0x00001000);
+      }
+      /**
+       * <code>optional bytes bytesValue = 13;</code>
+       */
+      public com.google.protobuf.ByteString getBytesValue() {
+        return bytesValue_;
+      }
+      /**
+       * <code>optional bytes bytesValue = 13;</code>
+       */
+      public Builder setBytesValue(com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00001000;
+        bytesValue_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>optional bytes bytesValue = 13;</code>
+       */
+      public Builder clearBytesValue() {
+        bitField0_ = (bitField0_ & ~0x00001000);
+        bytesValue_ = getDefaultInstance().getBytesValue();
+        onChanged();
+        return this;
+      }
+
       // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.Node)
     }
 
@@ -10287,7 +10371,7 @@ public final class NormalizedNodeMessages {
       "ntroller.mdsal.Attribute\022\017\n\007intType\030\006 \001(" +
       "\005\"f\n\022InstanceIdentifier\022B\n\targuments\030\001 \003" +
       "(\0132/.org.opendaylight.controller.mdsal.P" +
-      "athArgument\022\014\n\004code\030\002 \003(\t\"\245\003\n\004Node\022\014\n\004pa" +
+      "athArgument\022\014\n\004code\030\002 \003(\t\"\271\003\n\004Node\022\014\n\004pa" +
       "th\030\001 \001(\t\022\014\n\004type\030\002 \001(\t\022E\n\014pathArgument\030\003" +
       " \001(\0132/.org.opendaylight.controller.mdsal" +
       ".PathArgument\022\017\n\007intType\030\004 \001(\005\022@\n\nattrib",
@@ -10298,17 +10382,18 @@ public final class NormalizedNodeMessages {
       "pe\030\t \001(\005\022V\n\027instanceIdentifierValue\030\n \001(" +
       "\01325.org.opendaylight.controller.mdsal.In" +
       "stanceIdentifier\022\021\n\tbitsValue\030\013 \003(\t\022\014\n\004c" +
-      "ode\030\014 \003(\t\"`\n\tContainer\022\022\n\nparentPath\030\001 \002" +
-      "(\t\022?\n\016normalizedNode\030\002 \001(\0132\'.org.openday" +
-      "light.controller.mdsal.Node\"\246\001\n\014NodeMapE",
-      "ntry\022U\n\026instanceIdentifierPath\030\001 \002(\01325.o" +
-      "rg.opendaylight.controller.mdsal.Instanc" +
-      "eIdentifier\022?\n\016normalizedNode\030\002 \001(\0132\'.or" +
-      "g.opendaylight.controller.mdsal.Node\"N\n\007" +
-      "NodeMap\022C\n\nmapEntries\030\001 \003(\0132/.org.openda" +
-      "ylight.controller.mdsal.NodeMapEntryBO\n5" +
-      "org.opendaylight.controller.protobuff.me" +
-      "ssages.commonB\026NormalizedNodeMessages"
+      "ode\030\014 \003(\t\022\022\n\nbytesValue\030\r \001(\014\"`\n\tContain" +
+      "er\022\022\n\nparentPath\030\001 \002(\t\022?\n\016normalizedNode" +
+      "\030\002 \001(\0132\'.org.opendaylight.controller.mds",
+      "al.Node\"\246\001\n\014NodeMapEntry\022U\n\026instanceIden" +
+      "tifierPath\030\001 \002(\01325.org.opendaylight.cont" +
+      "roller.mdsal.InstanceIdentifier\022?\n\016norma" +
+      "lizedNode\030\002 \001(\0132\'.org.opendaylight.contr" +
+      "oller.mdsal.Node\"N\n\007NodeMap\022C\n\nmapEntrie" +
+      "s\030\001 \003(\0132/.org.opendaylight.controller.md" +
+      "sal.NodeMapEntryBO\n5org.opendaylight.con" +
+      "troller.protobuff.messages.commonB\026Norma" +
+      "lizedNodeMessages"
     };
     com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
       new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -10350,7 +10435,7 @@ public final class NormalizedNodeMessages {
           internal_static_org_opendaylight_controller_mdsal_Node_fieldAccessorTable = new
             com.google.protobuf.GeneratedMessage.FieldAccessorTable(
               internal_static_org_opendaylight_controller_mdsal_Node_descriptor,
-              new java.lang.String[] { "Path", "Type", "PathArgument", "IntType", "Attributes", "Child", "Value", "ValueType", "IntValueType", "InstanceIdentifierValue", "BitsValue", "Code", });
+              new java.lang.String[] { "Path", "Type", "PathArgument", "IntType", "Attributes", "Child", "Value", "ValueType", "IntValueType", "InstanceIdentifierValue", "BitsValue", "Code", "BytesValue", });
           internal_static_org_opendaylight_controller_mdsal_Container_descriptor =
             getDescriptor().getMessageTypes().get(6);
           internal_static_org_opendaylight_controller_mdsal_Container_fieldAccessorTable = new
index 356bfbf684295a0392198dd0b02d92fcf12b4d25..842a9725d166452a229625c36c51ee73c31d73d8 100644 (file)
@@ -63,6 +63,8 @@ message Node{
   repeated string bitsValue = 11; // intValueType = Bits
 
   repeated string code = 12; // A list of string codes which can be used for any repeated strings in the NormalizedNode
+
+  optional bytes bytesValue = 13;
 }
 
 message Container{
index cdb2e69e831eb67cab28311919f9d30e0698d7ec..bcc0fd85d0f343f7b1e9ec02ed6c4a6aec1f4027 100644 (file)
@@ -1,15 +1,20 @@
 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
 
+import com.google.common.base.Optional;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.opendaylight.controller.cluster.datastore.util.TestModel;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 public class NormalizedNodeSerializerTest {
 
@@ -49,6 +54,37 @@ public class NormalizedNodeSerializerTest {
         // created by serializing the original node and deSerializing it back.
         assertEquals(expectedNode, actualNode);
 
+        byte[] binaryData = new byte[5];
+        for(byte i=0;i<5;i++){
+            binaryData[i] = i;
+        }
+
+        ContainerNode node1 = TestModel.createBaseTestContainerBuilder()
+                .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATE_QNAME, binaryData))
+                .build();
+
+        NormalizedNodeMessages.Node serializedNode1 = NormalizedNodeSerializer
+                .serialize(node1);
+
+        ContainerNode node2 =
+                (ContainerNode) NormalizedNodeSerializer.deSerialize(serializedNode1);
+
+
+        // FIXME: This will not work due to BUG 2326. Once that is fixed we can uncomment this assertion
+        // assertEquals(node1, node2);
+
+        Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> child = node2.getChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.SOME_BINARY_DATE_QNAME));
+
+        Object value = child.get().getValue();
+
+        assertTrue("value should be of type byte[]", value instanceof byte[]);
+
+        byte[] bytesValue = (byte[]) value;
+
+        for(byte i=0;i<5;i++){
+            assertEquals(i, bytesValue[i]);
+        }
+
     }
 
     @Test(expected = NullPointerException.class)
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueTypeTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueTypeTest.java
new file mode 100644 (file)
index 0000000..8fe0633
--- /dev/null
@@ -0,0 +1,18 @@
+package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ValueTypeTest {
+
+    @Test
+    public void testGetSerializableType(){
+        byte[] b = new byte[10];
+        b[0] = 1;
+        b[2] = 2;
+
+        ValueType serializableType = ValueType.getSerializableType(b);
+        assertEquals(ValueType.BINARY_TYPE, serializableType);
+    }
+}
\ No newline at end of file
index cda4b06e2926cf42bb8c975c8e4b7fd79a89b781..99df01a32e17c9c10c0e4ada9268e52e15008162 100644 (file)
@@ -62,6 +62,7 @@ public class TestModel {
 
   public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc");
   public static final QName POINTER_QNAME = QName.create(TEST_QNAME, "pointer");
+  public static final QName SOME_BINARY_DATE_QNAME = QName.create(TEST_QNAME, "some-binary-data");
   public static final QName SOME_REF_QNAME = QName.create(TEST_QNAME,
       "some-ref");
   public static final QName MYIDENTITY_QNAME = QName.create(TEST_QNAME,
@@ -282,114 +283,115 @@ public class TestModel {
 
   }
 
-  public static ContainerNode createTestContainer() {
-
-
-    // Create a list of shoes
-    // This is to test leaf list entry
-    final LeafSetEntryNode<Object> nike =
-        ImmutableLeafSetEntryNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeWithValue(QName.create(
-                    TEST_QNAME, "shoe"), "nike")).withValue("nike").build();
-
-    final LeafSetEntryNode<Object> puma =
-        ImmutableLeafSetEntryNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeWithValue(QName.create(
-                    TEST_QNAME, "shoe"), "puma")).withValue("puma").build();
-
-    final LeafSetNode<Object> shoes =
-        ImmutableLeafSetNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeIdentifier(QName.create(
-                    TEST_QNAME, "shoe"))).withChild(nike).withChild(puma)
-            .build();
-
-
-    // Test a leaf-list where each entry contains an identity
-    final LeafSetEntryNode<Object> cap1 =
-        ImmutableLeafSetEntryNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeWithValue(QName.create(
-                    TEST_QNAME, "capability"), DESC_QNAME))
-            .withValue(DESC_QNAME).build();
-
-    final LeafSetNode<Object> capabilities =
-        ImmutableLeafSetNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeIdentifier(QName.create(
-                    TEST_QNAME, "capability"))).withChild(cap1).build();
-
-    ContainerNode switchFeatures =
-        ImmutableContainerNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeIdentifier(SWITCH_FEATURES_QNAME))
-            .withChild(capabilities).build();
-
-    // Create a leaf list with numbers
-    final LeafSetEntryNode<Object> five =
-        ImmutableLeafSetEntryNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                (new YangInstanceIdentifier.NodeWithValue(QName.create(
-                    TEST_QNAME, "number"), 5))).withValue(5).build();
-    final LeafSetEntryNode<Object> fifteen =
-        ImmutableLeafSetEntryNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                (new YangInstanceIdentifier.NodeWithValue(QName.create(
-                    TEST_QNAME, "number"), 15))).withValue(15).build();
-    final LeafSetNode<Object> numbers =
-        ImmutableLeafSetNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeIdentifier(QName.create(
-                    TEST_QNAME, "number"))).withChild(five).withChild(fifteen)
-            .build();
-
-
-    // Create augmentations
-    MapEntryNode mapEntry = createAugmentedListEntry(1, "First Test");
-
-    // Create a bits leaf
+  public static DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> createBaseTestContainerBuilder() {
+      // Create a list of shoes
+      // This is to test leaf list entry
+      final LeafSetEntryNode<Object> nike =
+              ImmutableLeafSetEntryNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                      TEST_QNAME, "shoe"), "nike")).withValue("nike").build();
+
+      final LeafSetEntryNode<Object> puma =
+              ImmutableLeafSetEntryNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                      TEST_QNAME, "shoe"), "puma")).withValue("puma").build();
+
+      final LeafSetNode<Object> shoes =
+              ImmutableLeafSetNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeIdentifier(QName.create(
+                                      TEST_QNAME, "shoe"))).withChild(nike).withChild(puma)
+                      .build();
+
+
+      // Test a leaf-list where each entry contains an identity
+      final LeafSetEntryNode<Object> cap1 =
+              ImmutableLeafSetEntryNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                      TEST_QNAME, "capability"), DESC_QNAME))
+                      .withValue(DESC_QNAME).build();
+
+      final LeafSetNode<Object> capabilities =
+              ImmutableLeafSetNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeIdentifier(QName.create(
+                                      TEST_QNAME, "capability"))).withChild(cap1).build();
+
+      ContainerNode switchFeatures =
+              ImmutableContainerNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeIdentifier(SWITCH_FEATURES_QNAME))
+                      .withChild(capabilities).build();
+
+      // Create a leaf list with numbers
+      final LeafSetEntryNode<Object> five =
+              ImmutableLeafSetEntryNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              (new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                      TEST_QNAME, "number"), 5))).withValue(5).build();
+      final LeafSetEntryNode<Object> fifteen =
+              ImmutableLeafSetEntryNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              (new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                      TEST_QNAME, "number"), 15))).withValue(15).build();
+      final LeafSetNode<Object> numbers =
+              ImmutableLeafSetNodeBuilder
+                      .create()
+                      .withNodeIdentifier(
+                              new YangInstanceIdentifier.NodeIdentifier(QName.create(
+                                      TEST_QNAME, "number"))).withChild(five).withChild(fifteen)
+                      .build();
+
+
+      // Create augmentations
+      MapEntryNode mapEntry = createAugmentedListEntry(1, "First Test");
+
+      // Create a bits leaf
       NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Object, LeafNode<Object>>
-          myBits = Builders.leafBuilder().withNodeIdentifier(
-          new YangInstanceIdentifier.NodeIdentifier(
-              QName.create(TEST_QNAME, "my-bits"))).withValue(
-          ImmutableSet.of("foo", "bar"));
+              myBits = Builders.leafBuilder().withNodeIdentifier(
+              new YangInstanceIdentifier.NodeIdentifier(
+                      QName.create(TEST_QNAME, "my-bits"))).withValue(
+              ImmutableSet.of("foo", "bar"));
 
 
       // Create the document
-    return ImmutableContainerNodeBuilder
-        .create()
-        .withNodeIdentifier(
-            new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
-        .withChild(myBits.build())
-        .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC))
-        .withChild(ImmutableNodes.leafNode(POINTER_QNAME, "pointer"))
-        .withChild(
-            ImmutableNodes.leafNode(SOME_REF_QNAME, YangInstanceIdentifier
-                .builder().build()))
-        .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME))
-
-        // .withChild(augmentationNode)
-        .withChild(shoes)
-        .withChild(numbers)
-        .withChild(switchFeatures)
-        .withChild(
-            mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(mapEntry).build())
-        .withChild(
-            mapNodeBuilder(OUTER_LIST_QNAME)
-                .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
-                .withChild(BAR_NODE).build()).build();
+      return ImmutableContainerNodeBuilder
+              .create()
+              .withNodeIdentifier(
+                      new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
+              .withChild(myBits.build())
+              .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC))
+              .withChild(ImmutableNodes.leafNode(POINTER_QNAME, "pointer"))
+              .withChild(
+                      ImmutableNodes.leafNode(SOME_REF_QNAME, YangInstanceIdentifier
+                              .builder().build()))
+              .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME))
+
+                      // .withChild(augmentationNode)
+              .withChild(shoes)
+              .withChild(numbers)
+              .withChild(switchFeatures)
+              .withChild(
+                      mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(mapEntry).build())
+              .withChild(
+                      mapNodeBuilder(OUTER_LIST_QNAME)
+                              .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
+                              .withChild(BAR_NODE).build());
+  }
 
+  public static ContainerNode createTestContainer() {
+      return createBaseTestContainerBuilder().build();
   }
 
   public static MapEntryNode createAugmentedListEntry(int id, String name) {
index 246cc682cd7ae277f36e152392209c8577c3785d..a1fbc1fdad1f897d265bbd6813d7a36962b70a3f 100644 (file)
@@ -107,6 +107,10 @@ module odl-datastore-test {
             }
         }
 
+        leaf some-binary-data {
+            type binary;
+        }
+
 
     }
 }