[ONOS-6979] Binary type in YOB and Serializer helper for Data Node.
Change-Id: Id071d7c8a9ab66d77d75f6f38bd6d3fb14304891
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/builtindatatype/ObjectProvider.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/builtindatatype/ObjectProvider.java
index aca5f15..cea5549 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/builtindatatype/ObjectProvider.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/builtindatatype/ObjectProvider.java
@@ -23,7 +23,6 @@
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.Base64;
import java.util.Iterator;
public final class ObjectProvider {
@@ -81,9 +80,6 @@
case BOOLEAN:
return Boolean.parseBoolean(leafValue);
case BINARY:
- byte[] data = Base64.getDecoder().decode(leafValue);
- String str = new String(data);
- return str;
case BITS:
case IDENTITYREF:
case ENUMERATION:
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
index 9be6820..ca8284a 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
@@ -51,6 +51,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Base64;
import java.util.Iterator;
import java.util.List;
@@ -126,7 +127,8 @@
break;
case BINARY:
- parentSetter.invoke(parentObj, ((String) value).getBytes());
+ byte[] data = Base64.getDecoder().decode((String) value);
+ parentSetter.invoke(parentObj, data);
break;
case BITS:
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/DataTreeContextSwitchTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/DataTreeContextSwitchTest.java
index 69fb3f6..9be64a4 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/DataTreeContextSwitchTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/DataTreeContextSwitchTest.java
@@ -1257,7 +1257,7 @@
n = it.next();
validateDataNode(n.getValue(), "leaf-aug", nameSpace,
SINGLE_INSTANCE_LEAF_VALUE_NODE,
- true, "1011");
+ true, "MTAxMQ==");
n = it.next();
validateDataNode(n.getValue(), "leaf-inter-aug", nameSpace,
SINGLE_INSTANCE_LEAF_VALUE_NODE,