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 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.openflow.controller.driver; 16 +package org.onosproject.core.netty;
17 17
18 import java.net.SocketAddress; 18 import java.net.SocketAddress;
19 19
...@@ -166,4 +166,4 @@ public class ChannelAdapter implements Channel { ...@@ -166,4 +166,4 @@ public class ChannelAdapter implements Channel {
166 public int compareTo(Channel o) { 166 public int compareTo(Channel o) {
167 return 0; 167 return 0;
168 } 168 }
169 -}
...\ No newline at end of file ...\ No newline at end of file
169 +}
......
...@@ -13,20 +13,14 @@ ...@@ -13,20 +13,14 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.openflow; 16 +package org.onosproject.net.driver;
17 17
18 import java.util.List; 18 import java.util.List;
19 import java.util.Map; 19 import java.util.Map;
20 import java.util.Set; 20 import java.util.Set;
21 21
22 -import org.onosproject.net.driver.Behaviour;
23 -import org.onosproject.net.driver.Driver;
24 -import org.onosproject.net.driver.DriverData;
25 -import org.onosproject.net.driver.DriverHandler;
26 -import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
27 -
28 /** 22 /**
29 - * Created by ray on 11/4/15. 23 + * Test adapter for the driver class.
30 */ 24 */
31 public class DriverAdapter implements Driver { 25 public class DriverAdapter implements Driver {
32 @Override 26 @Override
...@@ -79,12 +73,8 @@ public class DriverAdapter implements Driver { ...@@ -79,12 +73,8 @@ public class DriverAdapter implements Driver {
79 return null; 73 return null;
80 } 74 }
81 75
82 - @SuppressWarnings("unchecked")
83 @Override 76 @Override
84 public <T extends Behaviour> T createBehaviour(DriverHandler handler, Class<T> behaviourClass) { 77 public <T extends Behaviour> T createBehaviour(DriverHandler handler, Class<T> behaviourClass) {
85 - if (behaviourClass == OpenFlowSwitchDriver.class) {
86 - return (T) new OpenflowSwitchDriverAdapter();
87 - }
88 return null; 78 return null;
89 } 79 }
90 80
......
...@@ -13,18 +13,15 @@ ...@@ -13,18 +13,15 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.openflow; 16 +package org.onosproject.net.driver;
17 17
18 import java.util.Set; 18 import java.util.Set;
19 19
20 import org.onosproject.net.DeviceId; 20 import org.onosproject.net.DeviceId;
21 -import org.onosproject.net.driver.Behaviour; 21 +
22 -import org.onosproject.net.driver.Driver;
23 -import org.onosproject.net.driver.DriverHandler;
24 -import org.onosproject.net.driver.DriverService;
25 22
26 /** 23 /**
27 - * Created by ray on 11/4/15. 24 + * Testing adapter for the driver service interface.
28 */ 25 */
29 public class DriverServiceAdapter implements DriverService { 26 public class DriverServiceAdapter implements DriverService {
30 @Override 27 @Override
......
...@@ -80,14 +80,6 @@ ...@@ -80,14 +80,6 @@
80 </dependency> 80 </dependency>
81 81
82 <dependency> 82 <dependency>
83 - <groupId>org.onosproject</groupId>
84 - <artifactId>onos-of-ctl</artifactId>
85 - <scope>test</scope>
86 - <classifier>tests</classifier>
87 - <version>${project.version}</version>
88 - </dependency>
89 -
90 - <dependency>
91 <groupId>org.easymock</groupId> 83 <groupId>org.easymock</groupId>
92 <artifactId>easymock</artifactId> 84 <artifactId>easymock</artifactId>
93 <scope>test</scope> 85 <scope>test</scope>
......
...@@ -44,8 +44,10 @@ import org.onosproject.net.driver.DefaultDriverData; ...@@ -44,8 +44,10 @@ import org.onosproject.net.driver.DefaultDriverData;
44 import org.onosproject.net.driver.DefaultDriverHandler; 44 import org.onosproject.net.driver.DefaultDriverHandler;
45 import org.onosproject.net.driver.DefaultDriverProviderService; 45 import org.onosproject.net.driver.DefaultDriverProviderService;
46 import org.onosproject.net.driver.Driver; 46 import org.onosproject.net.driver.Driver;
47 +import org.onosproject.net.driver.DriverAdapter;
47 import org.onosproject.net.driver.DriverData; 48 import org.onosproject.net.driver.DriverData;
48 import org.onosproject.net.driver.DriverHandler; 49 import org.onosproject.net.driver.DriverHandler;
50 +import org.onosproject.net.driver.DriverServiceAdapter;
49 import org.onosproject.net.flow.DefaultTrafficSelector; 51 import org.onosproject.net.flow.DefaultTrafficSelector;
50 import org.onosproject.net.flow.DefaultTrafficTreatment; 52 import org.onosproject.net.flow.DefaultTrafficTreatment;
51 import org.onosproject.net.flow.TrafficSelector; 53 import org.onosproject.net.flow.TrafficSelector;
...@@ -60,8 +62,6 @@ import org.onosproject.net.flowobjective.ForwardingObjective; ...@@ -60,8 +62,6 @@ import org.onosproject.net.flowobjective.ForwardingObjective;
60 import org.onosproject.net.flowobjective.NextObjective; 62 import org.onosproject.net.flowobjective.NextObjective;
61 import org.onosproject.net.flowobjective.ObjectiveEvent; 63 import org.onosproject.net.flowobjective.ObjectiveEvent;
62 import org.onosproject.net.intent.TestTools; 64 import org.onosproject.net.intent.TestTools;
63 -import org.onosproject.openflow.DriverAdapter;
64 -import org.onosproject.openflow.DriverServiceAdapter;
65 65
66 import static org.hamcrest.CoreMatchers.hasItem; 66 import static org.hamcrest.CoreMatchers.hasItem;
67 import static org.hamcrest.MatcherAssert.assertThat; 67 import static org.hamcrest.MatcherAssert.assertThat;
......
...@@ -46,6 +46,13 @@ ...@@ -46,6 +46,13 @@
46 <groupId>org.onosproject</groupId> 46 <groupId>org.onosproject</groupId>
47 <artifactId>onos-api</artifactId> 47 <artifactId>onos-api</artifactId>
48 </dependency> 48 </dependency>
49 + <dependency>
50 + <groupId>org.onosproject</groupId>
51 + <artifactId>onos-api</artifactId>
52 + <scope>test</scope>
53 + <classifier>tests</classifier>
54 + <version>${project.version}</version>
55 + </dependency>
49 56
50 </dependencies> 57 </dependencies>
51 58
......
...@@ -18,6 +18,7 @@ package org.onosproject.openflow.controller.driver; ...@@ -18,6 +18,7 @@ package org.onosproject.openflow.controller.driver;
18 import org.jboss.netty.channel.Channel; 18 import org.jboss.netty.channel.Channel;
19 import org.junit.Before; 19 import org.junit.Before;
20 import org.junit.Test; 20 import org.junit.Test;
21 +import org.onosproject.core.netty.ChannelAdapter;
21 import org.onosproject.openflow.controller.Dpid; 22 import org.onosproject.openflow.controller.Dpid;
22 import org.onosproject.openflow.controller.OpenFlowEventListener; 23 import org.onosproject.openflow.controller.OpenFlowEventListener;
23 import org.projectfloodlight.openflow.protocol.OFMessage; 24 import org.projectfloodlight.openflow.protocol.OFMessage;
......
...@@ -47,6 +47,13 @@ ...@@ -47,6 +47,13 @@
47 <groupId>org.osgi</groupId> 47 <groupId>org.osgi</groupId>
48 <artifactId>org.osgi.compendium</artifactId> 48 <artifactId>org.osgi.compendium</artifactId>
49 </dependency> 49 </dependency>
50 + <dependency>
51 + <groupId>org.onosproject</groupId>
52 + <artifactId>onos-api</artifactId>
53 + <scope>test</scope>
54 + <classifier>tests</classifier>
55 + <version>${project.version}</version>
56 + </dependency>
50 </dependencies> 57 </dependencies>
51 58
52 <build> 59 <build>
......
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.openflow;
17 -
18 -import java.net.SocketAddress;
19 -
20 -import org.jboss.netty.channel.Channel;
21 -import org.jboss.netty.channel.ChannelConfig;
22 -import org.jboss.netty.channel.ChannelFactory;
23 -import org.jboss.netty.channel.ChannelFuture;
24 -import org.jboss.netty.channel.ChannelPipeline;
25 -
26 -/**
27 - * Adapter for testing against a netty channel.
28 - */
29 -public class ChannelAdapter implements Channel {
30 - @Override
31 - public Integer getId() {
32 - return null;
33 - }
34 -
35 - @Override
36 - public ChannelFactory getFactory() {
37 - return null;
38 - }
39 -
40 - @Override
41 - public Channel getParent() {
42 - return null;
43 - }
44 -
45 - @Override
46 - public ChannelConfig getConfig() {
47 - return null;
48 - }
49 -
50 - @Override
51 - public ChannelPipeline getPipeline() {
52 - return null;
53 - }
54 -
55 - @Override
56 - public boolean isOpen() {
57 - return false;
58 - }
59 -
60 - @Override
61 - public boolean isBound() {
62 - return false;
63 - }
64 -
65 - @Override
66 - public boolean isConnected() {
67 - return false;
68 - }
69 -
70 - @Override
71 - public SocketAddress getLocalAddress() {
72 - return null;
73 - }
74 -
75 - @Override
76 - public SocketAddress getRemoteAddress() {
77 - return null;
78 - }
79 -
80 - @Override
81 - public ChannelFuture write(Object o) {
82 - return null;
83 - }
84 -
85 - @Override
86 - public ChannelFuture write(Object o, SocketAddress socketAddress) {
87 - return null;
88 - }
89 -
90 - @Override
91 - public ChannelFuture bind(SocketAddress socketAddress) {
92 - return null;
93 - }
94 -
95 - @Override
96 - public ChannelFuture connect(SocketAddress socketAddress) {
97 - return null;
98 - }
99 -
100 - @Override
101 - public ChannelFuture disconnect() {
102 - return null;
103 - }
104 -
105 - @Override
106 - public ChannelFuture unbind() {
107 - return null;
108 - }
109 -
110 - @Override
111 - public ChannelFuture close() {
112 - return null;
113 - }
114 -
115 - @Override
116 - public ChannelFuture getCloseFuture() {
117 - return null;
118 - }
119 -
120 - @Override
121 - public int getInterestOps() {
122 - return 0;
123 - }
124 -
125 - @Override
126 - public boolean isReadable() {
127 - return false;
128 - }
129 -
130 - @Override
131 - public boolean isWritable() {
132 - return false;
133 - }
134 -
135 - @Override
136 - public ChannelFuture setInterestOps(int i) {
137 - return null;
138 - }
139 -
140 - @Override
141 - public ChannelFuture setReadable(boolean b) {
142 - return null;
143 - }
144 -
145 - @Override
146 - public boolean getUserDefinedWritability(int i) {
147 - return false;
148 - }
149 -
150 - @Override
151 - public void setUserDefinedWritability(int i, boolean b) {
152 -
153 - }
154 -
155 - @Override
156 - public Object getAttachment() {
157 - return null;
158 - }
159 -
160 - @Override
161 - public void setAttachment(Object o) {
162 -
163 - }
164 -
165 - @Override
166 - public int compareTo(Channel o) {
167 - return 0;
168 - }
169 -}
...@@ -29,10 +29,13 @@ import org.junit.rules.TemporaryFolder; ...@@ -29,10 +29,13 @@ import org.junit.rules.TemporaryFolder;
29 import org.onlab.junit.TestTools; 29 import org.onlab.junit.TestTools;
30 import org.onlab.util.ItemNotFoundException; 30 import org.onlab.util.ItemNotFoundException;
31 import org.onosproject.net.DeviceId; 31 import org.onosproject.net.DeviceId;
32 +import org.onosproject.net.driver.Behaviour;
32 import org.onosproject.net.driver.Driver; 33 import org.onosproject.net.driver.Driver;
33 -import org.onosproject.openflow.DriverAdapter; 34 +import org.onosproject.net.driver.DriverAdapter;
34 -import org.onosproject.openflow.DriverServiceAdapter; 35 +import org.onosproject.net.driver.DriverHandler;
36 +import org.onosproject.net.driver.DriverServiceAdapter;
35 import org.onosproject.openflow.OFDescStatsReplyAdapter; 37 import org.onosproject.openflow.OFDescStatsReplyAdapter;
38 +import org.onosproject.openflow.OpenflowSwitchDriverAdapter;
36 import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver; 39 import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
37 import org.projectfloodlight.openflow.protocol.OFDescStatsReply; 40 import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
38 import org.slf4j.Logger; 41 import org.slf4j.Logger;
...@@ -59,6 +62,17 @@ public class ControllerTest { ...@@ -59,6 +62,17 @@ public class ControllerTest {
59 Controller controller; 62 Controller controller;
60 protected static final Logger log = LoggerFactory.getLogger(ControllerTest.class); 63 protected static final Logger log = LoggerFactory.getLogger(ControllerTest.class);
61 64
65 + private class TestDriver extends DriverAdapter {
66 + @SuppressWarnings("unchecked")
67 + @Override
68 + public <T extends Behaviour> T createBehaviour(DriverHandler handler, Class<T> behaviourClass) {
69 + if (behaviourClass == OpenFlowSwitchDriver.class) {
70 + return (T) new OpenflowSwitchDriverAdapter();
71 + }
72 + return null;
73 + }
74 + }
75 +
62 /* 76 /*
63 * Writes the necessary file for the tests in the temporary directory 77 * Writes the necessary file for the tests in the temporary directory
64 */ 78 */
...@@ -91,7 +105,7 @@ public class ControllerTest { ...@@ -91,7 +105,7 @@ public class ControllerTest {
91 case ITEM_NOT_FOUND_DRIVER: 105 case ITEM_NOT_FOUND_DRIVER:
92 throw new ItemNotFoundException(); 106 throw new ItemNotFoundException();
93 case DRIVER_EXISTS: 107 case DRIVER_EXISTS:
94 - return new DriverAdapter(); 108 + return new TestDriver();
95 default: 109 default:
96 throw new AssertionError(); 110 throw new AssertionError();
97 } 111 }
......
...@@ -19,7 +19,7 @@ package org.onosproject.openflow.controller.impl; ...@@ -19,7 +19,7 @@ package org.onosproject.openflow.controller.impl;
19 import org.jboss.netty.buffer.ChannelBuffer; 19 import org.jboss.netty.buffer.ChannelBuffer;
20 import org.jboss.netty.buffer.ChannelBuffers; 20 import org.jboss.netty.buffer.ChannelBuffers;
21 import org.junit.Test; 21 import org.junit.Test;
22 -import org.onosproject.openflow.ChannelAdapter; 22 +import org.onosproject.core.netty.ChannelAdapter;
23 import org.onosproject.openflow.ChannelHandlerContextAdapter; 23 import org.onosproject.openflow.ChannelHandlerContextAdapter;
24 import org.projectfloodlight.openflow.protocol.OFHello; 24 import org.projectfloodlight.openflow.protocol.OFHello;
25 25
......