diff options
Diffstat (limited to 'cos/cosbase/src/test')
-rw-r--r-- | cos/cosbase/src/test/java/com/cablelabs/vcpe/cos/cosbase/client/CoSClientTest.java | 105 | ||||
-rw-r--r-- | cos/cosbase/src/test/java/com/cablelabs/vcpe/cos/cosbase/repository/CoSRepositoryTest.java | 63 |
2 files changed, 168 insertions, 0 deletions
diff --git a/cos/cosbase/src/test/java/com/cablelabs/vcpe/cos/cosbase/client/CoSClientTest.java b/cos/cosbase/src/test/java/com/cablelabs/vcpe/cos/cosbase/client/CoSClientTest.java new file mode 100644 index 0000000..cbf5516 --- /dev/null +++ b/cos/cosbase/src/test/java/com/cablelabs/vcpe/cos/cosbase/client/CoSClientTest.java @@ -0,0 +1,105 @@ +package com.cablelabs.vcpe.cos.cosbase.client; + +import com.cablelabs.vcpe.common.Dbg; +import com.cablelabs.vcpe.cos.cosbase.model.CoS; +import org.junit.Test; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by steve on 5/28/15. + */ + +public class CoSClientTest { + + @Test + public void testAll() throws Exception { + CoSClient coSClient = new CoSClient(); + + 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.dump(1); + + gold = coSClient.create(gold); + assertNotNull(gold); + + CoS retrievedCos = coSClient.get(gold.getId()); + + assertNotNull(retrievedCos); + Dbg.p("gold svc just retrieved from CoS"); + retrievedCos.dump(1); + retrievedCos = null; + + gold.setCommitedInfoRate(50); + Dbg.p("gold svc modified, to be updated"); + gold.dump(1); + assertNotNull(coSClient.update(gold)); + retrievedCos = coSClient.get(gold.getId()); + assertNotNull(retrievedCos); + Dbg.p("gold svc modified, just retrieved from CoS"); + retrievedCos.dump(1); + + coSClient.delete(gold.getId()); + + CoS vid = new CoS(); + CoS game = new CoS(); + CoS dl = new CoS(); + + vid.setAllProps ("vid", 100, 0.99, 17.43, 2.43, 0.1); + game.setAllProps("game", 75, 0.99, 7.43, 1.43, 0.01); + dl.setAllProps("dl", 100, 0.99, 17.43, 2.43, 0.02); + + vid = coSClient.create(vid); + assertNotNull(vid); + + game = coSClient.create(game); + assertNotNull(game); + + dl = coSClient.create(dl); + assertNotNull(dl); + + + + List<CoS> cosList = coSClient.getAll(); + assertNotNull(cosList); + assertEquals(cosList.size(), 3); + CoS.dumpList(cosList); + + coSClient.delete(game.getId()); + cosList = coSClient.getAll(); + assertNotNull(cosList); + assertEquals(cosList.size(), 2); + CoS.dumpList(cosList); + + coSClient.delete(vid.getId()); + cosList = coSClient.getAll(); + assertNotNull(cosList); + assertEquals(cosList.size(), 1); + CoS.dumpList(cosList); + + coSClient.delete(dl.getId()); + cosList = coSClient.getAll(); + assertNotNull(cosList); + assertEquals(cosList.size(), 0); + CoS.dumpList(cosList); + } + + @Test + public void testTestGet() throws Exception { + CoSClient coSClient = new CoSClient(); + CoS cos = coSClient.testGet(); + cos.dump();; + } + + @Test + public void testPing() throws Exception { + + CoSClient coSClient = new CoSClient(); + String resp = coSClient.ping(); + Dbg.p(resp); + } + +}
\ No newline at end of file diff --git a/cos/cosbase/src/test/java/com/cablelabs/vcpe/cos/cosbase/repository/CoSRepositoryTest.java b/cos/cosbase/src/test/java/com/cablelabs/vcpe/cos/cosbase/repository/CoSRepositoryTest.java new file mode 100644 index 0000000..0c46737 --- /dev/null +++ b/cos/cosbase/src/test/java/com/cablelabs/vcpe/cos/cosbase/repository/CoSRepositoryTest.java @@ -0,0 +1,63 @@ +package com.cablelabs.vcpe.cos.cosbase.repository; + +import com.cablelabs.vcpe.cos.cosbase.model.CoS; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Created by steve on 5/25/15. + */ +public class CoSRepositoryTest +{ + + @Test + public void test() { + + 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); + + CoSRespository repo = CoSRespositoryInMem.INSTANCE; + + assertNotNull(repo.add(gold)); + assertNotNull(repo.add(silver)); + assertNotNull(repo.add(bronze)); + assertNull(repo.add(bronze)); // duplicate + assertEquals(repo.count(), 3); + + assertNotNull(repo.get(gold.getId())); + assertNotNull(repo.get(silver.getId())); + assertNotNull(repo.get(bronze.getId())); + + assertNotNull(repo.delete(silver.getId())); + assertNull(repo.delete(silver.getId())); + assertNull(repo.delete("not-in-repo")); + assertEquals(repo.count(), 2); + + assertEquals(repo.get(gold.getId()).getCommitedInfoRate(), 100); + assertNotEquals(repo.get(bronze.getId()).getCommitedInfoRate(), 100); + + CoS tin = new CoS(); + tin.setAllProps("tin", 1, 0.50, 47.43, 2.43, 0.04); + + + assertNull(repo.update(tin)); // update non-existent cos + assertEquals(repo.count(), 3); + assertEquals(repo.get("tin").getCommitedInfoRate(), 1); + + tin.setCommitedInfoRate(5); + assertNotNull(repo.update(tin)); // update existing cos, same object + assertEquals(repo.get("tin").getCommitedInfoRate(), 5); + + CoS tin2 = new CoS(); + tin.setAllProps("tin", 8, 0.50, 47.43, 2.43, 0.04); + assertNotNull(repo.update(tin)); // update existing cos, new object + assertEquals(repo.get("tin").getCommitedInfoRate(), 8); + } +} |