Refactor some core testing adapters to not be in the openflow hierarchy

Change-Id: Ia2604337e4b9a7bfa4f6c3c06c5defc499143cba
diff --git a/protocols/openflow/api/pom.xml b/protocols/openflow/api/pom.xml
index ef41b40..f5be0a6 100644
--- a/protocols/openflow/api/pom.xml
+++ b/protocols/openflow/api/pom.xml
@@ -46,6 +46,13 @@
             <groupId>org.onosproject</groupId>
             <artifactId>onos-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+            <version>${project.version}</version>
+        </dependency>
 
     </dependencies>
 
diff --git a/protocols/openflow/api/src/test/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitchTest.java b/protocols/openflow/api/src/test/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitchTest.java
index fb8d977..ef0865b 100644
--- a/protocols/openflow/api/src/test/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitchTest.java
+++ b/protocols/openflow/api/src/test/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitchTest.java
@@ -18,6 +18,7 @@
 import org.jboss.netty.channel.Channel;
 import org.junit.Before;
 import org.junit.Test;
+import org.onosproject.core.netty.ChannelAdapter;
 import org.onosproject.openflow.controller.Dpid;
 import org.onosproject.openflow.controller.OpenFlowEventListener;
 import org.projectfloodlight.openflow.protocol.OFMessage;
