diff options
Diffstat (limited to 'framework/src/onos/core/api/src/test/java/org/onosproject/net/packet')
7 files changed, 0 insertions, 534 deletions
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultInboundPacketTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultInboundPacketTest.java deleted file mode 100644 index eda68240..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultInboundPacketTest.java +++ /dev/null @@ -1,81 +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.packet; - -import java.nio.ByteBuffer; - -import org.junit.Test; -import org.onlab.packet.Ethernet; -import org.onlab.packet.MacAddress; - -import com.google.common.testing.EqualsTester; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; -import static org.onosproject.net.NetTestTools.connectPoint; - -/** - * Unit tests for the DefaultInboundPacket class. - */ -public class DefaultInboundPacketTest { - - final Ethernet eth = new Ethernet() - .setDestinationMACAddress(MacAddress.BROADCAST) - .setSourceMACAddress(MacAddress.BROADCAST); - final ByteBuffer byteBuffer = ByteBuffer.wrap(eth.serialize()); - final DefaultInboundPacket packet1 = - new DefaultInboundPacket(connectPoint("d1", 1), - eth, - byteBuffer); - final DefaultInboundPacket sameAsPacket1 = - new DefaultInboundPacket(connectPoint("d1", 1), - eth, - byteBuffer); - final DefaultInboundPacket packet2 = - new DefaultInboundPacket(connectPoint("d2", 1), - eth, - byteBuffer); - /** - * Checks that the DefaultInboundPacket class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(DefaultInboundPacket.class); - } - - /** - * Tests the equals(), hashCode() and toString() methods. - */ - @Test - public void testEquals() { - new EqualsTester() - .addEqualityGroup(packet1, sameAsPacket1) - .addEqualityGroup(packet2) - .testEquals(); - } - - /** - * Tests the object creation through the constructor. - */ - @Test - public void testConstruction() { - assertThat(packet1.receivedFrom(), equalTo(connectPoint("d1", 1))); - assertThat(packet1.parsed(), equalTo(eth)); - assertThat(packet1.unparsed(), notNullValue()); - } -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultOutboundPacketTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultOutboundPacketTest.java deleted file mode 100644 index 21f997d9..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultOutboundPacketTest.java +++ /dev/null @@ -1,82 +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.packet; - -import java.nio.ByteBuffer; - -import org.junit.Test; -import org.onosproject.net.flow.TrafficTreatment; -import org.onosproject.net.intent.IntentTestsMocks; -import org.onlab.packet.Ethernet; -import org.onlab.packet.MacAddress; - -import com.google.common.testing.EqualsTester; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; -import static org.onosproject.net.NetTestTools.did; - -/** - * Unit tests for the DefaultOutboundPacketTest class. - */ -public class DefaultOutboundPacketTest { - final Ethernet eth = new Ethernet() - .setDestinationMACAddress(MacAddress.BROADCAST) - .setSourceMACAddress(MacAddress.BROADCAST); - final ByteBuffer byteBuffer = ByteBuffer.wrap(eth.serialize()); - final TrafficTreatment treatment = new IntentTestsMocks.MockTreatment(); - final DefaultOutboundPacket packet1 = - new DefaultOutboundPacket(did("d1"), - treatment, - byteBuffer); - final DefaultOutboundPacket sameAsPacket1 = - new DefaultOutboundPacket(did("d1"), - treatment, - byteBuffer); - final DefaultOutboundPacket packet2 = - new DefaultOutboundPacket(did("d2"), - treatment, - byteBuffer); - /** - * Checks that the DefaultOutboundPacket class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(DefaultOutboundPacket.class); - } - - /** - * Tests the equals(), hashCode() and toString() methods. - */ - @Test - public void testEquals() { - new EqualsTester() - .addEqualityGroup(packet1, sameAsPacket1) - .addEqualityGroup(packet2) - .testEquals(); - } - - /** - * Tests the object creation through the constructor. - */ - @Test - public void testConstruction() { - assertThat(packet1.sendThrough(), equalTo(did("d1"))); - assertThat(packet1.data(), equalTo(byteBuffer)); - assertThat(packet1.treatment(), equalTo(treatment)); - } -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultPacketContextTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultPacketContextTest.java deleted file mode 100644 index ee7ae7e5..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultPacketContextTest.java +++ /dev/null @@ -1,112 +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.packet; - -import java.nio.ByteBuffer; - -import org.junit.Test; -import org.onosproject.net.flow.TrafficTreatment; -import org.onosproject.net.intent.IntentTestsMocks; -import org.onlab.packet.Ethernet; -import org.onlab.packet.MacAddress; - -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.assertThatClassIsImmutableBaseClass; -import static org.onosproject.net.NetTestTools.connectPoint; -import static org.onosproject.net.NetTestTools.did; - -/** - * Unit tests for the DefaultPacketContextTest. - */ -public class DefaultPacketContextTest { - final Ethernet eth = new Ethernet() - .setDestinationMACAddress(MacAddress.BROADCAST) - .setSourceMACAddress(MacAddress.BROADCAST); - final ByteBuffer byteBuffer = ByteBuffer.wrap(eth.serialize()); - final DefaultInboundPacket inPacket = - new DefaultInboundPacket(connectPoint("d1", 1), - eth, - byteBuffer); - final TrafficTreatment treatment = new IntentTestsMocks.MockTreatment(); - final DefaultOutboundPacket outPacket = - new DefaultOutboundPacket(did("d1"), - treatment, - byteBuffer); - - static class MockPacketContext extends DefaultPacketContext { - - protected MockPacketContext(long time, InboundPacket inPkt, - OutboundPacket outPkt, boolean block) { - super(time, inPkt, outPkt, block); - } - - @Override - public void send() { - - } - - @Override - public boolean block() { - return super.block(); - } - } - - final DefaultPacketContext context1 = - new MockPacketContext(123L, inPacket, outPacket, true); - final DefaultPacketContext sameAsContext1 = - new MockPacketContext(123L, inPacket, outPacket, true); - final DefaultPacketContext context2 = - new MockPacketContext(123123L, inPacket, outPacket, true); - - /** - * Checks that the DefaultOutboundPacket class is immutable but can be - * used as a base class. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutableBaseClass(DefaultPacketContext.class); - } - - /** - * Tests the equals(), hashCode() and toString() methods. - */ - @Test - public void testEquals() { - // No hashCode() or equals() defined, object comparison is used. - new EqualsTester() - .addEqualityGroup(context1) - .addEqualityGroup(sameAsContext1) - .addEqualityGroup(context2) - .testEquals(); - } - - /** - * Tests that objects are created properly. - */ - @Test - public void testConstruction() { - assertThat(context1.block(), is(true)); - assertThat(context1.inPacket(), is(inPacket)); - assertThat(context1.isHandled(), is(true)); - assertThat(context1.outPacket(), is(outPacket)); - assertThat(context1.time(), is(123L)); - assertThat(context1.treatmentBuilder(), is(notNullValue())); - } -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultPacketRequestTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultPacketRequestTest.java deleted file mode 100644 index 592cd983..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/DefaultPacketRequestTest.java +++ /dev/null @@ -1,93 +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.packet; - -import org.junit.Test; -import org.onosproject.core.DefaultApplicationId; -import org.onosproject.net.NetTestTools; -import org.onosproject.net.flow.DefaultTrafficSelector; -import org.onosproject.net.flow.TrafficSelector; - -import com.google.common.testing.EqualsTester; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; - -/** - * Unit tests for the DefaultPacketRequest class. - */ -public class DefaultPacketRequestTest { - - private final TrafficSelector selector = DefaultTrafficSelector - .builder() - .matchIcmpCode((byte) 1) - .build(); - - private final DefaultPacketRequest packetRequest1 = - new DefaultPacketRequest(DefaultTrafficSelector.emptySelector(), - PacketPriority.CONTROL, - NetTestTools.APP_ID); - private final DefaultPacketRequest sameAsacketRequest1 = - new DefaultPacketRequest(DefaultTrafficSelector.emptySelector(), - PacketPriority.CONTROL, - NetTestTools.APP_ID); - private final DefaultPacketRequest packetRequest2 = - new DefaultPacketRequest(selector, - PacketPriority.CONTROL, - NetTestTools.APP_ID); - private final DefaultPacketRequest packetRequest3 = - new DefaultPacketRequest(DefaultTrafficSelector.emptySelector(), - PacketPriority.REACTIVE, - NetTestTools.APP_ID); - private final DefaultPacketRequest packetRequest4 = - new DefaultPacketRequest(DefaultTrafficSelector.emptySelector(), - PacketPriority.CONTROL, - new DefaultApplicationId(1, "foo")); - - /** - * Tests the operation of the equals(), toAstring() and hashCode() methods. - */ - @Test - public void testEquals() { - new EqualsTester() - .addEqualityGroup(packetRequest1, sameAsacketRequest1) - .addEqualityGroup(packetRequest2) - .addEqualityGroup(packetRequest3) - .addEqualityGroup(packetRequest4) - .testEquals(); - } - - /** - * Tests that building and fetching from a DefaultPacketRequest is correct. - */ - @Test - public void testConstruction() { - assertThat(packetRequest1.priority(), is(PacketPriority.CONTROL)); - assertThat(packetRequest1.priority().priorityValue(), - is(PacketPriority.CONTROL.priorityValue())); - assertThat(packetRequest1.selector(), is(DefaultTrafficSelector.emptySelector())); - assertThat(packetRequest1.appId(), is(NetTestTools.APP_ID)); - } - - /** - * Checks that the DefaultPacketRequest class is immutable. - */ - @Test - public void testImmutability() { - assertThatClassIsImmutable(DefaultPacketRequest.class); - } -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketEventTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketEventTest.java deleted file mode 100644 index f0d45f0c..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketEventTest.java +++ /dev/null @@ -1,51 +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.packet; - -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.is; - -/** - * Unit tests for PacketEvent class. - */ -public class PacketEventTest { - - OutboundPacket packet; - - @Test - public void testConstruction1() { - long time = System.currentTimeMillis(); - PacketEvent event = new PacketEvent(PacketEvent.Type.EMIT, packet); - - assertThat(event.type(), is(PacketEvent.Type.EMIT)); - assertThat(event.subject(), is(packet)); - assertThat(event.time(), greaterThanOrEqualTo(time)); - } - - @Test - public void testConstruction2() { - long time = 12345678; - PacketEvent event = new PacketEvent(PacketEvent.Type.EMIT, packet, time); - - assertThat(event.type(), is(PacketEvent.Type.EMIT)); - assertThat(event.subject(), is(packet)); - assertThat(event.time(), is(time)); - } - -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketProcessorTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketProcessorTest.java deleted file mode 100644 index 7b2ef541..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketProcessorTest.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.net.packet; - -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.lessThan; - -/** - * Unit tests for static APIs in the packet processor class. - */ -public class PacketProcessorTest { - - /** - * Tests a priority in the advisor range. - */ - @Test - public void testAdvisorPriorities() { - int advisorPriority = PacketProcessor.advisor(3); - assertThat(advisorPriority, lessThan(PacketProcessor.ADVISOR_MAX)); - assertThat(advisorPriority, greaterThanOrEqualTo(0)); - } - - /** - * Tests a priority in the director range. - */ - @Test - public void testDirectorPriorities() { - int directorPriority = PacketProcessor.director(3); - assertThat(directorPriority, lessThan(PacketProcessor.DIRECTOR_MAX)); - assertThat(directorPriority, greaterThanOrEqualTo(PacketProcessor.ADVISOR_MAX)); - } - - /** - * Tests a priority in the observer range. - */ - @Test - public void testObserverPriorities() { - int observerPriority = PacketProcessor.observer(3); - assertThat(observerPriority, lessThan(PacketProcessor.OBSERVER_MAX)); - assertThat(observerPriority, greaterThanOrEqualTo(PacketProcessor.DIRECTOR_MAX)); - } - -} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java deleted file mode 100644 index 2993ce6b..00000000 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java +++ /dev/null @@ -1,56 +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.packet; - -import org.onosproject.core.ApplicationId; -import org.onosproject.net.flow.TrafficSelector; - -import java.util.List; - -/** - * Test adapter for packet service. - */ -public class PacketServiceAdapter implements PacketService { - @Override - public void addProcessor(PacketProcessor processor, int priority) { - } - - @Override - public void removeProcessor(PacketProcessor processor) { - } - - @Override - public List<PacketProcessorEntry> getProcessors() { - return null; - } - - @Override - public List<PacketRequest> getRequests() { - return null; - } - - @Override - public void requestPackets(TrafficSelector selector, PacketPriority priority, ApplicationId appId) { - } - - @Override - public void cancelPackets(TrafficSelector selector, PacketPriority priority, ApplicationId appId) { - } - - @Override - public void emit(OutboundPacket packet) { - } -} |