Showing
8 changed files
with
120 additions
and
0 deletions
... | @@ -16,4 +16,11 @@ | ... | @@ -16,4 +16,11 @@ |
16 | 16 | ||
17 | <description>ONOS network control API</description> | 17 | <description>ONOS network control API</description> |
18 | 18 | ||
19 | + <dependencies> | ||
20 | + <dependency> | ||
21 | + <groupId>com.google.guava</groupId> | ||
22 | + <artifactId>guava-testlib</artifactId> | ||
23 | + </dependency> | ||
24 | + </dependencies> | ||
25 | + | ||
19 | </project> | 26 | </project> | ... | ... |
... | @@ -7,6 +7,7 @@ import java.net.URI; | ... | @@ -7,6 +7,7 @@ import java.net.URI; |
7 | */ | 7 | */ |
8 | public class DeviceId extends ElementId { | 8 | public class DeviceId extends ElementId { |
9 | 9 | ||
10 | + // TODO: Discuss whether we should just use ElementId for Device and Host alike | ||
10 | /** | 11 | /** |
11 | * Creates a device id using the supplied URI. | 12 | * Creates a device id using the supplied URI. |
12 | * | 13 | * | ... | ... |
1 | +package org.onlab.onos.net; | ||
2 | + | ||
3 | +import com.google.common.testing.EqualsTester; | ||
4 | +import org.junit.Test; | ||
5 | + | ||
6 | +/** | ||
7 | + * Test of the provider identifier. | ||
8 | + */ | ||
9 | +public class DeviceIdTest extends ElementIdTest { | ||
10 | + | ||
11 | + @Test | ||
12 | + public void basics() { | ||
13 | + new EqualsTester() | ||
14 | + .addEqualityGroup(new DeviceId(uri("of:foo")), | ||
15 | + new DeviceId(uri("of:foo"))) | ||
16 | + .addEqualityGroup(new DeviceId(uri("of:bar"))) | ||
17 | + .testEquals(); | ||
18 | + } | ||
19 | + | ||
20 | +} |
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 | +/** | ||
11 | + * Test of the provider identifier. | ||
12 | + */ | ||
13 | +public class ElementIdTest { | ||
14 | + | ||
15 | + public static URI uri(String str) { | ||
16 | + return URI.create(str); | ||
17 | + } | ||
18 | + | ||
19 | + @Test | ||
20 | + public void basics() { | ||
21 | + new EqualsTester() | ||
22 | + .addEqualityGroup(new ElementId(uri("of:foo")), | ||
23 | + new ElementId(uri("of:foo"))) | ||
24 | + .addEqualityGroup(new ElementId(uri("of:bar"))) | ||
25 | + .testEquals(); | ||
26 | + assertEquals("wrong uri", uri("ofcfg:foo"), | ||
27 | + new ElementId(uri("ofcfg:foo")).uri()); | ||
28 | + } | ||
29 | + | ||
30 | +} |
1 | +package org.onlab.onos.net.provider; | ||
2 | + | ||
3 | +import org.junit.Test; | ||
4 | + | ||
5 | +import static org.junit.Assert.assertEquals; | ||
6 | + | ||
7 | +/** | ||
8 | + * Test of the base provider implementation. | ||
9 | + */ | ||
10 | +public class AbstractProviderTest { | ||
11 | + | ||
12 | + @Test | ||
13 | + public void basics() { | ||
14 | + ProviderId id = new ProviderId("foo.bar"); | ||
15 | + TestProvider provider = new TestProvider(id); | ||
16 | + assertEquals("incorrect id", id, provider.id()); | ||
17 | + } | ||
18 | +} |
1 | +package org.onlab.onos.net.provider; | ||
2 | + | ||
3 | +import com.google.common.testing.EqualsTester; | ||
4 | +import org.junit.Test; | ||
5 | + | ||
6 | +/** | ||
7 | + * Test of the provider identifier. | ||
8 | + */ | ||
9 | +public class ProviderIdTest { | ||
10 | + | ||
11 | + @Test | ||
12 | + public void basics() { | ||
13 | + new EqualsTester() | ||
14 | + .addEqualityGroup(new ProviderId("foo"), new ProviderId("foo")) | ||
15 | + .addEqualityGroup(new ProviderId("bar")) | ||
16 | + .testEquals(); | ||
17 | + } | ||
18 | + | ||
19 | +} |
1 | +package org.onlab.onos.net.provider; | ||
2 | + | ||
3 | +/** | ||
4 | + * Test provider fixture. | ||
5 | + */ | ||
6 | +public class TestProvider extends AbstractProvider { | ||
7 | + | ||
8 | + /** | ||
9 | + * Creates a provider with the supplier identifier. | ||
10 | + * | ||
11 | + * @param id provider id | ||
12 | + */ | ||
13 | + protected TestProvider(ProviderId id) { | ||
14 | + super(id); | ||
15 | + } | ||
16 | + | ||
17 | +} |
... | @@ -61,6 +61,14 @@ | ... | @@ -61,6 +61,14 @@ |
61 | <version>17.0</version> | 61 | <version>17.0</version> |
62 | </dependency> | 62 | </dependency> |
63 | 63 | ||
64 | + <dependency> | ||
65 | + <groupId>com.google.guava</groupId> | ||
66 | + <artifactId>guava-testlib</artifactId> | ||
67 | + <version>17.0</version> | ||
68 | + <scope>test</scope> | ||
69 | + </dependency> | ||
70 | + | ||
71 | + | ||
64 | <!-- Web related --> | 72 | <!-- Web related --> |
65 | <dependency> | 73 | <dependency> |
66 | <groupId>com.sun.jersey</groupId> | 74 | <groupId>com.sun.jersey</groupId> | ... | ... |
-
Please register or login to post a comment