Merge "BUG 2307: Filtering proxy for Schema context functionality"
authorTony Tkacik <ttkacik@cisco.com>
Fri, 13 Feb 2015 09:02:54 +0000 (09:02 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 13 Feb 2015 09:02:55 +0000 (09:02 +0000)
common/features-builder/pom.xml
common/parent/pom.xml
yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONNormalizedNodeStreamWriter.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/CopyUtils.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/GroupingTest.java
yang/yang-parser-impl/src/test/resources/added-by-uses-leaf-test/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/added-by-uses-leaf-test/import-module.yang [new file with mode: 0644]

index 0576893ad410ec94f90adad2ee13361ffbb779c5..e82bf929e9b54bf24d55d412b2aac77fe274f8aa 100644 (file)
                     <artifactId>maven-surefire-plugin</artifactId>
                     <configuration>
                         <dependenciesToScan>
-                            <dependency>org.opendaylight.yangtools:features-test</dependency>
+                            <dependency>org.opendaylight.odlparent:features-test</dependency>
                         </dependenciesToScan>
                     </configuration>
                 </plugin>
     <dependencies>
         <!-- test the features.xml -->
         <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
+            <groupId>org.opendaylight.odlparent</groupId>
             <artifactId>features-test</artifactId>
-            <version>0.7.0-SNAPSHOT</version>
+            <version>1.5.0-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
index 812b59665b6bc28d03f66b6973ab993aaf55e7f9..d0e43ef25f2e4acf51af270696092dba4c700079 100644 (file)
             </plugin>
         </plugins>
     </reporting>
-
-
-    <!-- Note: we can not use variables for these URLs because we need to
-         be able to download the parent pom from the repository the first
-         time we go to use it (since it is in a different project).
-         To override the settings, use the "mirror" section of the
-         settings.xml. See http://maven.apache.org/settings.html -->
-    <repositories>
-        <!-- OpenDayLight Repo Mirror -->
-        <repository>
-            <id>opendaylight-mirror</id>
-            <name>opendaylight-mirror</name>
-            <url>http://nexus.opendaylight.org/content/groups/public/</url>
-            <snapshots>
-                <enabled>false</enabled>
-            </snapshots>
-            <releases>
-                <enabled>true</enabled>
-                <updatePolicy>never</updatePolicy>
-            </releases>
-        </repository>
-
-        <!-- OpenDayLight Snapshot artifact -->
-        <repository>
-            <id>opendaylight-snapshot</id>
-            <name>opendaylight-snapshot</name>
-            <url>http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
-            <snapshots>
-                <enabled>true</enabled>
-            </snapshots>
-            <releases>
-                <enabled>false</enabled>
-            </releases>
-        </repository>
-    </repositories>
 </project>
index 53c8d5439eee25017127ca65541f46b24eabe316..59ef1f1e501ffc53011230f5f2f8ba61271f530c 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.codec.SchemaTracker;
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -163,10 +162,9 @@ public class JSONNormalizedNodeStreamWriter implements NormalizedNodeStreamWrite
     public void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
         final SchemaNode schema = tracker.startContainerNode(name);
 
-        final boolean isPresence = schema instanceof ContainerSchemaNode ?
-                ((ContainerSchemaNode) schema).isPresenceContainer() : DEFAULT_EMIT_EMPTY_CONTAINERS;
-
-        context = new JSONStreamWriterNamedObjectContext(context, name, isPresence);
+        // FIXME this code ignores presence for containers
+        // but datastore does as well and it needs be fixed first (2399)
+        context = new JSONStreamWriterNamedObjectContext(context, name, DEFAULT_EMIT_EMPTY_CONTAINERS);
     }
 
     @Override
index 0ca3d88b276ce03c509f8a2705cd469603592de1..55cf82726d8d104a4d9c32facff1bcf6d77bc6ab 100644 (file)
@@ -202,7 +202,7 @@ public final class CopyUtils {
         }
 
         if (old.getType() == null) {
-            copy.setTypedef(copy(old.getTypedef(), copy, updateQName));
+            copy.setTypedef(old.getTypedef());
         } else {
             copy.setType(old.getType());
         }
