From: Ed Warnicke Date: Tue, 3 Dec 2013 12:37:44 +0000 (+0000) Subject: Merge "Added yang-test-plugin maven plugin. Generated source files are deleted before... X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~273 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=3cc482ed8acee2c0d3d6ff5e65288fef75ee1ba4;hp=dbab0ae40879d014e5c909f2e339b443890f5848;p=controller.git Merge "Added yang-test-plugin maven plugin. Generated source files are deleted before new ones are genarated, after that implemantaion code from stub.txt is inserted." --- diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend index 1762aac090..9381a5a070 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend @@ -48,8 +48,9 @@ import java.util.concurrent.locks.ReentrantLock import java.util.concurrent.Callable import java.util.WeakHashMap import javax.annotation.concurrent.GuardedBy +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry -class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable { +class BindingAwareBrokerImpl implements BindingAwareBroker, RpcProviderRegistry, AutoCloseable { private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl) private InstanceIdentifier root = InstanceIdentifier.builder().toInstance(); @@ -188,22 +189,30 @@ class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable { * Registers RPC Implementation * */ - def registerRpcImplementation(Class type, T service, OsgiProviderContext context, - Hashtable properties) { + override addRpcImplementation(Class type, T service) { + checkNotNull(type, "Service type should not be null") + checkNotNull(service, "Service type should not be null") + val proxy = getManagedDirectProxy(type) checkState(proxy.delegate === null, "The Service for type %s is already registered", type) - val osgiReg = context.bundleContext.registerService(type, service, properties); proxy.delegate = service; - return new RpcServiceRegistrationImpl(type, service, osgiReg, this); + return new RpcServiceRegistrationImpl(type, service, this); } - def RoutedRpcRegistration registerRoutedRpcImplementation(Class type, T service, - OsgiProviderContext context) { + override RoutedRpcRegistration addRoutedRpcImplementation(Class type, T service) { + checkNotNull(type, "Service type should not be null") + checkNotNull(service, "Service type should not be null") + val router = resolveRpcRouter(type); checkState(router !== null) return new RoutedRpcRegistrationImpl(service, router, this) } + + override getRpcService(Class service) { + checkNotNull(service, "Service should not be null"); + return getManagedDirectProxy(service) as T; + } private def RpcRouter resolveRpcRouter(Class type) { @@ -357,16 +366,14 @@ class RoutedRpcRegistrationImpl extends AbstractObjectRegi class RpcServiceRegistrationImpl extends AbstractObjectRegistration implements RpcRegistration { - val ServiceRegistration osgiRegistration; private var BindingAwareBrokerImpl broker; @Property val Class serviceType; - public new(Class type, T service, ServiceRegistration osgiReg, BindingAwareBrokerImpl broker) { + public new(Class type, T service, BindingAwareBrokerImpl broker) { super(service); this._serviceType = type; - this.osgiRegistration = osgiReg; this.broker = broker; } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend index 7fd3fd24d8..d1ec35157f 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend @@ -33,22 +33,13 @@ class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext } override addRpcImplementation(Class type, T implementation) { - - // TODO Auto-generated method stub - val properties = new Hashtable(); - properties.salServiceType = SAL_SERVICE_TYPE_PROVIDER - - // Fill requirements - val salReg = broker.registerRpcImplementation(type, implementation, this, properties) + val salReg = broker.addRpcImplementation(type, implementation) registeredServices.put(type, salReg) return salReg; } override addRoutedRpcImplementation(Class type, T implementation) throws IllegalStateException { - checkNotNull(type, "Service type should not be null") - checkNotNull(implementation, "Service type should not be null") - - val salReg = broker.registerRoutedRpcImplementation(type, implementation, this) + val salReg = broker.addRoutedRpcImplementation(type, implementation) registeredServices.put(type, salReg) return salReg; } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang b/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang index 38770c193c..9da073f71b 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang +++ b/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang @@ -25,6 +25,7 @@ module opendaylight-sal-binding-broker-impl { identity binding-broker-impl { base config:module-type; config:provided-service sal:binding-broker-osgi-registry; + config:provided-service sal:binding-rpc-registry; config:java-name-prefix BindingBrokerImpl; } diff --git a/opendaylight/md-sal/sal-rest-connector/pom.xml b/opendaylight/md-sal/sal-rest-connector/pom.xml index bdcb0bdd2b..3e13a584d4 100644 --- a/opendaylight/md-sal/sal-rest-connector/pom.xml +++ b/opendaylight/md-sal/sal-rest-connector/pom.xml @@ -77,6 +77,11 @@ 2.4 test + + org.opendaylight.yangtools + yang-model-util + 0.5.9-SNAPSHOT + diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java index 9608d65e41..a42c468c2a 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java @@ -8,6 +8,7 @@ import java.util.*; import javax.activation.UnsupportedDataTypeException; import org.opendaylight.controller.sal.restconf.impl.ControllerContext; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.*; import org.opendaylight.yangtools.yang.model.api.*; import org.opendaylight.yangtools.yang.model.api.type.*; @@ -144,25 +145,43 @@ class JsonMapper { List> nodeLeafLists = nodeParent.getSimpleNodesByName(node.getNodeType()); for (SimpleNode nodeLeafList : nodeLeafLists) { - writeValueOfNodeByType(writer, nodeLeafList, schema.getType()); + writeValueOfNodeByType(writer, nodeLeafList, schema.getType(), schema); } - writer.endArray(); } private void writeLeaf(JsonWriter writer, SimpleNode node, LeafSchemaNode schema) throws IOException { writeName(node, schema, writer); - writeValueOfNodeByType(writer, node, schema.getType()); + writeValueOfNodeByType(writer, node, schema.getType(), schema); } - private void writeValueOfNodeByType(JsonWriter writer, SimpleNode node, TypeDefinition type) - throws IOException { + private void writeValueOfNodeByType(JsonWriter writer, SimpleNode node, TypeDefinition type, + DataSchemaNode schema) throws IOException { String value = String.valueOf(node.getValue()); - // TODO check Leafref, InstanceIdentifierTypeDefinition, - // IdentityrefTypeDefinition, UnionTypeDefinition TypeDefinition baseType = resolveBaseTypeFrom(type); - if (baseType instanceof InstanceIdentifierTypeDefinition) { + + // TODO check InstanceIdentifierTypeDefinition, + // IdentityrefTypeDefinition + if (baseType instanceof IdentityrefTypeDefinition) { + if (node.getValue() instanceof QName) { + QName qName = (QName) node.getValue(); + + ControllerContext contContext = ControllerContext.getInstance(); + String moduleName = contContext.findModuleByNamespace(qName.getNamespace()); + + writer.value(moduleName + ":" + qName.getLocalName()); + } + + } else if (baseType instanceof LeafrefTypeDefinition) { + ControllerContext contContext = ControllerContext.getInstance(); + LeafSchemaNode lfSchemaNode = contContext.resolveTypeFromLeafref((LeafrefTypeDefinition) baseType, schema); + if (lfSchemaNode != null) { + writeValueOfNodeByType(writer, node, lfSchemaNode.getType(), lfSchemaNode); + } else { + writer.value(value); + } + } else if (baseType instanceof InstanceIdentifierTypeDefinition) { writer.value(((InstanceIdentifierTypeDefinition) baseType).getPathStatement().toString()); } else if (baseType instanceof UnionTypeDefinition) { processTypeIsUnionType(writer, (UnionTypeDefinition) baseType, value); diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend index eca4bd2572..470b4735a4 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend @@ -27,6 +27,9 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode import org.opendaylight.yangtools.yang.model.api.ListSchemaNode import org.opendaylight.yangtools.yang.model.api.RpcDefinition import org.opendaylight.yangtools.yang.model.api.SchemaContext +import org.opendaylight.yangtools.yang.model.api.SchemaNode +import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition +import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil import static com.google.common.base.Preconditions.* @@ -40,8 +43,7 @@ class ControllerContext implements SchemaServiceListener { private val BiMap uriToModuleName = HashBiMap.create(); private val Map moduleNameToUri = uriToModuleName.inverse(); - private val Map qnameToRpc = new ConcurrentHashMap(); - + private val Map qnameToRpc = new ConcurrentHashMap(); private new() { if (INSTANCE !== null) { @@ -52,7 +54,7 @@ class ControllerContext implements SchemaServiceListener { static def getInstance() { return INSTANCE } - + private def void checkPreconditions() { if (schemas === null) { throw new ResponseException(Response.Status.SERVICE_UNAVAILABLE, RestconfProvider::NOT_INITALIZED_MSG) @@ -131,7 +133,7 @@ class ControllerContext implements SchemaServiceListener { private def dispatch CharSequence toRestconfIdentifier(PathArgument argument, DataSchemaNode node) { throw new IllegalArgumentException("Conversion of generic path argument is not supported"); } - + def findModuleByNamespace(URI namespace) { checkPreconditions var module = uriToModuleName.get(namespace) @@ -311,24 +313,55 @@ class ControllerContext implements SchemaServiceListener { return str; } } - + private def QName toQName(String name) { val module = name.toModuleName; val node = name.toNodeName; val namespace = moduleNameToUri.get(module); - return new QName(namespace,null,node); + return new QName(namespace, null, node); } - + def getRpcDefinition(String name) { return qnameToRpc.get(name.toQName) } override onGlobalContextUpdated(SchemaContext context) { this.schemas = context; - for(operation : context.operations) { - val qname = new QName(operation.QName.namespace,null,operation.QName.localName); - qnameToRpc.put(qname,operation); + for (operation : context.operations) { + val qname = new QName(operation.QName.namespace, null, operation.QName.localName); + qnameToRpc.put(qname, operation); + } + } + + /** + * Resolve target type from leafref type. + * + * According to RFC 6020 referenced element has to be leaf (chapter 9.9). + * Therefore if other element is referenced then null value is returned. + * + * Currently only cases without path-predicate are supported. + * + * @param leafRef + * @param schemaNode + * data schema node which contains reference + * @return type if leaf is referenced and it is possible to find referenced + * node in schema context. In other cases null value is returned + */ + def LeafSchemaNode resolveTypeFromLeafref(LeafrefTypeDefinition leafRef, DataSchemaNode schemaNode) { + val xPath = leafRef.getPathStatement(); + val module = SchemaContextUtil.findParentModule(schemas, schemaNode); + + var SchemaNode foundSchemaNode + if (xPath.isAbsolute()) { + foundSchemaNode = SchemaContextUtil.findDataSchemaNode(schemas, module, xPath); + } else { + foundSchemaNode = SchemaContextUtil.findDataSchemaNodeForRelativeXPath(schemas, module, schemaNode, xPath); + } + + if (foundSchemaNode instanceof LeafSchemaNode) { + return foundSchemaNode as LeafSchemaNode; } + + return null; } - } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java index 89d24ad057..61942e81a6 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java @@ -211,10 +211,12 @@ final class TestUtils { null, byteArrayOS); jsonResult = byteArrayOS.toString(); - try { - outputToFile(byteArrayOS, outputPath); - } catch (IOException e) { - System.out.println("Output file wasn't cloased sucessfuly."); + if (outputPath != null) { + try { + outputToFile(byteArrayOS, outputPath); + } catch (IOException e) { + System.out.println("Output file wasn't cloased sucessfuly."); + } } return jsonResult; diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ToJsonIdentityrefTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ToJsonIdentityrefTest.java new file mode 100644 index 0000000000..c9ac042ff1 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ToJsonIdentityrefTest.java @@ -0,0 +1,61 @@ +package org.opendaylight.controller.sal.restconf.impl.test; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.util.Set; +import java.util.regex.*; + +import javax.ws.rs.WebApplicationException; + +import org.junit.*; +import org.opendaylight.yangtools.yang.data.api.*; +import org.opendaylight.yangtools.yang.data.impl.NodeFactory; +import org.opendaylight.yangtools.yang.model.api.*; + +public class ToJsonIdentityrefTest { + + private static Set modules; + private static DataSchemaNode dataSchemaNode; + + @BeforeClass + public static void initialization() { + modules = TestUtils.resolveModules("/yang-to-json-conversion/identityref"); + assertEquals(2, modules.size()); + Module module = TestUtils.resolveModule("identityref-module", modules); + assertNotNull(module); + dataSchemaNode = TestUtils.resolveDataSchemaNode(module, "cont"); + assertNotNull(dataSchemaNode); + + } + + @Test + public void identityrefToJsonTest() { + String json = null; + try { + json = TestUtils + .writeCompNodeWithSchemaContextToJson(prepareCompositeNode(), null, modules, dataSchemaNode); + } catch (WebApplicationException | IOException e) { + // shouldn't end here + assertTrue(false); + } + assertNotNull(json); + Pattern ptrn = Pattern.compile(".*\"lf1\"\\p{Space}*:\\p{Space}*\"identityref-module:name_test\".*", + Pattern.DOTALL); + Matcher mtch = ptrn.matcher(json); + + assertTrue(mtch.matches()); + } + + private CompositeNode prepareCompositeNode() { + MutableCompositeNode cont = NodeFactory.createMutableCompositeNode(TestUtils.buildQName("cont"), null, null, + ModifyAction.CREATE, null); + MutableSimpleNode lf1 = NodeFactory.createMutableSimpleNode(TestUtils.buildQName("lf1"), cont, + TestUtils.buildQName("name_test", "identityref:module", "2013-12-2"), ModifyAction.CREATE, null); + cont.getChildren().add(lf1); + cont.init(); + + return cont; + } + +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ToJsonLeafrefType.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ToJsonLeafrefType.java new file mode 100644 index 0000000000..a5cc02e9f2 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ToJsonLeafrefType.java @@ -0,0 +1,158 @@ +package org.opendaylight.controller.sal.restconf.impl.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.Set; +import java.util.regex.Matcher; + +import javax.ws.rs.WebApplicationException; + +import org.junit.*; +import org.opendaylight.yangtools.yang.model.api.*; + +public class ToJsonLeafrefType { + private static Set modules; + private static DataSchemaNode dataSchemaNode; + + @BeforeClass + public static void initialization() { + modules = TestUtils.resolveModules("/yang-to-json-conversion/leafref"); + assertEquals(2, modules.size()); + Module module = TestUtils.resolveModule("main-module", modules); + assertNotNull(module); + dataSchemaNode = TestUtils.resolveDataSchemaNode(module, "cont"); + assertNotNull(dataSchemaNode); + + } + + @Test + public void leafrefAbsolutePathToExistingLeafTest() { + String json = null; + try { + json = TestUtils.writeCompNodeWithSchemaContextToJson(TestUtils + .loadCompositeNode("/yang-to-json-conversion/leafref/xml/data_absolut_ref_to_existing_leaf.xml"), + "/yang-to-json-conversion/leafref/xml", modules, dataSchemaNode); + } catch (WebApplicationException | IOException e) { + // shouldn't end here + assertTrue(false); + } + assertNotNull(json); + java.util.regex.Pattern ptrn = java.util.regex.Pattern.compile(".*\"lf3\":\\p{Blank}*true.*", + java.util.regex.Pattern.DOTALL); + Matcher mtch = ptrn.matcher(json); + assertTrue(mtch.matches()); + } + + @Test + public void leafrefRelativePathToExistingLeafTest() { + String json = null; + try { + json = TestUtils.writeCompNodeWithSchemaContextToJson(TestUtils + .loadCompositeNode("/yang-to-json-conversion/leafref/xml/data_relativ_ref_to_existing_leaf.xml"), + "/yang-to-json-conversion/leafref/xml", modules, dataSchemaNode); + } catch (WebApplicationException | IOException e) { + // shouldn't end here + assertTrue(false); + } + assertNotNull(json); + java.util.regex.Pattern ptrn = java.util.regex.Pattern.compile(".*\"lf2\":\\p{Blank}*121.*", + java.util.regex.Pattern.DOTALL); + Matcher mtch = ptrn.matcher(json); + assertTrue(mtch.matches()); + } + + /** + * Tests case when reference to not existing element is present. In this + * case value from single node is printed as string. + */ + @Test + public void leafrefToNonExistingLeafTest() { + String json = null; + try { + json = TestUtils.writeCompNodeWithSchemaContextToJson(TestUtils + .loadCompositeNode("/yang-to-json-conversion/leafref/xml/data_ref_to_non_existing_leaf.xml"), + "/yang-to-json-conversion/leafref/xml", modules, dataSchemaNode); + } catch (WebApplicationException | IOException e) { + // shouldn't end here + assertTrue(false); + } + assertNotNull(json); + java.util.regex.Pattern ptrn = java.util.regex.Pattern.compile(".*\"lf5\":\\p{Blank}*\"137\".*", + java.util.regex.Pattern.DOTALL); + Matcher mtch = ptrn.matcher(json); + assertTrue(mtch.matches()); + } + + /** + * Tests case when non leaf element is referenced. In this case value from + * single node is printed as string. + */ + @Test + public void leafrefToNotLeafTest() { + String json = null; + try { + json = TestUtils.writeCompNodeWithSchemaContextToJson( + TestUtils.loadCompositeNode("/yang-to-json-conversion/leafref/xml/data_ref_to_not_leaf.xml"), + "/yang-to-json-conversion/leafref/xml", modules, dataSchemaNode); + } catch (WebApplicationException | IOException e) { + // shouldn't end here + assertTrue(false); + } + assertNotNull(json); + java.util.regex.Pattern ptrn = java.util.regex.Pattern.compile( + ".*\"cont-augment-module\\p{Blank}*:\\p{Blank}*lf6\":\\p{Blank}*\"44.33\".*", + java.util.regex.Pattern.DOTALL); + Matcher mtch = ptrn.matcher(json); + assertTrue(mtch.matches()); + } + + /** + * Tests case when leaflist element is refers to leaf. + */ + @Test + public void leafrefFromLeafListToLeafTest() { + String json = null; + try { + json = TestUtils + .writeCompNodeWithSchemaContextToJson( + TestUtils + .loadCompositeNode("/yang-to-json-conversion/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml"), + "/yang-to-json-conversion/leafref/xml", modules, dataSchemaNode); + } catch (WebApplicationException | IOException e) { + // shouldn't end here + assertTrue(false); + } + assertNotNull(json); + java.util.regex.Pattern ptrn = java.util.regex.Pattern + .compile( + ".*\"cont-augment-module\\p{Blank}*:\\p{Blank}*lflst1\":\\p{Blank}*.*345,\\p{Space}*346,\\p{Space}*347.*", + java.util.regex.Pattern.DOTALL); + Matcher mtch = ptrn.matcher(json); + assertTrue(mtch.matches()); + } + + /** + * Tests case when leaflist element is refers to leaf. + */ + @Test + public void leafrefFromLeafrefToLeafrefTest() { + String json = null; + try { + json = TestUtils.writeCompNodeWithSchemaContextToJson(TestUtils + .loadCompositeNode("/yang-to-json-conversion/leafref/xml/data_from_leafref_to_leafref.xml"), + "/yang-to-json-conversion/leafref/xml", modules, dataSchemaNode); + } catch (WebApplicationException | IOException e) { + // shouldn't end here + assertTrue(false); + } + assertNotNull(json); + java.util.regex.Pattern ptrn = java.util.regex.Pattern.compile( + ".*\"cont-augment-module\\p{Blank}*:\\p{Blank}*lf7\":\\p{Blank}*200.*", java.util.regex.Pattern.DOTALL); + Matcher mtch = ptrn.matcher(json); + assertTrue(mtch.matches()); + } + +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/identityref/identity-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/identityref/identity-module.yang new file mode 100644 index 0000000000..30890bf9c3 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/identityref/identity-module.yang @@ -0,0 +1,10 @@ +module identity-module { + namespace "identity:module"; + + prefix "idemod"; + revision 2013-12-2 { + } + + identity iden { + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/identityref/identityref-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/identityref/identityref-module.yang new file mode 100644 index 0000000000..273f5d77ee --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/identityref/identityref-module.yang @@ -0,0 +1,19 @@ +module identityref-module { + namespace "identityref:module"; + + prefix "iderefmod"; + + import identity-module {prefix idemo; revision-date 2013-12-2;} + + revision 2013-12-2 { + } + + container cont { + leaf lf1 { + type identityref { + base "idemo:iden"; + } + } + } + +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/cont-augment-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/cont-augment-module.yang new file mode 100644 index 0000000000..afc23b7946 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/cont-augment-module.yang @@ -0,0 +1,42 @@ +module cont-augment-module { + namespace "cont:augment:module"; + + prefix "cntaugmod"; + + import main-module {prefix mamo; revision-date 2013-12-2;} + + revision 2013-12-2 { + + } + + augment "/mamo:cont" { + leaf-list lflst1 { + type leafref { + path "../lf1"; + } + } + + leaf lf4 { + type leafref { + path "../lf1"; + } + } + + /* reference to not leaf element */ + leaf lf6 { + type leafref { + path "../lflst1"; + } + } + + leaf lf7 { + type leafref { + path "../lf4"; + } + } + } + + + + +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/main-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/main-module.yang new file mode 100644 index 0000000000..8c8039290c --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/main-module.yang @@ -0,0 +1,43 @@ +module main-module { + namespace "main:module"; + + prefix "mainmod"; + revision 2013-12-2 { + } + + container cont { + leaf lf1 { + type uint32; + } + + container cont1 { + leaf lf11 { + type boolean; + } + } + + leaf lf2 { + type leafref { + path "../lf1"; + } + } + + leaf lf3 { + type leafref { + path "/cont/cont1/lf11"; + } + } + + /* reference to nonexisting leaf */ + leaf lf5 { + type leafref { + path "/cont/lf"; + } + } + + + } + + + +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_absolut_ref_to_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_absolut_ref_to_existing_leaf.xml new file mode 100644 index 0000000000..bbebabec4e --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_absolut_ref_to_existing_leaf.xml @@ -0,0 +1,6 @@ + + + true + + true + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_from_leafref_to_leafref.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_from_leafref_to_leafref.xml new file mode 100644 index 0000000000..1bb9013a7f --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_from_leafref_to_leafref.xml @@ -0,0 +1,3 @@ + + 200 + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_ref_to_non_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_ref_to_non_existing_leaf.xml new file mode 100644 index 0000000000..dfea9c811d --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_ref_to_non_existing_leaf.xml @@ -0,0 +1,3 @@ + + 137 + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_ref_to_not_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_ref_to_not_leaf.xml new file mode 100644 index 0000000000..7b05b0c89f --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_ref_to_not_leaf.xml @@ -0,0 +1,3 @@ + + 44.33 + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml new file mode 100644 index 0000000000..0d8cf660ac --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml @@ -0,0 +1,5 @@ + + 345 + 346 + 347 + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_relativ_ref_to_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_relativ_ref_to_existing_leaf.xml new file mode 100644 index 0000000000..4a73a8b0c4 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/leafref/xml/data_relativ_ref_to_existing_leaf.xml @@ -0,0 +1,4 @@ + + 121 + 121 + \ No newline at end of file