Merge "Implemented module dependency sort, that returns modules in order in which...
authorGiovanni Meo <gmeo@cisco.com>
Thu, 2 May 2013 13:48:11 +0000 (13:48 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 2 May 2013 13:48:11 +0000 (13:48 +0000)
13 files changed:
opendaylight/distribution/opendaylight/pom.xml
opendaylight/forwardingrulesmanager/implementation/pom.xml
opendaylight/forwardingrulesmanager/integrationtest/pom.xml [new file with mode: 0644]
opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/FRMIntegrationTest.java [new file with mode: 0644]
opendaylight/forwardingrulesmanager/integrationtest/src/test/resources/logback.xml [new file with mode: 0644]
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ChoiceBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ChoiceCaseBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/IdentitySchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ModuleBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UsesNodeBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserListenerImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/TypesResolutionTest.java

index cf481b7f4bf27a6b8102e04b713bb4854d701b00..c26b38843b29833f3633e822c7ef86d45b531ef6 100644 (file)
@@ -42,6 +42,7 @@
     <module>../../arphandler</module>
     <module>../../forwardingrulesmanager/api</module>
     <module>../../forwardingrulesmanager/implementation</module>
+    <module>../../forwardingrulesmanager/integrationtest</module>
     <module>../../hosttracker/api</module>
     <module>../../hosttracker/implementation</module>
     <module>../../hosttracker/integrationtest</module>
index 2c0bc9319c1fc21e381d8b8db4034350c1c93758..0031773029f9619a150512e32c970b0d43c37bb7 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<project
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+  xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.opendaylight.controller</groupId>
   <version>0.4.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
+  <properties>
+    <!-- Sonar properties using jacoco to retrieve integration test results -->
+    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
+    <sonar.jacoco.Reportpath>target/jacoco.exec</sonar.jacoco.Reportpath>
+    <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
+    <sonar.language>java</sonar.language>
+  </properties>
   <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.jacoco</groupId>
+          <artifactId>jacoco-maven-plugin</artifactId>
+          <version>0.5.3.201107060350</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
     <plugins>
       <plugin>
-       <groupId>org.apache.felix</groupId>
-       <artifactId>maven-bundle-plugin</artifactId>
-       <version>2.3.6</version>
-       <extensions>true</extensions>
-       <configuration>
-         <instructions>
-           <Include-Resource>
-           </Include-Resource>
-           <Export-Package>
-           </Export-Package>
-           <Import-Package>
-                     org.opendaylight.controller.clustering.services,
-                     org.opendaylight.controller.configuration,
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>2.3.6</version>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Include-Resource>
+            </Include-Resource>
+            <Export-Package>
+            </Export-Package>
+            <Import-Package>
+              org.opendaylight.controller.clustering.services,
+              org.opendaylight.controller.configuration,
               org.opendaylight.controller.hosttracker,
               org.opendaylight.controller.hosttracker.hostAware,
               org.opendaylight.controller.switchmanager,
@@ -37,9 +55,9 @@
               org.opendaylight.controller.sal.core,
               org.opendaylight.controller.sal.flowprogrammer,
               org.opendaylight.controller.sal.match,
-                         org.opendaylight.controller.sal.utils,
+              org.opendaylight.controller.sal.utils,
               org.opendaylight.controller.sal.packet,
-                         org.opendaylight.controller.forwardingrulesmanager,
+              org.opendaylight.controller.forwardingrulesmanager,
               javax.xml.bind.annotation,
               javax.xml.bind,
               org.apache.felix.dm,
               org.osgi.service.component,
               org.slf4j,
               org.eclipse.osgi.framework.console,
-                         org.osgi.framework
-           </Import-Package>
-        <Bundle-Activator>
-             org.opendaylight.controller.forwardingrulesmanager.internal.Activator
-               </Bundle-Activator>
+              org.osgi.framework
+            </Import-Package>
+            <Bundle-Activator>
+              org.opendaylight.controller.forwardingrulesmanager.internal.Activator
+            </Bundle-Activator>
             <Require-Bundle>
               org.opendaylight.controller.hosttracker
             </Require-Bundle>
           </instructions>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.jacoco</groupId>
+        <artifactId>jacoco-maven-plugin</artifactId>
+        <configuration>
+          <includes>org.opendaylight.controller.*</includes>
+        </configuration>
+        <executions>
+          <execution>
+            <id>pre-test</id>
+            <goals>
+              <goal>prepare-agent</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>post-test</id>
+            <phase>test</phase>
+            <goals>
+              <goal>report</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
   <dependencies>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>configuration</artifactId>
       <version>0.4.0-SNAPSHOT</version>
-    </dependency>    
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
       <artifactId>switchmanager</artifactId>
       <version>0.4.0-SNAPSHOT</version>
     </dependency>
-       <dependency>
-               <groupId>org.opendaylight.controller</groupId>
-               <artifactId>sal</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
-       </dependency>
-       <dependency>
-               <groupId>org.opendaylight.controller</groupId>
-               <artifactId>forwardingrulesmanager</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
-       </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>forwardingrulesmanager</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
diff --git a/opendaylight/forwardingrulesmanager/integrationtest/pom.xml b/opendaylight/forwardingrulesmanager/integrationtest/pom.xml
new file mode 100644 (file)
index 0000000..7967d6f
--- /dev/null
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+  xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>commons.opendaylight</artifactId>
+    <version>1.4.0-SNAPSHOT</version>
+    <relativePath>../../commons/opendaylight</relativePath>
+  </parent>
+
+  <groupId>org.opendaylight.controller</groupId>
+  <artifactId>forwardingrulesmanager.integrationtest</artifactId>
+  <version>0.4.0-SNAPSHOT</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>hosttracker</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>hosttracker.implementation</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>configuration</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>configuration.implementation</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>clustering.services</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>clustering.stub</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>switchmanager</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>switchmanager.implementation</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal.implementation</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>forwardingrulesmanager</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>forwardingrulesmanager.implementation</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>containermanager</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>containermanager.implementation</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>protocol_plugins.stub</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>topologymanager</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <properties>
+    <!-- Sonar jacoco plugin to get integration test coverage info -->
+    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+    <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
+    <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+    <sonar.language>java</sonar.language>
+  </properties>
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.jacoco</groupId>
+          <artifactId>jacoco-maven-plugin</artifactId>
+          <version>0.5.3.201107060350</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.jacoco</groupId>
+        <artifactId>jacoco-maven-plugin</artifactId>
+        <version>0.5.3.201107060350</version>
+        <configuration>
+          <destFile>../implementation/target/jacoco-it.exec</destFile>
+          <includes>org.opendaylight.controller.*</includes>
+        </configuration>
+        <executions>
+          <execution>
+            <id>pre-test</id>
+            <goals>
+              <goal>prepare-agent</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>post-test</id>
+            <configuration>
+              <skip>true</skip>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git a/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/FRMIntegrationTest.java b/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/FRMIntegrationTest.java
new file mode 100644 (file)
index 0000000..73c6d79
--- /dev/null
@@ -0,0 +1,204 @@
+package org.opendaylight.controller.forwardingrulesmanager.internal;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Bundle;
+import javax.inject.Inject;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
+import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
+import org.opendaylight.controller.sal.action.Action;
+import org.opendaylight.controller.sal.action.Drop;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.flowprogrammer.Flow;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
+import org.opendaylight.controller.sal.reader.FlowOnNode;
+import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
+import org.opendaylight.controller.sal.reader.NodeDescription;
+import org.opendaylight.controller.sal.utils.NodeCreator;
+import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.osgi.framework.BundleContext;
+import static org.junit.Assert.*;
+import org.ops4j.pax.exam.junit.Configuration;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.util.PathUtils;
+
+@RunWith(PaxExam.class)
+public class FRMIntegrationTest {
+    private Logger log = LoggerFactory.getLogger(FRMIntegrationTest.class);
+    // get the OSGI bundle context
+    @Inject
+    private BundleContext bc;
+
+    private IForwardingRulesManager manager = null;
+
+    // Configure the OSGi container
+    @Configuration
+    public Option[] config() {
+        return options(
+                //
+                systemProperty("logback.configurationFile").value(
+                        "file:" + PathUtils.getBaseDir()
+                                + "/src/test/resources/logback.xml"),
+                // To start OSGi console for inspection remotely
+                systemProperty("osgi.console").value("2401"),
+                // Set the systemPackages (used by clustering)
+                systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
+                // List framework bundles
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",
+                        "1.0.0.v20120522-1841"),
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",
+                        "1.0.400.v20120522-2049"),
+                mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",
+                        "3.3.100.v20120522-1822"),
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",
+                        "1.4.0.v20120522-1841"),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",
+                        "0.8.0.v201108120515"),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",
+                        "0.8.0.v201108120515"),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
+                        "0.8.0.v201110170705"),
+                // List logger bundles
+                mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),
+                mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),
+                mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
+                mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
+                // List all the bundles on which the test case depends
+                mavenBundle("org.opendaylight.controller", "sal",
+                        "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller",
+                        "sal.implementation", "0.4.0-SNAPSHOT"),
+
+                mavenBundle("org.opendaylight.controller",
+                        "protocol_plugins.stub", "0.4.0-SNAPSHOT"),
+               
+                mavenBundle("org.opendaylight.controller", "containermanager",
+                        "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller",
+                        "containermanager.implementation", "0.4.0-SNAPSHOT"),
+
+                mavenBundle("org.opendaylight.controller",
+                        "forwardingrulesmanager", "0.4.0-SNAPSHOT"),
+
+                mavenBundle("org.opendaylight.controller",
+                        "forwardingrulesmanager.implementation",
+                        "0.4.0-SNAPSHOT"),
+
+                mavenBundle("org.opendaylight.controller",
+                        "clustering.services", "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "clustering.stub",
+                        "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "switchmanager",
+                        "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "switchmanager.implementation",
+                                "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "configuration",
+                        "0.4.0-SNAPSHOT"),
+
+                mavenBundle("org.opendaylight.controller",
+                        "configuration.implementation", "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "hosttracker",
+                        "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "hosttracker.implementation",
+                                "0.4.0-SNAPSHOT"),
+
+                // needed by hosttracker
+                mavenBundle("org.opendaylight.controller", "topologymanager",
+                        "0.4.0-SNAPSHOT"),
+
+                mavenBundle("org.jboss.spec.javax.transaction",
+                        "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
+                mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
+                mavenBundle("org.apache.felix",
+                        "org.apache.felix.dependencymanager", "3.1.0"),
+                junitBundles());
+    }
+
+    private String stateToString(int state) {
+        switch (state) {
+        case Bundle.ACTIVE:
+            return "ACTIVE";
+        case Bundle.INSTALLED:
+            return "INSTALLED";
+        case Bundle.RESOLVED:
+            return "RESOLVED";
+        case Bundle.UNINSTALLED:
+            return "UNINSTALLED";
+        default:
+            return "Not CONVERTED";
+        }
+    }
+
+    @Before
+    public void areWeReady() {
+        assertNotNull(bc);
+        boolean debugit = false;
+        Bundle b[] = bc.getBundles();
+        for (int i = 0; i < b.length; i++) {
+            int state = b[i].getState();
+            if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
+                log.debug("Bundle:" + b[i].getSymbolicName() + " state:"
+                        + stateToString(state));
+                debugit = true;
+            }
+        }
+        if (debugit) {
+            log.debug("Do some debugging because some bundle is "
+                    + "unresolved");
+        }
+
+        // Assert if true, if false we are good to go!
+        assertFalse(debugit);
+
+        ServiceReference r = bc
+                .getServiceReference(IForwardingRulesManager.class.getName());
+        if (r != null) {
+            this.manager = (IForwardingRulesManager) bc.getService(r);
+        }
+        // If StatisticsManager is null, cannot run tests.
+        assertNotNull(this.manager);
+
+    }
+
+    @Test
+    public void testFlowEntries() {
+        Flow flow = new Flow();
+
+        Match match = new Match();
+        try {
+            match.setField(MatchType.NW_DST, InetAddress.getByName("1.1.1.1"));
+        } catch (UnknownHostException e) {
+        }
+        flow.setMatch(match);
+        Action action = new Drop();
+
+        List<Action> actions = new ArrayList<Action>();
+        actions.add(action);
+        flow.setActions(actions);
+
+        Node node = NodeCreator.createOFNode(1L);
+        FlowEntry fe = new FlowEntry("g1", "f1", flow, node);
+
+        Status stat = manager.installFlowEntry(null);
+        Assert.assertTrue(stat.getCode().equals(StatusCode.NOTACCEPTABLE));
+    }
+
+}
\ No newline at end of file
diff --git a/opendaylight/forwardingrulesmanager/integrationtest/src/test/resources/logback.xml b/opendaylight/forwardingrulesmanager/integrationtest/src/test/resources/logback.xml
new file mode 100644 (file)
index 0000000..2d63ce5
--- /dev/null
@@ -0,0 +1,13 @@
+<configuration scan="true">
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <encoder>
+      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+      </pattern>
+    </encoder>
+  </appender>
+
+  <root level="error">
+    <appender-ref ref="STDOUT" />
+  </root>
+</configuration>
index 59a184e5737db9f0aab5512e40f2e44395a3be39..6245c9be8a79d8c17d256f1dd274b6b386a309bf 100644 (file)
@@ -53,26 +53,30 @@ public class NodeConnector implements Serializable {
         ConcurrentHashMap<String, ImmutablePair<Class<? extends Object>, String>> compatibleType =
             new ConcurrentHashMap<String, ImmutablePair<Class<? extends Object>, String>>();
         /**
-         * Represent a special port pointing toward the controller,
-         * this is to send data packets toward the controller from
-         * data plane.
+         * Represents the OFPP_CONTROLLER reserved port to forward a 
+         * packet to the controller, this is to send data packets 
+         * to the controller from the data plane triggering 
+         * a packet_in event.
          */
         public static String CONTROLLER = "CTRL";
         /**
-         * Special port describing ALL the ports in the system,
-         * should be used for flooding like mechanism but better
-         * to be careful with it
+         * Represents the OFPP_ALL reserved OF port 
+         * to forward to ALL the ports in the system ,
+         * should be used for flooding like mechanism to
+         * be used cautiously to avoid excessive flooding.
          */
         public static String ALL = "ALL";
         /**
-         * Describe the local networking stack of the node
-         * on which the packet is destined. Yet another special port
+         * Represents the OFPP_LOCAL reserved OF port
+         * to access the local networking stack of the node
+         * of which the packet is destined. Typically used for
+         * inband OF communications channel.
          */
         public static String SWSTACK = "SW";
         /**
-         * Describe a special destination that invoke the
-         * traditional HW forwarding on platforms that has this
-         * provision.
+         * Describes OFPP_Normal reserved port destination that invokes 
+         * the traditional native L2/L3 HW normal forwarding functionality 
+         * if supported on the forwarding element.
          */
         public static String HWPATH = "HW";
         public static String OPENFLOW = "OF";
@@ -441,7 +445,7 @@ public class NodeConnector implements Serializable {
      *
      * @param str String to be parsed in a NodeConnector
      *
-     * @return the NodeConnector if parse is succesfull, null otherwise
+     * @return the NodeConnector if parse is successful, null otherwise
      */
     public static NodeConnector fromString(String str) {
         if (str == null) {
@@ -534,14 +538,14 @@ public class NodeConnector implements Serializable {
 
     /**
      * return a NodeConnector from a pair (type, ID) in string format
-     * not containing explicitely the Node portion which has to be
+     * not containing explicitly the Node portion which has to be
      * supplied as parameter
      *
      * @param typeStr type String to be parsed in a NodeConnector
      * @param IDStr ID String portion to be parsed in a NodeConnector
      * @param n Node to which the NodeConnector is attached
      *
-     * @return the NodeConnector if parse is succesfull, null otherwise
+     * @return the NodeConnector if parse is successful, null otherwise
      */
     public static NodeConnector fromStringNoNode(String typeStr, String IDStr,
                                                  Node n) {
index eb8819657be5e9fac8653b912ce8b2b81ac87fa2..946ba4ae0529352bce572b57a541a1713ad1ce3a 100644 (file)
@@ -31,22 +31,26 @@ import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder
 
 public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         AugmentationTargetBuilder {
+    private final ChoiceNodeImpl instance;
+    // SchemaNode args
     private final QName qname;
     private SchemaPath schemaPath;
-    private final ConstraintsBuilder constraints;
-    private final ChoiceNodeImpl instance;
     private String description;
     private String reference;
     private Status status = Status.CURRENT;
+    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
+    // DataSchemaNode args
     private boolean augmenting;
     private boolean configuration;
-    private String defaultCase;
-
-    private final Set<ChoiceCaseBuilder> cases = new HashSet<ChoiceCaseBuilder>();
+    private final ConstraintsBuilder constraints;
+    // DataNodeContainer args
     private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
     private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
+    // AugmentationTarget args
     private final Set<AugmentationSchemaBuilder> addedAugmentations = new HashSet<AugmentationSchemaBuilder>();
-    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
+    // ChoiceNode args
+    private final Set<ChoiceCaseBuilder> cases = new HashSet<ChoiceCaseBuilder>();
+    private String defaultCase;
 
     public ChoiceBuilder(QName qname) {
         this.qname = qname;
@@ -62,6 +66,7 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         instance.setStatus(status);
         instance.setAugmenting(augmenting);
         instance.setConfiguration(configuration);
+        instance.setConstraints(constraints.build());
         instance.setDefaultCase(defaultCase);
 
         // CASES
@@ -85,8 +90,6 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         }
         instance.setUnknownSchemaNodes(unknownNodes);
 
-        instance.setConstraints(constraints.build());
-
         return instance;
     }
 
@@ -97,7 +100,8 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
     @Override
     public void addChildNode(DataSchemaNodeBuilder childNode) {
         if (!(childNode instanceof ChoiceCaseBuilder)) {
-            ChoiceCaseBuilder caseBuilder = new ChoiceCaseBuilder(childNode.getQName());
+            ChoiceCaseBuilder caseBuilder = new ChoiceCaseBuilder(
+                    childNode.getQName());
             caseBuilder.addChildNode(childNode);
             cases.add(caseBuilder);
         } else {
index 73d7e3dc0c7d9033f613572a2f5263f7c22b3c61..27cead10f11a0b32eb472be311b1fb9a18ba937d 100644 (file)
@@ -24,18 +24,18 @@ import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeB
 import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
 
-public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataSchemaNodeBuilder {
-
+public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
+        DataSchemaNodeBuilder {
     private final ChoiceCaseNodeImpl instance;
-    private final ConstraintsBuilder constraints;
     private SchemaPath schemaPath;
     private String description;
     private String reference;
     private Status status = Status.CURRENT;
+    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
     private boolean augmenting;
+    private final ConstraintsBuilder constraints;
     private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
     private final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
-    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
     ChoiceCaseBuilder(QName qname) {
         super(qname);
@@ -110,7 +110,7 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
 
     @Override
     public void setStatus(Status status) {
-        if(status != null) {
+        if (status != null) {
             this.status = status;
         }
     }
@@ -144,12 +144,14 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
 
     @Override
     public void addTypedef(TypeDefinitionBuilder typedefBuilder) {
-        throw new UnsupportedOperationException("Can not add type definition to choice case.");
+        throw new UnsupportedOperationException(
+                "Can not add type definition to choice case.");
     }
 
     @Override
     public void setConfiguration(boolean configuration) {
-        throw new UnsupportedOperationException("Can not add config definition to choice case.");
+        throw new UnsupportedOperationException(
+                "Can not add config definition to choice case.");
     }
 
     @Override
@@ -161,8 +163,7 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
         return augmentations;
     }
 
-
-    private static class ChoiceCaseNodeImpl implements ChoiceCaseNode {
+    private class ChoiceCaseNodeImpl implements ChoiceCaseNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
@@ -217,7 +218,7 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
         }
 
         private void setStatus(Status status) {
-            if(status != null) {
+            if (status != null) {
                 this.status = status;
             }
         }
@@ -251,7 +252,7 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
         }
 
         private void setUnknownSchemaNodes(List<UnknownSchemaNode> unknownNodes) {
-            if(unknownNodes != null) {
+            if (unknownNodes != null) {
                 this.unknownNodes = unknownNodes;
             }
         }
@@ -317,7 +318,6 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
             }
         }
 
-
         @Override
         public int hashCode() {
             final int prime = 31;
index 906afd97a04bbb12b485d8b3cab47072aebb0c05..5cfde8e7a0b7b7cbc21ababcc2c11a90dfcaf0eb 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.yang.model.parser.builder.impl;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -17,13 +18,13 @@ import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
 
-public class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
-
+public final class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
+    private final IdentitySchemaNodeImpl instance;
     private final QName qname;
     private SchemaPath schemaPath;
-    private final IdentitySchemaNodeImpl instance;
     private IdentitySchemaNodeBuilder baseIdentity;
     private String baseIdentityName;
+    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
     IdentitySchemaNodeBuilder(final QName qname) {
         this.qname = qname;
@@ -33,11 +34,17 @@ public class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
     @Override
     public IdentitySchemaNode build() {
         instance.setPath(schemaPath);
-
         if (baseIdentity != null) {
-            final IdentitySchemaNode base = baseIdentity.build();
-            instance.setBaseIdentity(base);
+            instance.setBaseIdentity(baseIdentity.build());
+        }
+
+        // UNKNOWN NODES
+        final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
+        for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
+            unknownNodes.add(b.build());
         }
+        instance.setUnknownSchemaNodes(unknownNodes);
+
         return instance;
     }
 
@@ -75,8 +82,7 @@ public class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
 
     @Override
     public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
-        throw new IllegalStateException(
-                "Can not add schema node to identity statement");
+        addedUnknownNodes.add(unknownNode);
     }
 
     public String getBaseIdentityName() {
@@ -91,13 +97,14 @@ public class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
         this.baseIdentity = baseType;
     }
 
-    private class IdentitySchemaNodeImpl implements IdentitySchemaNode {
+    private final class IdentitySchemaNodeImpl implements IdentitySchemaNode {
         private final QName qname;
         private IdentitySchemaNode baseIdentity;
         private String description;
         private String reference;
         private Status status = Status.CURRENT;
         private SchemaPath path;
+        private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
 
         private IdentitySchemaNodeImpl(final QName qname) {
             this.qname = qname;
@@ -157,7 +164,14 @@ public class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
 
         @Override
         public List<UnknownSchemaNode> getUnknownSchemaNodes() {
-            return Collections.emptyList();
+            return unknownNodes;
+        }
+
+        private void setUnknownSchemaNodes(
+                List<UnknownSchemaNode> unknownSchemaNodes) {
+            if (unknownSchemaNodes != null) {
+                this.unknownNodes = unknownSchemaNodes;
+            }
         }
 
         @Override
index e0ba03adfb0013f4eb69873ee96973b9f1c2733f..cca505e98505d26907b0c49202285cfda98040d6 100644 (file)
@@ -96,6 +96,8 @@ public class ModuleBuilder implements Builder {
      */
     @Override
     public Module build() {
+        instance.setPrefix(prefix);
+        instance.setRevision(revision);
         instance.setImports(imports);
         instance.setNamespace(namespace);
 
@@ -247,12 +249,10 @@ public class ModuleBuilder implements Builder {
 
     public void setRevision(final Date revision) {
         this.revision = revision;
-        instance.setRevision(revision);
     }
 
     public void setPrefix(final String prefix) {
         this.prefix = prefix;
-        instance.setPrefix(prefix);
     }
 
     public void setYangVersion(final String yangVersion) {
@@ -295,10 +295,8 @@ public class ModuleBuilder implements Builder {
     public ContainerSchemaNodeBuilder addContainerNode(
             final QName containerName, final List<String> parentPath) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
-
         final ContainerSchemaNodeBuilder containerBuilder = new ContainerSchemaNodeBuilder(
                 containerName);
-
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -318,10 +316,8 @@ public class ModuleBuilder implements Builder {
     public ListSchemaNodeBuilder addListNode(final QName listName,
             final List<String> parentPath) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
-
         final ListSchemaNodeBuilder listBuilder = new ListSchemaNodeBuilder(
                 listName);
-
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -341,10 +337,8 @@ public class ModuleBuilder implements Builder {
     public LeafSchemaNodeBuilder addLeafNode(final QName leafName,
             final List<String> parentPath) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
-
         final LeafSchemaNodeBuilder leafBuilder = new LeafSchemaNodeBuilder(
                 leafName);
-
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -364,7 +358,6 @@ public class ModuleBuilder implements Builder {
     public LeafListSchemaNodeBuilder addLeafListNode(final QName leafListName,
             final List<String> parentPath) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
-
         final LeafListSchemaNodeBuilder leafListBuilder = new LeafListSchemaNodeBuilder(
                 leafListName);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
@@ -386,7 +379,6 @@ public class ModuleBuilder implements Builder {
     public GroupingBuilder addGrouping(final QName qname,
             final List<String> parentPath) {
         final List<String> pathToGroup = new ArrayList<String>(parentPath);
-
         final GroupingBuilder builder = new GroupingBuilderImpl(qname);
         final ChildNodeBuilder parentNodeBuilder = (ChildNodeBuilder) moduleNodes
                 .get(pathToGroup);
@@ -405,7 +397,6 @@ public class ModuleBuilder implements Builder {
     public AugmentationSchemaBuilder addAugment(final String name,
             final List<String> parentPath) {
         final List<String> pathToAugment = new ArrayList<String>(parentPath);
-
         final AugmentationSchemaBuilder builder = new AugmentationSchemaBuilderImpl(
                 name);
 
index 7d3e9293571f25c155f0271f3ca7fe2ae48181d5..05d2faa4099e61e38c47e15fe69447ce79faaa35 100644 (file)
@@ -26,8 +26,7 @@ import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuild
 import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;\r
 import org.opendaylight.controller.yang.model.parser.util.RefineHolder;\r
 \r
-public class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {\r
-\r
+final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {\r
     private final UsesNodeImpl instance;\r
     private final SchemaPath groupingPath;\r
     private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();\r
@@ -89,8 +88,8 @@ public class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
         refines.add(refine);\r
     }\r
 \r
-    private SchemaPath parseUsesPath(final String augmentPath) {\r
-        final String[] splittedPath = augmentPath.split("/");\r
+    private SchemaPath parseUsesPath(final String groupingPathStr) {\r
+        final String[] splittedPath = groupingPathStr.split("/");\r
         final List<QName> path = new ArrayList<QName>();\r
         QName name;\r
         for (String pathElement : splittedPath) {\r
@@ -103,11 +102,11 @@ public class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
             }\r
             path.add(name);\r
         }\r
-        final boolean absolute = augmentPath.startsWith("/");\r
+        final boolean absolute = groupingPathStr.startsWith("/");\r
         return new SchemaPath(path, absolute);\r
     }\r
 \r
-    private static class UsesNodeImpl implements UsesNode {\r
+    private final class UsesNodeImpl implements UsesNode {\r
         private final SchemaPath groupingPath;\r
         private Set<AugmentationSchema> augmentations = Collections.emptySet();\r
         private boolean augmenting;\r
index 2023b47de3b960b9da29805440aeecb62b31f3df..98b81bd958d0ed338dc6c6a2521f233fa11928eb 100644 (file)
@@ -652,7 +652,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         final String nodeTypeStr = ctx.getChild(0).getText();
         final String[] splittedElement = nodeTypeStr.split(":");
         if (splittedElement.length == 1) {
-            nodeType = new QName(null, null, null, splittedElement[0]);
+            nodeType = new QName(null, null, yangModelPrefix, splittedElement[0]);
         } else {
             nodeType = new QName(null, null, splittedElement[0],
                     splittedElement[1]);
index 7acf7cbbe4cab1adf623a30df4d44deaa6631df6..4a48a4e2da477264e2d0de97f5369010aa889fbc 100644 (file)
@@ -19,7 +19,6 @@ import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
 import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition.Bit;
 import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;