diff options
author | sunil.unnava <sunil.unnava@att.com> | 2019-04-03 00:41:55 -0400 |
---|---|---|
committer | sunil.unnava <sunil.unnava@att.com> | 2019-04-03 00:43:04 -0400 |
commit | 34615204bca86d54ebfbedb15e8976515688c56c (patch) | |
tree | 7ff972385359fe1a4d64fbc52bbc069b9301d618 /src/test/java | |
parent | 49924c6b07a7f9418f04d09f9c94fac8e7d44485 (diff) |
add testcases
Issue-ID: DMAAP-1140
Change-Id: I249cf7b1b7f0692de224aee9b33aab8dbab20054
Signed-off-by: sunil.unnava <sunil.unnava@att.com>
Diffstat (limited to 'src/test/java')
4 files changed, 84 insertions, 22 deletions
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest.java index 2a79e92..beec641 100644 --- a/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest.java +++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest.java @@ -53,6 +53,16 @@ public class ApiKeyBeanTest { } + @Test + public void testApiKeyBean(){ + ApiKeyBean bean = new ApiKeyBean(); + bean.setDescription("description"); + bean.setEmail("email"); + assertEquals("description", bean.getDescription()); + assertEquals("email", bean.getEmail()); + + } + } diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPCambriaLimiterTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPCambriaLimiterTest.java index 853d770..f9b2554 100644 --- a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPCambriaLimiterTest.java +++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPCambriaLimiterTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ - package org.onap.dmaap.mr.cambria.beans; +package org.onap.dmaap.mr.cambria.beans; import static org.junit.Assert.*; @@ -41,43 +41,57 @@ public class DMaaPCambriaLimiterTest { @Test public void testGetSleepMsForRate() { - - - double value = 3; - DMaaPCambriaLimiter.getSleepMsForRate(value); - - String trueValue = "True"; - assertTrue(trueValue.equalsIgnoreCase("True")); - + + assertEquals(1000, DMaaPCambriaLimiter.getSleepMsForRate(100)); + assertEquals(0, DMaaPCambriaLimiter.getSleepMsForRate(0)); + } - + @Test public void testOnCall() { - - DMaaPCambriaLimiter limiter = new DMaaPCambriaLimiter(1,2, 3); + + DMaaPCambriaLimiter limiter = new DMaaPCambriaLimiter(1, 2, 3); try { - limiter.onCall("testTopic", "ConsumerGroup1", "client2","remoteHost"); + limiter.onCall("testTopic", "ConsumerGroup1", "client2", "remoteHost"); } catch (CambriaApiException e) { // TODO Auto-generated catch block e.printStackTrace(); } - + String trueValue = "True"; assertTrue(trueValue.equalsIgnoreCase("True")); - + + } + + @Test + public void testOnCallError2() { + + DMaaPCambriaLimiter limiter = new DMaaPCambriaLimiter(0, 2, 3, 1, 1); + try { + limiter.onCall("testTopic", "ConsumerGroup1", "client2", "remoteHost"); + } catch (CambriaApiException e) { + assertTrue(false); + } + + } + + @Test(expected = CambriaApiException.class) + public void testOnCallError() throws CambriaApiException { + + DMaaPCambriaLimiter limiter = new DMaaPCambriaLimiter(0.9, 2, 3, 1, 1); + limiter.onCall("testTopic", "ConsumerGroup1", "client2", "remoteHost"); + } - + @Test public void testOnSend() { - - DMaaPCambriaLimiter limiter = new DMaaPCambriaLimiter(3,3, 3); + + DMaaPCambriaLimiter limiter = new DMaaPCambriaLimiter(3, 3, 3); limiter.onSend("testTopic", "consumerGroup1", "client1", 100); - + String trueValue = "True"; assertTrue(trueValue.equalsIgnoreCase("True")); - + } - - } diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest.java index 9a67673..a945cd6 100644 --- a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest.java +++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest.java @@ -27,6 +27,9 @@ import org.junit.Before; import org.junit.Test; import org.onap.dmaap.dmf.mr.beans.DMaaPContext; +import org.springframework.mock.http.client.MockClientHttpRequest; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpSession; public class DMaaPContextTest { @@ -48,6 +51,21 @@ public class DMaaPContextTest { } + @Test + public void testDMaaPContext(){ + + DMaaPContext context=new DMaaPContext(); + context.setConsumerRequestTime("consumerRequestTime"); + assertEquals("consumerRequestTime", context.getConsumerRequestTime()); + MockHttpServletRequest request= new MockHttpServletRequest(); + MockHttpSession session=new MockHttpSession(); + request.setSession(session); + context.setRequest(request); + assertNotNull(context.getSession()); + + + } + } diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest.java index bb3af25..d88c408 100644 --- a/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest.java +++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest.java @@ -51,6 +51,26 @@ public class TopicBeanTest { } + @Test + public void testTopicBean() { + + TopicBean bean = new TopicBean("topicName", "topicDescription", 1,1,true); + assertNotNull(bean); + + } + + @Test + public void testTopicBeanStter() { + + TopicBean bean = new TopicBean(); + bean.setPartitionCount(1); + bean.setReplicationCount(1); + bean.setTopicDescription("topicDescription"); + bean.setTopicName("topicName"); + bean.setTransactionEnabled(true); + assertNotNull(bean); + } + } |