for (JavaAttribute ja : rpc.getParameters()) {
Field field = new Field(Collections.<String> emptyList(),
ja.getType().getFullyQualifiedName(),
- ja.getLowerCaseCammelCase());
+ ja.getLowerCaseCammelCase(), ja.getNullableDefaultWrappedForCode());
fields.add(field);
}
MethodDeclaration operation = new MethodDeclaration(
String varName = BindingGeneratorUtil
.parseToValidParamName(attrEntry.getKey());
- String fullyQualifiedName;
+ String fullyQualifiedName, nullableDefault = null;
if (attrEntry.getValue() instanceof TypedAttribute) {
Type type = ((TypedAttribute) attrEntry.getValue()).getType();
fullyQualifiedName = serializeType(type);
+ if(attrEntry.getValue() instanceof JavaAttribute) {
+ nullableDefault = ((JavaAttribute)attrEntry.getValue()).getNullableDefaultWrappedForCode();
+ }
} else {
fullyQualifiedName = FullyQualifiedNameHelper
.getFullyQualifiedName(packageName, attrEntry.getValue().getUpperCaseCammelCase());
}
- fields.add(new Field(fullyQualifiedName, varName));
+ fields.add(new Field(fullyQualifiedName, varName, nullableDefault));
String getterName = "get" + innerName;
MethodDefinition getter = new MethodDefinition(
String packageName) {
for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
String type;
+ String nullableDefaultWrapped = null;
AttributeIfc attributeIfc = attrEntry.getValue();
if (attributeIfc instanceof TypedAttribute) {
if (innerAttr instanceof JavaAttribute) {
fullyQualifiedName = ((JavaAttribute) innerAttr)
.getType().getFullyQualifiedName();
+ nullableDefaultWrapped = ((JavaAttribute) innerAttr).getNullableDefaultWrappedForCode();
} else if (innerAttr instanceof TOAttribute) {
fullyQualifiedName = FullyQualifiedNameHelper
.getFullyQualifiedName(packageName, innerAttr.getUpperCaseCammelCase());
}
fields.add(new Field(type, attributeIfc
- .getUpperCaseCammelCase()));
+ .getUpperCaseCammelCase(), nullableDefaultWrapped));
}
}
void processAttributes(Map<String, AttributeIfc> attributes,
String packageName) {
for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
- String type;
+ String type, nullableDefaultWrapped = null;
AttributeIfc attributeIfc = attrEntry.getValue();
if (attributeIfc instanceof TypedAttribute) {
TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
type = serializeType(typedAttribute.getType());
+ if (attributeIfc instanceof JavaAttribute) {
+ nullableDefaultWrapped = ((JavaAttribute) attributeIfc).getNullableDefaultWrappedForCode();
+ }
+
} else if (attributeIfc instanceof TOAttribute) {
String fullyQualifiedName = FullyQualifiedNameHelper
.getFullyQualifiedName(packageName, attributeIfc.getUpperCaseCammelCase());
if (innerAttr instanceof JavaAttribute) {
fullyQualifiedName = ((JavaAttribute) innerAttr)
.getType().getFullyQualifiedName();
+ nullableDefaultWrapped = ((JavaAttribute) innerAttr).getNullableDefaultWrappedForCode();
} else if (innerAttr instanceof TOAttribute) {
fullyQualifiedName = FullyQualifiedNameHelper
.getFullyQualifiedName(packageName, innerAttr.getUpperCaseCammelCase());
String varName = BindingGeneratorUtil
.parseToValidParamName(attrEntry.getKey());
moduleFields.add(new ModuleField(type, varName, attributeIfc
- .getUpperCaseCammelCase(), attributeIfc
- .getNullableDefault(), isDependency, dependency));
+ .getUpperCaseCammelCase(), nullableDefaultWrapped, isDependency, dependency));
String getterName = "get"
+ attributeIfc.getUpperCaseCammelCase();
*/
package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
-import java.util.List;
-
import com.google.common.collect.Lists;
+import java.util.List;
+
public class Field {
private final String type;
private final String name;
this(Lists.<String> newArrayList(), type, name, null);
}
+ public Field(String type, String name, String definition) {
+ this(Lists.<String> newArrayList(), type, name, definition);
+ }
+
public Field(List<String> modifiers, String type, String name) {
this(modifiers, type, name, null);
}
assertDeclaredField(fieldDeclarations,
"private java.util.concurrent.ThreadFactory threadfactoryDependency");
assertDeclaredField(fieldDeclarations,
- "private java.lang.Long keepAlive=10");
+ "private java.lang.Long keepAlive=new java.lang.Long(\"10\")");
assertDeclaredField(fieldDeclarations,
"private java.lang.Long coreSize");
assertDeclaredField(fieldDeclarations, "private byte[] binary");
*/
package org.opendaylight.controller.config.yangjmxgenerator.plugin;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
-import java.util.Collections;
-import java.util.Map;
-
+import com.google.common.collect.Maps;
import org.junit.Test;
import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import com.google.common.collect.Maps;
+import java.util.Collections;
+import java.util.Map;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
public class ModuleMXBeanEntryTemplatesTest {
doReturn("package.type").when(typeA).getFullyQualifiedName();
doReturn(typeA).when(attr).getType();
doReturn("Type").when(attr).getUpperCaseCammelCase();
+ doReturn("new Default()").when(attr).getNullableDefault();
return attr;
}
return getType(leaf, type);
}
+ public String getDefault(LeafSchemaNode node) {
+ return typeProvider.getTypeDefaultConstruction(node);
+ }
+
public Type getType(SchemaNode leaf, TypeDefinition<?> type) {
Type javaType;
try {
public class JavaAttribute extends AbstractAttribute implements TypedAttribute {
private final Type type;
- private final String nullableDescription, nullableDefault;
+ private final String nullableDescription, nullableDefault, nullableDefaultWrappedForCode;
private final TypeProviderWrapper typeProviderWrapper;
private final TypeDefinition<?> typeDefinition;
this.typeDefinition = leaf.getType();
this.typeProviderWrapper = typeProviderWrapper;
this.nullableDefault = leaf.getDefault();
+ this.nullableDefaultWrappedForCode = leaf.getDefault() == null ? null : typeProviderWrapper.getDefault(leaf);
this.nullableDescription = leaf.getDescription();
}
this.type = typeProviderWrapper.getType(leaf);
this.typeDefinition = leaf.getType();
this.typeProviderWrapper = typeProviderWrapper;
- this.nullableDefault = null;
+ this.nullableDefault = nullableDefaultWrappedForCode = null;
this.nullableDescription = leaf.getDescription();
}
+ public TypeDefinition<?> getTypeDefinition() {
+ return typeDefinition;
+ }
+
/**
* Returns the most base type
*/
return baseType;
}
+ public String getNullableDefaultWrappedForCode() {
+ return nullableDefaultWrappedForCode;
+ }
+
@Override
public Type getType() {
return type;
container dto-a {
leaf simple-arg {
type uint32;
+ default 1;
}
leaf port {
type inet:port-number;
+ default 8080;
}
+ leaf ip4 {
+ type inet:ipv4-address;
+ default 127.0.0.1;
+ }
+
+ leaf ip {
+ type inet:ip-address;
+ // TODO defaults for union default 0:0:0:0:0:0:0:1;
+ }
}
leaf as-number {
- mandatory true;
type inet:as-number;
+ default 44;
}
leaf simpleInt {
type uint32;
- default 99L;
+ default 99;
}
container dto_b {
leaf simple-int1 {
type uint32;
+ default 32;
}
leaf simple-int2 {
when "/config:modules/config:module/config:type = 'impl-netconf'";
leaf binaryLeaf {
type binary;
+ default ZGVmYXVsdEJpbg==;
}
leaf type {
type string;
+ default "default-string";
}
leaf extended {
type tt:extend-once;
+ default 1;
}
leaf extended-twice {
type tt:extend-twice;
+ default 2;
}
leaf extended-enum {
type tt:extend-enum;
+ default ONE;
}
leaf sleep-factor {
type decimal64 {
fraction-digits 2;
}
+ default 2.00;
}
container dto-c {
}
leaf simple-long {
- type int64 ;
+ type int64;
+ default -45;
}
leaf simple-long-2 {
type uint32;
+ default 445;
}
leaf simple-BigInteger {
type uint64;
+ default 545454;
}
leaf simple-byte {
type int8;
+ default -4;
}
leaf simple-short {
type uint8;
+ default 45;
}
leaf simple-test {
container deep {
leaf simple-int3 {
type uint16;
+ default 0;
}
}
}
container retValContainer {
leaf v1 {
type string;
+ default "from rpc";
}
leaf v2 {
org.osgi.framework,
org.osgi.util.tracker,
org.slf4j,
- org.w3c.dom
+ org.w3c.dom,
+ com.google.common.io,
+ org.opendaylight.yangtools.yang.model.api.type
</Import-Package>
<Export-Package>
</Export-Package>
import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListDependenciesAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
+import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
import javax.management.openmbean.ArrayType;
import javax.management.openmbean.CompositeType;
if (attributeIfc instanceof JavaAttribute) {
try {
- return caseJavaAttribute(attributeIfc.getOpenType());
+ if(((JavaAttribute)attributeIfc).getTypeDefinition() instanceof BinaryTypeDefinition) {
+ return caseJavaBinaryAttribute(attributeIfc.getOpenType());
+ } else
+ return caseJavaAttribute(attributeIfc.getOpenType());
} catch (UnknownOpenTypeException e) {
throw getIllegalArgumentException(attributeIfc);
}
throw getIllegalArgumentException(attributeIfc);
}
+ protected T caseJavaBinaryAttribute(OpenType<?> openType) {
+ return caseJavaAttribute(openType);
+ }
private IllegalArgumentException getIllegalArgumentException(AttributeIfc attributeIfc) {
return new IllegalArgumentException("Unknown attribute type " + attributeIfc.getClass() + ", " + attributeIfc
@Override
public AttributeConfigElement readElement(List<XmlElement> configNodes) {
if (configNodes.size() == 0)
- return AttributeConfigElement.createNullValue(nullableDefault);
+ return AttributeConfigElement.createNullValue(postprocessNullableDefault(nullableDefault));
return readElementHook(configNodes);
}
abstract AttributeConfigElement readElementHook(List<XmlElement> configNodes);
+ protected Object postprocessNullableDefault(String nullableDefault) {
+ return nullableDefault;
+ }
}
package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
import com.google.common.base.Optional;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.resolving.AttributeResolvingStrategy;
import javax.management.openmbean.OpenType;
}
- public static AttributeConfigElement create(AttributeIfc attributeIfc, Object value) {
- String nullableDefault = attributeIfc.getNullableDefault();
- return create(nullableDefault, value);
- }
-
- public static AttributeConfigElement create(String nullableDefault, Object value) {
+ public static AttributeConfigElement create(Object nullableDefault, Object value) {
return new AttributeConfigElement(nullableDefault, value);
}
- public static AttributeConfigElement createNullValue(AttributeIfc attributeIfc) {
- return new AttributeConfigElement(attributeIfc.getNullableDefault(), null);
- }
-
- public static AttributeConfigElement createNullValue(String nullableDefault) {
+ public static AttributeConfigElement createNullValue(Object nullableDefault) {
return new AttributeConfigElement(nullableDefault, null);
}
-
public Object getValue() {
return value;
}
import javax.management.openmbean.ArrayType;
import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenType;
import javax.management.openmbean.SimpleType;
import java.util.Map;
import java.util.Map.Entry;
return switchAttribute(attributeIfc);
}
+ @Override
+ protected AttributeReadingStrategy caseJavaBinaryAttribute(OpenType<?> openType) {
+ return new SimpleBinaryAttributeReadingStrategy(lastAttribute.getNullableDefault());
+ }
+
@Override
public AttributeReadingStrategy caseJavaSimpleAttribute(SimpleType<?> openType) {
return new SimpleAttributeReadingStrategy(lastAttribute.getNullableDefault());
String textContent = xmlElement.getTextContent();
Preconditions.checkNotNull(textContent, "This element should contain text %s", xmlElement);
- return AttributeConfigElement.create(getNullableDefault(), postprocessParsedValue(textContent));
+ return AttributeConfigElement.create(postprocessNullableDefault(getNullableDefault()),
+ postprocessParsedValue(textContent));
+ }
+
+ @Override
+ protected Object postprocessNullableDefault(String nullableDefault) {
+ return nullableDefault;
}
protected Object postprocessParsedValue(String textContent) {
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
+
+import com.google.common.collect.Lists;
+import com.google.common.io.BaseEncoding;
+
+import java.util.List;
+
+public class SimpleBinaryAttributeReadingStrategy extends SimpleAttributeReadingStrategy {
+
+ public SimpleBinaryAttributeReadingStrategy(String nullableDefault) {
+ super(nullableDefault);
+ }
+
+ protected Object postprocessParsedValue(String textContent) {
+ BaseEncoding en = BaseEncoding.base64();
+ byte[] decode = en.decode(textContent);
+ List<String> parsed = Lists.newArrayListWithCapacity(decode.length);
+ for (byte b : decode) {
+ parsed.add(Byte.toString(b));
+ }
+ return parsed;
+ }
+
+ @Override
+ protected Object postprocessNullableDefault(String nullableDefault) {
+ return nullableDefault == null ? null : postprocessParsedValue(nullableDefault);
+ }
+}
public class SimpleCompositeAttributeReadingStrategy extends SimpleAttributeReadingStrategy {
-
private final String key;
public SimpleCompositeAttributeReadingStrategy(String nullableDefault, String key) {
return map;
}
+ @Override
+ protected Object postprocessNullableDefault(String nullableDefault) {
+ return nullableDefault == null ? null : postprocessParsedValue(nullableDefault);
+ }
}
parsedInnerValue.isPresent() ? parsedInnerValue.get() : null);
}
- CompositeDataSupport parsedValue = null;
+ CompositeDataSupport parsedValue;
try {
parsedValue = new CompositeDataSupport(getOpenType(), items);
} catch (OpenDataException e) {
import javax.management.openmbean.ArrayType;
import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenType;
import javax.management.openmbean.SimpleType;
import java.util.Map;
import java.util.Map.Entry;
return switchAttribute(expectedAttr);
}
+ @Override
+ protected AttributeWritingStrategy caseJavaBinaryAttribute(OpenType<?> openType) {
+ return new SimpleBinaryAttributeWritingStrategy(document, key);
+ }
+
@Override
protected AttributeWritingStrategy caseJavaSimpleAttribute(SimpleType<?> openType) {
return new SimpleAttributeWritingStrategy(document, key);
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.toxml;
+
+import com.google.common.base.Preconditions;
+import com.google.common.io.BaseEncoding;
+import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
+import org.w3c.dom.Document;
+
+import java.util.List;
+
+public class SimpleBinaryAttributeWritingStrategy extends SimpleAttributeWritingStrategy {
+
+ /**
+ * @param document
+ * @param key
+ */
+ public SimpleBinaryAttributeWritingStrategy(Document document, String key) {
+ super(document, key);
+ }
+
+ protected Object preprocess(Object value) {
+ Util.checkType(value, List.class);
+ BaseEncoding en = BaseEncoding.base64();
+
+ List<?> list = (List<?>) value;
+ byte[] decoded = new byte[list.size()];
+ int i = 0;
+ for (Object bAsStr : list) {
+ Preconditions.checkArgument(bAsStr instanceof String, "Unexpected inner value for %s, expected string", value);
+ byte b = Byte.parseByte((String) bAsStr);
+ decoded[i++] = b;
+ }
+
+ return en.encode(decoded);
+ }
+
+}
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import javax.management.InstanceAlreadyExistsException;
edit("netconfMessages/editConfig.xml");
checkBinaryLeafEdited(getConfigCandidate());
+
// default-operation:none, should not affect binary leaf
edit("netconfMessages/editConfig_none.xml");
checkBinaryLeafEdited(getConfigCandidate());
// check after edit
commit();
Element response = getConfigRunning();
- System.err.println(XmlUtil.toString(response));
checkBinaryLeafEdited(response);
checkTypeConfigAttribute(response);
verifyNoMoreInteractions(netconfOperationRouter);
}
+ private void checkBigDecimal(Element response) {
+ String responseTrimmed = XmlUtil.toString(response).replaceAll("\\s", "");
+
+ assertContainsString(responseTrimmed, "<sleep-factorxmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">2.58</sleep-factor>");
+ // Default
+ assertContainsString(responseTrimmed, "<sleep-factorxmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">2.00</sleep-factor>");
+
+ }
+
private void closeSession() throws NetconfDocumentedException, ParserConfigurationException, SAXException,
IOException {
DefaultCloseSession closeOp = new DefaultCloseSession(NETCONF_SESSION_ID);
edit("netconfMessages/namespaces/editConfig_sameAttrDifferentNamespaces.xml");
} catch (NetconfDocumentedException e) {
String message = e.getMessage();
- assertThat(message,
- JUnitMatchers
- .containsString("Element simple-long-2 present multiple times with different namespaces"));
- assertThat(message,
- JUnitMatchers.containsString("urn:opendaylight:params:xml:ns:yang:controller:test:impl"));
- assertThat(message,
- JUnitMatchers
- .containsString(XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG));
+ assertContainsString(message, "Element simple-long-2 present multiple times with different namespaces");
+ assertContainsString(message, "urn:opendaylight:params:xml:ns:yang:controller:test:impl");
+ assertContainsString(message, XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG);
throw e;
}
}
edit("netconfMessages/namespaces/editConfig_differentNamespaceTO.xml");
} catch (NetconfDocumentedException e) {
String message = e.getMessage();
- assertThat(message, JUnitMatchers.containsString("Unrecognised elements"));
- assertThat(message, JUnitMatchers.containsString("simple-int2"));
- assertThat(message, JUnitMatchers.containsString("dto_d"));
+ assertContainsString(message, "Unrecognised elements");
+ assertContainsString(message, "simple-int2");
+ assertContainsString(message, "dto_d");
throw e;
}
}
edit("netconfMessages/namespaces/editConfig_sameAttrDifferentNamespacesList.xml");
} catch (NetconfDocumentedException e) {
String message = e.getMessage();
- assertThat(message,
- JUnitMatchers.containsString("Element binaryLeaf present multiple times with different namespaces"));
- assertThat(message,
- JUnitMatchers.containsString("urn:opendaylight:params:xml:ns:yang:controller:test:impl"));
- assertThat(message,
- JUnitMatchers
- .containsString(XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG));
+ assertContainsString(message, "Element binaryLeaf present multiple times with different namespaces");
+ assertContainsString(message, "urn:opendaylight:params:xml:ns:yang:controller:test:impl");
+ assertContainsString(message, XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG);
throw e;
}
}
try {
edit(file);
} catch (NetconfDocumentedException e) {
- assertThat(e.getMessage(), JUnitMatchers.containsString("Unrecognised elements"));
- assertThat(e.getMessage(), JUnitMatchers.containsString("unknownAttribute"));
+ assertContainsString(e.getMessage(), "Unrecognised elements");
+ assertContainsString(e.getMessage(), "unknownAttribute");
continue;
}
fail("Unrecognised test should throw exception " + file);
}
private void checkBinaryLeafEdited(final Element response) {
- final NodeList children = response.getElementsByTagName("binaryLeaf");
- assertEquals(3, children.getLength());
- final StringBuffer buf = new StringBuffer();
- for (int i = 0; i < 3; i++) {
- final Element e = (Element) children.item(i);
- buf.append(XmlElement.fromDomElement(e).getTextContent());
- }
- assertEquals("810", buf.toString());
+ String responseTrimmed = XmlUtil.toString(response).replaceAll("\\s", "");
+ String substring = "<binaryLeafxmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">YmluYXJ5</binaryLeaf>";
+ assertContainsString(responseTrimmed, substring);
+ substring = "<binaryLeafxmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">ZGVmYXVsdEJpbg==</binaryLeaf>";
+ assertContainsString(responseTrimmed, substring);
}
private void checkTypedefs(final Element response) {
- NodeList children = response.getElementsByTagName("extended");
- assertEquals(1, children.getLength());
+ String responseTrimmed = XmlUtil.toString(response).replaceAll("\\s", "");
+
+ String substring = "<extendedxmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">10</extended>";
+ assertContainsString(responseTrimmed, substring);
+ // Default
+ assertContainsString(responseTrimmed,
+ "<extendedxmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">1</extended>");
- children = response.getElementsByTagName("extended-twice");
- assertEquals(1, children.getLength());
+ assertContainsString(responseTrimmed,
+ "<extended-twicexmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">20</extended-twice>");
+ // Default
+ assertContainsString(responseTrimmed,
+ "<extended-twicexmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">2</extended-twice>");
+
+ assertContainsString(responseTrimmed,
+ "<extended-enumxmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">TWO</extended-enum>");
+ // Default
+ assertContainsString(responseTrimmed,
+ "<extended-enumxmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">ONE</extended-enum>");
+ }
+
+ private void assertContainsString(String string, String substring) {
+ assertThat(string, JUnitMatchers.containsString(substring));
}
private void checkEnum(final Element response) {
assertEquals(2, testingDepsSize);
}
- private void checkBigDecimal(Element response) {
- int size = response.getElementsByTagName("sleep-factor").getLength();
- assertEquals(1, size);
- }
-
-
private void checkTypeConfigAttribute(Element response) {
XmlElement modulesElement = XmlElement.fromDomElement(response).getOnlyChildElement("data")
RuntimeRpc netconf = new RuntimeRpc(yangStoreSnapshot, configRegistryClient, NETCONF_SESSION_ID);
response = executeOp(netconf, "netconfMessages/rpc.xml");
- assertThat(XmlUtil.toString(response), JUnitMatchers.containsString("testarg1".toUpperCase()));
+ assertContainsString(XmlUtil.toString(response), "testarg1".toUpperCase());
response = executeOp(netconf, "netconfMessages/rpcInner.xml");
- assertThat(XmlUtil.toString(response), JUnitMatchers.containsString("ok"));
+ assertContainsString(XmlUtil.toString(response), "ok");
response = executeOp(netconf, "netconfMessages/rpcInnerInner.xml");
- assertThat(XmlUtil.toString(response), JUnitMatchers.containsString("true"));
+ assertContainsString(XmlUtil.toString(response), "true");
response = executeOp(netconf, "netconfMessages/rpcInnerInner_complex_output.xml");
- assertThat(XmlUtil.toString(response), JUnitMatchers.containsString("1"));
- assertThat(XmlUtil.toString(response), JUnitMatchers.containsString("2"));
+ assertContainsString(XmlUtil.toString(response), "1");
+ assertContainsString(XmlUtil.toString(response), "2");
}
private Element get() throws NetconfDocumentedException, ParserConfigurationException, SAXException, IOException {
<name>test1</name>
<sleep-factor>
- 2.00
+ 2.58
</sleep-factor>
<extended>
- 1
+ 10
</extended>
<extended-twice>
- 1
+ 20
</extended-twice>
<extended-enum>
</extended-enum>
<simple-long-2>44</simple-long-2>
- <binaryLeaf>8</binaryLeaf>
- <binaryLeaf>1</binaryLeaf>
- <binaryLeaf>0</binaryLeaf>
+ <binaryLeaf>YmluYXJ5</binaryLeaf>
+
<type xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">configAttributeType</type>
<dto_d xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
<simple-int1>444</simple-int1>
</type>
<name>test1</name>
<simple-long-2>44</simple-long-2>
- <binaryLeaf>8</binaryLeaf>
- <binaryLeaf>7</binaryLeaf>
- <binaryLeaf>9</binaryLeaf>
+ <binaryLeaf>8ad1</binaryLeaf>
<dto_d>
<simple-int1>444</simple-int1>
<simple-int2>4444</simple-int2>
<name>test1</name>
<simple-long-2>44</simple-long-2>
- <binaryLeaf>8</binaryLeaf>
- <binaryLeaf>1</binaryLeaf>
- <binaryLeaf>0</binaryLeaf>
+ <binaryLeaf>8545649856</binaryLeaf>
<type xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">configAttributeType</type>
<dto_d>
<simple-int1>444</simple-int1>
<name>test1</name>
<simple-long-2>44</simple-long-2>
- <binaryLeaf>8</binaryLeaf>
- <binaryLeaf>1</binaryLeaf>
- <binaryLeaf>0</binaryLeaf>
+ <binaryLeaf>8545649856</binaryLeaf>
<dto_d xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
<simple-int1>444</simple-int1>
<simple-int2>4444</simple-int2>
<name>test1</name>
<simple-long-2>44</simple-long-2>
- <binaryLeaf>8</binaryLeaf>
- <binaryLeaf>1</binaryLeaf>
- <binaryLeaf>0</binaryLeaf>
+ <binaryLeaf>8545649856</binaryLeaf>
<dto_d>
<unknownAttribute>error</unknownAttribute>
<simple-int1>444</simple-int1>
<name>test1</name>
<simple-long-2>44</simple-long-2>
- <binaryLeaf>8</binaryLeaf>
- <binaryLeaf>1</binaryLeaf>
- <binaryLeaf>0</binaryLeaf>
+ <binaryLeaf>8545649856</binaryLeaf>
<dto_d>
<simple-int1>444</simple-int1>
<simple-int2>4444</simple-int2>