tom | de8d968 | 2014-08-27 01:11:43 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net; |
| 2 | |
| 3 | import com.google.common.testing.EqualsTester; |
| 4 | import org.junit.Test; |
| 5 | |
| 6 | import java.net.URI; |
| 7 | |
| 8 | import static org.junit.Assert.assertEquals; |
| 9 | |
| 10 | /** |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 11 | * Test of the network element identifier. |
tom | de8d968 | 2014-08-27 01:11:43 -0700 | [diff] [blame] | 12 | */ |
| 13 | public class ElementIdTest { |
| 14 | |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 15 | private static class FooId extends ElementId { |
| 16 | public FooId(URI uri) { |
| 17 | super(uri); |
| 18 | } |
| 19 | } |
| 20 | |
tom | de8d968 | 2014-08-27 01:11:43 -0700 | [diff] [blame] | 21 | public static URI uri(String str) { |
| 22 | return URI.create(str); |
| 23 | } |
| 24 | |
| 25 | @Test |
| 26 | public void basics() { |
| 27 | new EqualsTester() |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 28 | .addEqualityGroup(new FooId(uri("of:foo")), |
| 29 | new FooId(uri("of:foo"))) |
| 30 | .addEqualityGroup(new FooId(uri("of:bar"))) |
tom | de8d968 | 2014-08-27 01:11:43 -0700 | [diff] [blame] | 31 | .testEquals(); |
| 32 | assertEquals("wrong uri", uri("ofcfg:foo"), |
tom | ca20e0c | 2014-09-03 23:22:24 -0700 | [diff] [blame] | 33 | new FooId(uri("ofcfg:foo")).uri()); |
tom | de8d968 | 2014-08-27 01:11:43 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | } |