blob: cf209b317f04bcff096c60ca960b4e34a01b14c2 [file] [log] [blame]
tomde8d9682014-08-27 01:11:43 -07001package org.onlab.onos.net;
2
3import com.google.common.testing.EqualsTester;
4import org.junit.Test;
5
6import java.net.URI;
7
8import static org.junit.Assert.assertEquals;
9
10/**
tomca20e0c2014-09-03 23:22:24 -070011 * Test of the network element identifier.
tomde8d9682014-08-27 01:11:43 -070012 */
13public class ElementIdTest {
14
tomca20e0c2014-09-03 23:22:24 -070015 private static class FooId extends ElementId {
16 public FooId(URI uri) {
17 super(uri);
18 }
19 }
20
tomde8d9682014-08-27 01:11:43 -070021 public static URI uri(String str) {
22 return URI.create(str);
23 }
24
25 @Test
26 public void basics() {
27 new EqualsTester()
tomca20e0c2014-09-03 23:22:24 -070028 .addEqualityGroup(new FooId(uri("of:foo")),
29 new FooId(uri("of:foo")))
30 .addEqualityGroup(new FooId(uri("of:bar")))
tomde8d9682014-08-27 01:11:43 -070031 .testEquals();
32 assertEquals("wrong uri", uri("ofcfg:foo"),
tomca20e0c2014-09-03 23:22:24 -070033 new FooId(uri("ofcfg:foo")).uri());
tomde8d9682014-08-27 01:11:43 -070034 }
35
36}