@@ -235,7 +235,7 @@ public final class CopyUtils {
         }
 
         if (old.getType() == null) {
-            copy.setTypedef(copy(old.getTypedef(), copy, updateQName));
+            copy.setTypedef(old.getTypedef());
         } else {
             copy.setType(old.getType());
         }
index a4360a5a67a93345f8e121781ae64ac4bee919c6..3abb8508e7b337b933fbf1b9d121a789319c7131 100644 (file)
@@ -13,6 +13,8 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+
 import java.io.File;
 import java.io.IOException;
 import java.net.URI;
@@ -545,4 +547,41 @@ public class GroupingTest {
         assertEquals(gy.getDataChildByName("leaf-grouping-Y"),SchemaNodeUtils.getRootOriginalIfPossible( gx.getDataChildByName("leaf-grouping-Y")));
     }
 
+    @Test
+    public void testAddedByUsesLeafTypeQName() throws IOException,
+            URISyntaxException {
+
+        Set<Module> loadModules = TestUtils.loadModules(getClass().getResource(
+                "/added-by-uses-leaf-test").toURI());
+
+        assertEquals(2, loadModules.size());
+
+        Module foo = null;
+        Module imp = null;
+        for (Module module : loadModules) {
+            if (module.getName().equals("foo")) {
+                foo = module;
+            }
+            if (module.getName().equals("import-module")) {
+                imp = module;
+            }
+        }
+
+        LeafSchemaNode leaf = (LeafSchemaNode) ((ContainerSchemaNode) foo
+                .getDataChildByName("my-container"))
+                .getDataChildByName("my-leaf");
+
+        TypeDefinition impType = null;
+        Set<TypeDefinition<?>> typeDefinitions = imp.getTypeDefinitions();
+        for (TypeDefinition<?> typeDefinition : typeDefinitions) {
+            if (typeDefinition.getQName().getLocalName().equals("imp-type")) {
+                impType = typeDefinition;
+                break;
+            }
+        }
+
+        assertEquals(leaf.getType().getQName(), impType.getQName());
+
+    }
+
 }
diff --git a/yang/yang-parser-impl/src/test/resources/added-by-uses-leaf-test/foo.yang b/yang/yang-parser-impl/src/test/resources/added-by-uses-leaf-test/foo.yang
new file mode 100644 (file)
index 0000000..413d7c6
--- /dev/null
@@ -0,0 +1,20 @@
+module foo {
+    prefix foo;
+    namespace "namespace-foo";
+
+    import import-module { prefix imp; revision-date 1970-01-02; } 
+    
+    grouping grp {
+        leaf my-leaf {
+            type imp:imp-type;
+        }
+        
+    }
+    
+    container my-container {
+        uses grp;
+        uses imp:imp_grp;
+    }
+    
+}
+
diff --git a/yang/yang-parser-impl/src/test/resources/added-by-uses-leaf-test/import-module.yang b/yang/yang-parser-impl/src/test/resources/added-by-uses-leaf-test/import-module.yang
new file mode 100644 (file)
index 0000000..6cb9f69
--- /dev/null
@@ -0,0 +1,35 @@
+module import-module {
+    prefix imp;
+    namespace "import-module";
+
+    revision 1970-01-02 {
+        description "Initial revision.";
+    }
+
+    typedef imp-type {
+        type string {
+            length "0..100";
+        }
+    }
+
+    grouping imp_grp {
+        
+        typedef grp-type {
+            type string {
+                length "20..30";
+            }
+        }
+
+        leaf my-leaf2 {
+            type grp-type;
+        }
+        
+        leaf union-leaf {
+            type union {
+                type int16;
+                type string;
+            }
+        }
+    }
+}
+