diff options
Diffstat (limited to 'framework/src/onos/core/api/src/test/java/org/onosproject/net/device')
5 files changed, 0 insertions, 382 deletions
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DefaultDeviceDescriptionTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DefaultDeviceDescriptionTest.java deleted file mode 100644 index c00a6de0..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DefaultDeviceDescriptionTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2014 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.net.device; - -import org.junit.Test; -import org.onlab.packet.ChassisId; - -import java.net.URI; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.onosproject.net.Device.Type.SWITCH; - -/** - * Test of the default device description. - */ -public class DefaultDeviceDescriptionTest { - - private static final URI DURI = URI.create("of:foo"); - private static final String MFR = "whitebox"; - private static final String HW = "1.1.x"; - private static final String SW = "3.9.1"; - private static final String SN = "43311-12345"; - private static final ChassisId CID = new ChassisId(); - - - @Test - public void basics() { - DeviceDescription device = - new DefaultDeviceDescription(DURI, SWITCH, MFR, HW, SW, SN, CID); - assertEquals("incorrect uri", DURI, device.deviceUri()); - assertEquals("incorrect type", SWITCH, device.type()); - assertEquals("incorrect manufacturer", MFR, device.manufacturer()); - assertEquals("incorrect hw", HW, device.hwVersion()); - assertEquals("incorrect sw", SW, device.swVersion()); - assertEquals("incorrect serial", SN, device.serialNumber()); - assertTrue("incorrect toString", device.toString().contains("uri=of:foo")); - assertTrue("Incorrect chassis", device.chassisId().value() == 0); - } - -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DefaultPortStatisticsTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DefaultPortStatisticsTest.java deleted file mode 100644 index b691ebc3..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DefaultPortStatisticsTest.java +++ /dev/null @@ -1,126 +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.net.device; - -import java.lang.reflect.Constructor; -import java.util.Arrays; - -import org.junit.Assert; -import org.junit.Test; -import org.onosproject.net.NetTestTools; - -import com.google.common.testing.EqualsTester; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; - -/** - * DefaultPortStatistics unit tests. - */ -public class DefaultPortStatisticsTest { - - private final PortStatistics stats1 = DefaultPortStatistics.builder() - .setBytesReceived(1) - .setBytesSent(2) - .setDurationNano(3) - .setDurationSec(4) - .setPacketsReceived(5) - .setPacketsSent(6) - .setPacketsRxDropped(7) - .setPacketsRxErrors(8) - .setPacketsTxDropped(9) - .setPacketsTxErrors(10) - .setPort(80) - .setDeviceId(NetTestTools.did("1")) - .build(); - - private final PortStatistics stats2 = DefaultPortStatistics.builder() - .setBytesReceived(1) - .setBytesSent(2) - .setDurationNano(3) - .setDurationSec(4) - .setPacketsReceived(5) - .setPacketsSent(6) - .setPacketsRxDropped(7) - .setPacketsRxErrors(8) - .setPacketsTxDropped(9) - .setPacketsTxErrors(11) - .setPort(80) - .setDeviceId(NetTestTools.did("1")) - .build(); - - /** - * Checks that the GroupOperation class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(DefaultPortStatistics.class); - } - - @Test - public void testConstruction() { - assertThat(stats1.bytesReceived(), is(1L)); - assertThat(stats1.bytesSent(), is(2L)); - assertThat(stats1.durationNano(), is(3L)); - assertThat(stats1.durationSec(), is(4L)); - assertThat(stats1.packetsReceived(), is(5L)); - assertThat(stats1.packetsSent(), is(6L)); - assertThat(stats1.packetsRxDropped(), is(7L)); - assertThat(stats1.packetsRxErrors(), is(8L)); - assertThat(stats1.packetsTxDropped(), is(9L)); - assertThat(stats1.packetsTxErrors(), is(10L)); - assertThat(stats1.port(), is(80)); - } - - /** - * Tests the equals, hashCode and toString methods using Guava EqualsTester. - */ - @Test - public void testEquals() { - new EqualsTester() - .addEqualityGroup(stats1, stats1) - .addEqualityGroup(stats2) - .testEquals(); - } - - /** - * Tests that the empty argument list constructor for serialization - * is present and creates a proper object. - */ - @Test - public void testSerializerConstructor() { - try { - Constructor[] constructors = DefaultPortStatistics.class.getDeclaredConstructors(); - assertThat(constructors, notNullValue()); - Arrays.stream(constructors).filter(ctor -> - ctor.getParameterTypes().length == 0) - .forEach(noParamsCtor -> { - try { - noParamsCtor.setAccessible(true); - DefaultPortStatistics stats = - (DefaultPortStatistics) noParamsCtor.newInstance(); - assertThat(stats, notNullValue()); - } catch (Exception e) { - Assert.fail("Exception instantiating no parameters constructor"); - } - }); - } catch (Exception e) { - Assert.fail("Exception looking up constructors"); - } - } -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java deleted file mode 100644 index 7b43da6a..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java +++ /dev/null @@ -1,36 +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.net.device; - -import org.onosproject.net.DeviceId; -import org.onosproject.store.Timestamp; - -/** - * Test adapter for device clock service. - */ -public class DeviceClockServiceAdapter implements DeviceClockService { - - @Override - public boolean isTimestampAvailable(DeviceId deviceId) { - return false; - } - - @Override - public Timestamp getTimestamp(DeviceId deviceId) { - return null; - } - -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceEventTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceEventTest.java deleted file mode 100644 index a0fb9358..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceEventTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2014 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.net.device; - -import static org.junit.Assert.assertEquals; -import static org.onosproject.net.DeviceId.deviceId; - -import org.junit.Test; -import org.onosproject.event.AbstractEventTest; -import org.onosproject.net.DefaultDevice; -import org.onosproject.net.DefaultPort; -import org.onosproject.net.Device; -import org.onosproject.net.Port; -import org.onosproject.net.PortNumber; -import org.onosproject.net.provider.ProviderId; -import org.onlab.packet.ChassisId; - -/** - * Tests of the device event. - */ -public class DeviceEventTest extends AbstractEventTest { - - private Device createDevice() { - return new DefaultDevice(new ProviderId("of", "foo"), deviceId("of:foo"), - Device.Type.SWITCH, "box", "hw", "sw", "sn", new ChassisId()); - } - - @Override - @Test - public void withTime() { - Device device = createDevice(); - Port port = new DefaultPort(device, PortNumber.portNumber(123), true); - DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, - device, port, 123L); - validateEvent(event, DeviceEvent.Type.DEVICE_ADDED, device, 123L); - assertEquals("incorrect port", port, event.port()); - } - - @Override - @Test - public void withoutTime() { - Device device = createDevice(); - Port port = new DefaultPort(device, PortNumber.portNumber(123), true); - long before = System.currentTimeMillis(); - DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device, port); - long after = System.currentTimeMillis(); - validateEvent(event, DeviceEvent.Type.DEVICE_ADDED, device, before, after); - } - -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java deleted file mode 100644 index 5f52f6db..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java +++ /dev/null @@ -1,103 +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.net.device; - -import com.google.common.collect.FluentIterable; - -import org.onosproject.net.Device; -import org.onosproject.net.Device.Type; -import org.onosproject.net.DeviceId; -import org.onosproject.net.MastershipRole; -import org.onosproject.net.Port; -import org.onosproject.net.PortNumber; - -import java.util.Collections; -import java.util.List; - -/** - * Test adapter for device service. - */ -public class DeviceServiceAdapter implements DeviceService { - @Override - public int getDeviceCount() { - return 0; - } - - @Override - public Iterable<Device> getDevices() { - return Collections.emptyList(); - } - - @Override - public Iterable<Device> getAvailableDevices() { - return FluentIterable.from(getDevices()) - .filter(input -> isAvailable(input.id())); - } - - @Override - public Device getDevice(DeviceId deviceId) { - return null; - } - - @Override - public MastershipRole getRole(DeviceId deviceId) { - return MastershipRole.NONE; - } - - @Override - public List<Port> getPorts(DeviceId deviceId) { - return Collections.emptyList(); - } - - @Override - public List<PortStatistics> getPortStatistics(DeviceId deviceId) { - return null; - } - - @Override - public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) { - return null; - } - - @Override - public Port getPort(DeviceId deviceId, PortNumber portNumber) { - return null; - } - - @Override - public boolean isAvailable(DeviceId deviceId) { - return false; - } - - @Override - public void addListener(DeviceListener listener) { - } - - @Override - public void removeListener(DeviceListener listener) { - } - - @Override - public Iterable<Device> getDevices(Type type) { - return Collections.emptyList(); - } - - @Override - public Iterable<Device> getAvailableDevices(Type type) { - return Collections.emptyList(); - } - -} |