tom

Added unit tests; including guava-testlib.

......@@ -16,4 +16,11 @@
<description>ONOS network control API</description>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
</dependency>
</dependencies>
</project>
......
......@@ -7,6 +7,7 @@ import java.net.URI;
*/
public class DeviceId extends ElementId {
// TODO: Discuss whether we should just use ElementId for Device and Host alike
/**
* Creates a device id using the supplied URI.
*
......
package org.onlab.onos.net;
import com.google.common.testing.EqualsTester;
import org.junit.Test;
/**
* Test of the provider identifier.
*/
public class DeviceIdTest extends ElementIdTest {
@Test
public void basics() {
new EqualsTester()
.addEqualityGroup(new DeviceId(uri("of:foo")),
new DeviceId(uri("of:foo")))
.addEqualityGroup(new DeviceId(uri("of:bar")))
.testEquals();
}
}
package org.onlab.onos.net;
import com.google.common.testing.EqualsTester;
import org.junit.Test;
import java.net.URI;
import static org.junit.Assert.assertEquals;
/**
* Test of the provider identifier.
*/
public class ElementIdTest {
public static URI uri(String str) {
return URI.create(str);
}
@Test
public void basics() {
new EqualsTester()
.addEqualityGroup(new ElementId(uri("of:foo")),
new ElementId(uri("of:foo")))
.addEqualityGroup(new ElementId(uri("of:bar")))
.testEquals();
assertEquals("wrong uri", uri("ofcfg:foo"),
new ElementId(uri("ofcfg:foo")).uri());
}
}
package org.onlab.onos.net.provider;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Test of the base provider implementation.
*/
public class AbstractProviderTest {
@Test
public void basics() {
ProviderId id = new ProviderId("foo.bar");
TestProvider provider = new TestProvider(id);
assertEquals("incorrect id", id, provider.id());
}
}
package org.onlab.onos.net.provider;
import com.google.common.testing.EqualsTester;
import org.junit.Test;
/**
* Test of the provider identifier.
*/
public class ProviderIdTest {
@Test
public void basics() {
new EqualsTester()
.addEqualityGroup(new ProviderId("foo"), new ProviderId("foo"))
.addEqualityGroup(new ProviderId("bar"))
.testEquals();
}
}
package org.onlab.onos.net.provider;
/**
* Test provider fixture.
*/
public class TestProvider extends AbstractProvider {
/**
* Creates a provider with the supplier identifier.
*
* @param id provider id
*/
protected TestProvider(ProviderId id) {
super(id);
}
}
......@@ -61,6 +61,14 @@
<version>17.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
<version>17.0</version>
<scope>test</scope>
</dependency>
<!-- Web related -->
<dependency>
<groupId>com.sun.jersey</groupId>
......