Add first integration test for the TopologyManager bundle 21/1521/4
authorMoiz Raja <moraja@cisco.com>
Mon, 30 Sep 2013 21:25:14 +0000 (14:25 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 1 Oct 2013 13:45:40 +0000 (13:45 +0000)
Change-Id: I9a5230f0f72ba51a88bb36141773b4d00885a774
Signed-off-by: Moiz Raja <moraja@cisco.com>
opendaylight/distribution/opendaylight/pom.xml
opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/Activator.java
opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/TopologyServices.java [new file with mode: 0644]
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java
opendaylight/topologymanager/integrationtest/pom.xml [new file with mode: 0644]
opendaylight/topologymanager/integrationtest/src/test/java/org/opendaylight/controller/topologymanager/TopologyManagerIT.java [new file with mode: 0644]
opendaylight/topologymanager/integrationtest/src/test/resources/logback.xml [new file with mode: 0644]
opendaylight/usermanager/api/src/test/java/org/opendaylight/controller/usermanager/AuthenticatedUserTest.java

index 4345a3fd00e2f2d43a2cf198478ea4682a85fa69..ccdb26845bf2b2065cdad3dad19c2ce76ecbc6c5 100644 (file)
@@ -66,6 +66,7 @@
     <module>../../statisticsmanager/implementation</module>
     <module>../../statisticsmanager/integrationtest</module>
     <module>../../topologymanager/implementation</module>
+    <module>../../topologymanager/integrationtest</module>
     <module>../../usermanager/api</module>
     <module>../../usermanager/implementation</module>
     <module>../../connectionmanager/api</module>
index 79edd93c67466a6da6820fe654dd0aeea95ac656..843e60ec36fba1218b0aa61eac75a019d5e96067 100644 (file)
@@ -1,31 +1,35 @@
-package org.opendaylight.controller.protocol_plugins.stub.internal;
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 
-import java.util.Dictionary;
-import java.util.Hashtable;
 
-import org.apache.felix.dm.Component;
 
+package org.opendaylight.controller.protocol_plugins.stub.internal;
+
+import org.apache.felix.dm.Component;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
-import org.opendaylight.controller.sal.core.IContainerListener;
-import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
-import org.opendaylight.controller.sal.utils.INodeFactory;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
-import org.opendaylight.controller.sal.discovery.IDiscoveryService;
 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
-import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
-import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService;
 import org.opendaylight.controller.sal.reader.IPluginInReadService;
-import org.opendaylight.controller.sal.reader.IReadService;
 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
-
+import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
+import org.opendaylight.controller.sal.utils.INodeFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Dictionary;
+import java.util.Hashtable;
+
 /**
  * stub protocol plugin Activator
  *
@@ -68,7 +72,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      */
     @Override
     public Object[] getImplementations() {
-        Object[] res = { ReadService.class, InventoryService.class };
+        Object[] res = { ReadService.class, InventoryService.class, TopologyServices.class };
         return res;
     }
 
@@ -106,6 +110,17 @@ public class Activator extends ComponentActivatorAbstractBase {
             props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
             c.setInterface(IPluginInInventoryService.class.getName(), props);
         }
+
+        if(imp.equals(TopologyServices.class)){
+            Dictionary<String, Object> props = new Hashtable<String, Object>();
+            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
+            c.setInterface(IPluginInTopologyService.class.getName(), props);
+            c.add(createServiceDependency().setService(IPluginOutTopologyService.class, "")
+                    .setCallbacks("setPluginOutTopologyService", "unsetPluginOutTopologyService")
+                    .setRequired(true));
+
+        }
+
     }
 
     @Override
@@ -115,7 +130,8 @@ public class Activator extends ComponentActivatorAbstractBase {
                         FlowProgrammerService.class,
                         StubNodeFactory.class,
                         StubNodeConnectorFactory.class,
-                        InventoryService.class };
+                        InventoryService.class
+                };
         return res;
     }
 
@@ -159,5 +175,6 @@ public class Activator extends ComponentActivatorAbstractBase {
                     .setCallbacks("setPluginOutInventoryServices", "unsetPluginOutInventoryServices")
                     .setRequired(true));
         }
+
     }
 }
diff --git a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/TopologyServices.java b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/TopologyServices.java
new file mode 100644 (file)
index 0000000..104df0a
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.protocol_plugins.stub.internal;
+
+import org.opendaylight.controller.sal.core.Edge;
+import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
+import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
+import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+public class TopologyServices implements IPluginInTopologyService {
+    private IPluginOutTopologyService pluginOutTopologyService;
+
+
+    @Override
+    public void sollicitRefresh() {
+    }
+
+    public void setPluginOutTopologyService(IPluginOutTopologyService pluginOutTopologyService){
+        this.pluginOutTopologyService = pluginOutTopologyService;
+    }
+
+    public void unsetPluginOutTopologyService(IPluginOutTopologyService pluginOutTopologyService){
+        this.pluginOutTopologyService = null;
+    }
+
+
+    public void addEdge(Edge edge, Set<Property> properties, UpdateType updateType){
+
+        List<TopoEdgeUpdate > topoedgeupdateList = new ArrayList<TopoEdgeUpdate>();
+
+        topoedgeupdateList.add(new TopoEdgeUpdate(edge, properties, updateType));
+
+        this.pluginOutTopologyService.edgeUpdate(topoedgeupdateList);
+
+    }
+}
index a1bf55ddaf54f519b22504eb0a18c2068216c03d..c1c38aa76c85412ea7db20848580e6b490e822fa 100644 (file)
@@ -8,18 +8,12 @@
 
 package org.opendaylight.controller.sal.action;
 
