Migrated all YANG testfiles counting 50 lines or less.
JIRA: YANGTOOLS-1506
Change-Id: I0081dd4517f38e59d449170ff9135c8645265be4
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
public class StringPatternCheckingCodecTest {
@Test
public void testStringPatternCheckingCodec() {
- final var schemaContext = YangParserTestUtils.parseYangResource("/string-pattern-checking-codec-test.yang");
+ final var schemaContext = YangParserTestUtils.parseYang("""
+ module string-pattern-checking-codec-test {
+ namespace "string-pattern-checking-codec-test";
+ prefix "spcct";
+
+ container test-container {
+ leaf string-leaf-with-valid-pattern {
+ type string {
+ pattern "[A-Z]+";
+ }
+ }
+ }
+ }""");
assertNotNull(schemaContext);
final var testModuleQName = QNameModule.create(XMLNamespace.of("string-pattern-checking-codec-test"));
public class YT1097Test {
@Test
public void testBooleanStringUnion() {
- final Module module = YangParserTestUtils.parseYangResource("/yt1097.yang").findModule("yt1097").orElseThrow();
+ final Module module = YangParserTestUtils.parseYang("""
+ module yt1097 {
+ namespace yt1097;
+ prefix yt1097;
+
+ leaf foo {
+ type union {
+ type boolean;
+ type string;
+ }
+ }
+ }""").findModule("yt1097").orElseThrow();
final DataSchemaNode foo = module.findDataChildByName(QName.create(module.getQNameModule(), "foo"))
.orElseThrow();
assertThat(foo, instanceOf(LeafSchemaNode.class));
public class YT1437Test {
@Test
public void testDecimalFractionDigits() {
- final var module = YangParserTestUtils.parseYangResource("/yt1437.yang").findModule("yt1437").orElseThrow();
+ final var module = YangParserTestUtils.parseYang("""
+ module yt1437 {
+ namespace yt1437;
+ prefix yt1437;
+
+ leaf foo {
+ type decimal64 {
+ fraction-digits 2;
+ range "20.0..30.01 | 50";
+ }
+ }
+ }""").findModule("yt1437").orElseThrow();
final var foo = module.findDataChildByName(QName.create(module.getQNameModule(), "foo")).orElseThrow();
assertThat(foo, instanceOf(LeafSchemaNode.class));
@BeforeClass
public static void beforeClass() {
- final var foo = YangParserTestUtils.parseYangResource("/yt1442.yang")
+ final var foo = YangParserTestUtils.parseYang("""
+ module yt1442 {
+ namespace yt1442;
+ prefix yt1442;
+
+ leaf foo {
+ type decimal64 {
+ fraction-digits 2;
+ range 10.0..100.0 {
+ error-app-tag model-defined-app-tag;
+ error-message model-defined-message;
+ }
+ }
+ }
+ }""")
.getDataChildByName(QName.create("yt1442", "foo"));
assertThat(foo, instanceOf(LeafSchemaNode.class));
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
-import java.io.File;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.LinkedList;
@Before
public void setup() throws URISyntaxException {
- final File leafRefTestYang = new File(getClass().getResource("/builder-test/immutable-ordered-map-node.yang")
- .toURI());
- final var schema = YangParserTestUtils.parseYangFiles(leafRefTestYang);
+ final var schema = YangParserTestUtils.parseYang("""
+ module immutable-ordered-map-node {
+ yang-version 1;
+ namespace "test.namespace.builder.test";
+ prefix "iomn";
+
+ revision "2016-01-01" {
+ description "Initial revision.";
+ }
+
+ container root-container {
+ list list-ordered-by-user-with-key {
+ key "leaf-a";
+ ordered-by "user";
+ leaf leaf-a {
+ type string;
+ }
+ }
+ leaf-list leaf-list-ordered-by-user {
+ ordered-by "user";
+ type string;
+ }
+ }
+ }""");
final Module module = schema.getModules().iterator().next();
final DataSchemaNode root = module.getDataChildByName(ROOT_CONTAINER);
list = (ListSchemaNode)((ContainerSchemaNode) root).getDataChildByName(LIST_MAIN);
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<root xmlns="baz">
- <baz>
- <my-container-1>
- <my-leaf-1>value1</my-leaf-1>
- </my-container-1>
- <my-container-2>
- <inner-container>
- <my-leaf-2>value2</my-leaf-2>
- </inner-container>
- <my-leaf-3>value3</my-leaf-3>
- </my-container-2>
-
- <my-anyxml-data>
- <inner-container>
- <my-leaf-2>any-xml-leaf-2-value</my-leaf-2>
- </inner-container>
- <my-leaf-3>any-xml-leaf-3-value</my-leaf-3>
- </my-anyxml-data>
- </baz>
-</root>
\ No newline at end of file
+++ /dev/null
-module baz {
- namespace "baz";
- prefix baz;
-
- import yang-ext { prefix ext; revision-date 2013-07-09; }
-
- container baz {
- container my-container-1 {
- leaf my-leaf-1 {
- type string;
- }
- }
-
- container my-container-2 {
- container inner-container {
- leaf my-leaf-2 {
- type string;
- }
- }
- leaf my-leaf-3 {
- type string;
- }
- }
-
- anyxml my-anyxml-data {
- ext:anyxml-schema-location "/baz/my-container-2";
- }
- }
-}
+++ /dev/null
-module yang-ext {
- yang-version 1;
- namespace "urn:opendaylight:yang:extension:yang-ext";
- prefix "ext";
-
- contact "Anton Tkacik <ttkacik@cisco.com>";
-
- description
- "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";
-
- revision "2013-07-09" {
- description "";
- }
-
- // Augmentation name
-
- extension "augment-identifier" {
- description
- "YANG language extension which assigns an identifier to augmentation.
- Augment identifier is used to identify specific augment statement
- by name. The identifier syntax is defined formally defined by
- the rule 'identifier' in Section 12 of RFC 6020. All augment identifiers
- defined in a namespace MUST be unique. The namespace of augment
- identifiers is shared by module and its submodules.";
-
- /*
- Discussion:
- This extension allows for ease of development / debug
- of YANG modules and it is suitable for code generation,
- where each augment statement is nicely identified by
- unique name instead of combination of augment target
- and when condition.
- */
- argument "identifier";
- }
-
- // Context-aware RPCs
-
- grouping rpc-context-ref {
- description
- "A reference to RPC context.";
- leaf context-instance {
- type instance-identifier;
- description "Pointer to the context. ";
- }
- }
-
- extension "rpc-context-instance" {
- description
- "YANG language extension which defines enclosing (parent) schema
- node as referencable context for RPCs. The argument is identity
- which is used to identify RPC context type.";
-
- argument "context-type";
- }
-
- extension "context-reference" {
- argument "context-type";
- }
-
- extension "context-instance" {
- argument "context-type";
- }
-
- extension "instance-target" {
- argument "path";
- }
-
- extension "anyxml-schema-location" {
- argument "target-node";
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<my-anyxml-data xmlns="bar">
- <my-container-1>
- <my-leaf-1>value1</my-leaf-1>
- </my-container-1>
- <my-container-2>
- <my-leaf-2>value2</my-leaf-2>
- </my-container-2>
-</my-anyxml-data>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<foo xmlns="foo">
- <my-container-1>
- <my-leaf-1>value1</my-leaf-1>
- </my-container-1>
- <my-container-2>
- <inner-container>
- <my-leaf-2>value2</my-leaf-2>
- </inner-container>
- <my-leaf-3>value3</my-leaf-3>
- </my-container-2>
-
- <my-anyxml-data>
- <inner-container>
- <my-leaf-2>any-xml-leaf-2-value</my-leaf-2>
- </inner-container>
- <my-leaf-3>any-xml-leaf-3-value</my-leaf-3>
- </my-anyxml-data>
-</foo>
\ No newline at end of file
+++ /dev/null
-module bar {
- namespace "bar";
- prefix bar;
-
- container bar {
- container my-container-1 {
- leaf my-leaf-1 {
- type string;
- }
- }
-
- container my-container-2 {
- leaf my-leaf-2 {
- type string;
- }
- }
- }
-}
+++ /dev/null
-module foo {
- namespace "foo";
- prefix foo;
-
- import yang-ext { prefix ext; revision-date 2013-07-09; }
-
- container my-container-1 {
- leaf my-leaf-1 {
- type string;
- }
- }
-
- container my-container-2 {
- container inner-container {
- leaf my-leaf-2 {
- type string;
- }
- }
- leaf my-leaf-3 {
- type string;
- }
- }
-
- anyxml my-anyxml-data {
- ext:anyxml-schema-location "/my-container-2";
- }
-}
+++ /dev/null
-module yang-ext {
- yang-version 1;
- namespace "urn:opendaylight:yang:extension:yang-ext";
- prefix "ext";
-
- contact "Anton Tkacik <ttkacik@cisco.com>";
-
- description
- "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";
-
- revision "2013-07-09" {
- description "";
- }
-
- // Augmentation name
-
- extension "augment-identifier" {
- description
- "YANG language extension which assigns an identifier to augmentation.
- Augment identifier is used to identify specific augment statement
- by name. The identifier syntax is defined formally defined by
- the rule 'identifier' in Section 12 of RFC 6020. All augment identifiers
- defined in a namespace MUST be unique. The namespace of augment
- identifiers is shared by module and its submodules.";
-
- /*
- Discussion:
- This extension allows for ease of development / debug
- of YANG modules and it is suitable for code generation,
- where each augment statement is nicely identified by
- unique name instead of combination of augment target
- and when condition.
- */
- argument "identifier";
- }
-
- // Context-aware RPCs
-
- grouping rpc-context-ref {
- description
- "A reference to RPC context.";
- leaf context-instance {
- type instance-identifier;
- description "Pointer to the context. ";
- }
- }
-
- extension "rpc-context-instance" {
- description
- "YANG language extension which defines enclosing (parent) schema
- node as referencable context for RPCs. The argument is identity
- which is used to identify RPC context type.";
-
- argument "context-type";
- }
-
- extension "context-reference" {
- argument "context-type";
- }
-
- extension "context-instance" {
- argument "context-type";
- }
-
- extension "instance-target" {
- argument "path";
- }
-
- extension "anyxml-schema-location" {
- argument "target-node";
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<foo xmlns="foo">
- <root>
- <my-leaf>dp1o34</my-leaf>
- </root>
-</foo>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<foo xmlns="foo">
- <root>
- <my-leaf>dp0s3f9</my-leaf>
- </root>
-</foo>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<foo xmlns="foo">
- <root>
- <my-leaf>dp09P1p2s3</my-leaf>
- </root>
-</foo>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<foo xmlns="foo">
- <root>
- <my-leaf>dp0p3p1</my-leaf>
- </root>
-</foo>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<foo xmlns="foo">
- <root>
- <my-leaf>dp0s3</my-leaf>
- </root>
-</foo>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<foo xmlns="foo">
- <root>
- <my-leaf>dp09P1p2s1234</my-leaf>
- </root>
-</foo>
\ No newline at end of file
+++ /dev/null
-module foo {
- yang-version 1;
- namespace "foo";
- prefix "foo";
-
- revision "2016-03-22" {
- description "test";
- }
-
- container root {
- leaf my-leaf {
- type my-type;
- }
- }
-
- typedef my-type {
- type union {
- type string {
- pattern "dp[0-9]+o[0-9]+";
- }
- type string {
- pattern "dp[0-9]+s[0-9]+(f[0-9]+)?(d[0-9]+)?";
- }
- type string {
- pattern "dp[0-9]+(P[0-9]+)?p[0-9]{1,3}s[0-9]{1,3}(f[0-9]+)?(d[0-9]+)?";
- }
- type string {
- pattern "dp[0-9]+p[0-9]+p[0-9]+";
- }
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<foo xmlns="foo">
- <root>
- <ip-address>fwAAAQ==</ip-address>
- </root>
-</foo>
\ No newline at end of file
+++ /dev/null
-module foo {
- yang-version 1;
- namespace "foo";
- prefix "foo";
-
- revision "2015-11-05" {
- }
-
- typedef ipv4-address-binary {
- type binary {
- length "4";
- }
- }
-
- typedef ipv6-address-binary {
- type binary {
- length "16";
- }
- }
-
- typedef ip-address-binary {
- type union {
- type ipv4-address-binary;
- type ipv6-address-binary;
- }
- }
-
- container root {
- leaf ip-address {
- type ip-address-binary;
- }
- }
-}
+++ /dev/null
-<root-cont xmlns="foo">
- <my-outer-unkeyed-list>
- <ip>192.168.0.1</ip>
- <leaf-a>something</leaf-a>
- </my-outer-unkeyed-list>
- <my-outer-unkeyed-list>
- <ip>192.168.0.2</ip>
- <my-inner-unkeyed-list>
- <leaf-b>something else</leaf-b>
- <ip>192.168.0.3</ip>
- </my-inner-unkeyed-list>
- </my-outer-unkeyed-list>
-</root-cont>
\ No newline at end of file
+++ /dev/null
-module foo {
- namespace foo;
- prefix foo;
-
- revision 2017-03-10;
-
- container root-cont {
- list my-outer-unkeyed-list {
- leaf leaf-a {
- type string;
- }
-
- list my-inner-unkeyed-list {
- leaf leaf-b {
- type string;
- }
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-module immutable-ordered-map-node {
- yang-version 1;
- namespace "test.namespace.builder.test";
- prefix "iomn";
-
- revision "2016-01-01" {
- description "Initial revision.";
- }
-
- container root-container {
- list list-ordered-by-user-with-key {
- key "leaf-a";
- ordered-by "user";
-
- leaf leaf-a {
- type string;
- }
- }
-
- leaf-list leaf-list-ordered-by-user {
- ordered-by "user";
- type string;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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
- */
-module controller-network {
- yang-version 1;
- namespace "urn:opendaylight:controller:network";
- prefix "topos";
-
- import ietf-inet-types { prefix "inet"; }
-
- revision 2013-05-20 {
- description "Initial demo";
- }
-
-
-
-
- typedef topology-id {
- type string;
- }
-
- typedef node-id {
- type string;
- }
-
- typedef link-id {
- type string;
- }
-
- typedef tp-id {
- type string;
- description "identifier for termination points on a port";
- }
-
- typedef tp-ref {
- type leafref {
- path "/network/topologies/topology/nodes/node/termination-points/termination-point/tp-id";
- }
- }
- typedef topology-ref {
- type leafref {
- path "/network/topologies/topology/topology-id";
- }
- description "This type is used for leafs that reference topology identifier instance.";
- // currently not used
- }
-
- typedef node-ref {
- type leafref {
- path "/network/topologies/topology/nodes/node/node-id";
- }
- description "This type is used for leafs that reference a node instance.";
- }
-
- typedef link-ref {
- type leafref {
- path "/network/topologies/topology/links/link/link-id";
- }
- description "This type is used for leafs that reference a link instance.";
- // currently not used
- }
-
- typedef network-element-ref {
- type leafref {
- path "/network/network-elements/network-element/element-id";
- }
- }
-
-
- typedef element-id {
- type string;
- }
-
- container network {
- container topologies {
- list topology {
- description "
- This is the model of abstract topology which contains only Network
- Nodes and Network Links. Each topology MUST be identified by
- unique topology-id for reason that the store could contain many
- topologies.
- ";
- key "topology-id";
- leaf topology-id {
- type topology-id;
- description "
- It is presumed that datastore will contain many topologies. To
- distinguish between topologies it is vital to have UNIQUE
- topology identifier.
- ";
- }
-
- container types {
- description "
- The container for definition of topology types.
- The augmenting modules should add empty optional leaf
- to this container to signalize topology type.
- ";
- }
-
- container nodes {
- list node {
- description "The list of network nodes defined for topology.";
-
- key "node-id";
- leaf node-id {
- type node-id;
- description "The Topology identifier of network-node.";
- }
-
- leaf supporting-ne {
- type network-element-ref;
- }
-
- container termination-points {
- list termination-point {
- key "tp-id";
- leaf tp-id {
- type tp-id;
- }
- }
- }
- }
- }
-
- container links {
- list link {
- description "
- The Network Link which is defined by Local (Source) and
- Remote (Destination) Network Nodes. Every link MUST be
- defined either by identifier and his local and remote
- Network Nodes (in real applications it is common that many
- links are originated from one node and end up in same
- remote node). To ensure that we would always know to
- distinguish between links, every link SHOULD have
- identifier.
- ";
- key "link-id";
-
- leaf link-id {
- type link-id;
- }
- container source {
- leaf source-node {
- type node-ref;
- description "Source node identifier.";
- }
- leaf source-tp {
- type tp-ref;
- }
- }
- container destination {
- leaf dest-node {
- type node-ref;
- description "Destination node identifier.";
- }
- leaf dest-tp {
- type tp-ref;
- }
- }
- }
- }
- }
- }
- container network-elements {
- config true;
- list network-element {
- key "element-id";
- leaf element-id {
- type element-id;
- }
- }
- }
- }
-}
+++ /dev/null
-module serializer-test {
- yang-version 1;
- namespace "dom-serializer-test";
- prefix "dst";
-
- revision "2016-01-01" {
- description "Initial revision.";
- }
-
- typedef int-with-range {
- type int8 {
- range 1..20;
- }
- }
-
- container root {
- leaf first-leaf {
- type int-with-range;
- }
-
- leaf-list first-leaf-list {
- type string;
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-module foo {
- namespace "foo";
- prefix "foo";
-
- container cont {
- leaf lf1 {
- type string;
- }
-
- leaf lf2 {
- type string;
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2016 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
- */
-module iid-test {
- yang-version 1;
- namespace "urn:opendaylight:controller:iid:test";
- prefix "iidt";
-
- revision 2014-07-28 {
- description "Initial test";
- }
-
- container cont {
-
- list l {
- key "id";
-
- leaf id {
- type string;
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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
- */
-module xml-doc-test {
- yang-version 1;
- namespace "urn:opendaylight:controller:xml:doc:test";
- prefix "xmldt";
-
- revision 2014-07-28 {
- description "Initial test";
- }
-
- container cont {
-
- list l {
- key "id";
-
- leaf id {
- type string;
- }
- }
- }
-
- typedef custom-instance-identifier {
- type instance-identifier;
- }
-
- rpc test {
- input {
- leaf a {
- type string;
- }
-
- leaf ref {
- type custom-instance-identifier;
- }
- }
- }
-
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 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
- */
-module xml-doc-test-2 {
- yang-version 1;
- namespace "urn:opendaylight:controller:xml:doc:test2";
- prefix "xmldt";
-
- revision 2014-07-28 {
- description "Initial test";
- }
-
- container cont2 {
-
- list l {
- key "id";
-
- leaf id {
- type string;
- }
- }
- }
-}
+++ /dev/null
-module another {
- yang-version 1.1;
- namespace "urn:opendaylight:controller:sal:dom:store:another";
- prefix another;
-
- import test { prefix test; }
-
- augment "/test:root" {
- container another {
- list list-from-another-namespace {
- key "leaf-from-another-namespace";
- leaf leaf-from-another-namespace {
- type string;
- }
- }
- }
- }
-}
+++ /dev/null
-module test {
- yang-version 1.1;
- namespace "urn:opendaylight:controller:sal:dom:store:test";
- prefix test;
-
- revision 2014-03-13;
-
- container root {
- list list-a {
- key "leaf-a";
- leaf leaf-a {
- type string;
- }
- list list-b {
- key "leaf-b";
- leaf leaf-b {
- type string;
- }
- }
- }
-
- choice choice {
- }
-
- leaf leaf {
- type string;
- }
-
- leaf-list leaf-set {
- type string;
- }
-
- leaf-list user-leaf-set {
- ordered-by user;
- type string;
- }
-
- list user-map {
- ordered-by user;
- key "user-map-entry";
- leaf user-map-entry {
- type string;
- }
- }
-
- list unkeyed-list {
- leaf unkeyed-list-leaf {
- type string;
- }
- }
-
- anydata any-data {}
- }
-
- augment "/test:root/test:choice" {
- leaf augment {
- type string;
- }
- }
-}
+++ /dev/null
-module string-pattern-checking-codec-test {
- namespace "string-pattern-checking-codec-test";
- prefix "spcct";
-
- container test-container {
- leaf string-leaf-with-valid-pattern {
- type string {
- pattern "[A-Z]+";
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-module yt1097 {
- namespace yt1097;
- prefix yt1097;
-
- leaf foo {
- type union {
- type boolean;
- type string;
- }
- }
-}
-
+++ /dev/null
-module yt1437 {
- namespace yt1437;
- prefix yt1437;
-
- leaf foo {
- type decimal64 {
- fraction-digits 2;
- range "20.0..30.01 | 50";
- }
- }
-}
+++ /dev/null
-module yt1442 {
- namespace yt1442;
- prefix yt1442;
-
- leaf foo {
- type decimal64 {
- fraction-digits 2;
- range 10.0..100.0 {
- error-app-tag model-defined-app-tag;
- error-message model-defined-message;
- }
- }
- }
-}