3 import junit.framework.TestCase;
4 import org.junit.Assert;
5 import org.junit.Before;
7 import org.opendaylight.nemo.intent.algorithm.Edge;
9 import static org.junit.Assert.*;
12 * Created by zhangmeng on 2015/11/5.
14 public class EdgeTest extends TestCase {
20 private long bandwidth;
23 public void setUp() throws Exception {
29 //edge = new Edge(id,src,dest,metric,bandwidth);
33 public void testGetId() throws Exception {
34 edge = new Edge(id,src,dest,metric,bandwidth);
35 Assert.assertEquals(null,edge.getId());
37 edge = new Edge(id,src,dest,metric,bandwidth);
38 Assert.assertEquals(new String("test"),edge.getId());
42 public void testGetSrc() throws Exception {
43 edge = new Edge(id,src,dest,metric,bandwidth);
44 Assert.assertEquals(null,edge.getSrc());
46 edge = new Edge(id,src,dest,metric,bandwidth);
47 Assert.assertEquals(new String("test"),edge.getSrc());
51 public void testGetDest() throws Exception {
52 edge = new Edge(id,src,dest,metric,bandwidth);
53 Assert.assertEquals(null,edge.getDest());
55 edge = new Edge(id,src,dest,metric,bandwidth);
56 Assert.assertEquals(new String("test"),edge.getDest());
60 public void testGetMetric() throws Exception {
61 edge = new Edge(id,src,dest,metric,bandwidth);
62 Assert.assertEquals(0,edge.getMetric());
64 edge = new Edge(id,src,dest,metric,bandwidth);
65 Assert.assertEquals(1,edge.getMetric());
69 public void testGetBandwidth() throws Exception {
70 edge = new Edge(id,src,dest,metric,bandwidth);
71 Assert.assertEquals(0,edge.getBandwidth());
73 edge = new Edge(id,src,dest,metric,bandwidth);
74 Assert.assertEquals(1,edge.getBandwidth());
78 public void testSetMetric() throws Exception {
79 edge = new Edge(id,src,dest,metric,bandwidth);
80 Assert.assertEquals(0,edge.getMetric());
82 edge.setMetric(metric);
83 Assert.assertEquals(metric,edge.getMetric());
87 public void testSetBandwidth() throws Exception {
88 edge = new Edge(id,src,dest,metric,bandwidth);
89 Assert.assertEquals(0,edge.getBandwidth());
92 Assert.assertEquals(bandwidth,edge.getBandwidth());
96 public void testEquals() throws Exception {
97 String s = new String("tests");
98 Edge obj = new Edge(s,s,s,1,1);
101 metric = bandwidth = 1;
102 edge = new Edge(id,src,dest,metric,bandwidth);
104 Assert.assertTrue(obj.getId().equals(edge.getId()));
105 Assert.assertTrue(obj.getSrc().equals(edge.getSrc()));
106 Assert.assertTrue(obj.getDest().equals(edge.getDest()));
110 public void testToString() throws Exception {
111 edge = new Edge(id,src,dest,metric,bandwidth);
112 Assert.assertNotNull(edge.toString());