Maven test related fixes

- Workaround for usage of symlink in P4 code.
  Should probably avoid using symlink and load as resource
  for benefit of buck also
  https://buckbuild.com/concept/buckconfig.html#project.allow_symlinks

- Netconf Active client test dependency fix

- NetconfControllerImpl has mutable static variable,
  clean up after tests which potentiallu touches them

Change-Id: If7a70357a04ccc7e36377301de080385190d2776
diff --git a/apps/dhcprelay/pom.xml b/apps/dhcprelay/pom.xml
index 5e9d68e..40406e8 100644
--- a/apps/dhcprelay/pom.xml
+++ b/apps/dhcprelay/pom.xml
@@ -57,6 +57,11 @@
         </dependency>
 
         <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
@@ -77,6 +82,7 @@
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-api</artifactId>
+            <scope>test</scope>
             <classifier>tests</classifier>
         </dependency>
 
diff --git a/apps/netconf/client/pom.xml b/apps/netconf/client/pom.xml
index 2952033..f0ee3fb 100644
--- a/apps/netconf/client/pom.xml
+++ b/apps/netconf/client/pom.xml
@@ -44,7 +44,6 @@
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-api</artifactId>
-            <version>${onos.version}</version>
         </dependency>
 
         <dependency>
@@ -90,7 +89,6 @@
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onlab-osgi</artifactId>
-            <version>${onos.version}</version>
         </dependency>
 
         <dependency>
@@ -114,11 +112,16 @@
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-api</artifactId>
-            <version>${onos.version}</version>
             <scope>test</scope>
             <classifier>tests</classifier>
         </dependency>
 
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 
     <build>
diff --git a/core/net/pom.xml b/core/net/pom.xml
index c13f997..1278433 100644
--- a/core/net/pom.xml
+++ b/core/net/pom.xml
@@ -134,4 +134,16 @@
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <!-- Workaround for P4 test code using symlinks in git -->
+                <!-- last version which copies symlink target -->
+                <version>2.7</version>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>
diff --git a/drivers/bmv2/pom.xml b/drivers/bmv2/pom.xml
index 2234112..b68f094 100644
--- a/drivers/bmv2/pom.xml
+++ b/drivers/bmv2/pom.xml
@@ -27,7 +27,7 @@
 
     <artifactId>onos-drivers-bmv2</artifactId>
     <packaging>bundle</packaging>
-    
+
     <description>BMv2 device drivers</description>
     <dependencies>
         <dependency>
@@ -63,4 +63,16 @@
         </onos.app.requires>
     </properties>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <!-- Workaround for P4 test code using symlinks in git -->
+                <!-- last version which copies symlink target -->
+                <version>2.7</version>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java
index c991762..d05acc3 100644
--- a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java
+++ b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java
@@ -16,7 +16,6 @@
 
 package org.onosproject.netconf;
 
-import com.google.common.base.Preconditions;
 import org.onlab.packet.IpAddress;
 import org.onosproject.net.DeviceId;
 import org.onosproject.netconf.config.NetconfDeviceConfig;
