1 package org.opendaylight.nemo.intent.algorithm;
3 import junit.framework.TestCase;
5 import org.junit.Assert;
6 import org.junit.Before;
10 * Created by zhangmeng on 2015/11/5.
12 public class EdgeTest extends TestCase {
18 private long bandwidth;
21 public void setUp() throws Exception {
27 //edge = new Edge(id,src,dest,metric,bandwidth);
31 public void testGetId() throws Exception {
32 edge = new Edge(id,src,dest,metric,bandwidth);
33 Assert.assertEquals(null,edge.getId());
35 edge = new Edge(id,src,dest,metric,bandwidth);
36 Assert.assertEquals(new String("test"),edge.getId());
40 public void testGetSrc() throws Exception {
41 edge = new Edge(id,src,dest,metric,bandwidth);
42 Assert.assertEquals(null,edge.getSrc());
44 edge = new Edge(id,src,dest,metric,bandwidth);
45 Assert.assertEquals(new String("test"),edge.getSrc());
49 public void testGetDest() throws Exception {
50 edge = new Edge(id,src,dest,metric,bandwidth);
51 Assert.assertEquals(null,edge.getDest());
53 edge = new Edge(id,src,dest,metric,bandwidth);
54 Assert.assertEquals(new String("test"),edge.getDest());
58 public void testGetMetric() throws Exception {
59 edge = new Edge(id,src,dest,metric,bandwidth);
60 Assert.assertEquals(0,edge.getMetric());
62 edge = new Edge(id,src,dest,metric,bandwidth);
63 Assert.assertEquals(1,edge.getMetric());
67 public void testGetBandwidth() throws Exception {
68 edge = new Edge(id,src,dest,metric,bandwidth);
69 Assert.assertEquals(0,edge.getBandwidth());
71 edge = new Edge(id,src,dest,metric,bandwidth);
72 Assert.assertEquals(1,edge.getBandwidth());
76 public void testSetMetric() throws Exception {
77 edge = new Edge(id,src,dest,metric,bandwidth);
78 Assert.assertEquals(0,edge.getMetric());
80 edge.setMetric(metric);
81 Assert.assertEquals(metric,edge.getMetric());
85 public void testSetBandwidth() throws Exception {
86 edge = new Edge(id,src,dest,metric,bandwidth);
87 Assert.assertEquals(0,edge.getBandwidth());
90 Assert.assertEquals(bandwidth,edge.getBandwidth());
94 public void testEquals() throws Exception {
95 String s = new String("tests");
96 Edge obj = new Edge(s,s,s,1,1);
99 metric = bandwidth = 1;
100 edge = new Edge(id,src,dest,metric,bandwidth);
102 Assert.assertTrue(obj.getId().equals(edge.getId()));
103 Assert.assertTrue(obj.getSrc().equals(edge.getSrc()));
104 Assert.assertTrue(obj.getDest().equals(edge.getDest()));
108 public void testToString() throws Exception {
109 edge = new Edge(id,src,dest,metric,bandwidth);
110 Assert.assertNotNull(edge.toString());