into api and implementation bundles.
Change-Id: I04d5d89562316cafa89a5ee46e08eb724733711a
Signed-off-by: taochang <taochang@cisco.com>
import junit.framework.TestCase;\r
\r
import org.opendaylight.controller.hosttracker.IfIptoHost;\r
-import org.opendaylight.controller.hosttracker.HostTracker;\r
\r
import org.opendaylight.controller.switchmanager.ISwitchManager;\r
-import org.opendaylight.controller.switchmanager.internal.SwitchManagerImpl;\r
-\r
\r
public class ArphandlerTest extends TestCase {\r
\r
ah = new ArpHandler();\r
Assert.assertTrue(ah != null);\r
\r
- HostTracker hostTracker = null;\r
- hostTracker = new HostTracker();\r
- ah.setHostTracker(hostTracker);\r
- IfIptoHost ht= ah.getHostTracker();\r
- Assert.assertTrue(ht.equals(hostTracker));\r
- ah.unsetHostTracker(hostTracker);\r
- ht= ah.getHostTracker();\r
- Assert.assertTrue(ht == null);\r
- \r
- ah.setHostListener(hostTracker);\r
- ah.unsetHostListener(hostTracker);\r
- \r
- ISwitchManager swManager = new SwitchManagerImpl();\r
- ah.setSwitchManager(swManager);\r
- ah.unsetSwitchManager(swManager);\r
- \r
}\r
\r
-\r
}\r
<module>../../arphandler</module>
<module>../../forwardingrulesmanager/api</module>
<module>../../forwardingrulesmanager/implementation</module>
- <module>../../hosttracker</module>
+ <module>../../hosttracker/api</module>
+ <module>../../hosttracker/implementation</module>
+ <module>../../hosttracker/integrationtest</module>
<module>../../containermanager/api</module>
<module>../../containermanager/implementation</module>
- <module>../../switchmanager</module>
+ <module>../../switchmanager/api</module>
+ <module>../../switchmanager/implementation</module>
<module>../../statisticsmanager/api</module>
<module>../../statisticsmanager/implementation</module>
- <module>../../statisticsmanager/integrationtest</module>
+ <module>../../statisticsmanager/integrationtest</module>
<module>../../topologymanager</module>
<module>../../usermanager</module>
<module>../../security</module>
-<?xml version="1.0" encoding="UTF-8"?>
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.opendaylight</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../commons/opendaylight</relativePath>
- </parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>hosttracker</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>
- <Export-Package>
- org.opendaylight.controller.hosttracker,
- org.opendaylight.controller.hosttracker.hostAware
- </Export-Package>
- <Import-Package>
- org.opendaylight.controller.sal.core,
- org.opendaylight.controller.sal.utils,
- org.opendaylight.controller.hosttracker,
- org.opendaylight.controller.hosttracker.hostAware,
- org.opendaylight.controller.topologymanager,
- org.opendaylight.controller.sal.packet.address,
- org.opendaylight.controller.switchmanager,
- org.opendaylight.controller.clustering.services,
- javax.xml.bind.annotation,
- javax.xml.bind,
- org.apache.felix.dm,
- org.apache.commons.lang3.builder,
- org.osgi.service.component,
- org.slf4j,
- org.eclipse.osgi.framework.console,
- org.osgi.framework
- </Import-Package>
- <Bundle-Activator>
- org.opendaylight.controller.hosttracker.internal.Activator
- </Bundle-Activator>
- <Service-Component>
- </Service-Component>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>topologymanager</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>clustering.services</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>commons.opendaylight</artifactId>\r
+ <version>1.4.0-SNAPSHOT</version>\r
+ <relativePath>../../commons/opendaylight</relativePath>\r
+ </parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>hosttracker</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ <packaging>bundle</packaging>\r
+\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.felix</groupId>\r
+ <artifactId>maven-bundle-plugin</artifactId>\r
+ <version>2.3.6</version>\r
+ <extensions>true</extensions>\r
+ <configuration>\r
+ <instructions>\r
+ <Export-Package>\r
+ org.opendaylight.controller.hosttracker,\r
+ org.opendaylight.controller.hosttracker.hostAware\r
+ </Export-Package>\r
+ <Import-Package>\r
+ org.opendaylight.controller.sal.core,\r
+ org.opendaylight.controller.sal.utils,\r
+ org.opendaylight.controller.topologymanager,\r
+ org.opendaylight.controller.sal.packet.address,\r
+ org.opendaylight.controller.switchmanager,\r
+ org.opendaylight.controller.clustering.services,\r
+ javax.xml.bind.annotation,\r
+ javax.xml.bind,\r
+ org.apache.felix.dm,\r
+ org.apache.commons.lang3.builder,\r
+ org.osgi.service.component,\r
+ org.slf4j,\r
+ org.eclipse.osgi.framework.console,\r
+ org.osgi.framework\r
+ </Import-Package>\r
+ </instructions>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>topologymanager</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>switchmanager</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>clustering.services</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>sal</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ </dependencies>\r
+</project>\r
package org.opendaylight.controller.hosttracker.hostAware;
import java.net.InetAddress;
+import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
+
/**
* This Interface defines the methods to trigger the discovery of
--- /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.opendaylight</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../../commons/opendaylight</relativePath>
+ </parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>hosttracker.implementation</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <!-- Sonar properties using jacoco to retrieve integration test results -->
+ <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+ <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
+ <sonar.jacoco.Reportpath>target/jacobo.exec</sonar.jacoco.Reportpath>
+ <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <sonar.language>java</sonar.language>
+ </properties>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.5.3.201107060350</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.6</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ </Export-Package>
+ <Import-Package>
+ org.opendaylight.controller.sal.core,
+ org.opendaylight.controller.sal.utils,
+ org.opendaylight.controller.hosttracker,
+ org.opendaylight.controller.topologymanager,
+ org.opendaylight.controller.sal.packet.address,
+ org.opendaylight.controller.switchmanager,
+ org.opendaylight.controller.clustering.services,
+ org.opendaylight.controller.hosttracker.hostAware,
+ javax.xml.bind.annotation,
+ javax.xml.bind,
+ org.apache.felix.dm,
+ org.apache.commons.lang3.builder,
+ org.osgi.service.component,
+ org.slf4j,
+ org.eclipse.osgi.framework.console,
+ org.osgi.framework
+ </Import-Package>
+ <Bundle-Activator>
+ org.opendaylight.controller.hosttracker.internal.Activator
+ </Bundle-Activator>
+ <Service-Component>
+ </Service-Component>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <includes>org.opendaylight.controller.*</includes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>pre-test</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>post-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>topologymanager</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>clustering.services</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>hosttracker</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
package org.opendaylight.controller.hosttracker.internal;
import org.apache.felix.dm.Component;
-import org.opendaylight.controller.hosttracker.HostTracker;
+import org.opendaylight.controller.hosttracker.internal.HostTracker;
import org.opendaylight.controller.hosttracker.IfHostListener;
import org.opendaylight.controller.hosttracker.IfIptoHost;
import org.opendaylight.controller.hosttracker.IfNewHostNotify;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.hosttracker;
+package org.opendaylight.controller.hosttracker.internal;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.opendaylight.controller.clustering.services.IClusterServices;
import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
import org.opendaylight.controller.hosttracker.hostAware.IHostFinder;
+import org.opendaylight.controller.hosttracker.IfHostListener;
+import org.opendaylight.controller.hosttracker.IfIptoHost;
+import org.opendaylight.controller.hosttracker.IfNewHostNotify;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.core.Edge;
import org.opendaylight.controller.sal.core.Host;
* Provides a mechanism for applications to do an inline Host Discovery as opposed
* to a delayed discovery
*/
-package org.opendaylight.controller.hosttracker;
+package org.opendaylight.controller.hosttracker.internal;
/**
* This Class provides methods to discover Host through a blocking call
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
*/\r
\r
-package org.opendaylight.controller.hosttracker;\r
+package org.opendaylight.controller.hosttracker.internal;\r
\r
\r
import java.net.InetAddress;\r
--- /dev/null
+<configuration scan="true">\r
+\r
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+ <encoder>\r
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n\r
+ </pattern>\r
+ </encoder>\r
+ </appender>\r
+\r
+ <root level="error">\r
+ <appender-ref ref="STDOUT" />\r
+ </root>\r
+</configuration>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<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"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>commons.opendaylight</artifactId>\r
+ <version>1.4.0-SNAPSHOT</version>\r
+ <relativePath>../../../opendaylight/commons/opendaylight</relativePath>\r
+ </parent>\r
+\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>hosttracker.integrationtest</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ \r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>hosttracker</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>hosttracker.implementation</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>sal</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>sal.implementation</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>containermanager</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ \r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>containermanager.implementation</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>arphandler</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>clustering.services</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ \r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>clustering.services-implementation</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>switchmanager</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>switchmanager.implementation</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>configuration</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>configuration.implementation</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>topologymanager</artifactId>\r
+ <version>0.4.0-SNAPSHOT</version>\r
+ </dependency>\r
+ </dependencies>\r
+ <properties>\r
+ <!-- Sonar jacoco plugin to get integration test coverage info -->\r
+ <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>\r
+ <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>\r
+ <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>\r
+ <sonar.language>java</sonar.language>\r
+ </properties>\r
+ \r
+ <build>\r
+ <pluginManagement>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.jacoco</groupId>\r
+ <artifactId>jacoco-maven-plugin</artifactId>\r
+ <version>0.5.3.201107060350</version>\r
+ </plugin>\r
+ </plugins>\r
+ </pluginManagement>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.jacoco</groupId>\r
+ <artifactId>jacoco-maven-plugin</artifactId>\r
+ <version>0.5.3.201107060350</version>\r
+ <configuration>\r
+ <destFile>../implementation/target/jacoco-it.exec</destFile>\r
+ <includes>org.opendaylight.controller.*</includes>\r
+ </configuration>\r
+ <executions>\r
+ <execution>\r
+ <id>pre-test</id>\r
+ <goals>\r
+ <goal>prepare-agent</goal>\r
+ </goals>\r
+ </execution>\r
+ <execution>\r
+ <id>post-test</id>\r
+ <configuration>\r
+ <skip>true</skip>\r
+ </configuration>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+\r
+</project>\r
--- /dev/null
+\r
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.controller.hosttracker.internal;\r
+\r
+\r
+import java.net.InetAddress;\r
+import java.net.UnknownHostException;\r
+import java.util.ArrayList;\r
+import java.util.HashSet;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+import java.util.Map.Entry;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.osgi.framework.ServiceReference;\r
+import org.osgi.framework.Bundle;\r
+import javax.inject.Inject;\r
+\r
+import org.eclipse.osgi.framework.console.CommandProvider;\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.junit.Before;\r
+import org.junit.After;\r
+import org.junit.runner.RunWith;\r
+import org.opendaylight.controller.sal.core.Node;\r
+import org.opendaylight.controller.sal.core.NodeConnector;\r
+import org.opendaylight.controller.sal.core.UpdateType;\r
+import org.opendaylight.controller.sal.utils.NodeConnectorCreator;\r
+import org.opendaylight.controller.sal.utils.NodeCreator;\r
+import org.opendaylight.controller.sal.utils.Status;\r
+//import org.opendaylight.controller.hosttracker.*;\r
+import org.opendaylight.controller.hosttracker.IfIptoHost;\r
+import org.opendaylight.controller.hosttracker.IfHostListener;\r
+import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;\r
+import org.opendaylight.controller.switchmanager.IInventoryListener;\r
+import org.opendaylight.controller.switchmanager.ISwitchManager;\r
+import org.opendaylight.controller.switchmanager.ISwitchManagerAware;\r
+import org.opendaylight.controller.topologymanager.ITopologyManagerAware;\r
+\r
+import org.ops4j.pax.exam.junit.PaxExam;\r
+import org.ops4j.pax.exam.util.Filter;\r
+import org.osgi.framework.BundleContext;\r
+import static org.junit.Assert.*;\r
+import org.ops4j.pax.exam.junit.Configuration;\r
+import static org.ops4j.pax.exam.CoreOptions.*;\r
+\r
+import org.ops4j.pax.exam.Option;\r
+import org.ops4j.pax.exam.util.PathUtils;\r
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;\r
+import org.ops4j.pax.exam.spi.reactors.PerClass;\r
+\r
+@RunWith(PaxExam.class)\r
+public class HostTrackerIntegrationTest {\r
+ private Logger log = LoggerFactory\r
+ .getLogger(HostTrackerIntegrationTest.class);\r
+ // get the OSGI bundle context\r
+ @Inject\r
+ private BundleContext bc;\r
+ \r
+ private IfIptoHost hosttracker = null;\r
+ private ISwitchManagerAware switchManagerAware = null;\r
+ private IInventoryListener invtoryListener = null;\r
+ private IfHostListener hostListener = null;\r
+ private ITopologyManagerAware topologyManagerAware = null;\r
+ \r
+ // Configure the OSGi container\r
+ @Configuration\r
+ public Option[] config() {\r
+ return options(\r
+ //\r
+ systemProperty("logback.configurationFile").value(\r
+ "file:" + PathUtils.getBaseDir()\r
+ + "/src/test/resources/logback.xml"),\r
+ // To start OSGi console for inspection remotely\r
+ systemProperty("osgi.console").value("2401"),\r
+ // Set the systemPackages (used by clustering)\r
+ systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),\r
+ // List framework bundles\r
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",\r
+ "1.0.0.v20120522-1841"),\r
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",\r
+ "1.0.400.v20120522-2049"),\r
+ mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",\r
+ "3.3.100.v20120522-1822"),\r
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",\r
+ "1.4.0.v20120522-1841"),\r
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",\r
+ "0.8.0.v201108120515"),\r
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",\r
+ "0.8.0.v201108120515"),\r
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",\r
+ "0.8.0.v201110170705"),\r
+ // List logger bundles\r
+ mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),\r
+ mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),\r
+ mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),\r
+ mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),\r
+ \r
+ // List all the bundles on which the test case depends\r
+ mavenBundle("org.opendaylight.controller", "sal",\r
+ "0.4.0-SNAPSHOT"),\r
+ mavenBundle("org.opendaylight.controller", "sal.implementation",\r
+ "0.4.0-SNAPSHOT"),\r
+\r
+ // needed by statisticsmanager\r
+ mavenBundle("org.opendaylight.controller", "containermanager",\r
+ "0.4.0-SNAPSHOT"),\r
+ mavenBundle("org.opendaylight.controller", "containermanager.implementation",\r
+ "0.4.0-SNAPSHOT"),\r
+ \r
+ mavenBundle("org.opendaylight.controller",\r
+ "clustering.services", "0.4.0-SNAPSHOT"),\r
+ mavenBundle("org.opendaylight.controller",\r
+ "clustering.services-implementation", "0.4.0-SNAPSHOT"),\r
+\r
+ // needed by forwardingrulesmanager\r
+ mavenBundle("org.opendaylight.controller", "switchmanager",\r
+ "0.4.0-SNAPSHOT"),\r
+ mavenBundle("org.opendaylight.controller", "switchmanager.implementation",\r
+ "0.4.0-SNAPSHOT"),\r
+ mavenBundle("org.opendaylight.controller", "configuration",\r
+ "0.4.0-SNAPSHOT"),\r
+ mavenBundle("org.opendaylight.controller",\r
+ "configuration.implementation", "0.4.0-SNAPSHOT"),\r
+ mavenBundle("org.opendaylight.controller", "hosttracker",\r
+ "0.4.0-SNAPSHOT"),\r
+ mavenBundle("org.opendaylight.controller", "hosttracker.implementation",\r
+ "0.4.0-SNAPSHOT"),\r
+\r
+ // needed by hosttracker\r
+ mavenBundle("org.opendaylight.controller", "topologymanager",\r
+ "0.4.0-SNAPSHOT"),\r
+ mavenBundle("org.opendaylight.controller", "arphandler",\r
+ "0.4.0-SNAPSHOT"),\r
+\r
+\r
+ mavenBundle("org.jboss.spec.javax.transaction",\r
+ "jboss-transaction-api_1.1_spec", "1.0.1.Final"),\r
+ mavenBundle("org.apache.commons", "commons-lang3", "3.1"),\r
+ mavenBundle("org.apache.felix",\r
+ "org.apache.felix.dependencymanager", "3.1.0"),\r
+ junitBundles());\r
+ }\r
+\r
+ private String stateToString(int state) {\r
+ switch (state) {\r
+ case Bundle.ACTIVE:\r
+ return "ACTIVE";\r
+ case Bundle.INSTALLED:\r
+ return "INSTALLED";\r
+ case Bundle.RESOLVED:\r
+ return "RESOLVED";\r
+ case Bundle.UNINSTALLED:\r
+ return "UNINSTALLED";\r
+ default:\r
+ return "Not CONVERTED";\r
+ }\r
+ }\r
+\r
+ @Before\r
+ public void areWeReady() {\r
+ assertNotNull(bc);\r
+ boolean debugit = false;\r
+ Bundle b[] = bc.getBundles();\r
+ for (int i = 0; i < b.length; i++) {\r
+ int state = b[i].getState();\r
+ if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {\r
+ log.debug("Bundle:" + b[i].getSymbolicName() + " state:"\r
+ + stateToString(state));\r
+ debugit = true;\r
+ }\r
+ }\r
+ if (debugit) {\r
+ log.debug("Do some debugging because some bundle is "\r
+ + "unresolved");\r
+ }\r
+\r
+ // Assert if true, if false we are good to go!\r
+ assertFalse(debugit);\r
+\r
+ // Now lets create a hosttracker for testing purpose\r
+ ServiceReference s = bc\r
+ .getServiceReference(IfIptoHost.class.getName());\r
+ if (s != null) {\r
+ this.hosttracker = (IfIptoHost)bc.getService(s);\r
+ this.switchManagerAware = (ISwitchManagerAware) this.hosttracker;\r
+ this.invtoryListener = (IInventoryListener) this.hosttracker;\r
+ this.hostListener = (IfHostListener) this.hosttracker;\r
+ this.topologyManagerAware = (ITopologyManagerAware) this.hosttracker;\r
+ }\r
+\r
+ // If StatisticsManager is null, cannot run tests.\r
+ assertNotNull(this.hosttracker);\r
+ }\r
+ \r
+ \r
+ @Test\r
+ public void testStaticHost() throws UnknownHostException {\r
+ String ip;\r
+ \r
+ assertNotNull(this.hosttracker);\r
+ \r
+ // create one node and two node connectors\r
+ Node node1 = NodeCreator.createOFNode(1L);\r
+ NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector((short) 1, node1);\r
+ NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1);\r
+ \r
+ // test addStaticHost(), store into inactive host DB \r
+ Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66",\r
+ nc1_1, "0");\r
+ Assert.assertTrue(st.isSuccess());\r
+ st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77",\r
+ nc1_2, "0");\r
+ Assert.assertTrue(st.isSuccess());\r
+ \r
+ // check inactive DB\r
+ Iterator<HostNodeConnector> hnci = this.hosttracker.getInactiveStaticHosts().iterator();\r
+ while (hnci.hasNext()) {\r
+ ip = hnci.next().getNetworkAddressAsString();\r
+ Assert.assertTrue(ip.equals("192.168.0.8") || ip.equals("192.168.0.13"));\r
+ }\r
+ \r
+ // check active host DB\r
+ hnci = this.hosttracker.getActiveStaticHosts().iterator();\r
+ Assert.assertFalse(hnci.hasNext());\r
+ \r
+ // test removeStaticHost()\r
+ st = this.hosttracker.removeStaticHost("192.168.0.8");\r
+ Assert.assertTrue(st.isSuccess());\r
+\r
+ hnci = this.hosttracker.getInactiveStaticHosts().iterator();\r
+ while (hnci.hasNext()) {\r
+ ip = hnci.next().getNetworkAddressAsString();\r
+ Assert.assertTrue(ip.equals("192.168.0.13"));\r
+ }\r
+ } \r
+ \r
+\r
+ \r
+ @Test\r
+ public void testNotifyNodeConnector() throws UnknownHostException {\r
+ String ip;\r
+ \r
+ assertNotNull(this.invtoryListener);\r
+\r
+ // create one node and two node connectors\r
+ Node node1 = NodeCreator.createOFNode(1L);\r
+ NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector((short) 1, node1);\r
+ NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1);\r
+ \r
+ // test addStaticHost(), put into inactive host DB if not verifiable\r
+ Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66",\r
+ nc1_1, "0");\r
+ st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77",\r
+ nc1_2, "0");\r
+ \r
+ this.invtoryListener.notifyNodeConnector(nc1_1,\r
+ UpdateType.ADDED, null);\r
+\r
+ // check all host list\r
+ Iterator<HostNodeConnector> hnci = this.hosttracker\r
+ .getAllHosts().iterator();\r
+ while (hnci.hasNext()) {\r
+ ip = hnci.next().getNetworkAddressAsString();\r
+ Assert.assertTrue(ip.equals("192.168.0.8"));\r
+ }\r
+ \r
+ // check active host DB\r
+ hnci = this.hosttracker.getActiveStaticHosts().iterator();\r
+ while (hnci.hasNext()) {\r
+ ip = hnci.next().getNetworkAddressAsString();\r
+ Assert.assertTrue(ip.equals("192.168.0.8"));\r
+ }\r
+ \r
+ // check inactive host DB\r
+ hnci = this.hosttracker.getInactiveStaticHosts().iterator();\r
+ while (hnci.hasNext()) {\r
+ ip = hnci.next().getNetworkAddressAsString();\r
+ Assert.assertTrue(ip.equals("192.168.0.13"));\r
+ }\r
+ }\r
+ \r
+ \r
+ \r
+ @Test\r
+ public void testHostFind() throws UnknownHostException {\r
+ \r
+ assertNotNull(this.invtoryListener);\r
+\r
+ // create one node and two node connectors\r
+ Node node1 = NodeCreator.createOFNode(1L);\r
+ NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector((short) 1, node1);\r
+ NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1);\r
+ \r
+ // test addStaticHost(), put into inactive host DB if not verifiable\r
+ Status st = this.hosttracker.addStaticHost(\r
+ "192.168.0.8", "11:22:33:44:55:66", nc1_1, "0");\r
+ st = this.hosttracker.addStaticHost(\r
+ "192.168.0.13", "11:22:33:44:55:77", nc1_2, "0");\r
+ \r
+ HostNodeConnector hnc_1 = this.hosttracker\r
+ .hostFind(InetAddress.getByName("192.168.0.8"));\r
+ assertNull(hnc_1);\r
+ \r
+ this.invtoryListener.notifyNodeConnector(nc1_1,\r
+ UpdateType.ADDED, null);\r
+\r
+ hnc_1 = this.hosttracker.hostFind(InetAddress.getByName("192.168.0.8"));\r
+ assertNotNull(hnc_1);\r
+ \r
+ }\r
+ \r
+}\r
--- /dev/null
+<configuration scan="true">\r
+\r
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+ <encoder>\r
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n\r
+ </pattern>\r
+ </encoder>\r
+ </appender>\r
+\r
+ <root level="error">\r
+ <appender-ref ref="STDOUT" />\r
+ </root>\r
+</configuration>\r
--- /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.opendaylight</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../../commons/opendaylight</relativePath>
+ </parent>
+
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>switchmanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <!-- Sonar properties using jacoco to retrieve integration test results -->
+ <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+ <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
+ <sonar.jacoco.Reportpath>target/jacobo.exec</sonar.jacoco.Reportpath>
+ <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <sonar.language>java</sonar.language>
+ </properties>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.5.3.201107060350</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.6</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.opendaylight.controller.switchmanager
+ </Export-Package>
+ <Import-Package>
+ org.opendaylight.controller.clustering.services,
+ org.opendaylight.controller.configuration,
+ org.opendaylight.controller.sal.core,
+ org.opendaylight.controller.sal.utils,
+ org.opendaylight.controller.sal.packet,
+ org.opendaylight.controller.sal.inventory,
+ org.slf4j,
+ org.apache.felix.dm,
+ org.eclipse.osgi.framework.console,
+ org.osgi.framework,
+ javax.xml.bind.annotation,
+ org.apache.commons.lang3.builder
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <includes>org.opendaylight.controller.*</includes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>pre-test</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>post-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.services</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>sal</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
--- /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.opendaylight</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../../commons/opendaylight</relativePath>
+ </parent>
+
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>switchmanager.implementation</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <!-- Sonar properties using jacoco to retrieve integration test results -->
+ <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+ <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
+ <sonar.jacoco.Reportpath>target/jacobo.exec</sonar.jacoco.Reportpath>
+ <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <sonar.language>java</sonar.language>
+ </properties>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.5.3.201107060350</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.6</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ </Export-Package>
+ <Import-Package>
+ org.opendaylight.controller.switchmanager,
+ org.opendaylight.controller.clustering.services,
+ org.opendaylight.controller.configuration,
+ org.opendaylight.controller.sal.core,
+ org.opendaylight.controller.sal.utils,
+ org.opendaylight.controller.sal.packet,
+ org.opendaylight.controller.sal.inventory,
+ org.slf4j,
+ org.apache.felix.dm,
+ org.eclipse.osgi.framework.console,
+ org.osgi.framework,
+ javax.xml.bind.annotation,
+ org.apache.commons.lang3.builder
+ </Import-Package>
+ <Bundle-Activator>
+ org.opendaylight.controller.switchmanager.internal.Activator
+ </Bundle-Activator>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <includes>org.opendaylight.controller.*</includes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>pre-test</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>post-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.services</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>sal</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>switchmanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+<configuration scan="true">\r
+\r
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+ <encoder>\r
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n\r
+ </pattern>\r
+ </encoder>\r
+ </appender>\r
+\r
+ <root level="error">\r
+ <appender-ref ref="STDOUT" />\r
+ </root>\r
+</configuration>\r
+++ /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.opendaylight</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../commons/opendaylight</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>switchmanager</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>
- <Export-Package>
- org.opendaylight.controller.switchmanager
- </Export-Package>
- <Import-Package>
- org.opendaylight.controller.clustering.services,
- org.opendaylight.controller.configuration,
- org.opendaylight.controller.sal.core,
- org.opendaylight.controller.sal.utils,
- org.opendaylight.controller.sal.packet,
- org.opendaylight.controller.sal.inventory,
- org.slf4j,
- org.apache.felix.dm,
- org.eclipse.osgi.framework.console,
- org.osgi.framework,
- javax.xml.bind.annotation,
- org.apache.commons.lang3.builder
- </Import-Package>
- <Bundle-Activator>
- org.opendaylight.controller.switchmanager.internal.Activator
- </Bundle-Activator>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>clustering.services</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>sal</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-</project>