Ray Milkey
Committed by Gerrit Code Review

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

Change-Id: Ia2604337e4b9a7bfa4f6c3c06c5defc499143cba
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.openflow.controller.driver;
package org.onosproject.core.netty;
import java.net.SocketAddress;
......@@ -166,4 +166,4 @@ public class ChannelAdapter implements Channel {
public int compareTo(Channel o) {
return 0;
}
}
\ No newline at end of file
}
......
......@@ -13,20 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.openflow;
package org.onosproject.net.driver;
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.
* Test adapter for the driver class.
*/
public class DriverAdapter implements Driver {
@Override
......@@ -79,12 +73,8 @@ public class DriverAdapter implements Driver {
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;
}
......
......@@ -13,18 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.openflow;
package org.onosproject.net.driver;
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.
* Testing adapter for the driver service interface.
*/
public class DriverServiceAdapter implements DriverService {
@Override
......
......@@ -80,14 +80,6 @@
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-of-ctl</artifactId>
<scope>test</scope>
<classifier>tests</classifier>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
......
......@@ -44,8 +44,10 @@ import org.onosproject.net.driver.DefaultDriverData;
import org.onosproject.net.driver.DefaultDriverHandler;
import org.onosproject.net.driver.DefaultDriverProviderService;
import org.onosproject.net.driver.Driver;
import org.onosproject.net.driver.DriverAdapter;
import org.onosproject.net.driver.DriverData;
import org.onosproject.net.driver.DriverHandler;
import org.onosproject.net.driver.DriverServiceAdapter;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
......@@ -60,8 +62,6 @@ import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.net.flowobjective.NextObjective;
import org.onosproject.net.flowobjective.ObjectiveEvent;
import org.onosproject.net.intent.TestTools;
import org.onosproject.openflow.DriverAdapter;
import org.onosproject.openflow.DriverServiceAdapter;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.MatcherAssert.assertThat;
......
......@@ -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>
......
......@@ -18,6 +18,7 @@ package org.onosproject.openflow.controller.driver;
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;
......
......@@ -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>
......
/*
* 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;
}
}
......@@ -29,10 +29,13 @@ import org.junit.rules.TemporaryFolder;
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 @@ public class ControllerTest {
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 @@ public class ControllerTest {
case ITEM_NOT_FOUND_DRIVER:
throw new ItemNotFoundException();
case DRIVER_EXISTS:
return new DriverAdapter();
return new TestDriver();
default:
throw new AssertionError();
}
......
......@@ -19,7 +19,7 @@ package org.onosproject.openflow.controller.impl;
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;
......