Migrated all YANG testfiles counting 50 lines or less.
JIRA: YANGTOOLS-1506
Change-Id: I2ed3beef91692cd93c5bb8f81e5798d2d6557803
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
@BeforeClass
public static void beforeClass() {
- SCHEMA_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/yt1027");
+ SCHEMA_CONTEXT = YangParserTestUtils.parseYang("""
+ module yt1027 {
+ namespace "yt1027.test";
+ prefix tst;
+
+ leaf uint64 {
+ type uint64;
+ }
+
+ leaf int64 {
+ type int64;
+ }
+
+ leaf decimal {
+ type decimal64 {
+ fraction-digits 1;
+ }
+ }
+ }""");
DECIMAL_TYPE = (DecimalTypeDefinition) getTypeDefinition(DECIMAL);
INT64_TYPE = (Int64TypeDefinition) getTypeDefinition(INT64);
UINT64_TYPE = (Uint64TypeDefinition) getTypeDefinition(UINT64);
@BeforeClass
public static void initialization() {
- schemaContext = YangParserTestUtils.parseYangResourceDirectory("/bug-4501/yang");
+ schemaContext = YangParserTestUtils.parseYang("""
+ module foo {
+ namespace "foo";
+ prefix foo;
+ yang-version 1;
+
+ list hop {
+ leaf address {
+ type string;
+ }
+ leaf lrs-bits {
+ type bits {
+ bit lookup {
+ description "Lookup bit.";
+ }
+ bit rloc-probe {
+ description "RLOC-probe bit.";
+ }
+ bit strict {
+ description "Strict bit.";
+ }
+ }
+ description "Flag bits per hop.";
+ }
+ }
+ }""");
}
@AfterClass
@Test
public void newParserLeafRefTest() throws IOException, URISyntaxException {
- EffectiveModelContext context = YangParserTestUtils.parseYangResourceDirectory("/bug-4969/yang");
+ EffectiveModelContext context = YangParserTestUtils.parseYang("""
+ module bar {
+ namespace "bar";
+ prefix bar;
+
+ revision "2016-01-22" {
+ description "Initial version";
+ }
+
+ typedef ref1 {
+ type ref1-2;
+ }
+
+ typedef ref2 {
+ type ref2-2;
+ }
+
+ typedef ref3 {
+ type ref3-2;
+ }
+
+ typedef ref1-2 {
+ type leafref {
+ path "/bar:root/bar:l1";
+ }
+ }
+
+ typedef ref2-2 {
+ type leafref {
+ path "/bar:root/bar:l2";
+ }
+ }
+
+ typedef ref3-2 {
+ type leafref {
+ path "/bar:root/bar:l3";
+ }
+ }
+
+ container root {
+ leaf l1 {
+ type bits {
+ bit a;
+ bit b;
+ bit c;
+ bit d;
+ }
+ }
+ leaf l2 {
+ type leafref {
+ path "/root/l1";
+ }
+ }
+ leaf l3 {
+ type leafref {
+ path "../l1";
+ }
+ }
+ }
+ }""", """
+ module foo {
+ namespace "foo";
+ prefix foo;
+
+ import bar {
+ prefix bar; revision-date 2016-01-22;
+ }
+
+ revision "2016-01-22" {
+ description "Initial version";
+ }
+
+ container root {
+ leaf ref1 {
+ type bar:ref1;
+ }
+ leaf ref2 {
+ type bar:ref2;
+ }
+ leaf ref3 {
+ type bar:ref3;
+ }
+ leaf ref4 {
+ type leafref {
+ path "/bar:root/bar:l1";
+ }
+ }
+ }
+ }""");
assertNotNull(context);
verifyNormalizedNodeResult(context);
@Test
public void newParserLeafRefTest2() throws URISyntaxException, IOException {
- EffectiveModelContext context = YangParserTestUtils.parseYangResourceDirectory("/leafref/yang");
+ EffectiveModelContext context = YangParserTestUtils.parseYang("""
+ module augment-leafref-module {
+ namespace "augment:leafref:module";
+ prefix "auglfrfmo";
+ revision 2014-12-16 {
+ }
+ typedef leafreftype {
+ type leafref {
+ path "/auglfrfmo:cont/auglfrfmo:lf3";
+ }
+ }
+ container cont {
+ leaf lf3 {
+ type string;
+ }
+ }
+ }""", """
+ module leafref-module {
+ namespace "leafref:module";
+ prefix "lfrfmo";
+ import augment-leafref-module { prefix augleafref; revision-date 2014-12-16; }
+ revision 2013-11-18 {
+ }
+ container cont {
+ leaf lf1 {
+ type int32;
+ }
+ leaf lf2 {
+ type leafref {
+ path "/cont/lf1";
+ }
+ }
+ leaf lf4 {
+ type augleafref:leafreftype;
+ }
+ }
+ }""");
assertNotNull(context);
parseJsonToNormalizedNodes(context);
@Before
public void init() {
- schemaContext = YangParserTestUtils.parseYangResourceDirectory("/bug5446");
+ schemaContext = YangParserTestUtils.parseYang("""
+ 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;
+ }
+ }
+ }""");
}
@Test
@BeforeClass
public static void initialization() {
- schemaContext = YangParserTestUtils.parseYangResourceDirectory("/bug-6112/yang");
+ schemaContext = YangParserTestUtils.parseYang("""
+ module union-with-identityref {
+ yang-version 1;
+ namespace "union:identityref:test";
+ prefix "unionidentityreftest";
+ description "test union with identityref";
+ revision "2016-07-12";
+
+ identity ident-base;
+
+ identity ident-one {
+ base ident-base;
+ }
+
+ typedef union-type {
+ type union {
+ type uint8;
+ type identityref {
+ base ident-base;
+ }
+ }
+ }
+
+ container root {
+ leaf leaf-value {
+ type union-type;
+ }
+ }
+ }""");
}
@AfterClass
@Test
public void test() throws Exception {
- final var schemaContext = YangParserTestUtils.parseYangResource("/bug7246/yang/rpc-test.yang");
+ final var schemaContext = YangParserTestUtils.parseYang("""
+ module rpc-test {
+ namespace my-namespace;
+ prefix p;
+ feature my-name;
+ identity my-name;
+ extension my-name;
+
+ typedef my-name {
+ type string;
+ }
+
+ grouping my-name {
+ leaf my-name {
+ type my-name;
+ }
+ }
+
+ rpc my-name {
+ input {
+ container my-name {
+ leaf my-name {
+ type my-name;
+ }
+ }
+ }
+ output {
+ container my-name {
+ leaf my-name {
+ type my-name;
+ }
+ }
+ }
+ }
+ }""");
final var inputStructure = Builders.containerBuilder()
.withNodeIdentifier(new NodeIdentifier(qN("my-name")))
.withChild(ImmutableNodes.leafNode(new NodeIdentifier(qN("my-name")), "my-value"))
.node(BARCONTAINER_QNAME)
.node(QName.create(BARMOD, "bar-leaf"))
.build();
+ private static final String BAZ_YANG = """
+ module baz {
+ namespace baz-ns;
+ prefix baz-prefix;
+
+ container top-cont {
+ list keyed-list {
+ key empty-key-leaf;
+ leaf empty-key-leaf {
+ type empty;
+ }
+ leaf regular-leaf {
+ type int32;
+ }
+ }
+ leaf iid-leaf {
+ type instance-identifier;
+ }
+ }
+ }""";
+ private static final String FOOBAR_YANG = """
+ module foobar {
+ namespace foobar-ns;
+ prefix foobar-prefix;
+ container top-cont {
+ list keyed-list {
+ key iid-key-leaf;
+ leaf iid-key-leaf {
+ type instance-identifier;
+ }
+ leaf regular-leaf {
+ type int32;
+ }
+ }
+ leaf iid-leaf {
+ type instance-identifier;
+ }
+ leaf leaf-b {
+ type int32;
+ }
+ }
+ }""";
+ private static final String ZAB_YANG = """
+ module zab {
+ namespace zab-ns;
+ prefix zab-prefix;
+ identity base-id;
+ identity derived-id {
+ base base-id;
+ }
+ container top-cont {
+ list keyed-list {
+ key identityref-key-leaf;
+ leaf identityref-key-leaf {
+ type identityref {
+ base base-id;
+ }
+ }
+ leaf regular-leaf {
+ type int32;
+ }
+ }
+ leaf iid-leaf {
+ type instance-identifier;
+ }
+ }
+ }""";
private static EffectiveModelContext FULL_SCHEMA_CONTEXT;
@BeforeClass
public static void init() {
- FULL_SCHEMA_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/bug8083/yang/");
+ FULL_SCHEMA_CONTEXT = YangParserTestUtils.parseYang("""
+ module example-barmod {
+ namespace "http://example.com/barmod";
+ prefix "barmod";
+ import example-foomod {
+ prefix "foomod";
+ }
+ augment "/foomod:top/foomod:foo-list" {
+ container bar-container {
+ leaf bar-leaf {
+ type string;
+ }
+ }
+ }
+ }""", BAZ_YANG, """
+ module example-foomod {
+ namespace "http://example.com/foomod";
+ prefix "foomod";
+ container top {
+ leaf foo {
+ type instance-identifier;
+ }
+ list foo-list {
+ key name;
+ leaf name {
+ type string;
+ }
+ }
+ }
+ }""", FOOBAR_YANG, ZAB_YANG);
}
@AfterClass
@Test
public void testInstanceIdentifierPathWithEmptyListKey() throws IOException, URISyntaxException {
- final var schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/baz.yang");
+ final var schemaContext = YangParserTestUtils.parseYang(BAZ_YANG);
final String inputJson = loadTextFile("/bug8083/json/baz.json");
// deserialization
@Test
public void testInstanceIdentifierPathWithIdentityrefListKey() throws IOException, URISyntaxException {
- final var schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/zab.yang");
+ final var schemaContext = YangParserTestUtils.parseYang(ZAB_YANG);
final String inputJson = loadTextFile("/bug8083/json/zab.json");
// deserialization
@Test
public void testInstanceIdentifierPathWithInstanceIdentifierListKey() throws IOException, URISyntaxException {
- final EffectiveModelContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/foobar.yang");
+ final EffectiveModelContext schemaContext = YangParserTestUtils.parseYang(FOOBAR_YANG);
final String inputJson = loadTextFile("/bug8083/json/foobar.json");
// deserialization
@BeforeAll
static void beforeAll() {
- final var modelContext = YangParserTestUtils.parseYangResourceDirectory("/yt1473");
+ final var modelContext = YangParserTestUtils.parseYang("""
+ module bar {
+ namespace barns;
+ prefix bar;
+ import foo { prefix foo; }
+
+ identity two {
+ base foo:one;
+ }
+
+ leaf-list str {
+ type string;
+ }
+
+ leaf-list foo {
+ type identityref {
+ base foo:one;
+ }
+ }
+
+ leaf-list bar {
+ type instance-identifier;
+ }
+
+ leaf-list bee {
+ type foo:bitz;
+ }
+
+ leaf baz {
+ type instance-identifier;
+ }
+ }""", """
+ module foo {
+ namespace foons;
+ prefix foo;
+ identity one;
+
+ typedef bitz {
+ type bits {
+ bit one;
+ bit two;
+ bit three;
+ }
+ }
+
+ list foo {
+ key str;
+ leaf str {
+ type string;
+ }
+ }
+
+ list bar {
+ key qname;
+ leaf qname {
+ type identityref {
+ base one;
+ }
+ }
+ }
+
+ list baz {
+ key id;
+ leaf id {
+ type instance-identifier;
+ }
+ }
+
+ list bee {
+ key bts;
+ leaf bts {
+ type bitz;
+ }
+ }
+ }""");
final var baz = assertInstanceOf(ListSchemaNode.class, modelContext.getDataChildByName(FOO_BAZ));
final var id = assertInstanceOf(LeafSchemaNode.class, baz.getDataChildByName(FOO_ID));
final var type = assertInstanceOf(InstanceIdentifierTypeDefinition.class, id.getType());
+++ /dev/null
-module foo {
- namespace "foo";
- prefix foo;
- yang-version 1;
-
- list hop {
- leaf address {
- type string;
- }
-
- leaf lrs-bits {
- type bits {
- bit lookup {
- description
- "Lookup bit.";
- }
- bit rloc-probe {
- description
- "RLOC-probe bit.";
- }
- bit strict {
- description
- "Strict bit.";
- }
- }
- description
- "Flag bits per hop.";
- }
- }
-}
+++ /dev/null
-module bar {
- namespace "bar";
- prefix bar;
-
- revision "2016-01-22" {
- description "Initial version";
- }
-
- typedef ref1 {
- type ref1-2;
- }
-
- typedef ref2 {
- type ref2-2;
- }
-
- typedef ref3 {
- type ref3-2;
- }
-
- typedef ref1-2 {
- type leafref {
- path "/bar:root/bar:l1";
- }
- }
-
- typedef ref2-2 {
- type leafref {
- path "/bar:root/bar:l2";
- }
- }
-
- typedef ref3-2 {
- type leafref {
- path "/bar:root/bar:l3";
- }
- }
-
- container root {
- leaf l1 {
- type bits {
- bit a;
- bit b;
- bit c;
- bit d;
- }
- }
- leaf l2 {
- type leafref {
- path "/root/l1";
- }
- }
- leaf l3 {
- type leafref {
- path "../l1";
- }
- }
- }
-}
+++ /dev/null
-module foo {
- namespace "foo";
- prefix foo;
-
- import bar { prefix bar; revision-date 2016-01-22; }
-
- revision "2016-01-22" {
- description "Initial version";
- }
-
- container root {
- leaf ref1 {
- type bar:ref1;
- }
- leaf ref2 {
- type bar:ref2;
- }
- leaf ref3 {
- type bar:ref3;
- }
- leaf ref4 {
- type leafref {
- path "/bar:root/bar:l1";
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Intel Corporation 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 union-with-identityref {
- yang-version 1;
- namespace "union:identityref:test";
- prefix "unionidentityreftest";
-
- description "test union with identityref";
-
- revision "2016-07-12";
-
- identity ident-base;
- identity ident-one {
- base ident-base;
- }
-
- typedef union-type {
- type union {
- type uint8;
- type identityref {
- base ident-base;
- }
- }
- }
-
- container root {
- leaf leaf-value {
- type union-type;
- }
- }
-}
+++ /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
-module rpc-test {
- namespace my-namespace;
- prefix p;
-
- feature my-name;
-
- identity my-name;
-
- extension my-name;
-
- typedef my-name {
- type string;
- }
-
- grouping my-name {
- leaf my-name {
- type my-name;
- }
- }
-
- rpc my-name {
- input {
- container my-name {
- leaf my-name {
- type my-name;
- }
- }
- }
- output {
- container my-name {
- leaf my-name {
- type my-name;
- }
- }
- }
- }
-}
+++ /dev/null
-module example-barmod {
-
- namespace "http://example.com/barmod";
- prefix "barmod";
-
- import example-foomod {
- prefix "foomod";
- }
-
- augment "/foomod:top/foomod:foo-list" {
- container bar-container {
- leaf bar-leaf {
- type string;
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-module baz {
-
- namespace baz-ns;
- prefix baz-prefix;
-
- container top-cont {
- list keyed-list {
- key empty-key-leaf;
-
- leaf empty-key-leaf {
- type empty;
- }
-
- leaf regular-leaf {
- type int32;
- }
- }
-
- leaf iid-leaf {
- type instance-identifier;
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-module example-foomod {
-
- namespace "http://example.com/foomod";
- prefix "foomod";
-
- container top {
- leaf foo {
- type instance-identifier;
- }
-
- list foo-list {
- key name;
-
- leaf name {
- type string;
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-module foobar {
-
- namespace foobar-ns;
- prefix foobar-prefix;
-
- container top-cont {
- list keyed-list {
- key iid-key-leaf;
-
- leaf iid-key-leaf {
- type instance-identifier;
- }
-
- leaf regular-leaf {
- type int32;
- }
- }
-
- leaf iid-leaf {
- type instance-identifier;
- }
-
- leaf leaf-b {
- type int32;
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-module zab {
-
- namespace zab-ns;
- prefix zab-prefix;
-
- identity base-id;
-
- identity derived-id {
- base base-id;
- }
-
- container top-cont {
- list keyed-list {
- key identityref-key-leaf;
-
- leaf identityref-key-leaf {
- type identityref {
- base base-id;
- }
- }
-
- leaf regular-leaf {
- type int32;
- }
- }
-
- leaf iid-leaf {
- type instance-identifier;
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-module augment-leafref-module {
- namespace "augment:leafref:module";
-
- prefix "auglfrfmo";
- revision 2014-12-16 {
- }
-
- typedef leafreftype {
- type leafref {
- path "/auglfrfmo:cont/auglfrfmo:lf3";
- }
- }
-
- container cont {
- leaf lf3 {
- type string;
- }
- }
-}
+++ /dev/null
-module leafref-module {
- namespace "leafref:module";
-
- prefix "lfrfmo";
-
- import augment-leafref-module { prefix augleafref; revision-date 2014-12-16; }
- revision 2013-11-18 {
- }
-
- container cont {
- leaf lf1 {
- type int32;
- }
- leaf lf2 {
- type leafref {
- path "/cont/lf1";
- }
- }
- leaf lf4 {
- type augleafref:leafreftype;
- }
- }
-}
+++ /dev/null
-module yt1027 {
- namespace "yt1027.test";
- prefix tst;
-
- leaf uint64 {
- type uint64;
- }
-
- leaf int64 {
- type int64;
- }
-
- leaf decimal {
- type decimal64 {
- fraction-digits 1;
- }
- }
-}
-
+++ /dev/null
-module bar {
- namespace barns;
- prefix bar;
-
- import foo { prefix foo; }
-
- identity two {
- base foo:one;
- }
-
- leaf-list str {
- type string;
- }
-
- leaf-list foo {
- type identityref {
- base foo:one;
- }
- }
-
- leaf-list bar {
- type instance-identifier;
- }
-
- leaf-list bee {
- type foo:bitz;
- }
-
- leaf baz {
- type instance-identifier;
- }
-}
+++ /dev/null
-module foo {
- namespace foons;
- prefix foo;
-
- identity one;
-
- typedef bitz {
- type bits {
- bit one;
- bit two;
- bit three;
- }
- }
-
- list foo {
- key str;
- leaf str {
- type string;
- }
- }
-
- list bar {
- key qname;
- leaf qname {
- type identityref {
- base one;
- }
- }
- }
-
- list baz {
- key id;
- leaf id {
- type instance-identifier;
- }
- }
-
- list bee {
- key bts;
- leaf bts {
- type bitz;
- }
- }
-}