@@ -24,6 +23,9 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.io.File;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -64,9 +66,9 @@
      */
     public NetconfDeviceInfo(String name, String password, IpAddress ipAddress,
                              int port) {
-        Preconditions.checkArgument(!name.equals(""), "Empty device username");
-        Preconditions.checkNotNull(port > 0, "Negative port");
-        Preconditions.checkNotNull(ipAddress, "Null ip address");
+        checkArgument(!name.equals(""), "Empty device username");
+        checkNotNull(port > 0, "Negative port");
+        checkNotNull(ipAddress, "Null ip address");
         this.name = name;
         this.password = password;
         this.ipAddress = ipAddress;
@@ -93,9 +95,9 @@
      */
     public NetconfDeviceInfo(String name, String password, IpAddress ipAddress,
                              int port, String keyString) {
-        Preconditions.checkArgument(!name.equals(""), "Empty device name");
-        Preconditions.checkNotNull(port > 0, "Negative port");
-        Preconditions.checkNotNull(ipAddress, "Null ip address");
+        checkArgument(!name.equals(""), "Empty device name");
+        checkNotNull(port > 0, "Negative port");
+        checkNotNull(ipAddress, "Null ip address");
         this.name = name;
         this.password = password;
         this.ipAddress = ipAddress;
@@ -113,9 +115,9 @@
      * @param netconfConfig NetCf configuration
      */
     public NetconfDeviceInfo(NetconfDeviceConfig netconfConfig) {
-        Preconditions.checkArgument(!netconfConfig.username().isEmpty(), "Empty device name");
-        Preconditions.checkNotNull(netconfConfig.port() > 0, "Negative port");
-        Preconditions.checkNotNull(netconfConfig.ip(), "Null ip address");
+        checkArgument(!netconfConfig.username().isEmpty(), "Empty device name");
+        checkNotNull(netconfConfig.port() > 0, "Negative port");
+        checkNotNull(netconfConfig.ip(), "Null ip address");
 
         this.name = netconfConfig.username();
         this.password = netconfConfig.password();
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
index 5e6d7f9..daba5be 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
@@ -71,20 +71,23 @@
 
     private static final String ETHZ_SSH2 = "ethz-ssh2";
 
-    private static final int DEFAULT_CONNECT_TIMEOUT_SECONDS = 5;
+    protected static final int DEFAULT_CONNECT_TIMEOUT_SECONDS = 5;
     private static final String PROP_NETCONF_CONNECT_TIMEOUT = "netconfConnectTimeout";
+    // FIXME @Property should not be static
     @Property(name = PROP_NETCONF_CONNECT_TIMEOUT, intValue = DEFAULT_CONNECT_TIMEOUT_SECONDS,
             label = "Time (in seconds) to wait for a NETCONF connect.")
     protected static int netconfConnectTimeout = DEFAULT_CONNECT_TIMEOUT_SECONDS;
 
     private static final String PROP_NETCONF_REPLY_TIMEOUT = "netconfReplyTimeout";
-    private static final int DEFAULT_REPLY_TIMEOUT_SECONDS = 5;
+    protected static final int DEFAULT_REPLY_TIMEOUT_SECONDS = 5;
+    // FIXME @Property should not be static
     @Property(name = PROP_NETCONF_REPLY_TIMEOUT, intValue = DEFAULT_REPLY_TIMEOUT_SECONDS,
             label = "Time (in seconds) waiting for a NetConf reply")
     protected static int netconfReplyTimeout = DEFAULT_REPLY_TIMEOUT_SECONDS;
 
     private static final String PROP_NETCONF_IDLE_TIMEOUT = "netconfIdleTimeout";
-    private static final int DEFAULT_IDLE_TIMEOUT_SECONDS = 300;
+    protected static final int DEFAULT_IDLE_TIMEOUT_SECONDS = 300;
+    // FIXME @Property should not be static
     @Property(name = PROP_NETCONF_IDLE_TIMEOUT, intValue = DEFAULT_IDLE_TIMEOUT_SECONDS,
             label = "Time (in seconds) SSH session will close if no traffic seen")
     protected static int netconfIdleTimeout = DEFAULT_IDLE_TIMEOUT_SECONDS;
@@ -93,7 +96,7 @@
     private static final String APACHE_MINA_STR = "apache-mina";
     @Property(name = SSH_LIBRARY, value = APACHE_MINA_STR,
             label = "Ssh Library instead of apache_mina (i.e. ethz-ssh2")
-    protected static NetconfSshClientLib sshLibrary = NetconfSshClientLib.APACHE_MINA;
+    protected NetconfSshClientLib sshLibrary = NetconfSshClientLib.APACHE_MINA;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected ComponentConfigService cfgService;
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfControllerImplTest.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfControllerImplTest.java
index ed4eabf..d77c222 100644
--- a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfControllerImplTest.java
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfControllerImplTest.java
@@ -125,6 +125,9 @@
         ctrl.deviceService = deviceService;
         ctrl.deviceKeyService = deviceKeyService;
         ctrl.netCfgService = netCfgService;
+        NetconfControllerImpl.netconfConnectTimeout = NetconfControllerImpl.DEFAULT_CONNECT_TIMEOUT_SECONDS;
+        NetconfControllerImpl.netconfIdleTimeout = NetconfControllerImpl.DEFAULT_IDLE_TIMEOUT_SECONDS;
+        NetconfControllerImpl.netconfReplyTimeout = NetconfControllerImpl.DEFAULT_REPLY_TIMEOUT_SECONDS;
 
         //Creating mock devices
         deviceInfo1 = new NetconfDeviceInfo("device1", "001", IpAddress.valueOf(DEVICE_1_IP), DEVICE_1_PORT);
@@ -179,6 +182,10 @@
     @After
     public void tearDown() {
         ctrl.deactivate();
+        // resetting static variables..
+        NetconfControllerImpl.netconfConnectTimeout = NetconfControllerImpl.DEFAULT_CONNECT_TIMEOUT_SECONDS;
+        NetconfControllerImpl.netconfIdleTimeout = NetconfControllerImpl.DEFAULT_IDLE_TIMEOUT_SECONDS;
+        NetconfControllerImpl.netconfReplyTimeout = NetconfControllerImpl.DEFAULT_REPLY_TIMEOUT_SECONDS;
     }
 
     /**
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionImplTest.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionImplTest.java
index 842bafd..6e609e1 100644
--- a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionImplTest.java
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionImplTest.java
@@ -120,6 +120,9 @@
         log.info("SSH Server opened on port {}", PORT_NUMBER);
 
         NetconfController netconfCtl = new NetconfControllerImpl();
+        NetconfControllerImpl.netconfConnectTimeout = NetconfControllerImpl.DEFAULT_CONNECT_TIMEOUT_SECONDS;
+        NetconfControllerImpl.netconfIdleTimeout = NetconfControllerImpl.DEFAULT_IDLE_TIMEOUT_SECONDS;
+        NetconfControllerImpl.netconfReplyTimeout = NetconfControllerImpl.DEFAULT_REPLY_TIMEOUT_SECONDS;
 
         NetconfDeviceInfo deviceInfo1 = new NetconfDeviceInfo(
                 TEST_USERNAME, TEST_PASSWORD, Ip4Address.valueOf(TEST_HOSTNAME), PORT_NUMBER);
@@ -172,6 +175,9 @@
         }
 
         sshServerNetconf.stop();
+        NetconfControllerImpl.netconfConnectTimeout = NetconfControllerImpl.DEFAULT_CONNECT_TIMEOUT_SECONDS;
+        NetconfControllerImpl.netconfIdleTimeout = NetconfControllerImpl.DEFAULT_IDLE_TIMEOUT_SECONDS;
+        NetconfControllerImpl.netconfReplyTimeout = NetconfControllerImpl.DEFAULT_REPLY_TIMEOUT_SECONDS;
     }
 
     @Test