Search in sources :

Example 16 with Frequency

use of org.onlab.util.Frequency in project onos by opennetworkinglab.

the class DefaultOmsPortTest method basicTests.

@Test
public void basicTests() {
    PortNumber pn = PortNumber.portNumber(4900);
    Annotations annotations = DefaultAnnotations.builder().set("Base", "value").build();
    boolean isEnabled = true;
    Port base = new DefaultPort(DEV, pn, isEnabled, Port.Type.VIRTUAL, 2, annotations);
    Frequency minFrequency = Frequency.ofGHz(3);
    Frequency maxFrequency = Frequency.ofGHz(33);
    Frequency grid = Frequency.ofGHz(2);
    OmsPort oms = new DefaultOmsPort(base, minFrequency, maxFrequency, grid);
    // basic attributes and annotations are inherited from base
    assertThat(oms.element(), is(DEV));
    assertThat(oms.isEnabled(), is(isEnabled));
    assertThat(oms.number(), is(pn));
    assertThat(oms.annotations(), is(annotations));
    assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
    assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
    assertThat(oms.maxFrequency(), is(maxFrequency));
    assertThat(oms.minFrequency(), is(minFrequency));
    assertThat(oms.grid(), is(grid));
    assertThat("((33-3)/2)+1 = 16", oms.totalChannels(), is((short) 16));
}
Also used : OmsPort(org.onosproject.net.optical.OmsPort) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) DefaultPort(org.onosproject.net.DefaultPort) OmsPort(org.onosproject.net.optical.OmsPort) Port(org.onosproject.net.Port) Frequency(org.onlab.util.Frequency) PortNumber(org.onosproject.net.PortNumber) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Example 17 with Frequency

use of org.onlab.util.Frequency in project onos by opennetworkinglab.

the class DefaultOmsPortTest method testEquality.

@Test
public void testEquality() {
    PortNumber pn = PortNumber.portNumber(4900);
    Annotations an = DefaultAnnotations.builder().set("Base", "value").build();
    Annotations an2 = DefaultAnnotations.builder().set("Base", "value2").build();
    Port base = new DefaultPort(DEV, pn, true, Port.Type.VIRTUAL, 2, an);
    Frequency minF = Frequency.ofGHz(3);
    Frequency maxF = Frequency.ofGHz(33);
    Frequency grid = Frequency.ofGHz(2);
    // reference OMS port
    OmsPort oms = new DefaultOmsPort(base, minF, maxF, grid);
    new EqualsTester().addEqualityGroup(oms, // different base port type or portspeed is ignored
    new DefaultOmsPort(new DefaultPort(DEV, pn, true, an), minF, maxF, grid)).addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, portNumber(1), true, an), minF, maxF, grid)).addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, pn, false, an), minF, maxF, grid)).addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, pn, true, an2), minF, maxF, grid)).addEqualityGroup(new DefaultOmsPort(base, Frequency.ofKHz(3), maxF, grid)).addEqualityGroup(new DefaultOmsPort(base, minF, Frequency.ofKHz(33), grid)).addEqualityGroup(new DefaultOmsPort(base, minF, maxF, Frequency.ofKHz(2))).testEquals();
}
Also used : OmsPort(org.onosproject.net.optical.OmsPort) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) EqualsTester(com.google.common.testing.EqualsTester) DefaultPort(org.onosproject.net.DefaultPort) OmsPort(org.onosproject.net.optical.OmsPort) Port(org.onosproject.net.Port) Frequency(org.onlab.util.Frequency) PortNumber(org.onosproject.net.PortNumber) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Aggregations

Frequency (org.onlab.util.Frequency)17 PortNumber (org.onosproject.net.PortNumber)6 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)5 DeviceId (org.onosproject.net.DeviceId)4 OchSignal (org.onosproject.net.OchSignal)4 Port (org.onosproject.net.Port)4 DeviceService (org.onosproject.net.device.DeviceService)4 Test (org.junit.Test)3 FlowRuleParser (org.onosproject.drivers.odtn.impl.FlowRuleParser)3 Annotations (org.onosproject.net.Annotations)3 ChannelSpacing (org.onosproject.net.ChannelSpacing)3 DefaultPort (org.onosproject.net.DefaultPort)3 GridType (org.onosproject.net.GridType)3 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)3 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)3 OmsPort (org.onosproject.net.optical.OmsPort)3 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)2 ImmutableList (com.google.common.collect.ImmutableList)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 StringReader (java.io.StringReader)2