mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-24 22:01:02 +02:00
Unit tests for some uncovered Intent types
Change-Id: I9ddd0a4f8d12222b6f5c6bc2d127d6082bc0649d
This commit is contained in:
parent
3ad8d4b181
commit
a05fd20b79
@ -15,15 +15,70 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.net.intent;
|
package org.onosproject.net.intent;
|
||||||
|
|
||||||
import org.junit.Test;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.onlab.packet.MplsLabel;
|
||||||
|
import org.onosproject.net.flow.TrafficSelector;
|
||||||
|
import org.onosproject.net.flow.TrafficTreatment;
|
||||||
|
|
||||||
|
import com.google.common.testing.EqualsTester;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
|
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
|
||||||
|
import static org.onosproject.net.NetTestTools.APP_ID;
|
||||||
|
import static org.onosproject.net.NetTestTools.connectPoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for the MplsIntent class.
|
* Unit tests for the MplsIntent class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MplsIntentTest {
|
public class MplsIntentTest extends AbstractIntentTest {
|
||||||
|
static final int PRIORITY = 22;
|
||||||
|
|
||||||
|
MplsIntent intent1;
|
||||||
|
MplsIntent intent2;
|
||||||
|
|
||||||
|
Optional<MplsLabel> label1;
|
||||||
|
Optional<MplsLabel> label2;
|
||||||
|
|
||||||
|
TrafficSelector selector;
|
||||||
|
TrafficTreatment treatment;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void mplsIntentTestSetUp() throws Exception {
|
||||||
|
|
||||||
|
label1 = Optional.of(MplsLabel.mplsLabel(1));
|
||||||
|
label2 = Optional.of(MplsLabel.mplsLabel(2));
|
||||||
|
|
||||||
|
selector = new IntentTestsMocks.MockSelector();
|
||||||
|
treatment = new IntentTestsMocks.MockTreatment();
|
||||||
|
|
||||||
|
intent1 = MplsIntent.builder()
|
||||||
|
.appId(APP_ID)
|
||||||
|
.ingressLabel(label1)
|
||||||
|
.egressLabel(label2)
|
||||||
|
.ingressPoint(connectPoint("in", 1))
|
||||||
|
.egressPoint(connectPoint("out", 1))
|
||||||
|
.selector(selector)
|
||||||
|
.treatment(treatment)
|
||||||
|
.priority(PRIORITY)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
intent2 = MplsIntent.builder()
|
||||||
|
.appId(APP_ID)
|
||||||
|
.ingressLabel(label1)
|
||||||
|
.egressLabel(label2)
|
||||||
|
.ingressPoint(connectPoint("in", 2))
|
||||||
|
.egressPoint(connectPoint("out", 2))
|
||||||
|
.selector(selector)
|
||||||
|
.treatment(treatment)
|
||||||
|
.priority(PRIORITY)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that the MplsIntent class is immutable.
|
* Checks that the MplsIntent class is immutable.
|
||||||
@ -33,4 +88,30 @@ public class MplsIntentTest {
|
|||||||
assertThatClassIsImmutable(MplsIntent.class);
|
assertThatClassIsImmutable(MplsIntent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the operation of equals(), hashCode() and toString() methods.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testEquals() {
|
||||||
|
new EqualsTester()
|
||||||
|
.addEqualityGroup(intent1)
|
||||||
|
.addEqualityGroup(intent2)
|
||||||
|
.testEquals();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that the MplsIntent objects are created correctly.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testContents() {
|
||||||
|
assertThat(intent1.appId(), equalTo(APP_ID));
|
||||||
|
assertThat(intent1.ingressLabel(), equalTo(label1));
|
||||||
|
assertThat(intent1.egressLabel(), equalTo(label2));
|
||||||
|
assertThat(intent1.ingressPoint(), equalTo(connectPoint("in", 1)));
|
||||||
|
assertThat(intent1.egressPoint(), equalTo(connectPoint("out", 1)));
|
||||||
|
assertThat(intent1.selector(), equalTo(intent2.selector()));
|
||||||
|
assertThat(intent1.treatment(), equalTo(intent2.treatment()));
|
||||||
|
assertThat(intent1.priority(), is(PRIORITY));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,14 +15,64 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.net.intent;
|
package org.onosproject.net.intent;
|
||||||
|
|
||||||
import org.junit.Test;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.onlab.packet.MplsLabel;
|
||||||
|
import org.onosproject.net.Path;
|
||||||
|
import org.onosproject.net.flow.TrafficSelector;
|
||||||
|
import org.onosproject.net.flow.TrafficTreatment;
|
||||||
|
|
||||||
|
import com.google.common.testing.EqualsTester;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
|
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
|
||||||
|
import static org.onosproject.net.NetTestTools.APP_ID;
|
||||||
|
import static org.onosproject.net.NetTestTools.createPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for the MplsPathIntent class.
|
* Unit tests for the MplsPathIntent class.
|
||||||
*/
|
*/
|
||||||
public class MplsPathIntentTest {
|
public class MplsPathIntentTest extends AbstractIntentTest {
|
||||||
|
|
||||||
|
static final int PRIORITY = 777;
|
||||||
|
|
||||||
|
MplsPathIntent intent1;
|
||||||
|
MplsPathIntent intent2;
|
||||||
|
Path defaultPath;
|
||||||
|
Optional<MplsLabel> label1;
|
||||||
|
Optional<MplsLabel> label2;
|
||||||
|
TrafficSelector selector;
|
||||||
|
TrafficTreatment treatment;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void mplsPathIntentTestSetUp() {
|
||||||
|
defaultPath = createPath("a", "b", "c");
|
||||||
|
selector = new IntentTestsMocks.MockSelector();
|
||||||
|
treatment = new IntentTestsMocks.MockTreatment();
|
||||||
|
|
||||||
|
label1 = Optional.of(MplsLabel.mplsLabel(1));
|
||||||
|
label2 = Optional.of(MplsLabel.mplsLabel(2));
|
||||||
|
intent1 = MplsPathIntent.builder()
|
||||||
|
.appId(APP_ID)
|
||||||
|
.ingressLabel(label1)
|
||||||
|
.egressLabel(label2)
|
||||||
|
.path(defaultPath)
|
||||||
|
.priority(PRIORITY)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
intent2 = MplsPathIntent.builder()
|
||||||
|
.appId(APP_ID)
|
||||||
|
.ingressLabel(label1)
|
||||||
|
.egressLabel(label2)
|
||||||
|
.path(defaultPath)
|
||||||
|
.priority(PRIORITY)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that the MplsPathIntent class is immutable.
|
* Checks that the MplsPathIntent class is immutable.
|
||||||
@ -32,4 +82,29 @@ public class MplsPathIntentTest {
|
|||||||
assertThatClassIsImmutable(MplsPathIntent.class);
|
assertThatClassIsImmutable(MplsPathIntent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the operation of equals(), hashCode() and toString() methods.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testEquals() {
|
||||||
|
new EqualsTester()
|
||||||
|
.addEqualityGroup(intent1)
|
||||||
|
.addEqualityGroup(intent2)
|
||||||
|
.testEquals();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that the MPLS path intent objects are created correctly.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testContents() {
|
||||||
|
assertThat(intent1.appId(), equalTo(APP_ID));
|
||||||
|
assertThat(intent1.ingressLabel(), equalTo(label1));
|
||||||
|
assertThat(intent1.egressLabel(), equalTo(label2));
|
||||||
|
assertThat(intent1.selector(), equalTo(intent2.selector()));
|
||||||
|
assertThat(intent1.treatment(), equalTo(intent2.treatment()));
|
||||||
|
assertThat(intent1.priority(), is(PRIORITY));
|
||||||
|
assertThat(intent1.path(), is(defaultPath));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,11 +15,48 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.net.intent;
|
package org.onosproject.net.intent;
|
||||||
|
|
||||||
|
import org.hamcrest.Matchers;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.onosproject.net.Path;
|
||||||
|
|
||||||
|
import com.google.common.testing.EqualsTester;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
|
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
|
||||||
|
import static org.onosproject.net.NetTestTools.APP_ID;
|
||||||
|
import static org.onosproject.net.NetTestTools.connectPoint;
|
||||||
|
import static org.onosproject.net.NetTestTools.createPath;
|
||||||
|
|
||||||
public class OpticalPathIntentTest {
|
public class OpticalPathIntentTest extends AbstractIntentTest {
|
||||||
|
|
||||||
|
static final int PRIORITY = 777;
|
||||||
|
|
||||||
|
OpticalPathIntent intent1;
|
||||||
|
OpticalPathIntent intent2;
|
||||||
|
Path defaultPath;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void opticalPathIntentTestSetUp() {
|
||||||
|
defaultPath = createPath("a", "b", "c");
|
||||||
|
intent1 = OpticalPathIntent.builder()
|
||||||
|
.appId(APP_ID)
|
||||||
|
.src(connectPoint("one", 1))
|
||||||
|
.dst(connectPoint("two", 2))
|
||||||
|
.path(defaultPath)
|
||||||
|
.priority(PRIORITY)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
intent2 = OpticalPathIntent.builder()
|
||||||
|
.appId(APP_ID)
|
||||||
|
.src(connectPoint("two", 1))
|
||||||
|
.dst(connectPoint("one", 2))
|
||||||
|
.path(defaultPath)
|
||||||
|
.priority(PRIORITY)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that the OpticalPathIntent class is immutable.
|
* Checks that the OpticalPathIntent class is immutable.
|
||||||
@ -29,4 +66,26 @@ public class OpticalPathIntentTest {
|
|||||||
assertThatClassIsImmutable(OpticalPathIntent.class);
|
assertThatClassIsImmutable(OpticalPathIntent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the operation of equals(), hashCode() and toString() methods.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testEquals() {
|
||||||
|
new EqualsTester()
|
||||||
|
.addEqualityGroup(intent1)
|
||||||
|
.addEqualityGroup(intent2)
|
||||||
|
.testEquals();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that the optical path ntent objects are created correctly.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testContents() {
|
||||||
|
assertThat(intent1.appId(), equalTo(APP_ID));
|
||||||
|
assertThat(intent1.src(), Matchers.equalTo(connectPoint("one", 1)));
|
||||||
|
assertThat(intent1.dst(), Matchers.equalTo(connectPoint("two", 2)));
|
||||||
|
assertThat(intent1.priority(), is(PRIORITY));
|
||||||
|
assertThat(intent1.path(), is(defaultPath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,14 +15,56 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.net.intent;
|
package org.onosproject.net.intent;
|
||||||
|
|
||||||
|
import org.hamcrest.Matchers;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.onosproject.net.flow.TrafficSelector;
|
||||||
|
import org.onosproject.net.flow.TrafficTreatment;
|
||||||
|
|
||||||
|
import com.google.common.testing.EqualsTester;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
|
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
|
||||||
|
import static org.onosproject.net.NetTestTools.APP_ID;
|
||||||
|
import static org.onosproject.net.NetTestTools.connectPoint;
|
||||||
/**
|
/**
|
||||||
* Unit tests for the TwoWayP2PIntent class.
|
* Unit tests for the TwoWayP2PIntent class.
|
||||||
*/
|
*/
|
||||||
public class TwoWayP2PIntentTest {
|
public class TwoWayP2PIntentTest extends AbstractIntentTest {
|
||||||
|
|
||||||
|
TrafficSelector selector;
|
||||||
|
TrafficTreatment treatment;
|
||||||
|
|
||||||
|
TwoWayP2PIntent intent1;
|
||||||
|
TwoWayP2PIntent intent2;
|
||||||
|
|
||||||
|
static final int PRIORITY = 12;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void twoWatP2PIntentTestSetUp() {
|
||||||
|
selector = new IntentTestsMocks.MockSelector();
|
||||||
|
treatment = new IntentTestsMocks.MockTreatment();
|
||||||
|
|
||||||
|
intent1 = TwoWayP2PIntent.builder()
|
||||||
|
.appId(APP_ID)
|
||||||
|
.priority(PRIORITY)
|
||||||
|
.selector(selector)
|
||||||
|
.treatment(treatment)
|
||||||
|
.one(connectPoint("one", 1))
|
||||||
|
.two(connectPoint("two", 2))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
intent2 = TwoWayP2PIntent.builder()
|
||||||
|
.appId(APP_ID)
|
||||||
|
.priority(PRIORITY)
|
||||||
|
.selector(selector)
|
||||||
|
.treatment(treatment)
|
||||||
|
.one(connectPoint("two", 2))
|
||||||
|
.two(connectPoint("three", 2))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that the TwoWayP2PIntent class is immutable.
|
* Checks that the TwoWayP2PIntent class is immutable.
|
||||||
@ -32,4 +74,27 @@ public class TwoWayP2PIntentTest {
|
|||||||
assertThatClassIsImmutable(TwoWayP2PIntent.class);
|
assertThatClassIsImmutable(TwoWayP2PIntent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the operation of equals(), hashCode() and toString() methods.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testEquals() {
|
||||||
|
new EqualsTester()
|
||||||
|
.addEqualityGroup(intent1)
|
||||||
|
.addEqualityGroup(intent2)
|
||||||
|
.testEquals();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that the optical path ntent objects are created correctly.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testContents() {
|
||||||
|
assertThat(intent1.appId(), equalTo(APP_ID));
|
||||||
|
assertThat(intent1.one(), Matchers.equalTo(connectPoint("one", 1)));
|
||||||
|
assertThat(intent1.two(), Matchers.equalTo(connectPoint("two", 2)));
|
||||||
|
assertThat(intent1.priority(), is(PRIORITY));
|
||||||
|
assertThat(intent1.selector(), is(selector));
|
||||||
|
assertThat(intent1.treatment(), is(treatment));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user