<artifactId>sal.implementation</artifactId>
<version>0.4.0-SNAPSHOT</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>clustering.services-implementation</artifactId>
<version>0.4.0-SNAPSHOT</version>
<!--
Used to register JMX statistics in any available MBean server
-->
- <jmxStatistics enabled="true"/>
+ <jmxStatistics enabled="true"/>
</default>
<!-- transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" -->
<namedCache name="transactional-type">
<version>0.8.0.v201110170705</version>
</dependency>
</dependencies>
-
+
<build>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>maven-paxexam-plugin</artifactId>
<configuration scan="true">
-
+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
-
+
<root level="error">
<appender-ref ref="STDOUT" />
</root>
<projectinfo>2.6</projectinfo>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.version>2.3.2</compiler.version>
- <surefire.version>2.13</surefire.version>
+ <surefire.version>2.15</surefire.version>
+ <failsafe.version>2.15</failsafe.version>
<exam.version>3.0.0</exam.version>
<url.version>1.5.0</url.version>
<enunciate.version>1.26.2</enunciate.version>
<configLocation>${project.parent.basedir}/space_and_tabs_checks.xml</configLocation>
<consoleOutput>true</consoleOutput>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <sourceDirectory>${project.basedir}</sourceDirectory>
+ <includes>**\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
- <version>2.14.1</version>
+ <version>${failsafe.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
- <goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<configuration scan="true">
-
+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
-
+
<root level="error">
<appender-ref ref="STDOUT" />
</root>
--- /dev/null
+configuration
--- /dev/null
+<?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.integrationtest</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <relativePath>../../commons/integrationtest</relativePath>
+ </parent>
+ <artifactId>configuration.integrationtest</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <dependencies>
+ <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>sal</artifactId>
+ <version>0.5.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>clustering.services</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.services-implementation</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>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>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>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>hosttracker</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>topologymanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+package org.opendaylight.controller.configuration.internal;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.io.File;
+
+import javax.inject.Inject;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.configuration.IConfigurationService;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.PathUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(PaxExam.class)
+public class ConfigurationIT {
+ private Logger logger = LoggerFactory
+ .getLogger(ConfigurationIT.class);
+ // get the OSGI bundle context
+ @Inject
+ private BundleContext bc;
+ private IClusterServices clusterService = null;
+ private IConfigurationService configService = 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"),
+ mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
+ mavenBundle("org.jboss.spec.javax.transaction",
+ "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
+ mavenBundle("org.apache.felix",
+ "org.apache.felix.dependencymanager", "3.1.0"),
+ // List all the bundles on which the test case depends
+ mavenBundle("org.opendaylight.controller", "sal",
+ "0.5.0-SNAPSHOT"), // SAL connects the protocols
+ // plug-ins to other stuff
+ mavenBundle("org.opendaylight.controller",
+ "sal.implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "protocol_plugins.stub", "0.4.0-SNAPSHOT"),
+ // needed bundles by switchmanager
+ mavenBundle("org.opendaylight.controller", "containermanager",
+ "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "containermanager.implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "switchmanager",
+ "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "switchmanager.implementation", "0.4.0-SNAPSHOT"),
+ // needed bundles by configuration
+ mavenBundle("org.opendaylight.controller",
+ "clustering.services", "0.4.0-SNAPSHOT"), // what are
+ // the
+ // clustering
+ // services
+ // for
+ mavenBundle("org.opendaylight.controller", "clustering.stub",
+ "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "clustering.services-implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "configuration",
+ "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "configuration.implementation", "0.4.0-SNAPSHOT"),
+ 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 areWeReadyForClustering() {
+ 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) {
+ logger.debug("Bundle:" + b[i].getSymbolicName() + " state:"
+ + stateToString(state));
+ debugit = true;
+ }
+ }
+ if (debugit) {
+ logger.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(IClusterServices.class
+ .getName());
+ if (r != null) {
+ this.clusterService = (IClusterServices) bc.getService(r);
+ }
+ // If StatisticsManager is null, cannot run tests.
+ assertNotNull(this.clusterService);
+
+ }
+
+ @Before
+ public void areWeReadyForConfiguration() {
+ 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) {
+ logger.debug("Bundle:" + b[i].getSymbolicName() + " state:"
+ + stateToString(state));
+ debugit = true;
+ }
+ }
+ if (debugit) {
+ logger.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(IConfigurationService.class
+ .getName());
+ if (r != null) {
+ this.configService = (IConfigurationService) bc.getService(r);
+ }
+ // If StatisticsManager is null, cannot run tests.
+ assertNotNull(this.configService);
+
+ }
+
+ @Test
+ public void saveConfiguration() {
+ File f = new File(GlobalConstants.STARTUPHOME.toString());
+ boolean success = f.exists();
+ if (!success) {
+ success = f.mkdirs();
+ }
+ if(success){
+ Status status = new Status(StatusCode.SUCCESS, null);
+ if (this.configService != null) {
+ status = this.configService.saveConfigurations();
+ }
+ if (status.getCode().equals(StatusCode.SUCCESS)) {
+ Assert.assertTrue("Successfully saved config for "
+ + configService.getClass().getSimpleName(), status
+ .getCode().equals(StatusCode.SUCCESS));
+ } else {
+ Assert.assertFalse("Failed to save config for "
+ + configService.getClass().getSimpleName(), status
+ .getCode().equals(StatusCode.INTERNALERROR));
+ }
+ }
+ }
+
+}
--- /dev/null
+<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>
<artifactId>containermanager</artifactId>
<version>0.4.0-SNAPSHOT</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal</artifactId>
<version>0.5.0-SNAPSHOT</version>
- </dependency>
+ </dependency>
</dependencies>
</project>
<module>../../clustering/test</module>
<module>../../configuration/api</module>
<module>../../configuration/implementation</module>
+ <module>../../configuration/integrationtest</module>
<module>../../routing/dijkstra_implementation</module>
<module>../../arphandler</module>
<module>../../forwardingrulesmanager/api</module>
<module>../../statisticsmanager/implementation</module>
<module>../../statisticsmanager/integrationtest</module>
<module>../../topologymanager</module>
- <module>../../usermanager</module>
+ <module>../../usermanager/api</module>
+ <module>../../usermanager/implementation</module>
<module>../../security</module>
<module>../../samples/northbound/loadbalancer</module>
<module>../../commons/concepts</module>
<module>../../commons/integrationtest</module>
-
+
</modules>
<build>
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>osgipackage</id>
<formats>
<format>dir</format>
<excludes>
<exclude>org.opendaylight.controller.thirdparty:org.openflow.openflowj</exclude>
<exclude>org.opendaylight.controller:clustering.stub</exclude>
- <exclude>org.opendaylight.controller:logging.bridge</exclude>
- <exclude>org.opendaylight.controller:protocol_plugins.stub</exclude>
- <exclude>org.opendaylight.controller:*.integrationtest</exclude>
+ <exclude>org.opendaylight.controller:logging.bridge</exclude>
+ <exclude>org.opendaylight.controller:protocol_plugins.stub</exclude>
+ <exclude>org.opendaylight.controller:*.integrationtest</exclude>
<exclude>org.opendaylight.controller:hosttracker_new</exclude>
<exclude>org.opendaylight.controller:hosttracker_new.implementation</exclude>
</excludes>
<includeDependencies>false</includeDependencies>
</binaries>
</moduleSet>
- <moduleSet>
- <includes>
- <include>org.opendaylight.controller:logging.bridge</include>
- </includes>
- <binaries>
- <outputDirectory>opendaylight/lib</outputDirectory>
- <outputFileNameMapping>
- ${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
- </outputFileNameMapping>
- <unpack>false</unpack>
- <includeDependencies>false</includeDependencies>
- </binaries>
- </moduleSet>
+ <moduleSet>
+ <includes>
+ <include>org.opendaylight.controller:logging.bridge</include>
+ </includes>
+ <binaries>
+ <outputDirectory>opendaylight/lib</outputDirectory>
+ <outputFileNameMapping>
+ ${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
+ </outputFileNameMapping>
+ <unpack>false</unpack>
+ <includeDependencies>false</includeDependencies>
+ </binaries>
+ </moduleSet>
</moduleSets>
<dependencySets>
<dependencySet>
<exclude>virgomirror:org.eclipse.jdt.core.compiler.batch</exclude>
<exclude>org.apache.felix:org.apache.felix.fileinstall</exclude>
<exclude>geminiweb:org.eclipse.virgo.kernel.equinox.extensions</exclude>
- <exclude>org.slf4j:slf4j-api</exclude>
- <exclude>ch.qos.logback:logback-core</exclude>
- <exclude>ch.qos.logback:logback-classic</exclude>
- <exclude>com.sun.jersey:jersey-core</exclude>
- <exclude>com.sun.jersey:jersey-json</exclude>
- <exclude>com.sun.jersey:jersey-server</exclude>
+ <exclude>org.slf4j:slf4j-api</exclude>
+ <exclude>ch.qos.logback:logback-core</exclude>
+ <exclude>ch.qos.logback:logback-classic</exclude>
+ <exclude>com.sun.jersey:jersey-core</exclude>
+ <exclude>com.sun.jersey:jersey-json</exclude>
+ <exclude>com.sun.jersey:jersey-server</exclude>
</excludes>
<outputFileNameMapping>
- ${artifact.groupId}.${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
+ ${artifact.groupId}.${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
</outputFileNameMapping>
<unpack>false</unpack>
<scope>runtime</scope>
<include>virgomirror:org.eclipse.jdt.core.compiler.batch</include>
<include>org.apache.felix:org.apache.felix.fileinstall</include>
<include>geminiweb:org.eclipse.virgo.kernel.equinox.extensions</include>
- <include>org.slf4j:slf4j-api</include>
- <include>ch.qos.logback:logback-core</include>
- <include>ch.qos.logback:logback-classic</include>
- <include>com.sun.jersey:jersey-core</include>
- <include>com.sun.jersey:jersey-json</include>
- <include>com.sun.jersey:jersey-server</include>
+ <include>org.slf4j:slf4j-api</include>
+ <include>ch.qos.logback:logback-core</include>
+ <include>ch.qos.logback:logback-classic</include>
+ <include>com.sun.jersey:jersey-core</include>
+ <include>com.sun.jersey:jersey-json</include>
+ <include>com.sun.jersey:jersey-server</include>
</includes>
<useTransitiveDependencies>false</useTransitiveDependencies>
<outputFileNameMapping>
- ${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
+ ${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
</outputFileNameMapping>
<unpack>false</unpack>
<scope>runtime</scope>
osgi.bundles=\
- reference\:file\:../lib/org.apache.felix.fileinstall-3.1.6.jar@1:start,\
- reference\:file\:../lib/org.eclipse.jdt.core.compiler.batch-3.8.0.I20120518-2145.jar@1:start,\
- reference\:file\:../lib/org.eclipse.equinox.ds-1.4.0.v20120522-1841.jar@2:start,\
- reference\:file\:../lib/org.eclipse.equinox.util-1.0.400.v20120522-2049.jar@2:start,\
- reference\:file\:../lib/org.eclipse.osgi.services-3.3.100.v20120522-1822@2:start,\
- reference\:file\:../lib/org.eclipse.equinox.console-1.0.0.v20120522-1841.jar@start,\
- reference\:file\:../lib/slf4j-api-1.7.2.jar@1:start,\
- reference\:file\:../lib/logback-classic-1.0.9.jar@1:start,\
- reference\:file\:../lib/logback-core-1.0.9.jar@1:start,\
+ reference\:file\:../lib/org.apache.felix.fileinstall-3.1.6.jar@1:start,\
+ reference\:file\:../lib/org.eclipse.jdt.core.compiler.batch-3.8.0.I20120518-2145.jar@1:start,\
+ reference\:file\:../lib/org.eclipse.equinox.ds-1.4.0.v20120522-1841.jar@2:start,\
+ reference\:file\:../lib/org.eclipse.equinox.util-1.0.400.v20120522-2049.jar@2:start,\
+ reference\:file\:../lib/org.eclipse.osgi.services-3.3.100.v20120522-1822@2:start,\
+ reference\:file\:../lib/org.eclipse.equinox.console-1.0.0.v20120522-1841.jar@start,\
+ reference\:file\:../lib/slf4j-api-1.7.2.jar@1:start,\
+ reference\:file\:../lib/logback-classic-1.0.9.jar@1:start,\
+ reference\:file\:../lib/logback-core-1.0.9.jar@1:start,\
reference\:file\:../lib/logging.bridge-0.4.0-SNAPSHOT@1:start,\
reference\:file\:../lib/jersey-core-1.17.jar@2:start,\
reference\:file\:../lib/jersey-json-1.17.jar@2:start,\
org.osgi.framework.system.packages.extra=sun.reflect,sun.reflect.misc,sun.misc
# This is not Eclipse App
eclipse.ignoreApp=true
-# Don't shutdown equinox if the eclipse App has ended,
+# Don't shutdown equinox if the eclipse App has ended,
# which is our case because we are not running any eclipse application
osgi.noShutdown=true
# Clean any cached data on restart of the framework
felix.fileinstall.noInitialDelay=true
# Auto start the bundles at level 4
felix.fileinstall.start.level=4
-# Avoid to auto-install following bundles, that means those need
+# Avoid to auto-install following bundles, that means those need
# to be started manually or in other way like osgi.bundles
felix.fileinstall.filter=^(?!org.apache.felix.fileinstall).*
# TLS configuration
# To enable TLS, set secureChannelEnabled=true and specify the location of controller Java KeyStore and TrustStore files.
-# The Java KeyStore contains controller's private key and certificate. The Java TrustStore contains the trusted certificate
+# The Java KeyStore contains controller's private key and certificate. The Java TrustStore contains the trusted certificate
# entries, including switches' Certification Authority (CA) certificates. For example,
# secureChannelEnabled=true
# controllerKeyStore=./configuration/ctlKeyStore
<logger name="org.opendaylight.controller.topologymanager" level="INFO"/>
<logger name="org.opendaylight.controller.usermanager" level="INFO"/>
<!-- Web modules -->
- <logger name="org.opendaylight.controller.web" level="INFO"/>
+ <logger name="org.opendaylight.controller.web" level="INFO"/>
</configuration>
connectionTimeout="20000"
redirectPort="8443" />
-<!--
- Please remove the comments around the following Connector tag to enable HTTPS Authentication support.
- Remember to add a valid keystore in the configuration folder.
- More info : http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+<!--
+ Please remove the comments around the following Connector tag to enable HTTPS Authentication support.
+ Remember to add a valid keystore in the configuration folder.
+ More info : http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
-->
-
- <!--
+
+ <!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
unpackWARs="false" autoDeploy="false"
deployOnStartup="false" createDirs="false">
<Realm className="org.opendaylight.controller.security.ControllerCustomRealm" />
- <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-
+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
+
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
- prefix="web_access_log_" suffix=".txt" resolveHosts="false"
- rotatable="true" fileDateFormat="yyyy-MM"
- pattern="%{yyyy-MM-dd HH:mm:ss.SSS z}t - [%a] - %r"/>
-
+ prefix="web_access_log_" suffix=".txt" resolveHosts="false"
+ rotatable="true" fileDateFormat="yyyy-MM"
+ pattern="%{yyyy-MM-dd HH:mm:ss.SSS z}t - [%a] - %r"/>
+
</Host>
</Engine>
</Service>
SETLOCAL
SETLOCAL ENABLEDELAYEDEXPANSION
IF EXIST "%JAVA_HOME%" (
- set basedir=%~dp0
+ set basedir=%~dp0
REM Now set the classpath:
set cp="!basedir!lib\org.eclipse.osgi-3.8.1.v20120830-144521.jar;!basedir!lib\org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar;!basedir!lib\org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar"
ECHO JAVA_HOME environment variable is not set
PAUSE
)
-ENDLOCAL
\ No newline at end of file
+ENDLOCAL
<artifactId>distribution.p2site</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
-
+
<build>
<plugins>
<plugin>
--- /dev/null
+OVERVIEW
+========
+This distribution is built to allow to deploy all the commons parents
+in one shot. This is needed because the way how maven works when a
+"mvn deploy" is called on a multi-module project, only the modules
+that are listed in there are deployed. All the opendaylight modules
+has a parent, those parents module will not be deployed when deploying
+a distribution hence if someone tries to compile a module without
+compiling the whole system it will run in missing parent errors.
+To address the issue this distribution will collect all the known
+parents and deploy them in one shot.
+
+The user of this distribution is one of the Jenkins jobs and not
+developers.
--- /dev/null
+<?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>
+ <prerequisites>
+ <maven>3.0</maven>
+ </prerequisites>
+
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.opendaylight</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../../commons/opendaylight</relativePath>
+ </parent>
+ <artifactId>distribution.parents</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <modules>
+ <module>../../commons/concepts</module>
+ <module>../../commons/integrationtest</module>
+ <module>../../commons/opendaylight</module>
+ <module>../../../third-party/commons/thirdparty</module>
+ </modules>
+</project>
<!-- Northbound common hooks -->
<module>../../northbound/commons</module>
</modules>
-
+
<build>
<plugins>
<plugin>
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>package</id>
<groupId>org.opendaylight.controller</groupId>
<artifactId>configuration</artifactId>
<version>0.4.0-SNAPSHOT</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.core.Host;
import org.opendaylight.controller.sal.core.Node;
return !Arrays.equals(emptyArray, macaddr);
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
- return "HostNodeConnector[" + ReflectionToStringBuilder.toString(this)
- + "]";
+ return "HostNodeConnector [nodeConnector=" + nodeConnector + ", vlan="
+ + vlan + ", staticHost=" + staticHost + "]";
}
public boolean isV4Host() {
org.opendaylight.controller.sal.authorization,
org.opendaylight.controller.containermanager,
org.opendaylight.controller.usermanager,
- javax.servlet.http,
+ javax.servlet.http,
org.slf4j
</Import-Package>
</instructions>
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/flow"/>
</services>
<version>0.5.0-SNAPSHOT</version>
</dependency>
</dependencies>
- </plugin>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
org.opendaylight.controller.northbound.commons.utils,
org.opendaylight.controller.sal.authorization,
org.opendaylight.controller.usermanager,
- com.sun.jersey.spi.container.servlet,
+ com.sun.jersey.spi.container.servlet,
javax.ws.rs,
javax.ws.rs.core,
javax.xml.bind.annotation,
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
<version>0.4.0-SNAPSHOT</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>forwardingrulesmanager</artifactId>
<version>${enunciate.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.northbound</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.northbound</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller.thirdparty</groupId>
<artifactId>com.sun.jersey.jersey-servlet</artifactId>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
-
- <servlet>
- <servlet-name>JAXRSFlowProgrammer</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>javax.ws.rs.Application</param-name>
- <param-value>org.opendaylight.controller.flowprogrammer.northbound.FlowProgrammerNorthboundRSApplication</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>JAXRSFlowProgrammer</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+
+ <servlet>
+ <servlet-name>JAXRSFlowProgrammer</servlet-name>
+ <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>javax.ws.rs.Application</param-name>
+ <param-value>org.opendaylight.controller.flowprogrammer.northbound.FlowProgrammerNorthboundRSApplication</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JAXRSFlowProgrammer</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
-
<security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
-
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
\ No newline at end of file
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/host"/>
</services>
<version>0.5.0-SNAPSHOT</version>
</dependency>
</dependencies>
- </plugin>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSHostTracker</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
\ No newline at end of file
<artifactId>jersey-core</artifactId>
<version>${jersey.version}</version>
</dependency>
- <!-- <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId>
+ <!-- <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId>
<version>${jersey.version}</version> </dependency> -->
<dependency>
<groupId>com.sun.jersey</groupId>
</dependencies>
</project>
-
import org.opendaylight.controller.switchmanager.IInventoryListener;
import org.opendaylight.controller.usermanager.IUserManager;
-
@RunWith(PaxExam.class)
public class NorthboundIT {
- private Logger log = LoggerFactory
- .getLogger(NorthboundIT.class);
+ private Logger log = LoggerFactory.getLogger(NorthboundIT.class);
// get the OSGI bundle context
@Inject
private BundleContext bc;
}
@Test
- public void testSwitchManager() {
+ public void testSubnetsNorthbound() throws JSONException {
+ String baseURL = "http://127.0.0.1:8080/controller/nb/v2/subnet/";
+
+ String name1 = "testSubnet1";
+ String subnet1 = "1.1.1.1/24";
+ String name2 = "testSubnet2";
+ String subnet2 = "2.2.2.2/24";
+
+ // Test GET subnets in default container
+ String result = getJsonResult(baseURL + "default");
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+ Assert.assertEquals("{}", result);
+
+ // Test GET subnet1 expecting 404
+ result = getJsonResult(baseURL + "default/" + name1);
+ Assert.assertEquals(404, httpResponseCode.intValue());
+
+ // Test POST subnet1
+ String queryParameter = new QueryParameter("subnetName", name1).add(
+ "subnet", subnet1).getString();
+ result = getJsonResult(baseURL + "default/" + name1 + queryParameter,
+ "POST");
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ // Test GET subnet1
+ result = getJsonResult(baseURL + "default/" + name1);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ Assert.assertEquals(200, httpResponseCode.intValue());
+ Assert.assertEquals(name1, json.getString("@name"));
+ Assert.assertEquals(subnet1, json.getString("@subnet"));
+
+ // Test POST subnet2
+ queryParameter = new QueryParameter("subnetName", name2).add("subnet",
+ subnet2).getString();
+ result = getJsonResult(baseURL + "default/" + name2 + queryParameter,
+ "POST");
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ // Test GET all subnets in default container
+ result = getJsonResult(baseURL + "default");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ JSONArray subnetConfigArray = json.getJSONArray("subnetConfig");
+ JSONObject subnetConfig;
+ Assert.assertEquals(2, subnetConfigArray.length());
+ for (int i = 0; i < subnetConfigArray.length(); i++) {
+ subnetConfig = subnetConfigArray.getJSONObject(i);
+ if (subnetConfig.getString("@name").equals(name1)) {
+ Assert.assertEquals(subnet1, subnetConfig.getString("@subnet"));
+ } else if (subnetConfig.getString("@name").equals(name2)) {
+ Assert.assertEquals(subnet2, subnetConfig.getString("@subnet"));
+ } else {
+ // Unexpected config name
+ Assert.assertTrue(false);
+ }
+ }
+
+ // Test DELETE subnet1
+ result = getJsonResult(baseURL + "default/" + name1, "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
+
+ // Test GET deleted subnet1
+ result = getJsonResult(baseURL + "default/" + name1);
+ Assert.assertEquals(404, httpResponseCode.intValue());
+
+ }
+
+ @Test
+ public void testStaticRoutingNorthbound() throws JSONException {
+ String baseURL = "http://127.0.0.1:8080/controller/nb/v2/staticroute/";
+
+ String name1 = "testRoute1";
+ String prefix1 = "192.168.1.1/24";
+ String nextHop1 = "0.0.0.0";
+ String name2 = "testRoute2";
+ String prefix2 = "192.168.1.1/16";
+ String nextHop2 = "1.1.1.1";
+
+ // Test GET static routes in default container, expecting no results
+ String result = getJsonResult(baseURL + "default");
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+ Assert.assertEquals("{}", result);
+
+ // Test insert static route
+ String requestBody = "{\"name\":\"" + name1 + "\", \"prefix\":\""
+ + prefix1 + "\", \"nextHop\":\"" + nextHop1 + "\"}";
+ result = getJsonResult(baseURL + "default/" + name1, "POST",
+ requestBody);
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ requestBody = "{\"name\":\"" + name2 + "\", \"prefix\":\"" + prefix2
+ + "\", \"nextHop\":\"" + nextHop2 + "\"}";
+ result = getJsonResult(baseURL + "default/" + name2, "POST",
+ requestBody);
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ // Test Get all static routes
+ result = getJsonResult(baseURL + "default");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ JSONArray staticRoutes = json.getJSONArray("staticRoute");
+ Assert.assertEquals(2, staticRoutes.length());
+ JSONObject route;
+ for (int i = 0; i < staticRoutes.length(); i++) {
+ route = staticRoutes.getJSONObject(i);
+ if (route.getString("name").equals(name1)) {
+ Assert.assertEquals(prefix1, route.getString("prefix"));
+ Assert.assertEquals(nextHop1, route.getString("nextHop"));
+ } else if (route.getString("name").equals(name2)) {
+ Assert.assertEquals(prefix2, route.getString("prefix"));
+ Assert.assertEquals(nextHop2, route.getString("nextHop"));
+ } else {
+ // static route has unknown name
+ Assert.assertTrue(false);
+ }
+ }
+
+ // Test get specific static route
+ result = getJsonResult(baseURL + "default/" + name1);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+
+ Assert.assertEquals(name1, json.getString("name"));
+ Assert.assertEquals(prefix1, json.getString("prefix"));
+ Assert.assertEquals(nextHop1, json.getString("nextHop"));
+
+ result = getJsonResult(baseURL + "default/" + name2);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+
+ Assert.assertEquals(name2, json.getString("name"));
+ Assert.assertEquals(prefix2, json.getString("prefix"));
+ Assert.assertEquals(nextHop2, json.getString("nextHop"));
+
+ // Test delete static route
+ result = getJsonResult(baseURL + "default/" + name1, "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
+
+ result = getJsonResult(baseURL + "default");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ JSONObject singleStaticRoute = json.getJSONObject("staticRoute");
+ Assert.assertEquals(name2, singleStaticRoute.getString("name"));
+
+ }
+
+ @Test
+ public void testSwitchManager() throws JSONException {
String baseURL = "http://127.0.0.1:8080/controller/nb/v2/switch/default/";
// define Node/NodeConnector attributes for test
int ncBandwidth = 1000000000;
// Test GET all nodes
- try {
- String result = getJsonResult(baseURL + "nodes");
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
-
- // Test for first node
- JSONObject node = getJsonInstance(json, "nodeProperties", nodeId_1);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_1, nodeType, timestamp_1,
- timestampName_1, actionsValue_1, capabilitiesValue_1,
- tablesValue_1, buffersValue_1);
-
- // Test 2nd node, properties of 2nd node same as first node
- node = getJsonInstance(json, "nodeProperties", nodeId_2);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_2, nodeType, timestamp_1,
- timestampName_1, actionsValue_1, capabilitiesValue_1,
- tablesValue_1, buffersValue_1);
-
- // Test 3rd node, properties of 3rd node same as first node
- node = getJsonInstance(json, "nodeProperties", nodeId_3);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_3, nodeType, timestamp_1,
- timestampName_1, actionsValue_1, capabilitiesValue_1,
- tablesValue_1, buffersValue_1);
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
+ String result = getJsonResult(baseURL + "nodes");
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+
+ // Test for first node
+ JSONObject node = getJsonInstance(json, "nodeProperties", nodeId_1);
+ Assert.assertNotNull(node);
+ testNodeProperties(node, nodeId_1, nodeType, timestamp_1,
+ timestampName_1, actionsValue_1, capabilitiesValue_1,
+ tablesValue_1, buffersValue_1);
+
+ // Test 2nd node, properties of 2nd node same as first node
+ node = getJsonInstance(json, "nodeProperties", nodeId_2);
+ Assert.assertNotNull(node);
+ testNodeProperties(node, nodeId_2, nodeType, timestamp_1,
+ timestampName_1, actionsValue_1, capabilitiesValue_1,
+ tablesValue_1, buffersValue_1);
+
+ // Test 3rd node, properties of 3rd node same as first node
+ node = getJsonInstance(json, "nodeProperties", nodeId_3);
+ Assert.assertNotNull(node);
+ testNodeProperties(node, nodeId_3, nodeType, timestamp_1,
+ timestampName_1, actionsValue_1, capabilitiesValue_1,
+ tablesValue_1, buffersValue_1);
// Test GET nodeConnectors of a node
- try {
- //Test first node
- String result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
-
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_1, ncType, nodeId_1, nodeType, ncState,
- ncCapabilities, ncBandwidth);
-
- //Test second node
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_2);
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
-
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_2, ncType, nodeId_2, nodeType, ncState,
- ncCapabilities, ncBandwidth);
-
- //Test third node
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_3);
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
-
- nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_3, ncType, nodeId_3, nodeType, ncState,
- ncCapabilities, ncBandwidth);
-
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
+ // Test first node
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ JSONObject nodeConnectorProperties = json
+ .getJSONObject("nodeConnectorProperties");
+
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_1,
+ ncType, nodeId_1, nodeType, ncState, ncCapabilities,
+ ncBandwidth);
+
+ // Test second node
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_2);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties");
+
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_2,
+ ncType, nodeId_2, nodeType, ncState, ncCapabilities,
+ ncBandwidth);
+
+ // Test third node
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_3);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+
+ nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties");
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_3,
+ ncType, nodeId_3, nodeType, ncState, ncCapabilities,
+ ncBandwidth);
// Test delete node property
- try {
- // Delete timestamp property from node1
- String result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
- + "/property/timeStamp", "DELETE");
- Assert.assertEquals(200, httpResponseCode.intValue());
-
- // Check node1
- result = getJsonResult(baseURL + "nodes");
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject node = getJsonInstance(json, "nodeProperties", nodeId_1);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_1, nodeType, null, null,
- actionsValue_1, capabilitiesValue_1, tablesValue_1,
- buffersValue_1);
-
- // Delete actions property from node2
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_2
- + "/property/actions", "DELETE");
- Assert.assertEquals(200, httpResponseCode.intValue());
-
- // Check node2
- result = getJsonResult(baseURL + "nodes");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- node = getJsonInstance(json, "nodeProperties", nodeId_2);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_2, nodeType, timestamp_1,
- timestampName_1, null, capabilitiesValue_1, tablesValue_1,
- buffersValue_1);
-
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
+ // Delete timestamp property from node1
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
+ + "/property/timeStamp", "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
+
+ // Check node1
+ result = getJsonResult(baseURL + "nodes");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ node = getJsonInstance(json, "nodeProperties", nodeId_1);
+ Assert.assertNotNull(node);
+ testNodeProperties(node, nodeId_1, nodeType, null, null,
+ actionsValue_1, capabilitiesValue_1, tablesValue_1,
+ buffersValue_1);
+
+ // Delete actions property from node2
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_2
+ + "/property/actions", "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
+
+ // Check node2
+ result = getJsonResult(baseURL + "nodes");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ node = getJsonInstance(json, "nodeProperties", nodeId_2);
+ Assert.assertNotNull(node);
+ testNodeProperties(node, nodeId_2, nodeType, timestamp_1,
+ timestampName_1, null, capabilitiesValue_1, tablesValue_1,
+ buffersValue_1);
// Test add property to node
- try {
- // Add Tier and Bandwidth property to node1
- String result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
- + "/property/tier/1001", "PUT");
- Assert.assertEquals(201, httpResponseCode.intValue());
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
- + "/property/bandwidth/1002", "PUT");
- Assert.assertEquals(201, httpResponseCode.intValue());
-
- // Test for first node
- result = getJsonResult(baseURL + "nodes");
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject node = getJsonInstance(json, "nodeProperties", nodeId_1);
- Assert.assertNotNull(node);
- Assert.assertEquals(1001, node.getJSONObject("properties")
- .getJSONObject("tier").getInt("tierValue"));
- Assert.assertEquals(1002, node.getJSONObject("properties")
- .getJSONObject("bandwidth").getInt("bandwidthValue"));
-
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
+ // Add Tier and Bandwidth property to node1
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
+ + "/property/tier/1001", "PUT");
+ Assert.assertEquals(201, httpResponseCode.intValue());
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
+ + "/property/bandwidth/1002", "PUT");
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ // Test for first node
+ result = getJsonResult(baseURL + "nodes");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ node = getJsonInstance(json, "nodeProperties", nodeId_1);
+ Assert.assertNotNull(node);
+ Assert.assertEquals(1001, node.getJSONObject("properties")
+ .getJSONObject("tier").getInt("tierValue"));
+ Assert.assertEquals(1002, node.getJSONObject("properties")
+ .getJSONObject("bandwidth").getInt("bandwidthValue"));
// Test delete nodeConnector property
- try {
- // Delete state property of nodeconnector1
- String result = getJsonResult(baseURL + "nodeconnector/STUB/"
- + nodeId_1 + "/STUB/" + nodeConnectorId_1
- + "/property/state", "DELETE");
- Assert.assertEquals(200, httpResponseCode.intValue());
-
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
-
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_1, ncType, nodeId_1, nodeType, null,
- ncCapabilities, ncBandwidth);
-
- // Delete capabilities property of nodeconnector2
- result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_2
- + "/STUB/" + nodeConnectorId_2 + "/property/capabilities",
- "DELETE");
- Assert.assertEquals(200, httpResponseCode.intValue());
-
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_2);
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
-
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_2, ncType, nodeId_2, nodeType, ncState,
- null, ncBandwidth);
+ // Delete state property of nodeconnector1
+ result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_1
+ + "/STUB/" + nodeConnectorId_1 + "/property/state", "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties");
+
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_1,
+ ncType, nodeId_1, nodeType, null, ncCapabilities, ncBandwidth);
+
+ // Delete capabilities property of nodeconnector2
+ result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_2
+ + "/STUB/" + nodeConnectorId_2 + "/property/capabilities",
+ "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
+
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_2);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties");
+
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_2,
+ ncType, nodeId_2, nodeType, ncState, null, ncBandwidth);
// Test PUT nodeConnector property
- try {
- int newBandwidth = 1001;
-
- // Add Name/Bandwidth property to nodeConnector1
- String result = getJsonResult(baseURL + "nodeconnector/STUB/"
- + nodeId_1 + "/STUB/" + nodeConnectorId_1
- + "/property/bandwidth/" + newBandwidth, "PUT");
- Assert.assertEquals(201, httpResponseCode.intValue());
-
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
-
- // Check for new bandwidth value, state value removed from previous
- // test
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_1, ncType, nodeId_1, nodeType, null,
- ncCapabilities, newBandwidth);
+ int newBandwidth = 1001;
+
+ // Add Name/Bandwidth property to nodeConnector1
+ result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_1
+ + "/STUB/" + nodeConnectorId_1 + "/property/bandwidth/"
+ + newBandwidth, "PUT");
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties");
+
+ // Check for new bandwidth value, state value removed from previous
+ // test
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_1,
+ ncType, nodeId_1, nodeType, null, ncCapabilities, newBandwidth);
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
}
@Test
- public void testStatistics() {
+ public void testStatistics() throws JSONException {
String actionTypes[] = { "drop", "loopback", "flood", "floodAll",
"controller", "swPath", "hwPath", "output", "setDlSrc",
"setDlDst", "setDlType", "setVlanId", "setVlanPcp",
System.out.println("Starting Statistics JAXB client.");
String baseURL = "http://127.0.0.1:8080/controller/nb/v2/statistics/default/";
- try {
- String result = getJsonResult(baseURL + "flowstats");
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject flowStatistics = getJsonInstance(json, "flowStatistics",
- 0xCAFE);
- JSONObject node = flowStatistics.getJSONObject("node");
- // test that node was returned properly
- Assert.assertTrue(node.getInt("@id") == 0xCAFE);
- Assert.assertTrue(node.getString("@type").equals("STUB"));
-
- // test that flow statistics results are correct
- JSONArray flowStats = flowStatistics.getJSONArray("flowStat");
- for (int i = 0; i < flowStats.length(); i++) {
-
- JSONObject flowStat = flowStats.getJSONObject(i);
- testFlowStat(flowStat, actionTypes[i]);
- }
+ String result = getJsonResult(baseURL + "flowstats");
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+ JSONObject flowStatistics = getJsonInstance(json, "flowStatistics",
+ 0xCAFE);
+ JSONObject node = flowStatistics.getJSONObject("node");
+ // test that node was returned properly
+ Assert.assertTrue(node.getInt("@id") == 0xCAFE);
+ Assert.assertTrue(node.getString("@type").equals("STUB"));
- // for /controller/nb/v2/statistics/default/portstats
- result = getJsonResult(baseURL + "portstats");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- JSONObject portStatistics = getJsonInstance(json, "portStatistics",
- 0xCAFE);
- JSONObject node2 = portStatistics.getJSONObject("node");
- // test that node was returned properly
- Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
- Assert.assertTrue(node2.getString("@type").equals("STUB"));
-
- // test that port statistic results are correct
- JSONObject portStat = portStatistics.getJSONObject("portStat");
- Assert.assertTrue(portStat.getInt("receivePackets") == 250);
- Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
- Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
- Assert.assertTrue(portStat.getInt("transmitBytes") == 5000);
- Assert.assertTrue(portStat.getInt("receiveDrops") == 2);
- Assert.assertTrue(portStat.getInt("transmitDrops") == 50);
- Assert.assertTrue(portStat.getInt("receiveErrors") == 3);
- Assert.assertTrue(portStat.getInt("transmitErrors") == 10);
- Assert.assertTrue(portStat.getInt("receiveFrameError") == 5);
- Assert.assertTrue(portStat.getInt("receiveOverRunError") == 6);
- Assert.assertTrue(portStat.getInt("receiveCrcError") == 1);
- Assert.assertTrue(portStat.getInt("collisionCount") == 4);
-
- // test for getting one specific node's stats
- result = getJsonResult(baseURL + "flowstats/STUB/51966");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- node = json.getJSONObject("node");
- // test that node was returned properly
- Assert.assertTrue(node.getInt("@id") == 0xCAFE);
- Assert.assertTrue(node.getString("@type").equals("STUB"));
-
- // test that flow statistics results are correct
- flowStats = json.getJSONArray("flowStat");
- for (int i = 0; i < flowStats.length(); i++) {
- JSONObject flowStat = flowStats.getJSONObject(i);
- testFlowStat(flowStat, actionTypes[i]);
- }
+ // test that flow statistics results are correct
+ JSONArray flowStats = flowStatistics.getJSONArray("flowStat");
+ for (int i = 0; i < flowStats.length(); i++) {
- result = getJsonResult(baseURL + "portstats/STUB/51966");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- node2 = json.getJSONObject("node");
- // test that node was returned properly
- Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
- Assert.assertTrue(node2.getString("@type").equals("STUB"));
-
- // test that port statistic results are correct
- portStat = json.getJSONObject("portStat");
- Assert.assertTrue(portStat.getInt("receivePackets") == 250);
- Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
- Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
- Assert.assertTrue(portStat.getInt("transmitBytes") == 5000);
- Assert.assertTrue(portStat.getInt("receiveDrops") == 2);
- Assert.assertTrue(portStat.getInt("transmitDrops") == 50);
- Assert.assertTrue(portStat.getInt("receiveErrors") == 3);
- Assert.assertTrue(portStat.getInt("transmitErrors") == 10);
- Assert.assertTrue(portStat.getInt("receiveFrameError") == 5);
- Assert.assertTrue(portStat.getInt("receiveOverRunError") == 6);
- Assert.assertTrue(portStat.getInt("receiveCrcError") == 1);
- Assert.assertTrue(portStat.getInt("collisionCount") == 4);
+ JSONObject flowStat = flowStats.getJSONObject(i);
+ testFlowStat(flowStat, actionTypes[i]);
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
+ }
+ // for /controller/nb/v2/statistics/default/portstats
+ result = getJsonResult(baseURL + "portstats");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ JSONObject portStatistics = getJsonInstance(json, "portStatistics",
+ 0xCAFE);
+ JSONObject node2 = portStatistics.getJSONObject("node");
+ // test that node was returned properly
+ Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
+ Assert.assertTrue(node2.getString("@type").equals("STUB"));
+
+ // test that port statistic results are correct
+ JSONObject portStat = portStatistics.getJSONObject("portStat");
+ Assert.assertTrue(portStat.getInt("receivePackets") == 250);
+ Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
+ Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
+ Assert.assertTrue(portStat.getInt("transmitBytes") == 5000);
+ Assert.assertTrue(portStat.getInt("receiveDrops") == 2);
+ Assert.assertTrue(portStat.getInt("transmitDrops") == 50);
+ Assert.assertTrue(portStat.getInt("receiveErrors") == 3);
+ Assert.assertTrue(portStat.getInt("transmitErrors") == 10);
+ Assert.assertTrue(portStat.getInt("receiveFrameError") == 5);
+ Assert.assertTrue(portStat.getInt("receiveOverRunError") == 6);
+ Assert.assertTrue(portStat.getInt("receiveCrcError") == 1);
+ Assert.assertTrue(portStat.getInt("collisionCount") == 4);
+
+ // test for getting one specific node's stats
+ result = getJsonResult(baseURL + "flowstats/STUB/51966");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ node = json.getJSONObject("node");
+ // test that node was returned properly
+ Assert.assertTrue(node.getInt("@id") == 0xCAFE);
+ Assert.assertTrue(node.getString("@type").equals("STUB"));
+
+ // test that flow statistics results are correct
+ flowStats = json.getJSONArray("flowStat");
+ for (int i = 0; i < flowStats.length(); i++) {
+ JSONObject flowStat = flowStats.getJSONObject(i);
+ testFlowStat(flowStat, actionTypes[i]);
}
+
+ result = getJsonResult(baseURL + "portstats/STUB/51966");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ node2 = json.getJSONObject("node");
+ // test that node was returned properly
+ Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
+ Assert.assertTrue(node2.getString("@type").equals("STUB"));
+
+ // test that port statistic results are correct
+ portStat = json.getJSONObject("portStat");
+ Assert.assertTrue(portStat.getInt("receivePackets") == 250);
+ Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
+ Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
+ Assert.assertTrue(portStat.getInt("transmitBytes") == 5000);
+ Assert.assertTrue(portStat.getInt("receiveDrops") == 2);
+ Assert.assertTrue(portStat.getInt("transmitDrops") == 50);
+ Assert.assertTrue(portStat.getInt("receiveErrors") == 3);
+ Assert.assertTrue(portStat.getInt("transmitErrors") == 10);
+ Assert.assertTrue(portStat.getInt("receiveFrameError") == 5);
+ Assert.assertTrue(portStat.getInt("receiveOverRunError") == 6);
+ Assert.assertTrue(portStat.getInt("receiveCrcError") == 1);
+ Assert.assertTrue(portStat.getInt("collisionCount") == 4);
}
- private void testFlowStat(JSONObject flowStat, String actionType) {
- try {
- Assert.assertTrue(flowStat.getInt("tableId") == 1);
- Assert.assertTrue(flowStat.getInt("durationSeconds") == 40);
- Assert.assertTrue(flowStat.getInt("durationNanoseconds") == 400);
- Assert.assertTrue(flowStat.getInt("packetCount") == 200);
- Assert.assertTrue(flowStat.getInt("byteCount") == 100);
-
- // test that flow information is correct
- JSONObject flow = flowStat.getJSONObject("flow");
- Assert.assertTrue(flow.getInt("priority") == 3500);
- Assert.assertTrue(flow.getInt("idleTimeout") == 1000);
- Assert.assertTrue(flow.getInt("hardTimeout") == 2000);
- Assert.assertTrue(flow.getInt("id") == 12345);
-
- JSONObject match = (flow.getJSONObject("match")
- .getJSONObject("matchField"));
- Assert.assertTrue(match.getString("type").equals("NW_DST"));
- Assert.assertTrue(match.getString("value").equals("1.1.1.1"));
-
- JSONObject act = flow.getJSONObject("actions");
- Assert.assertTrue(act.getString("@type").equals(actionType));
-
- if (act.getString("@type").equals("output")) {
- JSONObject port = act.getJSONObject("port");
- JSONObject port_node = port.getJSONObject("node");
- Assert.assertTrue(port.getInt("@id") == 51966);
- Assert.assertTrue(port.getString("@type").equals("STUB"));
- Assert.assertTrue(port_node.getInt("@id") == 51966);
- Assert.assertTrue(port_node.getString("@type").equals("STUB"));
- }
+ private void testFlowStat(JSONObject flowStat, String actionType)
+ throws JSONException {
+ Assert.assertTrue(flowStat.getInt("tableId") == 1);
+ Assert.assertTrue(flowStat.getInt("durationSeconds") == 40);
+ Assert.assertTrue(flowStat.getInt("durationNanoseconds") == 400);
+ Assert.assertTrue(flowStat.getInt("packetCount") == 200);
+ Assert.assertTrue(flowStat.getInt("byteCount") == 100);
+
+ // test that flow information is correct
+ JSONObject flow = flowStat.getJSONObject("flow");
+ Assert.assertTrue(flow.getInt("priority") == 3500);
+ Assert.assertTrue(flow.getInt("idleTimeout") == 1000);
+ Assert.assertTrue(flow.getInt("hardTimeout") == 2000);
+ Assert.assertTrue(flow.getInt("id") == 12345);
+
+ JSONObject match = (flow.getJSONObject("match")
+ .getJSONObject("matchField"));
+ Assert.assertTrue(match.getString("type").equals("NW_DST"));
+ Assert.assertTrue(match.getString("value").equals("1.1.1.1"));
+
+ JSONObject act = flow.getJSONObject("actions");
+ Assert.assertTrue(act.getString("@type").equals(actionType));
+
+ if (act.getString("@type").equals("output")) {
+ JSONObject port = act.getJSONObject("port");
+ JSONObject port_node = port.getJSONObject("node");
+ Assert.assertTrue(port.getInt("@id") == 51966);
+ Assert.assertTrue(port.getString("@type").equals("STUB"));
+ Assert.assertTrue(port_node.getInt("@id") == 51966);
+ Assert.assertTrue(port_node.getString("@type").equals("STUB"));
+ }
- if (act.getString("@type").equals("setDlSrc")) {
- byte srcMatch[] = { (byte) 5, (byte) 4, (byte) 3, (byte) 2,
- (byte) 1 };
- String src = act.getString("address");
- byte srcBytes[] = new byte[5];
- srcBytes[0] = Byte.parseByte(src.substring(0, 2));
- srcBytes[1] = Byte.parseByte(src.substring(2, 4));
- srcBytes[2] = Byte.parseByte(src.substring(4, 6));
- srcBytes[3] = Byte.parseByte(src.substring(6, 8));
- srcBytes[4] = Byte.parseByte(src.substring(8, 10));
- Assert.assertTrue(Arrays.equals(srcBytes, srcMatch));
- }
+ if (act.getString("@type").equals("setDlSrc")) {
+ byte srcMatch[] = { (byte) 5, (byte) 4, (byte) 3, (byte) 2,
+ (byte) 1 };
+ String src = act.getString("address");
+ byte srcBytes[] = new byte[5];
+ srcBytes[0] = Byte.parseByte(src.substring(0, 2));
+ srcBytes[1] = Byte.parseByte(src.substring(2, 4));
+ srcBytes[2] = Byte.parseByte(src.substring(4, 6));
+ srcBytes[3] = Byte.parseByte(src.substring(6, 8));
+ srcBytes[4] = Byte.parseByte(src.substring(8, 10));
+ Assert.assertTrue(Arrays.equals(srcBytes, srcMatch));
+ }
- if (act.getString("@type").equals("setDlDst")) {
- byte dstMatch[] = { (byte) 1, (byte) 2, (byte) 3, (byte) 4,
- (byte) 5 };
- String dst = act.getString("address");
- byte dstBytes[] = new byte[5];
- dstBytes[0] = Byte.parseByte(dst.substring(0, 2));
- dstBytes[1] = Byte.parseByte(dst.substring(2, 4));
- dstBytes[2] = Byte.parseByte(dst.substring(4, 6));
- dstBytes[3] = Byte.parseByte(dst.substring(6, 8));
- dstBytes[4] = Byte.parseByte(dst.substring(8, 10));
- Assert.assertTrue(Arrays.equals(dstBytes, dstMatch));
- }
- if (act.getString("@type").equals("setDlType"))
- Assert.assertTrue(act.getInt("dlType") == 10);
- if (act.getString("@type").equals("setVlanId"))
- Assert.assertTrue(act.getInt("vlanId") == 2);
- if (act.getString("@type").equals("setVlanPcp"))
- Assert.assertTrue(act.getInt("pcp") == 3);
- if (act.getString("@type").equals("setVlanCfi"))
- Assert.assertTrue(act.getInt("cfi") == 1);
-
- if (act.getString("@type").equals("setNwSrc"))
- Assert.assertTrue(act.getString("address").equals("2.2.2.2"));
- if (act.getString("@type").equals("setNwDst"))
- Assert.assertTrue(act.getString("address").equals("1.1.1.1"));
-
- if (act.getString("@type").equals("pushVlan")) {
- int head = act.getInt("VlanHeader");
- // parsing vlan header
- int id = head & 0xfff;
- int cfi = (head >> 12) & 0x1;
- int pcp = (head >> 13) & 0x7;
- int tag = (head >> 16) & 0xffff;
- Assert.assertTrue(id == 1234);
- Assert.assertTrue(cfi == 1);
- Assert.assertTrue(pcp == 1);
- Assert.assertTrue(tag == 0x8100);
- }
- if (act.getString("@type").equals("setNwTos"))
- Assert.assertTrue(act.getInt("tos") == 16);
- if (act.getString("@type").equals("setTpSrc"))
- Assert.assertTrue(act.getInt("port") == 4201);
- if (act.getString("@type").equals("setTpDst"))
- Assert.assertTrue(act.getInt("port") == 8080);
- } catch (Exception e) {
- Assert.assertTrue(false);
+ if (act.getString("@type").equals("setDlDst")) {
+ byte dstMatch[] = { (byte) 1, (byte) 2, (byte) 3, (byte) 4,
+ (byte) 5 };
+ String dst = act.getString("address");
+ byte dstBytes[] = new byte[5];
+ dstBytes[0] = Byte.parseByte(dst.substring(0, 2));
+ dstBytes[1] = Byte.parseByte(dst.substring(2, 4));
+ dstBytes[2] = Byte.parseByte(dst.substring(4, 6));
+ dstBytes[3] = Byte.parseByte(dst.substring(6, 8));
+ dstBytes[4] = Byte.parseByte(dst.substring(8, 10));
+ Assert.assertTrue(Arrays.equals(dstBytes, dstMatch));
+ }
+ if (act.getString("@type").equals("setDlType"))
+ Assert.assertTrue(act.getInt("dlType") == 10);
+ if (act.getString("@type").equals("setVlanId"))
+ Assert.assertTrue(act.getInt("vlanId") == 2);
+ if (act.getString("@type").equals("setVlanPcp"))
+ Assert.assertTrue(act.getInt("pcp") == 3);
+ if (act.getString("@type").equals("setVlanCfi"))
+ Assert.assertTrue(act.getInt("cfi") == 1);
+
+ if (act.getString("@type").equals("setNwSrc"))
+ Assert.assertTrue(act.getString("address").equals("2.2.2.2"));
+ if (act.getString("@type").equals("setNwDst"))
+ Assert.assertTrue(act.getString("address").equals("1.1.1.1"));
+
+ if (act.getString("@type").equals("pushVlan")) {
+ int head = act.getInt("VlanHeader");
+ // parsing vlan header
+ int id = head & 0xfff;
+ int cfi = (head >> 12) & 0x1;
+ int pcp = (head >> 13) & 0x7;
+ int tag = (head >> 16) & 0xffff;
+ Assert.assertTrue(id == 1234);
+ Assert.assertTrue(cfi == 1);
+ Assert.assertTrue(pcp == 1);
+ Assert.assertTrue(tag == 0x8100);
}
+ if (act.getString("@type").equals("setNwTos"))
+ Assert.assertTrue(act.getInt("tos") == 16);
+ if (act.getString("@type").equals("setTpSrc"))
+ Assert.assertTrue(act.getInt("port") == 4201);
+ if (act.getString("@type").equals("setTpDst"))
+ Assert.assertTrue(act.getInt("port") == 8080);
}
@Test
- public void testFlowProgrammer() {
- try {
- String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flow/default/";
- // Attempt to get a flow that doesn't exit. Should return 404
- // status.
- String result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
- Assert.assertTrue(result.equals("404"));
-
- // test add flow1
- String fc = "{\"dynamic\":\"false\", \"name\":\"test1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
- result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
- Assert.assertTrue(httpResponseCode == 201);
-
- // test get returns flow that was added.
- result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
- // check that result came out fine.
- Assert.assertTrue(httpResponseCode == 200);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- Assert.assertTrue(json.getString("name").equals("test1"));
- Assert.assertTrue(json.getString("actions").equals("DROP"));
- Assert.assertTrue(json.getString("installInHw").equals("true"));
- JSONObject node = json.getJSONObject("node");
- Assert.assertTrue(node.getString("@type").equals("STUB"));
- Assert.assertTrue(node.getString("@id").equals("51966"));
- // test adding same flow again fails due to repeat name..return 409
- // code
- result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
- Assert.assertTrue(result.equals("409"));
-
- fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
- result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
- // test should return 500 for error due to same flow being added.
- Assert.assertTrue(result.equals("500"));
-
- // add second flow that's different
- fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
- result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
- Assert.assertTrue(httpResponseCode == 201);
-
- // check that request returns both flows given node.
- result = getJsonResult(baseURL + "STUB/51966/", "GET");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
- JSONArray ja = json.getJSONArray("flowConfig");
- Integer count = ja.length();
- Assert.assertTrue(count == 2);
-
- // check that request returns both flows given just container.
- result = getJsonResult(baseURL);
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
- ja = json.getJSONArray("flowConfig");
- count = ja.length();
- Assert.assertTrue(count == 2);
-
- // delete a flow, check that it's no longer in list.
- result = getJsonResult(baseURL + "STUB/51966/test2", "DELETE");
- Assert.assertTrue(httpResponseCode == 200);
-
- result = getJsonResult(baseURL + "STUB/51966/test2", "GET");
- Assert.assertTrue(result.equals("404"));
-
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
-
+ public void testFlowProgrammer() throws JSONException {
+ String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flow/default/";
+ // Attempt to get a flow that doesn't exit. Should return 404
+ // status.
+ String result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
+ Assert.assertTrue(result.equals("404"));
+
+ // test add flow1
+ String fc = "{\"dynamic\":\"false\", \"name\":\"test1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
+ Assert.assertTrue(httpResponseCode == 201);
+
+ // test get returns flow that was added.
+ result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
+ // check that result came out fine.
+ Assert.assertTrue(httpResponseCode == 200);
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+ Assert.assertTrue(json.getString("name").equals("test1"));
+ Assert.assertTrue(json.getString("actions").equals("DROP"));
+ Assert.assertTrue(json.getString("installInHw").equals("true"));
+ JSONObject node = json.getJSONObject("node");
+ Assert.assertTrue(node.getString("@type").equals("STUB"));
+ Assert.assertTrue(node.getString("@id").equals("51966"));
+ // test adding same flow again fails due to repeat name..return 409
+ // code
+ result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
+ Assert.assertTrue(result.equals("409"));
+
+ fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
+ // test should return 500 for error due to same flow being added.
+ Assert.assertTrue(result.equals("500"));
+
+ // add second flow that's different
+ fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
+ Assert.assertTrue(httpResponseCode == 201);
+
+ // check that request returns both flows given node.
+ result = getJsonResult(baseURL + "STUB/51966/", "GET");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
+ JSONArray ja = json.getJSONArray("flowConfig");
+ Integer count = ja.length();
+ Assert.assertTrue(count == 2);
+
+ // check that request returns both flows given just container.
+ result = getJsonResult(baseURL);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
+ ja = json.getJSONArray("flowConfig");
+ count = ja.length();
+ Assert.assertTrue(count == 2);
+
+ // delete a flow, check that it's no longer in list.
+ result = getJsonResult(baseURL + "STUB/51966/test2", "DELETE");
+ Assert.assertTrue(httpResponseCode == 200);
+
+ result = getJsonResult(baseURL + "STUB/51966/test2", "GET");
+ Assert.assertTrue(result.equals("404"));
}
// method to extract a JSONObject with specified node ID from a JSONObject
}
@Test
- public void testHostTracker() {
+ public void testHostTracker() throws JSONException {
System.out.println("Starting HostTracker JAXB client.");
String baseURL = "http://127.0.0.1:8080/controller/nb/v2/host/default";
// test POST method: addHost()
- try {
- String queryParameter = new QueryParameter("dataLayerAddress",
- dataLayerAddress_1).add("nodeType", nodeType_1)
- .add("nodeId", nodeId_1.toString())
- .add("nodeConnectorType", nodeConnectorType_1)
- .add("nodeConnectorId", nodeConnectorId_1.toString())
- .add("vlan", vlan_1).getString();
-
- String result = getJsonResult(baseURL + "/" + networkAddress_1
- + queryParameter, "POST");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
-
- // vlan is not passed through query parameter but should be
- // defaulted to "0"
- queryParameter = new QueryParameter("dataLayerAddress",
- dataLayerAddress_2).add("nodeType", nodeType_2)
- .add("nodeId", nodeId_2.toString())
- .add("nodeConnectorType", nodeConnectorType_2)
- .add("nodeConnectorId", nodeConnectorId_2.toString())
- .getString();
-
- result = getJsonResult(baseURL + "/" + networkAddress_2
- + queryParameter, "POST");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
+ String queryParameter = new QueryParameter("dataLayerAddress",
+ dataLayerAddress_1).add("nodeType", nodeType_1)
+ .add("nodeId", nodeId_1.toString())
+ .add("nodeConnectorType", nodeConnectorType_1)
+ .add("nodeConnectorId", nodeConnectorId_1.toString())
+ .add("vlan", vlan_1).getString();
+
+ String result = getJsonResult(baseURL + "/" + networkAddress_1
+ + queryParameter, "POST");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
+
+ // vlan is not passed through query parameter but should be
+ // defaulted to "0"
+ queryParameter = new QueryParameter("dataLayerAddress",
+ dataLayerAddress_2).add("nodeType", nodeType_2)
+ .add("nodeId", nodeId_2.toString())
+ .add("nodeConnectorType", nodeConnectorType_2)
+ .add("nodeConnectorId", nodeConnectorId_2.toString())
+ .getString();
+
+ result = getJsonResult(baseURL + "/" + networkAddress_2
+ + queryParameter, "POST");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
// define variables for decoding returned strings
String networkAddress;
// the two hosts should be in inactive host DB
// test GET method: getInactiveHosts()
- try {
- String result = getJsonResult(baseURL + "/inactive", "GET");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+ result = getJsonResult(baseURL + "/inactive", "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+ // there should be at least two hosts in the DB
+ Assert.assertTrue(json.get("host") instanceof JSONArray);
+ JSONArray ja = json.getJSONArray("host");
+ Integer count = ja.length();
+ Assert.assertTrue(count == 2);
+
+ for (int i = 0; i < count; i++) {
+ host_jo = ja.getJSONObject(i);
+ dl_jo = host_jo.getJSONObject("dataLayerAddress");
+ nc_jo = host_jo.getJSONObject("nodeConnector");
+ node_jo = nc_jo.getJSONObject("node");
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- // there should be at least two hosts in the DB
- Assert.assertTrue(json.get("host") instanceof JSONArray);
- JSONArray ja = json.getJSONArray("host");
- Integer count = ja.length();
- Assert.assertTrue(count == 2);
-
- for (int i = 0; i < count; i++) {
- host_jo = ja.getJSONObject(i);
- dl_jo = host_jo.getJSONObject("dataLayerAddress");
- nc_jo = host_jo.getJSONObject("nodeConnector");
- node_jo = nc_jo.getJSONObject("node");
-
- networkAddress = host_jo.getString("networkAddress");
- if (networkAddress.equalsIgnoreCase(networkAddress_1)) {
- Assert.assertTrue(dl_jo.getString("macAddress")
- .equalsIgnoreCase(dataLayerAddress_1));
- Assert.assertTrue(nc_jo.getString("@type")
- .equalsIgnoreCase(nodeConnectorType_1));
- Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
- Assert.assertTrue(node_jo.getString("@type")
- .equalsIgnoreCase(nodeType_1));
- Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
- Assert.assertTrue(host_jo.getString("vlan")
- .equalsIgnoreCase(vlan_1));
- } else if (networkAddress.equalsIgnoreCase(networkAddress_2)) {
- Assert.assertTrue(dl_jo.getString("macAddress")
- .equalsIgnoreCase(dataLayerAddress_2));
- Assert.assertTrue(nc_jo.getString("@type")
- .equalsIgnoreCase(nodeConnectorType_2));
- Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_2);
- Assert.assertTrue(node_jo.getString("@type")
- .equalsIgnoreCase(nodeType_2));
- Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_2);
- Assert.assertTrue(host_jo.getString("vlan")
- .equalsIgnoreCase(vlan_2));
- } else {
- Assert.assertTrue(false);
- }
+ networkAddress = host_jo.getString("networkAddress");
+ if (networkAddress.equalsIgnoreCase(networkAddress_1)) {
+ Assert.assertTrue(dl_jo.getString("macAddress")
+ .equalsIgnoreCase(dataLayerAddress_1));
+ Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(
+ nodeConnectorType_1));
+ Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
+ Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(
+ nodeType_1));
+ Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
+ Assert.assertTrue(host_jo.getString("vlan").equalsIgnoreCase(
+ vlan_1));
+ } else if (networkAddress.equalsIgnoreCase(networkAddress_2)) {
+ Assert.assertTrue(dl_jo.getString("macAddress")
+ .equalsIgnoreCase(dataLayerAddress_2));
+ Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(
+ nodeConnectorType_2));
+ Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_2);
+ Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(
+ nodeType_2));
+ Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_2);
+ Assert.assertTrue(host_jo.getString("vlan").equalsIgnoreCase(
+ vlan_2));
+ } else {
+ Assert.assertTrue(false);
}
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
}
// test GET method: getActiveHosts() - no host expected
- try {
- String result = getJsonResult(baseURL, "GET");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+ result = getJsonResult(baseURL, "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- Assert.assertFalse(hostInJson(json, networkAddress_1));
- Assert.assertFalse(hostInJson(json, networkAddress_2));
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ Assert.assertFalse(hostInJson(json, networkAddress_1));
+ Assert.assertFalse(hostInJson(json, networkAddress_2));
// put the 1st host into active host DB
Node nd;
}
// verify the host shows up in active host DB
- try {
- String result = getJsonResult(baseURL, "GET");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
+ result = getJsonResult(baseURL, "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- Assert.assertTrue(hostInJson(json, networkAddress_1));
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+
+ Assert.assertTrue(hostInJson(json, networkAddress_1));
// test GET method for getHostDetails()
- try {
- String result = getJsonResult(baseURL + "/" + networkAddress_1,
- "GET");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
+ result = getJsonResult(baseURL + "/" + networkAddress_1, "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- Assert.assertFalse(json.length() == 0);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
- dl_jo = json.getJSONObject("dataLayerAddress");
- nc_jo = json.getJSONObject("nodeConnector");
- node_jo = nc_jo.getJSONObject("node");
+ Assert.assertFalse(json.length() == 0);
- Assert.assertTrue(json.getString("networkAddress")
- .equalsIgnoreCase(networkAddress_1));
- Assert.assertTrue(dl_jo.getString("macAddress").equalsIgnoreCase(
- dataLayerAddress_1));
- Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(
- nodeConnectorType_1));
- Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
- Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(
- nodeType_1));
- Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
- Assert.assertTrue(json.getString("vlan").equalsIgnoreCase(vlan_1));
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
+ dl_jo = json.getJSONObject("dataLayerAddress");
+ nc_jo = json.getJSONObject("nodeConnector");
+ node_jo = nc_jo.getJSONObject("node");
+
+ Assert.assertTrue(json.getString("networkAddress").equalsIgnoreCase(
+ networkAddress_1));
+ Assert.assertTrue(dl_jo.getString("macAddress").equalsIgnoreCase(
+ dataLayerAddress_1));
+ Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(
+ nodeConnectorType_1));
+ Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
+ Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(
+ nodeType_1));
+ Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
+ Assert.assertTrue(json.getString("vlan").equalsIgnoreCase(vlan_1));
// test DELETE method for deleteFlow()
- try {
- String result = getJsonResult(baseURL + "/" + networkAddress_1,
- "DELETE");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
+ result = getJsonResult(baseURL + "/" + networkAddress_1, "DELETE");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
// verify host_1 removed from active host DB
// test GET method: getActiveHosts() - no host expected
- try {
- String result = getJsonResult(baseURL, "GET");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
+ result = getJsonResult(baseURL, "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+
+ Assert.assertFalse(hostInJson(json, networkAddress_1));
- Assert.assertFalse(hostInJson(json, networkAddress_1));
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
}
private Boolean hostInJson(JSONObject json, String hostIp)
mavenBundle("org.opendaylight.controller", "usermanager",
"0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "usermanager.implementation", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "logging.bridge",
"0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "clustering.test",
mavenBundle("com.sun.jersey", "jersey-json", "1.17")
.startLevel(2), junitBundles());
}
-}
\ No newline at end of file
+}
connectionTimeout="20000"
redirectPort="8443" />
-<!--
- Please remove the comments around the following Connector tag to enable HTTPS Authentication support.
- Remember to add a valid keystore in the configuration folder.
- More info : http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+<!--
+ Please remove the comments around the following Connector tag to enable HTTPS Authentication support.
+ Remember to add a valid keystore in the configuration folder.
+ More info : http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
-->
-
- <!--
+
+ <!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
unpackWARs="false" autoDeploy="false"
deployOnStartup="false" createDirs="false">
<Realm className="org.opendaylight.controller.security.ControllerCustomRealm" />
- <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-
+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
+
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
- prefix="web_access_log_" suffix=".txt" resolveHosts="false"
- rotatable="true" fileDateFormat="yyyy-MM"
- pattern="%{yyyy-MM-dd HH:mm:ss.SSS z}t - [%a] - %r"/>
-
+ prefix="web_access_log_" suffix=".txt" resolveHosts="false"
+ rotatable="true" fileDateFormat="yyyy-MM"
+ pattern="%{yyyy-MM-dd HH:mm:ss.SSS z}t - [%a] - %r"/>
+
</Host>
</Engine>
</Service>
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/staticroute"/>
</services>
<groupId>org.opendaylight.controller.thirdparty</groupId>
<artifactId>com.sun.jersey.jersey-servlet</artifactId>
<version>1.17-SNAPSHOT</version>
- </dependency>
+ </dependency>
</dependencies>
</project>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSStaticRouting</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
- <servlet-mapping>
- <servlet-name>JAXRSStaticRouting</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>JAXRSStaticRouting</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
\ No newline at end of file
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/statistics"/>
</services>
<version>0.5.0-SNAPSHOT</version>
</dependency>
</dependencies>
- </plugin>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSStatistics</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
\ No newline at end of file
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSSubnets</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<servlet-name>JAXRSSubnets</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/switch"/>
</services>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSSwitchManager</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
\ No newline at end of file
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/topology"/>
</services>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSTopology</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.4.0-SNAPSHOT</version>
<relativePath>../../../opendaylight/commons/opendaylight</relativePath>
</parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>northboundtest</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>2.3.6</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.opendaylight.controller.sal.core,
- org.eclipse.osgi.framework.console,
- org.osgi.framework,
- org.apache.felix.dm
- </Import-Package>
- <Export-Package>
- </Export-Package>
- <Bundle-Activator>
- org.opendaylight.controller.northboundtest.unittestsuite.internal.Activator
- </Bundle-Activator>
- <Service-Component>
- </Service-Component>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>northboundtest</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.6</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.opendaylight.controller.sal.core,
+ org.eclipse.osgi.framework.console,
+ org.osgi.framework,
+ org.apache.felix.dm
+ </Import-Package>
+ <Export-Package>
+ </Export-Package>
+ <Bundle-Activator>
+ org.opendaylight.controller.northboundtest.unittestsuite.internal.Activator
+ </Bundle-Activator>
+ <Service-Component>
+ </Service-Component>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
</project>
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.openflow.protocol.OFMessage;
/**
import java.util.LinkedList;
import java.util.List;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.openflow.protocol.OFPacketOut;
import org.openflow.protocol.OFPort;
import org.openflow.protocol.OFVendor;
}
}
- /**
- * Prints the contents of V6FlowMod in a string format.
- */
@Override
public String toString() {
- return "V6FlowMod[" + ReflectionToStringBuilder.toString(this) + "]";
+ return "V6FlowMod [match=" + match + ", cookie=" + cookie
+ + ", command=" + command + ", idleTimeout=" + idleTimeout
+ + ", hardTimeout=" + hardTimeout + ", priority=" + priority
+ + ", bufferId=" + bufferId + ", outPort=" + outPort
+ + ", flags=" + flags + ", actions=" + actions + ", match_len="
+ + match_len + ", actions_len=" + actions_len + ", pad_size="
+ + pad_size + "]";
}
}
package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.openflow.protocol.OFMatch;
-import org.openflow.util.U16;
-import org.openflow.util.U8;
-
import java.net.Inet6Address;
-import org.opendaylight.controller.sal.utils.HexEncode;
-
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.opendaylight.controller.sal.utils.HexEncode;
+import org.openflow.protocol.OFMatch;
+import org.openflow.util.U16;
+import org.openflow.util.U8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public String toString() {
- return "V6Match[" + ReflectionToStringBuilder.toString(this) + "]";
+ return "V6Match [nwSrc=" + nwSrc + ", nwDst=" + nwDst
+ + ", inputPortMask=" + inputPortMask + ", dataLayerSourceMask="
+ + HexEncode.bytesToHexStringFormat(dataLayerSourceMask)
+ + ", dataLayerDestinationMask="
+ + HexEncode.bytesToHexStringFormat(dataLayerDestinationMask)
+ + ", dataLayerVirtualLanMask=" + dataLayerVirtualLanMask
+ + ", dataLayerVirtualLanPriorityCodePointMask="
+ + dataLayerVirtualLanPriorityCodePointMask
+ + ", dataLayerTypeMask=" + dataLayerTypeMask
+ + ", networkTypeOfServiceMask=" + networkTypeOfServiceMask
+ + ", networkProtocolMask=" + networkProtocolMask
+ + ", networkSourceMask=" + networkSourceMask
+ + ", networkDestinationMask=" + networkDestinationMask
+ + ", transportSourceMask=" + transportSourceMask
+ + ", transportDestinationMask=" + transportDestinationMask
+ + ", srcIPv6SubnetMaskbits=" + srcIPv6SubnetMaskbits
+ + ", dstIPv6SubnetMaskbits=" + dstIPv6SubnetMaskbits
+ + ", inputPortState=" + inputPortState + ", dlSourceState="
+ + dlSourceState + ", dlDestState=" + dlDestState
+ + ", dlVlanState=" + dlVlanState + ", ethTypeState="
+ + ethTypeState + ", nwTosState=" + nwTosState
+ + ", nwProtoState=" + nwProtoState + ", nwSrcState="
+ + nwSrcState + ", nwDstState=" + nwDstState + ", tpSrcState="
+ + tpSrcState + ", tpDstState=" + tpDstState + ", match_len="
+ + match_len + ", pad_size=" + pad_size + "]";
}
/**
import java.nio.ByteBuffer;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.openflow.protocol.statistics.OFVendorStatistics;
@Override
public String toString() {
- return "V6StatsRequest[" + ReflectionToStringBuilder.toString(this)
+ return "V6StatsRequest [msgsubtype=" + msgsubtype + ", outPort="
+ + outPort + ", match_len=" + match_len + ", tableId=" + tableId
+ "]";
}
org.opendaylight.controller.protocol_plugins.stub.internal
</Export-Package>
<Bundle-Activator>
- org.opendaylight.controller.protocol_plugins.stub.internal.Activator
+ org.opendaylight.controller.protocol_plugins.stub.internal.Activator
</Bundle-Activator>
</instructions>
<manifestLocation>${project.basedir}/META-INF</manifestLocation>
<scope>test</scope>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-
+import org.opendaylight.controller.sal.utils.HexEncode;
/**
* The class contains MAC address property.
*/
@Override
public String toString() {
- return "MacAddress[" + ReflectionToStringBuilder.toString(this) + "]";
+ return "MacAddress [address=" +
+ HexEncode.bytesToHexStringFormat(address) + "]";
}
}
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-
/**
* @file DataLinkAddress.java
*
@Override
public String toString() {
- return "DataLinkAddress[" + ReflectionToStringBuilder.toString(this)
- + "]";
+ return "DataLinkAddress [name=" + name + "]";
}
}
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.utils.HexEncode;
@Override
public String toString() {
- return "EthernetAddress[" + ReflectionToStringBuilder.toString(this)
+ return "EthernetAddress [macAddress=" + HexEncode.bytesToHexStringFormat(macAddress)
+ "]";
}
import java.util.Set;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.opendaylight.controller.sal.core.Edge;
import org.opendaylight.controller.sal.core.Property;
import org.opendaylight.controller.sal.core.UpdateType;
@Override
public String toString() {
- return "TopoEdgeUpdate[" + ReflectionToStringBuilder.toString(this)
- + "]";
+ return "TopoEdgeUpdate [edge=" + edge + ", props=" + props + ", type="
+ + type + "]";
}
@Override
import org.opendaylight.controller.binding.generator.util.ReferencedTypeImpl;
import org.opendaylight.controller.binding.generator.util.Types;
+import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl;
import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;
import org.opendaylight.controller.sal.binding.model.api.*;
import org.opendaylight.controller.sal.binding.model.api.type.builder.*;
import org.opendaylight.controller.sal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.controller.yang.binding.Notification;
import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.common.RpcResult;
import org.opendaylight.controller.yang.model.api.*;
import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
import org.opendaylight.controller.yang.model.util.DataNodeIterator;
import org.opendaylight.controller.yang.model.util.ExtendedType;
+import org.opendaylight.controller.yang.model.util.SchemaContextUtil;
import java.util.*;
+import java.util.concurrent.Future;
import static org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil.*;
import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findDataSchemaNode;
@Override
public List<Type> generateTypes(final SchemaContext context) {
if (context == null) {
- throw new IllegalArgumentException("Schema Context reference " +
- "cannot be NULL!");
+ throw new IllegalArgumentException("Schema Context reference "
+ + "cannot be NULL!");
}
if (context.getModules() == null) {
- throw new IllegalStateException("Schema Context does not contain " +
- "defined modules!");
+ throw new IllegalStateException("Schema Context does not contain "
+ + "defined modules!");
}
final List<Type> generatedTypes = new ArrayList<>();
generatedTypes.addAll(allListsToGenTypes(module));
generatedTypes.addAll(allAugmentsToGenTypes(module));
generatedTypes.addAll(allRPCMethodsToGenType(module));
- generatedTypes.addAll(allNotifycationsToGenType(module));
+ generatedTypes.addAll(allNotificationsToGenType(module));
+ generatedTypes.addAll(allIdentitiesToGenTypes(module, context));
+ generatedTypes.addAll(allGroupingsToGenTypes(module));
}
return generatedTypes;
}
@Override
public List<Type> generateTypes(final SchemaContext context,
- final Set<Module> modules) {
+ final Set<Module> modules) {
if (context == null) {
- throw new IllegalArgumentException("Schema Context reference " +
- "cannot be NULL!");
+ throw new IllegalArgumentException("Schema Context reference "
+ + "cannot be NULL!");
}
if (context.getModules() == null) {
- throw new IllegalStateException("Schema Context does not contain " +
- "defined modules!");
+ throw new IllegalStateException("Schema Context does not contain "
+ + "defined modules!");
}
if (modules == null) {
- throw new IllegalArgumentException("Sef of Modules cannot be " +
- "NULL!");
+ throw new IllegalArgumentException("Sef of Modules cannot be "
+ + "NULL!");
}
final List<Type> filteredGenTypes = new ArrayList<>();
generatedTypes.addAll(allListsToGenTypes(contextModule));
generatedTypes.addAll(allAugmentsToGenTypes(contextModule));
generatedTypes.addAll(allRPCMethodsToGenType(contextModule));
- generatedTypes.addAll(allNotifycationsToGenType(contextModule));
+ generatedTypes.addAll(allNotificationsToGenType(contextModule));
+ generatedTypes.addAll(allIdentitiesToGenTypes(contextModule,
+ context));
+ generatedTypes.addAll(allGroupingsToGenTypes(contextModule));
if (modules.contains(contextModule)) {
filteredGenTypes.addAll(generatedTypes);
private List<Type> allTypeDefinitionsToGenTypes(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
throw new IllegalArgumentException("Module name cannot be NULL!");
}
if (module.getTypeDefinitions() == null) {
- throw new IllegalArgumentException("Type Definitions for module " +
- module.getName() + " cannot be NULL!");
+ throw new IllegalArgumentException("Type Definitions for module "
+ + module.getName() + " cannot be NULL!");
}
final Set<TypeDefinition<?>> typeDefinitions = module
final List<Type> generatedTypes = new ArrayList<>();
for (final TypeDefinition<?> typedef : typeDefinitions) {
if (typedef != null) {
- final Type type = ((TypeProviderImpl)typeProvider)
+ final Type type = ((TypeProviderImpl) typeProvider)
.generatedTypeForExtendedDefinitionType(typedef);
if ((type != null) && !generatedTypes.contains(type)) {
generatedTypes.add(type);
private List<Type> allContainersToGenTypes(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
}
if (module.getChildNodes() == null) {
- throw new IllegalArgumentException("Reference to Set of Child " +
- "Nodes in module " + module.getName() + " cannot be " +
- "NULL!");
+ throw new IllegalArgumentException("Reference to Set of Child "
+ + "Nodes in module " + module.getName() + " cannot be "
+ + "NULL!");
}
final List<Type> generatedTypes = new ArrayList<>();
- final DataNodeIterator it = new DataNodeIterator(
- module);
+ final DataNodeIterator it = new DataNodeIterator(module);
final List<ContainerSchemaNode> schemaContainers = it.allContainers();
final String basePackageName = moduleNamespaceToPackageName(module);
for (final ContainerSchemaNode container : schemaContainers) {
- generatedTypes.add(containerToGenType(basePackageName,
- container));
+ generatedTypes.add(containerToGenType(basePackageName, container));
}
return generatedTypes;
}
private List<Type> allListsToGenTypes(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
}
if (module.getChildNodes() == null) {
- throw new IllegalArgumentException("Reference to Set of Child " +
- "Nodes in module " + module.getName() + " cannot be " +
- "NULL!");
+ throw new IllegalArgumentException("Reference to Set of Child "
+ + "Nodes in module " + module.getName() + " cannot be "
+ + "NULL!");
}
final List<Type> generatedTypes = new ArrayList<>();
- final DataNodeIterator it = new DataNodeIterator(
- module);
+ final DataNodeIterator it = new DataNodeIterator(module);
final List<ListSchemaNode> schemaLists = it.allLists();
final String basePackageName = moduleNamespaceToPackageName(module);
if (schemaLists != null) {
private List<Type> allAugmentsToGenTypes(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
}
if (module.getChildNodes() == null) {
- throw new IllegalArgumentException("Reference to Set of " +
- "Augmentation Definitions in module " + module.getName()
+ throw new IllegalArgumentException("Reference to Set of "
+ + "Augmentation Definitions in module " + module.getName()
+ " cannot be NULL!");
}
final String basePackageName = moduleNamespaceToPackageName(module);
final List<AugmentationSchema> augmentations = resolveAugmentations(module);
for (final AugmentationSchema augment : augmentations) {
- generatedTypes.addAll(augmentationToGenTypes(basePackageName, augment));
+ generatedTypes.addAll(augmentationToGenTypes(basePackageName,
+ augment));
}
return generatedTypes;
}
private List<AugmentationSchema> resolveAugmentations(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getAugmentations() == null) {
throw new IllegalStateException("Augmentations Set cannot be NULL!");
}
- final Set<AugmentationSchema> augmentations = module
- .getAugmentations();
+ final Set<AugmentationSchema> augmentations = module.getAugmentations();
final List<AugmentationSchema> sortedAugmentations = new ArrayList<>(
augmentations);
Collections.sort(sortedAugmentations,
new Comparator<AugmentationSchema>() {
@Override
- public int compare(
- AugmentationSchema augSchema1,
+ public int compare(AugmentationSchema augSchema1,
AugmentationSchema augSchema2) {
- if (augSchema1.getTargetPath().getPath()
- .size() > augSchema2
+ if (augSchema1.getTargetPath().getPath().size() > augSchema2
.getTargetPath().getPath().size()) {
return 1;
- } else if (augSchema1.getTargetPath()
- .getPath().size() < augSchema2
+ } else if (augSchema1.getTargetPath().getPath().size() < augSchema2
.getTargetPath().getPath().size()) {
return -1;
}
private GeneratedType moduleToDataType(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
final GeneratedTypeBuilder moduleDataTypeBuilder = moduleTypeBuilder(
final String basePackageName = moduleNamespaceToPackageName(module);
if (moduleDataTypeBuilder != null) {
final Set<DataSchemaNode> dataNodes = module.getChildNodes();
- resolveDataSchemaNodes(basePackageName, moduleDataTypeBuilder, dataNodes);
+ resolveDataSchemaNodes(basePackageName, moduleDataTypeBuilder,
+ dataNodes);
}
return moduleDataTypeBuilder.toInstance();
}
- private List<GeneratedType> allRPCMethodsToGenType(final Module module) {
+ private List<Type> allRPCMethodsToGenType(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
}
if (module.getChildNodes() == null) {
- throw new IllegalArgumentException("Reference to Set of " +
- "RPC Method Definitions in module " + module.getName()
+ throw new IllegalArgumentException("Reference to Set of "
+ + "RPC Method Definitions in module " + module.getName()
+ " cannot be NULL!");
}
final String basePackageName = moduleNamespaceToPackageName(module);
final Set<RpcDefinition> rpcDefinitions = module.getRpcs();
- final List<GeneratedType> genRPCTypes = new ArrayList<>();
-
+ final List<Type> genRPCTypes = new ArrayList<>();
+ final GeneratedTypeBuilder interfaceBuilder = moduleTypeBuilder(module,
+ "Service");
+ final Type future = Types.typeForClass(Future.class);
for (final RpcDefinition rpc : rpcDefinitions) {
if (rpc != null) {
+
+ String rpcName = parseToClassName(rpc.getQName()
+ .getLocalName());
+ MethodSignatureBuilder method = interfaceBuilder
+ .addMethod(rpcName);
+
final List<DataNodeIterator> rpcInOut = new ArrayList<>();
- rpcInOut.add(new DataNodeIterator(rpc.getInput()));
- rpcInOut.add(new DataNodeIterator(rpc.getOutput()));
+ ContainerSchemaNode input = rpc.getInput();
+ ContainerSchemaNode output = rpc.getOutput();
+
+ if (input != null) {
+ rpcInOut.add(new DataNodeIterator(input));
+ GeneratedTypeBuilder inType = addRawInterfaceDefinition(
+ basePackageName, input, rpcName);
+ resolveDataSchemaNodes(basePackageName, inType, input.getChildNodes());
+ Type inTypeInstance = inType.toInstance();
+ genRPCTypes.add(inTypeInstance);
+ method.addParameter(inTypeInstance, "input");
+ }
+
+ Type outTypeInstance = Types.typeForClass(Void.class);
+ if (output != null) {
+ rpcInOut.add(new DataNodeIterator(output));
+
+ GeneratedTypeBuilder outType = addRawInterfaceDefinition(
+ basePackageName, output, rpcName);
+ resolveDataSchemaNodes(basePackageName, outType, output.getChildNodes());
+ outTypeInstance = outType.toInstance();
+ genRPCTypes.add(outTypeInstance);
+
+ }
+
+ final Type rpcRes = Types.parameterizedTypeFor(
+ Types.typeForClass(RpcResult.class), outTypeInstance);
+ method.addReturnType(Types.parameterizedTypeFor(future, rpcRes));
for (DataNodeIterator it : rpcInOut) {
List<ContainerSchemaNode> nContainers = it.allContainers();
if ((nContainers != null) && !nContainers.isEmpty()) {
for (final ContainerSchemaNode container : nContainers) {
- genRPCTypes.add(containerToGenType(basePackageName, container));
+ genRPCTypes.add(containerToGenType(basePackageName,
+ container));
+ }
+ }
+ List<ListSchemaNode> nLists = it.allLists();
+ if ((nLists != null) && !nLists.isEmpty()) {
+ for (final ListSchemaNode list : nLists) {
+ genRPCTypes.addAll(listToGenType(basePackageName,
+ list));
}
}
}
}
}
+ genRPCTypes.add(interfaceBuilder.toInstance());
return genRPCTypes;
}
- private List<Type> allNotifycationsToGenType(final Module module) {
+ private List<Type> allNotificationsToGenType(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
}
if (module.getChildNodes() == null) {
- throw new IllegalArgumentException("Reference to Set of " +
- "Notification Definitions in module " + module.getName()
+ throw new IllegalArgumentException("Reference to Set of "
+ + "Notification Definitions in module " + module.getName()
+ " cannot be NULL!");
}
for (final NotificationDefinition notification : notifications) {
if (notification != null) {
- final List<DataNodeIterator> notifyChildren = new ArrayList<>();
+ DataNodeIterator it = new DataNodeIterator(notification);
- for (DataSchemaNode childNode : notification.getChildNodes()) {
- if (childNode instanceof DataNodeContainer) {
- notifyChildren.add(new DataNodeIterator((DataNodeContainer) childNode));
- }
+ // Containers
+ for (ContainerSchemaNode node : it.allContainers()) {
+ genNotifyTypes
+ .add(containerToGenType(basePackageName, node));
}
-
- for (DataNodeIterator it : notifyChildren) {
- List<ContainerSchemaNode> nContainers = it.allContainers();
- List<ListSchemaNode> nLists = it.allLists();
- if ((nContainers != null) && !nContainers.isEmpty()) {
- for (final ContainerSchemaNode container : nContainers) {
- genNotifyTypes.add(containerToGenType(basePackageName, container));
- }
- }
- if ((nLists != null) && !nLists.isEmpty()) {
- for (final ListSchemaNode list : nLists) {
- genNotifyTypes.addAll(listToGenType(basePackageName, list));
- }
- }
+ // Lists
+ for (ListSchemaNode node : it.allLists()) {
+ genNotifyTypes.addAll(listToGenType(basePackageName, node));
}
+ final GeneratedTypeBuilder notificationTypeBuilder = addRawInterfaceDefinition(
+ basePackageName, notification);
+ notificationTypeBuilder.addImplementsType(Types
+ .typeForClass(Notification.class));
+ // Notification object
+ resolveDataSchemaNodes(basePackageName,
+ notificationTypeBuilder, notification.getChildNodes());
+ genNotifyTypes.add(notificationTypeBuilder.toInstance());
}
}
return genNotifyTypes;
}
+ private List<Type> allIdentitiesToGenTypes(final Module module,
+ final SchemaContext context) {
+ List<Type> genTypes = new ArrayList<Type>();
+
+ final Set<IdentitySchemaNode> schemaIdentities = module.getIdentities();
+
+ final String basePackageName = moduleNamespaceToPackageName(module);
+
+ if (schemaIdentities != null && !schemaIdentities.isEmpty()) {
+ for (final IdentitySchemaNode identity : schemaIdentities) {
+ genTypes.add(identityToGenType(basePackageName, identity,
+ context));
+ }
+ }
+ return genTypes;
+ }
+
+ private GeneratedType identityToGenType(final String basePackageName,
+ IdentitySchemaNode identity, SchemaContext context) {
+ if (identity == null) {
+ return null;
+ }
+
+ final String packageName = packageNameForGeneratedType(basePackageName,
+ identity.getPath());
+
+ final String genTypeName = parseToClassName(identity.getQName()
+ .getLocalName());
+ final GeneratedTOBuilderImpl newType = new GeneratedTOBuilderImpl(
+ packageName, genTypeName);
+
+ IdentitySchemaNode baseIdentity = identity.getBaseIdentity();
+ if (baseIdentity != null) {
+ Module baseIdentityParentModule = SchemaContextUtil.findParentModule(
+ context, baseIdentity);
+
+ final String returnTypePkgName = moduleNamespaceToPackageName(baseIdentityParentModule);
+ final String returnTypeName = parseToClassName(baseIdentity
+ .getQName().getLocalName());
+
+ GeneratedTransferObject gto = new GeneratedTOBuilderImpl(
+ returnTypePkgName, returnTypeName).toInstance();
+ newType.addExtendsType(gto);
+ } else {
+ newType.addExtendsType(Types.getBaseIdentityTO());
+ }
+
+ return newType.toIdentityInstance();
+ }
+
+ private List<Type> allGroupingsToGenTypes(Module module) {
+ final List<Type> genTypes = new ArrayList<Type>();
+ final String basePackageName = moduleNamespaceToPackageName(module);
+ Set<GroupingDefinition> groupings = module.getGroupings();
+ if (groupings != null && !groupings.isEmpty()) {
+ for (final GroupingDefinition grouping : groupings) {
+ genTypes.add(groupingToGenType(basePackageName, grouping));
+ }
+ }
+ return genTypes;
+ }
+
+ private GeneratedType groupingToGenType(final String basePackageName,
+ GroupingDefinition grouping) {
+ if (grouping == null) {
+ return null;
+ }
+
+ final String packageName = packageNameForGeneratedType(basePackageName,
+ grouping.getPath());
+ final Set<DataSchemaNode> schemaNodes = grouping.getChildNodes();
+ final GeneratedTypeBuilder typeBuilder = addRawInterfaceDefinition(
+ packageName, grouping);
+
+ resolveDataSchemaNodes(basePackageName, typeBuilder, schemaNodes);
+ return typeBuilder.toInstance();
+ }
+
private EnumTypeDefinition enumTypeDefFromExtendedType(
final TypeDefinition<?> typeDefinition) {
if (typeDefinition != null) {
}
private GeneratedTypeBuilder moduleTypeBuilder(final Module module,
- final String postfix) {
+ final String postfix) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
String packageName = moduleNamespaceToPackageName(module);
- final String moduleName = parseToClassName(module.getName())
- + postfix;
+ final String moduleName = parseToClassName(module.getName()) + postfix;
return new GeneratedTypeBuilderImpl(packageName, moduleName);
}
private List<Type> augmentationToGenTypes(final String augmentPackageName,
- final AugmentationSchema augSchema) {
+ final AugmentationSchema augSchema) {
if (augmentPackageName == null) {
throw new IllegalArgumentException("Package Name cannot be NULL!");
}
// EVERY augmented interface will extends Augmentation<T> interface
// and DataObject interface!!!
final SchemaPath targetPath = augSchema.getTargetPath();
- final DataSchemaNode targetSchemaNode = findDataSchemaNode(schemaContext,
- targetPath);
- if ((targetSchemaNode != null) &&
- (targetSchemaNode.getQName() != null) &&
- (targetSchemaNode.getQName().getLocalName() != null)) {
+ final DataSchemaNode targetSchemaNode = findDataSchemaNode(
+ schemaContext, targetPath);
+ if ((targetSchemaNode != null) && (targetSchemaNode.getQName() != null)
+ && (targetSchemaNode.getQName().getLocalName() != null)) {
final Module targetModule = findParentModule(schemaContext,
targetSchemaNode);
final String targetBasePackage = moduleNamespaceToPackageName(targetModule);
- final String targetPackageName = packageNameForGeneratedType(targetBasePackage,
- targetSchemaNode.getPath());
+ final String targetPackageName = packageNameForGeneratedType(
+ targetBasePackage, targetSchemaNode.getPath());
- final String targetSchemaNodeName = targetSchemaNode.getQName().getLocalName();
- final Set<DataSchemaNode> augChildNodes = augSchema
- .getChildNodes();
+ final String targetSchemaNodeName = targetSchemaNode.getQName()
+ .getLocalName();
+ final Set<DataSchemaNode> augChildNodes = augSchema.getChildNodes();
final GeneratedTypeBuilder augTypeBuilder = addRawAugmentGenTypeDefinition(
- augmentPackageName, targetPackageName, targetSchemaNodeName, augSchema);
+ augmentPackageName, targetPackageName,
+ targetSchemaNodeName, augSchema);
if (augTypeBuilder != null) {
genTypes.add(augTypeBuilder.toInstance());
}
genTypeBuilders.put(augmentPackageName, augmentBuilders);
}
- final String augTypeName = augGenTypeName(augmentBuilders, targetTypeName);
- final Type targetTypeRef = new ReferencedTypeImpl(targetPackageName, targetTypeName);
- final Set<DataSchemaNode> augChildNodes = augSchema
- .getChildNodes();
+ final String augTypeName = augGenTypeName(augmentBuilders,
+ targetTypeName);
+ final Type targetTypeRef = new ReferencedTypeImpl(targetPackageName,
+ targetTypeName);
+ final Set<DataSchemaNode> augChildNodes = augSchema.getChildNodes();
final GeneratedTypeBuilder augTypeBuilder = new GeneratedTypeBuilderImpl(
augmentPackageName, augTypeName);
augTypeBuilder.addImplementsType(Types
.augmentationTypeFor(targetTypeRef));
- augSchemaNodeToMethods(augmentPackageName, augTypeBuilder, augChildNodes);
+ augSchemaNodeToMethods(augmentPackageName, augTypeBuilder,
+ augChildNodes);
augmentBuilders.put(augTypeName, augTypeBuilder);
return augTypeBuilder;
}
- private List<Type> augmentationBodyToGenTypes(final String augBasePackageName,
- final Set<DataSchemaNode> augChildNodes) {
+ private List<Type> augmentationBodyToGenTypes(
+ final String augBasePackageName,
+ final Set<DataSchemaNode> augChildNodes) {
final List<Type> genTypes = new ArrayList<>();
final List<DataNodeIterator> augSchemaIts = new ArrayList<>();
for (final DataSchemaNode childNode : augChildNodes) {
if ((augContainers != null) && !augContainers.isEmpty()) {
for (final ContainerSchemaNode container : augContainers) {
- genTypes.add(containerToGenType(augBasePackageName, container));
+ genTypes.add(containerToGenType(augBasePackageName,
+ container));
}
}
if ((augLists != null) && !augLists.isEmpty()) {
}
private GeneratedType containerToGenType(final String basePackageName,
- ContainerSchemaNode containerNode) {
+ ContainerSchemaNode containerNode) {
if (containerNode == null) {
return null;
}
- final String packageName = packageNameForGeneratedType(
- basePackageName, containerNode.getPath());
+ final String packageName = packageNameForGeneratedType(basePackageName,
+ containerNode.getPath());
final Set<DataSchemaNode> schemaNodes = containerNode.getChildNodes();
final GeneratedTypeBuilder typeBuilder = addRawInterfaceDefinition(
packageName, containerNode);
if (schemaNode.isAugmenting()) {
continue;
}
- addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);
+ addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode,
+ typeBuilder);
}
}
return typeBuilder;
if ((schemaNodes != null) && (typeBuilder != null)) {
for (final DataSchemaNode schemaNode : schemaNodes) {
if (schemaNode.isAugmenting()) {
- addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);
+ addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode,
+ typeBuilder);
}
}
}
return typeBuilder;
}
- private void addSchemaNodeToBuilderAsMethod(
- final String basePackageName,
+ private void addSchemaNodeToBuilderAsMethod(final String basePackageName,
final DataSchemaNode schemaNode,
final GeneratedTypeBuilder typeBuilder) {
if (schemaNode != null && typeBuilder != null) {
enumBuilder.getPackageName(),
enumBuilder.getName());
}
- ((TypeProviderImpl)typeProvider).putReferencedType(leaf
- .getPath(), returnType);
+ ((TypeProviderImpl) typeProvider).putReferencedType(
+ leaf.getPath(), returnType);
}
if (returnType != null) {
constructGetter(typeBuilder, leafName, leafDesc, returnType);
if (!leaf.isConfiguration()) {
- constructSetter(typeBuilder, leafName, leafDesc, returnType);
+ constructSetter(typeBuilder, leafName, leafDesc,
+ returnType);
}
return true;
}
}
private boolean resolveContainerSchemaNode(final String basePackageName,
- final GeneratedTypeBuilder typeBuilder,
- final ContainerSchemaNode containerNode) {
+ final GeneratedTypeBuilder typeBuilder,
+ final ContainerSchemaNode containerNode) {
if ((containerNode != null) && (typeBuilder != null)) {
final String nodeName = containerNode.getQName().getLocalName();
}
private boolean resolveListSchemaNode(final String basePackageName,
- final GeneratedTypeBuilder typeBuilder,
- final ListSchemaNode schemaNode) {
+ final GeneratedTypeBuilder typeBuilder,
+ final ListSchemaNode schemaNode) {
if ((schemaNode != null) && (typeBuilder != null)) {
final String listName = schemaNode.getQName().getLocalName();
}
private GeneratedTypeBuilder addRawInterfaceDefinition(
- final String packageName, final DataSchemaNode schemaNode) {
+ final String packageName, final SchemaNode schemaNode) {
+ return addRawInterfaceDefinition(packageName, schemaNode, "");
+ }
+
+ private GeneratedTypeBuilder addRawInterfaceDefinition(
+ final String packageName, final SchemaNode schemaNode,
+ final String prefix) {
if (schemaNode == null) {
return null;
}
final String schemaNodeName = schemaNode.getQName().getLocalName();
if ((packageName != null) && (schemaNodeName != null)) {
- final String genTypeName = parseToClassName(schemaNodeName);
+ final String genTypeName = prefix + parseToClassName(schemaNodeName)
+ ;
final GeneratedTypeBuilder newType = new GeneratedTypeBuilderImpl(
packageName, genTypeName);
return setMethod;
}
-
private List<Type> listToGenType(final String basePackageName,
- final ListSchemaNode list) {
+ final ListSchemaNode list) {
if (basePackageName == null) {
throw new IllegalArgumentException(
"Package Name for Generated Type cannot be NULL!");
"List Schema Node cannot be NULL!");
}
- final String packageName = packageNameForGeneratedType(
- basePackageName, list.getPath());
+ final String packageName = packageNameForGeneratedType(basePackageName,
+ list.getPath());
final GeneratedTypeBuilder typeBuilder = resolveListTypeBuilder(
packageName, list);
final List<String> listKeys = listKeys(list);
if (schemaNode.isAugmenting()) {
continue;
}
- addSchemaNodeToListBuilders(basePackageName, schemaNode, typeBuilder,
- genTOBuilder, listKeys);
+ addSchemaNodeToListBuilders(basePackageName, schemaNode,
+ typeBuilder, genTOBuilder, listKeys);
}
return typeBuildersToGenTypes(typeBuilder, genTOBuilder);
}
private void addSchemaNodeToListBuilders(final String basePackageName,
- final DataSchemaNode schemaNode,
- final GeneratedTypeBuilder typeBuilder,
- final GeneratedTOBuilder genTOBuilder,
- final List<String> listKeys) {
+ final DataSchemaNode schemaNode,
+ final GeneratedTypeBuilder typeBuilder,
+ final GeneratedTOBuilder genTOBuilder, final List<String> listKeys) {
if (schemaNode == null) {
throw new IllegalArgumentException(
"Data Schema Node cannot be NULL!");
resolveContainerSchemaNode(basePackageName, typeBuilder,
(ContainerSchemaNode) schemaNode);
} else if (schemaNode instanceof ListSchemaNode) {
- resolveListSchemaNode(basePackageName, typeBuilder, (ListSchemaNode) schemaNode);
+ resolveListSchemaNode(basePackageName, typeBuilder,
+ (ListSchemaNode) schemaNode);
}
}
* @return
*/
private GeneratedTOBuilder resolveListKey(final String packageName,
- final ListSchemaNode list) {
+ final ListSchemaNode list) {
final String listName = list.getQName().getLocalName() + "Key";
return schemaNodeToTransferObjectBuilder(packageName, list, listName);
}
private boolean isPartOfListKey(final LeafSchemaNode leaf,
- final List<String> keys) {
+ final List<String> keys) {
if ((leaf != null) && (keys != null) && (leaf.getQName() != null)) {
final String leafName = leaf.getQName().getLocalName();
if (keys.contains(leafName)) {
final String genTypeName = parseToClassName(schemaNodeName);
GeneratedTypeBuilder typeBuilder = null;
- final Map<String, GeneratedTypeBuilder> builders = genTypeBuilders.get(packageName);
+ final Map<String, GeneratedTypeBuilder> builders = genTypeBuilders
+ .get(packageName);
if (builders != null) {
typeBuilder = builders.get(genTypeName);
}
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
+import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.*;
import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
final LeafrefTypeDefinition leafref = (LeafrefTypeDefinition) baseTypeDef;
returnType = provideTypeForLeafref(leafref);
} else if (baseTypeDef instanceof IdentityrefTypeDefinition) {
-
+ final IdentityrefTypeDefinition idref = (IdentityrefTypeDefinition)typeDefinition;
+ returnType = returnTypeForIdentityref(idref);
} else if (baseTypeDef instanceof EnumTypeDefinition) {
final EnumTypeDefinition enumTypeDef = (EnumTypeDefinition) baseTypeDef;
returnType = resolveEnumFromTypeDefinition(enumTypeDef,
final LeafrefTypeDefinition leafref = (LeafrefTypeDefinition) typeDefinition;
returnType = provideTypeForLeafref(leafref);
} else if (typeDefinition instanceof IdentityrefTypeDefinition) {
-
+ final IdentityrefTypeDefinition idref = (IdentityrefTypeDefinition)typeDefinition;
+ returnType = returnTypeForIdentityref(idref);
} else {
returnType = BaseYangTypes.BASE_YANG_TYPES_PROVIDER
.javaTypeForSchemaDefinitionType(typeDefinition);
// }
return returnType;
}
+
+ private Type returnTypeForIdentityref(IdentityrefTypeDefinition idref) {
+ QName baseIdQName = idref.getIdentity();
+ Module module = schemaContext.findModuleByNamespace(baseIdQName.getNamespace());
+ IdentitySchemaNode identity = null;
+ for(IdentitySchemaNode id : module.getIdentities()) {
+ if(id.getQName().equals(baseIdQName)) {
+ identity = id;
+ }
+ }
+ if(identity == null) {
+ throw new IllegalArgumentException("Target identity '" + baseIdQName + "' do not exists");
+ }
+
+ final String basePackageName = moduleNamespaceToPackageName(module);
+ final String packageName = packageNameForGeneratedType(basePackageName, identity.getPath());
+ final String genTypeName = parseToClassName(identity.getQName().getLocalName());
+
+ Type baseType = Types.typeForClass(Class.class);
+ Type paramType = Types.wildcardTypeFor(packageName, genTypeName);
+ Type returnType = Types.parameterizedTypeFor(baseType, paramType);
+ return returnType;
+ }
public Type generatedTypeForExtendedDefinitionType(
final TypeDefinition<?> typeDefinition) {
assertTrue(genTypes != null);
assertEquals("Expected count of all Generated Types from yang models " +
- "is 22", 22, genTypes.size());
+ "is 22", 25, genTypes.size());
GeneratedType genInterface = null;
for (final Type type : genTypes) {
final BindingGenerator bindingGen = new BindingGeneratorImpl();
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(2, genTypes.size());
+ assertEquals(3, genTypes.size());
final Type type = genTypes.get(1);
assertTrue(type instanceof Enumeration);
assertNotNull("genTypes is null", genTypes);
assertFalse("genTypes is empty", genTypes.isEmpty());
assertEquals("Expected Generated Types from provided sub set of " +
- "modules should be 23!", 23,
+ "modules should be 23!", 25,
genTypes.size());
}
assertNotNull("genTypes is null", genTypes);
assertFalse("genTypes is empty", genTypes.isEmpty());
assertEquals("Expected Generated Types from provided sub set of " +
- "modules should be 25!", 25, genTypes.size());
+ "modules should be 25!", 28, genTypes.size());
}
}
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(27, genTypes.size());
+ assertEquals(29, genTypes.size());
}
@Test
final BindingGenerator bindingGen = new BindingGeneratorImpl();
final List<Type> genTypes = bindingGen.generateTypes(context);
- assertEquals(53, genTypes.size());
+ assertEquals(57, genTypes.size());
assertTrue(genTypes != null);
GeneratedTransferObject gtIfcKey = null;
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(3, genTypes.size());
+ assertEquals(4, genTypes.size());
final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(3, genTypes.size());
+ assertEquals(4, genTypes.size());
final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(5, genTypes.size());
+ assertEquals(6, genTypes.size());
int genTypesCount = 0;
int genTOsCount = 0;
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(7, genTypes.size());
+ assertEquals(8, genTypes.size());
int genTypesCount = 0;
int genTOsCount = 0;
}
}
- assertEquals(5, genTypesCount);
+ assertEquals(6, genTypesCount);
assertEquals(2, genTOsCount);
}
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(14, genTypes.size());
+ assertEquals(15, genTypes.size());
int genTypesCount = 0;
int genTOsCount = 0;
}
}
- assertEquals(11, genTypesCount);
+ assertEquals(12, genTypesCount);
assertEquals(3, genTOsCount);
}
}
import java.util.Map;\r
import java.util.Set;\r
\r
+import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;\r
import org.opendaylight.controller.sal.binding.model.api.ConcreteType;\r
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;\r
import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;\r
import org.opendaylight.controller.sal.binding.model.api.Type;\r
+import org.opendaylight.controller.sal.binding.model.api.WildcardType;\r
import org.opendaylight.controller.yang.binding.Augmentable;\r
import org.opendaylight.controller.yang.binding.Augmentation;\r
+import org.opendaylight.controller.yang.binding.BaseIdentity;\r
import org.opendaylight.controller.yang.binding.DataObject;\r
\r
public final class Types {\r
\r
/**\r
* Returns an instance of {@link ConcreteType} describing the class\r
- * \r
+ *\r
* @param cls\r
* Class to describe\r
* @return Description of class\r
/**\r
* Returns an instance of {@link ParameterizedType} describing the typed\r
* {@link Map}<K,V>\r
- * \r
+ *\r
* @param keyType\r
* Key Type\r
* @param valueType\r
/**\r
* Returns an instance of {@link ParameterizedType} describing the typed\r
* {@link Set}<V> with concrete type of value.\r
- * \r
+ *\r
* @param valueType\r
* Value Type\r
* @return Description of generic type instance of Set\r
/**\r
* Returns an instance of {@link ParameterizedType} describing the typed\r
* {@link List}<V> with concrete type of value.\r
- * \r
+ *\r
* @param valueType\r
* Value Type\r
* @return Description of type instance of List\r
return parameterizedTypeFor(LIST_TYPE, valueType);\r
}\r
\r
+ public static GeneratedTransferObject getBaseIdentityTO() {\r
+ Class<BaseIdentity> cls = BaseIdentity.class;\r
+ GeneratedTOBuilderImpl gto = new GeneratedTOBuilderImpl(cls.getPackage().getName(),\r
+ cls.getSimpleName());\r
+ return gto.toInstance();\r
+ }\r
+\r
/**\r
- * \r
+ *\r
* @param type\r
* @param parameters\r
* @return\r
Type... parameters) {\r
return new ParametrizedTypeImpl(type, parameters);\r
}\r
- \r
+\r
+ public static WildcardType wildcardTypeFor(String packageName, String typeName) {\r
+ return new WildcardTypeImpl(packageName, typeName);\r
+ }\r
+\r
public static ParameterizedType augmentableTypeFor(Type valueType) {\r
final Type augmentable = typeForClass(Augmentable.class);\r
return parameterizedTypeFor(augmentable, valueType);\r
}\r
- \r
+\r
public static ParameterizedType augmentationTypeFor(Type valueType) {\r
final Type augmentation = typeForClass(Augmentation.class);\r
return parameterizedTypeFor(augmentation, valueType);\r
}\r
- \r
+\r
private static class ConcreteTypeImpl extends AbstractBaseType implements\r
ConcreteType {\r
private ConcreteTypeImpl(String pkName, String name) {\r
}\r
\r
}\r
+\r
+ private static class WildcardTypeImpl extends AbstractBaseType\r
+ implements WildcardType {\r
+ public WildcardTypeImpl(String packageName, String typeName) {\r
+ super(packageName, typeName);\r
+ }\r
+ }\r
+\r
}\r
import org.opendaylight.controller.sal.binding.model.api.Constant;
import org.opendaylight.controller.sal.binding.model.api.Enumeration;
import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferIdentityObject;
import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
import org.opendaylight.controller.sal.binding.model.api.Type;
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
import org.opendaylight.controller.sal.binding.model.api.type.builder.MethodSignatureBuilder;
-public final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
+public class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
private String packageName;
private final String name;
private String comment = "";
-
+
private GeneratedTransferObject extendsType;
private final List<Type> implementsTypes = new ArrayList<Type>();
private final List<EnumBuilder> enumerations = new ArrayList<EnumBuilder>();
}
return null;
}
-
+
@Override
public boolean addImplementsType(final Type genType) {
if (genType != null) {
}
return false;
}
-
+
@Override
public EnumBuilder addEnumeration(String name) {
final String innerPackageName = packageName + "." + this.name;
@Override
public GeneratedTransferObject toInstance() {
- return new GeneratedTransferObjectImpl(packageName, name, comment,
- annotationBuilders, extendsType, implementsTypes, constantDefintions, enumerations,
- methodDefinitions, properties, equalsProperties,
- hashProperties, toStringProperties);
+ return new GeneratedTransferObjectImpl(packageName, name, comment,
+ annotationBuilders, extendsType, implementsTypes,
+ constantDefintions, enumerations, methodDefinitions,
+ properties, equalsProperties, hashProperties,
+ toStringProperties);
+ }
+
+ @Override
+ public GeneratedTransferObject toIdentityInstance() {
+ return new GeneratedTransferIdentityObjectImpl(packageName, name, comment,
+ annotationBuilders, extendsType, implementsTypes,
+ constantDefintions, enumerations, methodDefinitions,
+ properties, equalsProperties, hashProperties,
+ toStringProperties);
}
private static final class GeneratedPropertyBuilderImpl implements
@Override
public GeneratedProperty toInstance(final Type definingType) {
- return new GeneratedPropertyImpl(name, comment, annotationBuilders, definingType,
- returnType, isFinal, isReadOnly, parameters, accessModifier);
+ return new GeneratedPropertyImpl(name, comment, annotationBuilders,
+ definingType, returnType, isFinal, isReadOnly, parameters,
+ accessModifier);
}
}
private final boolean isReadOnly;
private final List<MethodSignature.Parameter> parameters;
private final AccessModifier modifier;
-
+
public GeneratedPropertyImpl(final String name, final String comment,
- final List<AnnotationTypeBuilder> annotationBuilders, final Type parent, final Type returnType,
+ final List<AnnotationTypeBuilder> annotationBuilders,
+ final Type parent, final Type returnType,
final boolean isFinal, final boolean isReadOnly,
final List<Parameter> parameters, final AccessModifier modifier) {
super();
public List<AnnotationType> getAnnotations() {
return annotations;
}
-
+
@Override
public Type getReturnType() {
return returnType;
return isFinal;
}
-
-
@Override
public int hashCode() {
final int prime = 31;
if (other.returnType != null) {
return false;
}
- } else if (!returnType.getPackageName().equals(other.returnType.getPackageName())) {
+ } else if (!returnType.getPackageName().equals(
+ other.returnType.getPackageName())) {
return false;
} else if (!returnType.getName().equals(other.returnType.getName())) {
return false;
}
}
- private static final class GeneratedTransferObjectImpl implements
+ private static class GeneratedTransferObjectImpl implements
GeneratedTransferObject {
private final String packageName;
private final List<Type> implementsTypes;
public GeneratedTransferObjectImpl(final String packageName,
- final String name,
- final String comment,
+ final String name, final String comment,
final List<AnnotationTypeBuilder> annotationBuilders,
final GeneratedTransferObject extendsType,
final List<Type> implementsTypes,
this.comment = comment;
this.annotations = toUnmodifiableAnnotations(annotationBuilders);
this.extendsType = extendsType;
- this.implementsTypes = Collections.unmodifiableList(implementsTypes);
+ this.implementsTypes = Collections
+ .unmodifiableList(implementsTypes);
this.constants = toUnmodifiableConstant(constantBuilders);
this.enumerations = toUnmodifiableEnumerations(enumBuilders);
this.properties = toUnmodifiableProperties(propBuilers);
public Type getParentType() {
return null;
}
-
+
@Override
public String getComment() {
return comment;
}
-
+
@Override
public List<AnnotationType> getAnnotations() {
return annotations;
}
-
+
@Override
public List<Type> getImplements() {
return implementsTypes;
public GeneratedTransferObject getExtends() {
return extendsType;
}
-
+
@Override
public List<Enumeration> getEnumDefintions() {
return enumerations;
return builder.toString();
}
}
+
+ private static final class GeneratedTransferIdentityObjectImpl extends
+ GeneratedTransferObjectImpl implements
+ GeneratedTransferIdentityObject {
+ public GeneratedTransferIdentityObjectImpl(final String packageName,
+ final String name, final String comment,
+ final List<AnnotationTypeBuilder> annotationBuilders,
+ final GeneratedTransferObject extendsType,
+ final List<Type> implementsTypes,
+ final List<ConstantBuilder> constantBuilders,
+ final List<EnumBuilder> enumBuilders,
+ final List<MethodSignatureBuilder> methodBuilders,
+ final List<GeneratedPropertyBuilder> propBuilers,
+ final List<GeneratedPropertyBuilder> equalsBuilers,
+ final List<GeneratedPropertyBuilder> hashCodeBuilers,
+ final List<GeneratedPropertyBuilder> stringBuilers) {
+ super(packageName, name, comment, annotationBuilders, extendsType,
+ implementsTypes, constantBuilders, enumBuilders,
+ methodBuilders, propBuilers, equalsBuilers,
+ hashCodeBuilers, stringBuilers);
+ }
+ }
}
import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;
import org.opendaylight.controller.sal.binding.model.api.Enumeration;
import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferIdentityObject;
import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.controller.sal.binding.model.api.Type;
@Override
public Writer generate(Type type) throws IOException {
final Writer writer = new StringWriter();
+ boolean isIdentity = type instanceof GeneratedTransferIdentityObject;
+
if (type instanceof GeneratedTransferObject) {
GeneratedTransferObject genTO = (GeneratedTransferObject) type;
imports = GeneratorUtil.createImports(genTO);
writer.write(NL);
writer.write(GeneratorUtil.createClassDeclaration(genTO, "",
- imports));
+ imports, isIdentity));
writer.write(NL);
writer.write(NL);
}
writer.write(NL);
writer.write(GeneratorUtil.createConstructor(genTO, TAB,
- imports) + NL);
+ imports, isIdentity) + NL);
writer.write(NL);
for (GeneratedProperty field : fields) {
writer.write(GeneratorUtil.createGetter(field, TAB,
package org.opendaylight.controller.sal.java.api.generator;
final class Constants {
-
public static final String IFC = "interface";
public static final String CLASS = "class";
public static final String PKG = "package";
public static final String COMMA = ",";
public static final String NL = "\n";
public static final String SC = ";";
- public static final String TAB = "\t";
+ public static final String TAB = " ";
public static final String PUBLIC = "public";
public static final String PRIVATE = "private";
+ public static final String PROTECTED = "protected";
public static final String STATIC = "static";
+ public static final String ABSTRACT = "abstract";
public static final String FINAL = "final";
public static final String EXTENDS = "extends";
public static final String IMPLEMENTS = "implements";
import org.opendaylight.controller.sal.binding.model.api.MethodSignature.Parameter;
import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;
import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.sal.binding.model.api.WildcardType;
public final class GeneratorUtil {
- private GeneratorUtil() {
- }
-
- public static String createIfcDeclaration(final GeneratedType genType,
- final String indent,
- final Map<String, LinkedHashMap<String, Integer>> availableImports) {
- return createFileDeclaration(IFC, genType, indent, availableImports);
- }
-
- public static String createClassDeclaration(
- final GeneratedTransferObject genTransferObject,
- final String indent,
- final Map<String, LinkedHashMap<String, Integer>> availableImports) {
- return createFileDeclaration(CLASS, genTransferObject, indent,
- availableImports);
- }
-
- public static String createPackageDeclaration(final String packageName) {
- return PKG + GAP + packageName + SC;
- }
-
- private static String createFileDeclaration(final String type,
- final GeneratedType genType, final String indent,
- final Map<String, LinkedHashMap<String, Integer>> availableImports) {
- final StringBuilder builder = new StringBuilder();
- final String currentPkg = genType.getPackageName();
-
- createComment(builder, genType.getComment(), indent);
-
- if (!genType.getAnnotations().isEmpty()) {
- final List<AnnotationType> annotations = genType.getAnnotations();
- appendAnnotations(builder, annotations);
- builder.append(NL);
- }
- builder.append(PUBLIC + GAP + type + GAP + genType.getName() + GAP);
-
- if (genType instanceof GeneratedTransferObject) {
- GeneratedTransferObject genTO = (GeneratedTransferObject) genType;
-
- if (genTO.getExtends() != null) {
- builder.append(EXTENDS + GAP);
- builder.append(genTO.getExtends() + GAP);
- }
- }
-
- final List<Type> genImplements = genType.getImplements();
- if (!genImplements.isEmpty()) {
- if (genType instanceof GeneratedTransferObject) {
- builder.append(IMPLEMENTS + GAP);
- } else {
- builder.append(EXTENDS + GAP);
- }
- builder.append(getExplicitType(genImplements.get(0),
- availableImports, currentPkg));
-
- for (int i = 1; i < genImplements.size(); ++i) {
- builder.append(", ");
- builder.append(getExplicitType(genImplements.get(i),
- availableImports, currentPkg));
- }
- }
-
- builder.append(GAP + LCB);
- return builder.toString();
- }
-
- private static StringBuilder appendAnnotations(final StringBuilder builder,
- final List<AnnotationType> annotations) {
- if ((builder != null) && (annotations != null)) {
- for (final AnnotationType annotation : annotations) {
- builder.append("@");
- builder.append(annotation.getPackageName());
- builder.append(".");
- builder.append(annotation.getName());
-
- if (annotation.containsParameters()) {
- builder.append("(");
- final List<AnnotationType.Parameter> parameters = annotation
- .getParameters();
- appendAnnotationParams(builder, parameters);
- builder.append(")");
- }
- }
- }
- return builder;
- }
-
- private static StringBuilder appendAnnotationParams(
- final StringBuilder builder,
- final List<AnnotationType.Parameter> parameters) {
- if (parameters != null) {
- int i = 0;
- for (final AnnotationType.Parameter param : parameters) {
- if (param == null) {
- continue;
- }
- if (i > 0) {
- builder.append(", ");
- }
- final String paramName = param.getName();
- if (param.getValue() != null) {
- builder.append(paramName);
- builder.append(" = ");
- builder.append(param.getValue());
- } else {
- builder.append(paramName);
- builder.append(" = {");
- final List<String> values = param.getValues();
- builder.append(values.get(0));
- for (int j = 1; j < values.size(); ++j) {
- builder.append(", ");
- builder.append(values.get(j));
- }
- builder.append("}");
- }
- i++;
- }
- }
- return builder;
- }
-
- public static String createConstant(final Constant constant,
- final String indent,
- final Map<String, LinkedHashMap<String, Integer>> availableImports,
- final String&nb