summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest.java10
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPCambriaLimiterTest.java58
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest.java18
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest.java20
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);
+ }
+
}