diff --git a/protocols/openflow/api/src/test/java/org/onosproject/openflow/controller/driver/ChannelAdapter.java b/protocols/openflow/api/src/test/java/org/onosproject/openflow/controller/driver/ChannelAdapter.java
deleted file mode 100644
index 60f0c2e..0000000
--- a/protocols/openflow/api/src/test/java/org/onosproject/openflow/controller/driver/ChannelAdapter.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.openflow.controller.driver;
-
-import java.net.SocketAddress;
-
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelConfig;
-import org.jboss.netty.channel.ChannelFactory;
-import org.jboss.netty.channel.ChannelFuture;
-import org.jboss.netty.channel.ChannelPipeline;
-
-/**
- * Adapter for testing against a netty channel.
- */
-public class ChannelAdapter implements Channel {
-    @Override
-    public Integer getId() {
-        return null;
-    }
-
-    @Override
-    public ChannelFactory getFactory() {
-        return null;
-    }
-
-    @Override
-    public Channel getParent() {
-        return null;
-    }
-
-    @Override
-    public ChannelConfig getConfig() {
-        return null;
-    }
-
-    @Override
-    public ChannelPipeline getPipeline() {
-        return null;
-    }
-
-    @Override
-    public boolean isOpen() {
-        return false;
-    }
-
-    @Override
-    public boolean isBound() {
-        return false;
-    }
-
-    @Override
-    public boolean isConnected() {
-        return false;
-    }
-
-    @Override
-    public SocketAddress getLocalAddress() {
-        return null;
-    }
-
-    @Override
-    public SocketAddress getRemoteAddress() {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture write(Object o) {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture write(Object o, SocketAddress socketAddress) {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture bind(SocketAddress socketAddress) {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture connect(SocketAddress socketAddress) {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture disconnect() {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture unbind() {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture close() {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture getCloseFuture() {
-        return null;
-    }
-
-    @Override
-    public int getInterestOps() {
-        return 0;
-    }
-
-    @Override
-    public boolean isReadable() {
-        return false;
-    }
-
-    @Override
-    public boolean isWritable() {
-        return false;
-    }
-
-    @Override
-    public ChannelFuture setInterestOps(int i) {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture setReadable(boolean b) {
-        return null;
-    }
-
-    @Override
-    public boolean getUserDefinedWritability(int i) {
-        return false;
-    }
-
-    @Override
-    public void setUserDefinedWritability(int i, boolean b) {
-
-    }
-
-    @Override
-    public Object getAttachment() {
-        return null;
-    }
-
-    @Override
-    public void setAttachment(Object o) {
-
-    }
-
-    @Override
-    public int compareTo(Channel o) {
-        return 0;
-    }
-}
\ No newline at end of file
diff --git a/protocols/openflow/ctl/pom.xml b/protocols/openflow/ctl/pom.xml
index bda354b..a5674a7 100644
--- a/protocols/openflow/ctl/pom.xml
+++ b/protocols/openflow/ctl/pom.xml
@@ -47,6 +47,13 @@
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelAdapter.java b/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelAdapter.java
deleted file mode 100644
index f428595..0000000
--- a/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelAdapter.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.openflow;
-
-import java.net.SocketAddress;
-
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelConfig;
-import org.jboss.netty.channel.ChannelFactory;
-import org.jboss.netty.channel.ChannelFuture;
-import org.jboss.netty.channel.ChannelPipeline;
-
-/**
- * Adapter for testing against a netty channel.
- */
-public class ChannelAdapter implements Channel {
-    @Override
-    public Integer getId() {
-        return null;
-    }
-
-    @Override
-    public ChannelFactory getFactory() {
-        return null;
-    }
-
-    @Override
-    public Channel getParent() {
-        return null;
-    }
-
-    @Override
-    public ChannelConfig getConfig() {
-        return null;
-    }
-
-    @Override
-    public ChannelPipeline getPipeline() {
-        return null;
-    }
-
-    @Override
-    public boolean isOpen() {
-        return false;
-    }
-
-    @Override
-    public boolean isBound() {
-        return false;
-    }
-
-    @Override
-    public boolean isConnected() {
-        return false;
-    }
-
-    @Override
-    public SocketAddress getLocalAddress() {
-        return null;
-    }
-
-    @Override
-    public SocketAddress getRemoteAddress() {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture write(Object o) {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture write(Object o, SocketAddress socketAddress) {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture bind(SocketAddress socketAddress) {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture connect(SocketAddress socketAddress) {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture disconnect() {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture unbind() {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture close() {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture getCloseFuture() {
-        return null;
-    }
-
-    @Override
-    public int getInterestOps() {
-        return 0;
-    }
-
-    @Override
-    public boolean isReadable() {
-        return false;
-    }
-
-    @Override
-    public boolean isWritable() {
-        return false;
-    }
-
-    @Override
-    public ChannelFuture setInterestOps(int i) {
-        return null;
-    }
-
-    @Override
-    public ChannelFuture setReadable(boolean b) {
-        return null;
-    }
-
-    @Override
-    public boolean getUserDefinedWritability(int i) {
-        return false;
-    }
-
-    @Override
-    public void setUserDefinedWritability(int i, boolean b) {
-
-    }
-
-    @Override
-    public Object getAttachment() {
-        return null;
-    }
-
-    @Override
-    public void setAttachment(Object o) {
-
-    }
-
-    @Override
-    public int compareTo(Channel o) {
-        return 0;
-    }
-}
diff --git a/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverAdapter.java b/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverAdapter.java
deleted file mode 100644
index a070b56..0000000
--- a/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverAdapter.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.openflow;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.onosproject.net.driver.Behaviour;
-import org.onosproject.net.driver.Driver;
-import org.onosproject.net.driver.DriverData;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
-
-/**
- * Created by ray on 11/4/15.
- */
-public class DriverAdapter implements Driver {
-    @Override
-    public String name() {
-        return null;
-    }
-
-    @Override
-    public Driver parent() {
-        return null;
-    }
-
-    @Override
-    public List<Driver> parents() {
-        return null;
-    }
-
-    @Override
-    public String manufacturer() {
-        return null;
-    }
-
-    @Override
-    public String hwVersion() {
-        return null;
-    }
-
-    @Override
-    public String swVersion() {
-        return null;
-    }
-
-    @Override
-    public Set<Class<? extends Behaviour>> behaviours() {
-        return null;
-    }
-
-    @Override
-    public Class<? extends Behaviour> implementation(Class<? extends Behaviour> behaviour) {
-        return null;
-    }
-
-    @Override
-    public boolean hasBehaviour(Class<? extends Behaviour> behaviourClass) {
-        return true;
-    }
-
-    @Override
-    public <T extends Behaviour> T createBehaviour(DriverData data, Class<T> behaviourClass) {
-        return null;
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public <T extends Behaviour> T createBehaviour(DriverHandler handler, Class<T> behaviourClass) {
-        if (behaviourClass == OpenFlowSwitchDriver.class) {
-            return (T) new OpenflowSwitchDriverAdapter();
-        }
-        return null;
-    }
-
-    @Override
-    public Map<String, String> properties() {
-        return null;
-    }
-
-    @Override
-    public Driver merge(Driver other) {
-        return null;
-    }
-
-    @Override
-    public Set<String> keys() {
-        return null;
-    }
-
-    @Override
-    public String value(String key) {
-        return null;
-    }
-}
diff --git a/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverServiceAdapter.java b/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverServiceAdapter.java
deleted file mode 100644
index 25596ad..0000000
--- a/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverServiceAdapter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.openflow;
-
-import java.util.Set;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.driver.Behaviour;
-import org.onosproject.net.driver.Driver;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-
-/**
- * Created by ray on 11/4/15.
- */
-public class DriverServiceAdapter implements DriverService {
-    @Override
-    public Set<Driver> getDrivers() {
-        return null;
-    }
-
-    @Override
-    public Set<Driver> getDrivers(Class<? extends Behaviour> withBehaviour) {
-        return null;
-    }
-
-    @Override
-    public Driver getDriver(String mfr, String hw, String sw) {
-        return null;
-    }
-
-    @Override
-    public Driver getDriver(DeviceId deviceId) {
-        return null;
-    }
-
-    @Override
-    public DriverHandler createHandler(DeviceId deviceId, String... credentials) {
-        return null;
-    }
-
-    @Override
-    public Driver getDriver(String driverName) {
-        return null;
-    }
-}
diff --git a/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/ControllerTest.java b/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/ControllerTest.java
index f4e6191..a7bfcb5 100644
--- a/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/ControllerTest.java
+++ b/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/ControllerTest.java
@@ -29,10 +29,13 @@
 import org.onlab.junit.TestTools;
 import org.onlab.util.ItemNotFoundException;
 import org.onosproject.net.DeviceId;
+import org.onosproject.net.driver.Behaviour;
 import org.onosproject.net.driver.Driver;
-import org.onosproject.openflow.DriverAdapter;
-import org.onosproject.openflow.DriverServiceAdapter;
+import org.onosproject.net.driver.DriverAdapter;
+import org.onosproject.net.driver.DriverHandler;
+import org.onosproject.net.driver.DriverServiceAdapter;
 import org.onosproject.openflow.OFDescStatsReplyAdapter;
+import org.onosproject.openflow.OpenflowSwitchDriverAdapter;
 import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
 import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
 import org.slf4j.Logger;
@@ -59,6 +62,17 @@
     Controller controller;
     protected static final Logger log = LoggerFactory.getLogger(ControllerTest.class);
 
+    private class TestDriver extends DriverAdapter {
+        @SuppressWarnings("unchecked")
+        @Override
+        public <T extends Behaviour> T createBehaviour(DriverHandler handler, Class<T> behaviourClass) {
+            if (behaviourClass == OpenFlowSwitchDriver.class) {
+                return (T) new OpenflowSwitchDriverAdapter();
+            }
+            return null;
+        }
+    }
+
     /*
      * Writes the necessary file for the tests in the temporary directory
      */
@@ -91,7 +105,7 @@
                 case ITEM_NOT_FOUND_DRIVER:
                     throw new ItemNotFoundException();
                 case DRIVER_EXISTS:
-                    return new DriverAdapter();
+                    return new TestDriver();
                 default:
                     throw new AssertionError();
             }
diff --git a/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java b/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java
index ed1db23..01dde14 100644
--- a/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java
+++ b/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java
@@ -19,7 +19,7 @@
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.jboss.netty.buffer.ChannelBuffers;
 import org.junit.Test;
-import org.onosproject.openflow.ChannelAdapter;
+import org.onosproject.core.netty.ChannelAdapter;
 import org.onosproject.openflow.ChannelHandlerContextAdapter;
 import org.projectfloodlight.openflow.protocol.OFHello;