-import java.io.Serializable;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSeeAlso;
-import javax.xml.bind.annotation.XmlTransient;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.xml.bind.annotation.*;
+import java.io.Serializable;
+
 /**
  * Represents the generic action to be applied to the matched
  * frame/packet/message
diff --git a/opendaylight/topologymanager/integrationtest/pom.xml b/opendaylight/topologymanager/integrationtest/pom.xml
new file mode 100644 (file)
index 0000000..8d949f4
--- /dev/null
@@ -0,0 +1,146 @@
+<?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.1-SNAPSHOT</version>
+    <relativePath>../../commons/integrationtest</relativePath>
+  </parent>
+  <scm>
+    <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+    <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+    <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
+  </scm>
+
+  <artifactId>topologymanager.integrationtest</artifactId>
+  <version>0.4.0-SNAPSHOT</version>
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>protocol_plugins.stub</artifactId>
+      <version>0.4.1-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>containermanager</artifactId>
+      <version>0.5.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>containermanager.it.implementation</artifactId>
+      <version>0.5.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.stub</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>statisticsmanager</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>statisticsmanager.implementation</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>switchmanager</artifactId>
+      <version>0.5.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>
+  <properties>
+    <!-- Sonar jacoco plugin to get integration test coverage info -->
+    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+    <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
+    <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+    <sonar.language>java</sonar.language>
+  </properties>
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.jacoco</groupId>
+          <artifactId>jacoco-maven-plugin</artifactId>
+          <version>0.5.3.201107060350</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.jacoco</groupId>
+        <artifactId>jacoco-maven-plugin</artifactId>
+        <version>0.5.3.201107060350</version>
+        <configuration>
+          <destFile>../implementation/target/jacoco-it.exec</destFile>
+          <includes>org.opendaylight.controller.*</includes>
+        </configuration>
+        <executions>
+          <execution>
+            <id>pre-test</id>
+            <goals>
+              <goal>prepare-agent</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>post-test</id>
+            <configuration>
+              <skip>true</skip>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/opendaylight/topologymanager/integrationtest/src/test/java/org/opendaylight/controller/topologymanager/TopologyManagerIT.java b/opendaylight/topologymanager/integrationtest/src/test/java/org/opendaylight/controller/topologymanager/TopologyManagerIT.java
new file mode 100644 (file)
index 0000000..296be72
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.topologymanager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.protocol_plugins.stub.internal.TopologyServices;
+import org.opendaylight.controller.sal.core.*;
+import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
+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;
+
+import javax.inject.Inject;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+@RunWith(PaxExam.class)
+public class TopologyManagerIT {
+    private Logger log = LoggerFactory
+            .getLogger(TopologyManagerIT.class);
+    // get the OSGI bundle context
+    @Inject
+    private BundleContext bc;
+
+    private ITopologyManager manager = null;
+
+    // Configure the OSGi container
+    @Configuration
+    public Option[] config() {
+        return options(
+                //
+                systemProperty("logback.configurationFile").value(
+                        "file:" + PathUtils.getBaseDir()
+                                + "/src/test/resources/logback.xml"),
+                // To start OSGi console for inspection remotely
+                systemProperty("osgi.console").value("2401"),
+                // Set the systemPackages (used by clustering)
+                systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
+                // List framework bundles
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject(),
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.util").versionAsInProject(),
+                mavenBundle("equinoxSDK381", "org.eclipse.osgi.services").versionAsInProject(),
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds").versionAsInProject(),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject(),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject(),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject(),
+                // List logger bundles
+                mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
+                mavenBundle("org.slf4j", "log4j-over-slf4j")
+                        .versionAsInProject(),
+                mavenBundle("ch.qos.logback", "logback-core")
+                        .versionAsInProject(),
+                mavenBundle("ch.qos.logback", "logback-classic")
+                        .versionAsInProject(),
+                // needed by statisticsmanager
+                mavenBundle("org.opendaylight.controller", "containermanager")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "containermanager.it.implementation")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "clustering.services")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "clustering.stub")
+                    .versionAsInProject(),
+                // needed by forwardingrulesmanager
+                mavenBundle("org.opendaylight.controller", "configuration")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "configuration.implementation")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "hosttracker")
+                    .versionAsInProject(),
+
+                // List all the bundles on which the test case depends
+                mavenBundle("org.opendaylight.controller", "sal")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "sal.implementation")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "protocol_plugins.stub")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "switchmanager")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "switchmanager.implementation")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "statisticsmanager")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "statisticsmanager.implementation")
+                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "forwardingrulesmanager")
+                    .versionAsInProject(),
+
+                // needed by hosttracker
+                mavenBundle("org.opendaylight.controller", "topologymanager")
+                        .versionAsInProject(),
+                mavenBundle("org.jboss.spec.javax.transaction",
+                        "jboss-transaction-api_1.1_spec").versionAsInProject(),
+                mavenBundle("org.apache.commons", "commons-lang3")
+                        .versionAsInProject(),
+                mavenBundle("org.apache.felix",
+                        "org.apache.felix.dependencymanager")
+                        .versionAsInProject(), junitBundles());
+    }
+
+    private String stateToString(int state) {
+        switch (state) {
+        case Bundle.ACTIVE:
+            return "ACTIVE";
+        case Bundle.INSTALLED:
+            return "INSTALLED";
+        case Bundle.RESOLVED:
+            return "RESOLVED";
+        case Bundle.UNINSTALLED:
+            return "UNINSTALLED";
+        default:
+            return "Not CONVERTED";
+        }
+    }
+
+    @Before
+    public void areWeReady() {
+        assertNotNull(bc);
+        boolean debugit = false;
+        Bundle b[] = bc.getBundles();
+        for (int i = 0; i < b.length; i++) {
+            int state = b[i].getState();
+            if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
+                log.debug("Bundle:" + b[i].getSymbolicName() + " state:"
+                        + stateToString(state));
+                debugit = true;
+            }
+        }
+        if (debugit) {
+            log.debug("Do some debugging because some bundle is "
+                    + "unresolved");
+        }
+
+        // Assert if true, if false we are good to go!
+        assertFalse(debugit);
+
+        ServiceReference r = bc.getServiceReference(ITopologyManager.class
+                .getName());
+        if (r != null) {
+            this.manager = (ITopologyManager) bc.getService(r);
+        }
+        // If StatisticsManager is null, cannot run tests.
+        assertNotNull(this.manager);
+
+    }
+
+
+    /**
+     *  This test verifies that the isInternal method of the TopologyManager returns true when a node is internal and
+     *  not otherwise
+     *
+     *  To make a node interval we add a node using the plugin interface (TopologyServices.addEdge) this is to ensure
+     *  that when TopologyManager sees the edge is via it's dependency on the SAL ITopologyService.
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testIsInternal() throws Exception{
+        Node node1 = new Node("STUB", 0xCAFE);
+        Node node2 = new Node("STUB", 0XFACE);
+
+        NodeConnector head = new NodeConnector("STUB", node1.getID(), node1);
+        NodeConnector tail = new NodeConnector("STUB", node2.getID(), node2);
+
+        assert(this.manager.isInternal(head));
+
+        Set<Property> properties = new HashSet<Property>();
+
+        ServiceReference r = bc.getServiceReference(IPluginInTopologyService.class
+                .getName());
+        TopologyServices topologyServices = null;
+        if (r != null) {
+            if(bc.getService(r) instanceof TopologyServices) {
+                topologyServices = (TopologyServices) bc.getService(r);
+            } else {
+                throw new RuntimeException("topology service registered is not from the stub plugin implementation");
+            }
+        }
+
+        topologyServices.addEdge(new Edge(tail, head), properties, UpdateType.ADDED);
+
+        assert(this.manager.isInternal(head));
+    }
+
+}
diff --git a/opendaylight/topologymanager/integrationtest/src/test/resources/logback.xml b/opendaylight/topologymanager/integrationtest/src/test/resources/logback.xml
new file mode 100644 (file)
index 0000000..2d63ce5
--- /dev/null
@@ -0,0 +1,13 @@
+<configuration scan="true">
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <encoder>
+      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+      </pattern>
+    </encoder>
+  </appender>
+
+  <root level="error">
+    <appender-ref ref="STDOUT" />
+  </root>
+</configuration>
index d16373c34971ceac7e241bfc8f6cef5c01787af0..b8a1a987694cfec72ae8898256cabe1e12e0fe7f 100644 (file)
@@ -8,17 +8,15 @@
 
 package org.opendaylight.controller.usermanager;
 
-import java.util.Arrays;
-import java.util.List;
-
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
-
 import org.opendaylight.controller.sal.authorization.UserLevel;
-import org.opendaylight.controller.usermanager.AuthenticatedUser;
 import org.springframework.security.core.GrantedAuthority;
 
+import java.util.Arrays;
+import java.util.List;
+
 public class AuthenticatedUserTest {
 
         static String[] roleArray;
@@ -64,6 +62,7 @@ public class AuthenticatedUserTest {
 
         @Test
         public void testGetGrantedAuthorities() {
+                user = new AuthenticatedUser("auser");
                 List<GrantedAuthority> gaList = user
                                 .getGrantedAuthorities(UserLevel.NETWORKOPERATOR);
                 Assert.assertTrue(gaList.get(0).getAuthority()