Sovietaced | 13f8802 | 2014-12-02 06:38:34 -0500 | [diff] [blame^] | 1 | package org.projectfloodlight.protocol; |
| 2 | |
| 3 | import java.util.Arrays; |
| 4 | import java.util.HashSet; |
| 5 | |
| 6 | import org.junit.Test; |
| 7 | import org.projectfloodlight.openflow.protocol.OFFactories; |
| 8 | import org.projectfloodlight.openflow.protocol.OFFactory; |
| 9 | import org.projectfloodlight.openflow.protocol.OFPortConfig; |
| 10 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
| 11 | import org.projectfloodlight.openflow.protocol.OFPortState; |
| 12 | import org.projectfloodlight.openflow.protocol.OFVersion; |
| 13 | |
| 14 | import static org.hamcrest.Matchers.is; |
| 15 | |
| 16 | import static org.junit.Assert.assertThat; |
| 17 | |
| 18 | public class OFPortDescTest { |
| 19 | |
| 20 | OFFactory factory = OFFactories.getFactory(OFVersion.OF_13); |
| 21 | |
| 22 | @Test |
| 23 | public void testIsEnabled() { |
| 24 | // Default |
| 25 | OFPortDesc desc = factory.buildPortDesc() |
| 26 | .build(); |
| 27 | assertThat(desc.isEnabled(), is(true)); |
| 28 | |
| 29 | // Partially disabled |
| 30 | desc = factory.buildPortDesc() |
| 31 | .setConfig(new HashSet<OFPortConfig>(Arrays.asList(OFPortConfig.PORT_DOWN))) |
| 32 | .build(); |
| 33 | assertThat(desc.isEnabled(), is(false)); |
| 34 | |
| 35 | // Fully disabled |
| 36 | desc = factory.buildPortDesc() |
| 37 | .setConfig(new HashSet<OFPortConfig>(Arrays.asList(OFPortConfig.PORT_DOWN))) |
| 38 | .setState(new HashSet<OFPortState>(Arrays.asList(OFPortState.LINK_DOWN))) |
| 39 | .build(); |
| 40 | assertThat(desc.isEnabled(), is(false)); |
| 41 | } |
| 42 | } |