tom

Added a slew of adapters to shorten the tests and to allow them to be used in more upcoming tests.

1 +package org.onlab.onos.net.device;
2 +
3 +import org.onlab.onos.net.Device;
4 +import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.MastershipRole;
6 +import org.onlab.onos.net.Port;
7 +import org.onlab.onos.net.PortNumber;
8 +
9 +import java.util.List;
10 +
11 +/**
12 + * Test adapter for device service.
13 + */
14 +public class DeviceServiceAdapter implements DeviceService {
15 + @Override
16 + public int getDeviceCount() {
17 + return 0;
18 + }
19 +
20 + @Override
21 + public Iterable<Device> getDevices() {
22 + return null;
23 + }
24 +
25 + @Override
26 + public Device getDevice(DeviceId deviceId) {
27 + return null;
28 + }
29 +
30 + @Override
31 + public MastershipRole getRole(DeviceId deviceId) {
32 + return null;
33 + }
34 +
35 + @Override
36 + public List<Port> getPorts(DeviceId deviceId) {
37 + return null;
38 + }
39 +
40 + @Override
41 + public Port getPort(DeviceId deviceId, PortNumber portNumber) {
42 + return null;
43 + }
44 +
45 + @Override
46 + public boolean isAvailable(DeviceId deviceId) {
47 + return false;
48 + }
49 +
50 + @Override
51 + public void addListener(DeviceListener listener) {
52 + }
53 +
54 + @Override
55 + public void removeListener(DeviceListener listener) {
56 + }
57 +
58 +}
1 +package org.onlab.onos.net.host;
2 +
3 +import org.onlab.onos.net.ConnectPoint;
4 +import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.Host;
6 +import org.onlab.onos.net.HostId;
7 +import org.onlab.packet.IPAddress;
8 +import org.onlab.packet.MACAddress;
9 +import org.onlab.packet.VLANID;
10 +
11 +import java.util.Set;
12 +
13 +/**
14 + * Test adapter for host service.
15 + */
16 +public class HostServiceAdapter implements HostService {
17 + @Override
18 + public int getHostCount() {
19 + return 0;
20 + }
21 +
22 + @Override
23 + public Iterable<Host> getHosts() {
24 + return null;
25 + }
26 +
27 + @Override
28 + public Host getHost(HostId hostId) {
29 + return null;
30 + }
31 +
32 + @Override
33 + public Set<Host> getHostsByVlan(VLANID vlanId) {
34 + return null;
35 + }
36 +
37 + @Override
38 + public Set<Host> getHostsByMac(MACAddress mac) {
39 + return null;
40 + }
41 +
42 + @Override
43 + public Set<Host> getHostsByIp(IPAddress ip) {
44 + return null;
45 + }
46 +
47 + @Override
48 + public Set<Host> getConnectedHosts(ConnectPoint connectPoint) {
49 + return null;
50 + }
51 +
52 + @Override
53 + public Set<Host> getConnectedHosts(DeviceId deviceId) {
54 + return null;
55 + }
56 +
57 + @Override
58 + public void addListener(HostListener listener) {
59 + }
60 +
61 + @Override
62 + public void removeListener(HostListener listener) {
63 + }
64 +
65 +}
1 +package org.onlab.onos.net.link;
2 +
3 +import org.onlab.onos.net.ConnectPoint;
4 +import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.Link;
6 +
7 +import java.util.Set;
8 +
9 +/**
10 + * Test adapter for link service.
11 + */
12 +public class LinkServiceAdapter implements LinkService {
13 + @Override
14 + public int getLinkCount() {
15 + return 0;
16 + }
17 +
18 + @Override
19 + public Iterable<Link> getLinks() {
20 + return null;
21 + }
22 +
23 + @Override
24 + public Set<Link> getDeviceLinks(DeviceId deviceId) {
25 + return null;
26 + }
27 +
28 + @Override
29 + public Set<Link> getDeviceEgressLinks(DeviceId deviceId) {
30 + return null;
31 + }
32 +
33 + @Override
34 + public Set<Link> getDeviceIngressLinks(DeviceId deviceId) {
35 + return null;
36 + }
37 +
38 + @Override
39 + public Set<Link> getLinks(ConnectPoint connectPoint) {
40 + return null;
41 + }
42 +
43 + @Override
44 + public Set<Link> getEgressLinks(ConnectPoint connectPoint) {
45 + return null;
46 + }
47 +
48 + @Override
49 + public Set<Link> getIngressLinks(ConnectPoint connectPoint) {
50 + return null;
51 + }
52 +
53 + @Override
54 + public Link getLink(ConnectPoint src, ConnectPoint dst) {
55 + return null;
56 + }
57 +
58 + @Override
59 + public void addListener(LinkListener listener) {
60 + }
61 +
62 + @Override
63 + public void removeListener(LinkListener listener) {
64 + }
65 +
66 +}
1 +package org.onlab.onos.net.topology;
2 +
3 +import org.onlab.onos.net.ConnectPoint;
4 +import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.Link;
6 +import org.onlab.onos.net.Path;
7 +
8 +import java.util.Set;
9 +
10 +/**
11 + * Test adapter for topology service.
12 + */
13 +public class TopologyServiceAdapter implements TopologyService {
14 + @Override
15 + public Topology currentTopology() {
16 + return null;
17 + }
18 +
19 + @Override
20 + public boolean isLatest(Topology topology) {
21 + return false;
22 + }
23 +
24 + @Override
25 + public TopologyGraph getGraph(Topology topology) {
26 + return null;
27 + }
28 +
29 + @Override
30 + public Set<TopologyCluster> getClusters(Topology topology) {
31 + return null;
32 + }
33 +
34 + @Override
35 + public TopologyCluster getCluster(Topology topology, ClusterId clusterId) {
36 + return null;
37 + }
38 +
39 + @Override
40 + public Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster) {
41 + return null;
42 + }
43 +
44 + @Override
45 + public Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster) {
46 + return null;
47 + }
48 +
49 + @Override
50 + public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst) {
51 + return null;
52 + }
53 +
54 + @Override
55 + public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
56 + return null;
57 + }
58 +
59 + @Override
60 + public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) {
61 + return false;
62 + }
63 +
64 + @Override
65 + public boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint) {
66 + return false;
67 + }
68 +
69 + @Override
70 + public void addListener(TopologyListener listener) {
71 + }
72 +
73 + @Override
74 + public void removeListener(TopologyListener listener) {
75 + }
76 +
77 +}
1 +package org.onlab.onos.of.controller;
2 +
3 +import org.projectfloodlight.openflow.protocol.OFMessage;
4 +
5 +/**
6 + * Test adapter for the OpenFlow controller interface.
7 + */
8 +public class OpenflowControllerAdapter implements OpenFlowController {
9 + @Override
10 + public Iterable<OpenFlowSwitch> getSwitches() {
11 + return null;
12 + }
13 +
14 + @Override
15 + public Iterable<OpenFlowSwitch> getMasterSwitches() {
16 + return null;
17 + }
18 +
19 + @Override
20 + public Iterable<OpenFlowSwitch> getEqualSwitches() {
21 + return null;
22 + }
23 +
24 + @Override
25 + public OpenFlowSwitch getSwitch(Dpid dpid) {
26 + return null;
27 + }
28 +
29 + @Override
30 + public OpenFlowSwitch getMasterSwitch(Dpid dpid) {
31 + return null;
32 + }
33 +
34 + @Override
35 + public OpenFlowSwitch getEqualSwitch(Dpid dpid) {
36 + return null;
37 + }
38 +
39 + @Override
40 + public void addListener(OpenFlowSwitchListener listener) {
41 + }
42 +
43 + @Override
44 + public void removeListener(OpenFlowSwitchListener listener) {
45 + }
46 +
47 + @Override
48 + public void addPacketListener(int priority, PacketListener listener) {
49 + }
50 +
51 + @Override
52 + public void removePacketListener(PacketListener listener) {
53 + }
54 +
55 + @Override
56 + public void write(Dpid dpid, OFMessage msg) {
57 + }
58 +
59 + @Override
60 + public void processPacket(Dpid dpid, OFMessage msg) {
61 + }
62 +
63 + @Override
64 + public void setRole(Dpid dpid, RoleState role) {
65 + }
66 +}
...@@ -144,10 +144,24 @@ ...@@ -144,10 +144,24 @@
144 </dependency> 144 </dependency>
145 <dependency> 145 <dependency>
146 <groupId>org.onlab.onos</groupId> 146 <groupId>org.onlab.onos</groupId>
147 - <artifactId>onos-of-api</artifactId> 147 + <artifactId>onos-api</artifactId>
148 <version>${project.version}</version> 148 <version>${project.version}</version>
149 + <classifier>tests</classifier>
150 + <scope>test</scope>
149 </dependency> 151 </dependency>
150 152
153 + <dependency>
154 + <groupId>org.onlab.onos</groupId>
155 + <artifactId>onos-of-api</artifactId>
156 + <version>${project.version}</version>
157 + </dependency>
158 + <dependency>
159 + <groupId>org.onlab.onos</groupId>
160 + <artifactId>onos-of-api</artifactId>
161 + <version>${project.version}</version>
162 + <classifier>tests</classifier>
163 + <scope>test</scope>
164 + </dependency>
151 </dependencies> 165 </dependencies>
152 </dependencyManagement> 166 </dependencyManagement>
153 167
......
1 package org.onlab.onos.provider.of.host.impl; 1 package org.onlab.onos.provider.of.host.impl;
2 2
3 -import static org.junit.Assert.assertEquals;
4 -import static org.junit.Assert.assertNotNull;
5 -import static org.junit.Assert.assertNull;
6 -
7 -import java.util.Set;
8 -
9 import org.junit.After; 3 import org.junit.After;
10 import org.junit.Before; 4 import org.junit.Before;
11 import org.junit.Test; 5 import org.junit.Test;
12 import org.onlab.onos.net.ConnectPoint; 6 import org.onlab.onos.net.ConnectPoint;
13 -import org.onlab.onos.net.DeviceId;
14 import org.onlab.onos.net.HostId; 7 import org.onlab.onos.net.HostId;
15 -import org.onlab.onos.net.Link;
16 -import org.onlab.onos.net.Path;
17 import org.onlab.onos.net.host.HostDescription; 8 import org.onlab.onos.net.host.HostDescription;
18 import org.onlab.onos.net.host.HostProvider; 9 import org.onlab.onos.net.host.HostProvider;
19 import org.onlab.onos.net.host.HostProviderRegistry; 10 import org.onlab.onos.net.host.HostProviderRegistry;
20 import org.onlab.onos.net.host.HostProviderService; 11 import org.onlab.onos.net.host.HostProviderService;
21 import org.onlab.onos.net.provider.AbstractProviderService; 12 import org.onlab.onos.net.provider.AbstractProviderService;
22 import org.onlab.onos.net.provider.ProviderId; 13 import org.onlab.onos.net.provider.ProviderId;
23 -import org.onlab.onos.net.topology.ClusterId;
24 -import org.onlab.onos.net.topology.LinkWeight;
25 import org.onlab.onos.net.topology.Topology; 14 import org.onlab.onos.net.topology.Topology;
26 -import org.onlab.onos.net.topology.TopologyCluster; 15 +import org.onlab.onos.net.topology.TopologyServiceAdapter;
27 -import org.onlab.onos.net.topology.TopologyGraph;
28 -import org.onlab.onos.net.topology.TopologyListener;
29 -import org.onlab.onos.net.topology.TopologyService;
30 import org.onlab.onos.of.controller.Dpid; 16 import org.onlab.onos.of.controller.Dpid;
31 -import org.onlab.onos.of.controller.OpenFlowController;
32 import org.onlab.onos.of.controller.OpenFlowPacketContext; 17 import org.onlab.onos.of.controller.OpenFlowPacketContext;
33 -import org.onlab.onos.of.controller.OpenFlowSwitch; 18 +import org.onlab.onos.of.controller.OpenflowControllerAdapter;
34 -import org.onlab.onos.of.controller.OpenFlowSwitchListener;
35 import org.onlab.onos.of.controller.PacketListener; 19 import org.onlab.onos.of.controller.PacketListener;
36 -import org.onlab.onos.of.controller.RoleState;
37 import org.onlab.packet.ARP; 20 import org.onlab.packet.ARP;
38 import org.onlab.packet.Ethernet; 21 import org.onlab.packet.Ethernet;
39 import org.onlab.packet.MACAddress; 22 import org.onlab.packet.MACAddress;
...@@ -41,6 +24,10 @@ import org.onlab.packet.VLANID; ...@@ -41,6 +24,10 @@ import org.onlab.packet.VLANID;
41 import org.projectfloodlight.openflow.protocol.OFMessage; 24 import org.projectfloodlight.openflow.protocol.OFMessage;
42 import org.projectfloodlight.openflow.types.OFPort; 25 import org.projectfloodlight.openflow.types.OFPort;
43 26
27 +import java.util.Set;
28 +
29 +import static org.junit.Assert.*;
30 +
44 public class OpenFlowHostProviderTest { 31 public class OpenFlowHostProviderTest {
45 32
46 private static final Integer INPORT = 10; 33 private static final Integer INPORT = 10;
...@@ -145,124 +132,22 @@ public class OpenFlowHostProviderTest { ...@@ -145,124 +132,22 @@ public class OpenFlowHostProviderTest {
145 132
146 } 133 }
147 134
148 - private class TestController implements OpenFlowController { 135 + private class TestController extends OpenflowControllerAdapter {
149 -
150 PacketListener pktListener; 136 PacketListener pktListener;
151 137
152 @Override 138 @Override
153 - public Iterable<OpenFlowSwitch> getSwitches() {
154 - return null;
155 - }
156 -
157 - @Override
158 - public Iterable<OpenFlowSwitch> getMasterSwitches() {
159 - return null;
160 - }
161 -
162 - @Override
163 - public Iterable<OpenFlowSwitch> getEqualSwitches() {
164 - return null;
165 - }
166 -
167 - @Override
168 - public OpenFlowSwitch getSwitch(Dpid dpid) {
169 - return null;
170 - }
171 -
172 - @Override
173 - public OpenFlowSwitch getMasterSwitch(Dpid dpid) {
174 - return null;
175 - }
176 -
177 - @Override
178 - public OpenFlowSwitch getEqualSwitch(Dpid dpid) {
179 - return null;
180 - }
181 -
182 - @Override
183 - public void addListener(OpenFlowSwitchListener listener) {
184 - }
185 -
186 - @Override
187 - public void removeListener(OpenFlowSwitchListener listener) {
188 - }
189 -
190 - @Override
191 public void addPacketListener(int priority, PacketListener listener) { 139 public void addPacketListener(int priority, PacketListener listener) {
192 pktListener = listener; 140 pktListener = listener;
193 } 141 }
194 142
195 @Override 143 @Override
196 - public void removePacketListener(PacketListener listener) {
197 - }
198 -
199 - @Override
200 - public void write(Dpid dpid, OFMessage msg) {
201 - }
202 -
203 - @Override
204 public void processPacket(Dpid dpid, OFMessage msg) { 144 public void processPacket(Dpid dpid, OFMessage msg) {
205 - OpenFlowPacketContext ctx = 145 + OpenFlowPacketContext ctx = new TestPacketContext(dpid);
206 - new TestPacketContext(dpid);
207 -
208 pktListener.handlePacket(ctx); 146 pktListener.handlePacket(ctx);
209 } 147 }
210 -
211 - @Override
212 - public void setRole(Dpid dpid, RoleState role) {
213 - }
214 - }
215 -
216 - private class TestTopologyService implements TopologyService {
217 -
218 - @Override
219 - public Topology currentTopology() {
220 - return null;
221 - }
222 -
223 - @Override
224 - public boolean isLatest(Topology topology) {
225 - return false;
226 - }
227 -
228 - @Override
229 - public TopologyGraph getGraph(Topology topology) {
230 - return null;
231 - }
232 -
233 - @Override
234 - public Set<TopologyCluster> getClusters(Topology topology) {
235 - return null;
236 - }
237 -
238 - @Override
239 - public TopologyCluster getCluster(Topology topology, ClusterId clusterId) {
240 - return null;
241 - }
242 -
243 - @Override
244 - public Set<DeviceId> getClusterDevices(Topology topology,
245 - TopologyCluster cluster) {
246 - return null;
247 - }
248 -
249 - @Override
250 - public Set<Link> getClusterLinks(Topology topology,
251 - TopologyCluster cluster) {
252 - return null;
253 - }
254 -
255 - @Override
256 - public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst) {
257 - return null;
258 - }
259 -
260 - @Override
261 - public Set<Path> getPaths(Topology topology, DeviceId src,
262 - DeviceId dst, LinkWeight weight) {
263 - return null;
264 } 148 }
265 149
150 + private class TestTopologyService extends TopologyServiceAdapter {
266 @Override 151 @Override
267 public boolean isInfrastructure(Topology topology, 152 public boolean isInfrastructure(Topology topology,
268 ConnectPoint connectPoint) { 153 ConnectPoint connectPoint) {
...@@ -272,21 +157,6 @@ public class OpenFlowHostProviderTest { ...@@ -272,21 +157,6 @@ public class OpenFlowHostProviderTest {
272 } 157 }
273 return false; 158 return false;
274 } 159 }
275 -
276 - @Override
277 - public boolean isBroadcastPoint(Topology topology,
278 - ConnectPoint connectPoint) {
279 - return false;
280 - }
281 -
282 - @Override
283 - public void addListener(TopologyListener listener) {
284 - }
285 -
286 - @Override
287 - public void removeListener(TopologyListener listener) {
288 - }
289 -
290 } 160 }
291 161
292 private class TestPacketContext implements OpenFlowPacketContext { 162 private class TestPacketContext implements OpenFlowPacketContext {
......
...@@ -28,6 +28,19 @@ ...@@ -28,6 +28,19 @@
28 <groupId>org.onlab.onos</groupId> 28 <groupId>org.onlab.onos</groupId>
29 <artifactId>onos-of-api</artifactId> 29 <artifactId>onos-of-api</artifactId>
30 </dependency> 30 </dependency>
31 + <dependency>
32 + <groupId>org.onlab.onos</groupId>
33 + <artifactId>onos-of-api</artifactId>
34 + <classifier>tests</classifier>
35 + <scope>test</scope>
36 + </dependency>
37 +
38 + <dependency>
39 + <groupId>org.onlab.onos</groupId>
40 + <artifactId>onos-api</artifactId>
41 + <classifier>tests</classifier>
42 + <scope>test</scope>
43 + </dependency>
31 </dependencies> 44 </dependencies>
32 45
33 </project> 46 </project>
......