aboutsummaryrefslogtreecommitdiffstats
path: root/evc/evcbase/src/test/java/com/cablelabs/vcpe
diff options
context:
space:
mode:
authorMufaddal Makati <mmakati@mmakatimbpr15.cablelabs.com>2015-08-07 13:09:49 -0700
committerMufaddal Makati <mmakati@mmakatimbpr15.cablelabs.com>2015-08-07 13:09:49 -0700
commited73dbf357aff41edcbab401a94e5fbc266d9391 (patch)
treee3561a9290e4bd0de19704228867ec91910e68ed /evc/evcbase/src/test/java/com/cablelabs/vcpe
parentf44f4aa8b5eb244fc7603c17e875eebf0f3b0b67 (diff)
First Commit
Diffstat (limited to 'evc/evcbase/src/test/java/com/cablelabs/vcpe')
-rw-r--r--evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/client/EvcClientTest.java163
-rw-r--r--evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/repository/EvcRepositoryTest.java120
2 files changed, 283 insertions, 0 deletions
diff --git a/evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/client/EvcClientTest.java b/evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/client/EvcClientTest.java
new file mode 100644
index 0000000..3f62320
--- /dev/null
+++ b/evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/client/EvcClientTest.java
@@ -0,0 +1,163 @@
+package com.cablelabs.vcpe.evc.evcbase.client;
+
+import com.cablelabs.vcpe.common.Dbg;
+import com.cablelabs.vcpe.cos.cosbase.client.CoSClient;
+import com.cablelabs.vcpe.cos.cosbase.model.CoS;
+import com.cablelabs.vcpe.evc.evcbase.model.Evc;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Created by steve on 6/8/15.
+ */
+public class EvcClientTest {
+
+ @Test
+ public void testAll() throws Exception {
+
+ // We have to have a CoS for Evc to referece
+ CoSClient coSClient = new CoSClient();
+
+ // Add gold service to CoS layer
+ CoS gold = new CoS();
+ gold.setAllProps("gold", 100, 0.99, 17.43, 2.43, 0.01);
+ Dbg.p("gold svc being created in CoS");
+
+ gold = coSClient.create(gold);
+ assertNotNull(gold);
+
+ Evc evc_1 = new Evc();
+
+ List<String> uniIdList1 = new ArrayList<String>();
+ uniIdList1.add("unset-id-1");
+ uniIdList1.add("unset-id-1");
+
+ List<String> uniMacList1 = new ArrayList<String>();
+ uniMacList1.add("11:00:11:11:11:11");
+ uniMacList1.add("11:00:22:22:22:22");
+
+ List<String> ipList1 = new ArrayList<String>();
+ ipList1.add("192.168.1.1");
+ ipList1.add("192.168.1.2");
+
+ evc_1.setAllNonPerfProps("id-unset-1",
+ Evc.EvcType.POINT_TO_POINT, 2, uniIdList1, uniMacList1, ipList1,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ true, true, 1600, gold.getId());
+
+ EvcClient evcClient = new EvcClient();
+ Dbg.p(evc_1.getId()+" being created via evcmgr");
+ evc_1.dump(1);
+
+ evc_1 = evcClient.create(evc_1);
+ assertNotNull(evc_1);
+
+ Evc retrievedEvc = evcClient.get(evc_1.getId());
+ assertNotNull(retrievedEvc);
+ Dbg.p("evc just retrieved from Evc Service");
+ retrievedEvc.dump(1);
+ retrievedEvc = null;
+
+ evc_1.setBroadcastFrameDelivery(Evc.FrameDelivery.DISCARD);
+ Dbg.p("EVC["+ evc_1.getId()+ "] : about to be updated");
+ evc_1.dump(1);
+ assertNotNull(evcClient.update(evc_1));
+ retrievedEvc = evcClient.get(evc_1.getId());
+ assertNotNull(retrievedEvc);
+ Dbg.p("EVC["+ evc_1.getId()+ "] : retrieved after the update");
+ retrievedEvc.dump(1);
+
+ Evc evc_2 = new Evc();
+ Evc evc_3 = new Evc();
+
+ List<String> uniIdList2 = new ArrayList<String>();
+ uniIdList2.add("unset-id-11");
+ uniIdList2.add("unset-id-22");
+
+ List<String> uniIdList3 = new ArrayList<String>();
+ uniIdList3.add("unset-id-111");
+ uniIdList3.add("unset-id-222");
+
+ List<String> uniMacList2 = new ArrayList<String>();
+ uniMacList2.add("22:00:11:11:11:11");
+ uniMacList2.add("22:00:22:22:22:22");
+
+ List<String> uniMacList3 = new ArrayList<String>();
+ uniMacList3.add("33:00:11:11:11:11");
+ uniMacList3.add("33:00:22:22:22:22");
+
+ List<String> ipList2 = new ArrayList<String>();
+ ipList2.add("192.168.2.1");
+ ipList2.add("192.168.2.2");
+
+ List<String> ipList3 = new ArrayList<String>();
+ ipList3.add("192.168.3.1");
+ ipList3.add("192.168.3.2");
+
+ evc_2.setAllNonPerfProps("id-unset-2",
+ Evc.EvcType.ROOTED_MULTIPOINT, 2, uniIdList2, uniMacList2, ipList2,
+ Evc.FrameDelivery.CONDITIONAL,
+ Evc.FrameDelivery.CONDITIONAL,
+ Evc.FrameDelivery.CONDITIONAL,
+ true, false, 1111, gold.getId());
+
+ evc_3.setAllNonPerfProps("id-unset-3",
+ Evc.EvcType.MULTIPOINT_TO_MULTIPOINT, 2, uniIdList3, uniMacList2, ipList3,
+ Evc.FrameDelivery.DISCARD,
+ Evc.FrameDelivery.DISCARD,
+ Evc.FrameDelivery.DISCARD,
+ false, true, 2222, gold.getId());
+
+ evc_2 = evcClient.create(evc_2);
+ assertNotNull(evc_2);
+
+ evc_3 = evcClient.create(evc_3);
+ assertNotNull(evc_3);
+
+ List<Evc> evcList = evcClient.getAll();
+ assertNotNull(evcList);
+ assertEquals(evcList.size(), 3);
+
+ Evc.dumpList(evcList);
+
+ evcClient.delete(evc_3.getId());
+ evcList = evcClient.getAll();
+ assertNotNull(evcList);
+ assertEquals(evcList.size(),2);
+ Evc.dumpList(evcList);
+
+ evcClient.delete(evc_2.getId());
+ evcList = evcClient.getAll();
+ assertNotNull(evcList);
+ assertEquals(evcList.size(),1);
+ Evc.dumpList(evcList);
+
+ evcClient.delete(evc_1.getId());
+ evcList = evcClient.getAll();
+ assertNotNull(evcList);
+ assertEquals(evcList.size(),0);
+ Evc.dumpList(evcList);
+ }
+
+ @Test
+ public void testTestGet() throws Exception {
+ EvcClient evcClient = new EvcClient();
+ Evc evc = evcClient.testGet();
+ evc.dump();;
+ }
+
+ @Test
+ public void testPing() throws Exception {
+
+ EvcClient evcClient = new EvcClient();
+ String resp = evcClient.ping();
+ Dbg.p(resp);
+ }
+}
diff --git a/evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/repository/EvcRepositoryTest.java b/evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/repository/EvcRepositoryTest.java
new file mode 100644
index 0000000..402d20b
--- /dev/null
+++ b/evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/repository/EvcRepositoryTest.java
@@ -0,0 +1,120 @@
+package com.cablelabs.vcpe.evc.evcbase.repository;
+
+import com.cablelabs.vcpe.cos.cosbase.model.CoS;
+import com.cablelabs.vcpe.evc.evcbase.model.Evc;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by steve on 5/25/15.
+ */
+public class EvcRepositoryTest
+{
+
+ @Test
+ public void test() {
+
+ // First, create a couple of CoS's to reference
+ CoS gold = new CoS();
+ CoS silver = new CoS();
+ CoS bronze = new CoS();
+
+ // id CIR/MBS avail delay jitter frameloss
+ gold.setAllProps("gold", 100, 0.99, 17.43, 2.43, 0.01);
+ silver.setAllProps("silver", 50, 0.95, 27.43, 2.43, 0.02);
+ bronze.setAllProps("bronze", 25, 0.90, 37.43, 2.43, 0.03);
+
+ Evc evc_1 = new Evc();
+ Evc evc_2 = new Evc();
+ Evc evc_3 = new Evc();
+
+ List<String> uniIdList = new ArrayList<String>();
+ uniIdList.add("UNI-1");
+ uniIdList.add("UNI-2");
+
+ List<String> uniMacList = new ArrayList<String>();
+ uniMacList.add("11:11:11:11:11:11");
+ uniMacList.add("22:22:22:22:22:22");
+
+ List<String> uniIpList = new ArrayList<String>();
+ uniIpList.add("192.168.1.1");
+ uniIpList.add("192.168.1.2");
+
+ evc_1.setAllNonPerfProps("evc_1",
+ Evc.EvcType.POINT_TO_POINT, 2, uniIdList, uniMacList, uniIpList,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ true, true, 1600, gold.getId());
+ evc_2.setAllNonPerfProps("evc_2",
+ Evc.EvcType.POINT_TO_POINT, 2, uniIdList, uniMacList, uniIpList,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ true, true, 1500, silver.getId());
+ evc_3.setAllNonPerfProps("evc_3",
+ Evc.EvcType.POINT_TO_POINT, 2, uniIdList, uniMacList, uniIpList,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ true, true, 1400, bronze.getId());
+
+ evc_1.dump();
+ evc_2.dump();
+ evc_3.dump();
+
+ EvcRespository repo = EvcRespositoryInMem.INSTANCE;
+
+ assertNotNull(repo.add(evc_1));
+ assertNotNull(repo.add(evc_2));
+ assertNotNull(repo.add(evc_3));
+ assertNull(repo.add(evc_3)); // duplicate
+ assertEquals(repo.count(), 3);
+
+ assertNotNull(repo.get(evc_1.getId()));
+ assertNotNull(repo.get(evc_2.getId()));
+ assertNotNull(repo.get(evc_3.getId()));
+
+ assertNotNull(repo.delete(evc_2.getId()));
+ assertNull(repo.delete(evc_2.getId()));
+ assertNull(repo.delete("not-in-repo"));
+ assertEquals(repo.count(), 2);
+
+ assertEquals(repo.get(evc_1.getId()).getEvcMaxSvcFrameSize(), 1600);
+ assertNotEquals(repo.get(evc_3.getId()).getEvcMaxSvcFrameSize(), 1600);
+
+ Evc evc_4 = new Evc();
+ evc_4.setAllNonPerfProps("evc_4",
+ Evc.EvcType.POINT_TO_POINT, 2, uniIdList, uniMacList, uniIpList,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ true, true, 1200, bronze.getId());
+
+ assertNull(repo.update(evc_4)); // update non-existent cos
+ assertEquals(repo.count(), 3);
+ assertEquals(repo.get("evc_4").getEvcMaxSvcFrameSize(), 1200);
+
+ evc_4.setEvcMaxSvcFrameSize(1250);
+ assertNotNull(repo.update(evc_4)); // update existing evc, same object
+ assertEquals(repo.get(evc_4.getId()).getEvcMaxSvcFrameSize(), 1250);
+
+ evc_4.dump();
+
+ Evc evc_4_2 = new Evc();
+ evc_4_2.setAllNonPerfProps("evc_4",
+ Evc.EvcType.POINT_TO_POINT, 2, uniIdList, uniMacList, uniIpList,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ true, true, 500, bronze.getId());
+
+ assertNotNull(repo.update(evc_4_2)); // update evc, new object
+ assertEquals(repo.get(evc_4_2.getId()).getEvcMaxSvcFrameSize(), 500);
+ }
+}