aboutsummaryrefslogtreecommitdiffstats
path: root/policy-management/src/test/java/org
diff options
context:
space:
mode:
authorMagnusen, Drew (dm741q) <dm741q@att.com>2017-09-22 15:15:10 -0500
committerMagnusen, Drew (dm741q) <dm741q@att.com>2017-09-25 10:58:22 -0500
commit91dd37afbb996b781c2598d3736b602a8d6c999b (patch)
tree93d5356267381570db1282920694c20e547c10fc /policy-management/src/test/java/org
parentb9ddac6c072d7c00d61363efe2aaed9b37aa34d2 (diff)
Added junits to cover PUT/DELETE in RestManager
Added some more junits that cover some of the PUT/DELETE methods in the RestManager class. Not all are covered yet. Issue-Id: POLICY-109 Change-Id: I7d7ac9656338c6ba0b3ffb76221fde5a90637236 Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
Diffstat (limited to 'policy-management/src/test/java/org')
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java92
1 files changed, 89 insertions, 3 deletions
diff --git a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
index 981d5748..3a9f8a4b 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
@@ -28,7 +28,9 @@ import java.util.Properties;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
import org.onap.policy.drools.properties.PolicyProperties;
import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
@@ -36,11 +38,15 @@ import org.slf4j.LoggerFactory;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RestManagerTest {
@@ -117,11 +123,85 @@ public class RestManagerTest {
}
-
+
@Test
- public void GETTest() throws ClientProtocolException, IOException, InterruptedException {
- assertTrue(PolicyEngine.manager.isAlive());
+ public void putDeleteTest() throws ClientProtocolException, IOException, InterruptedException {
+ HttpPut httpPut;
+ HttpDelete httpDelete;
+ CloseableHttpResponse response;
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/events");
+ httpPut.addHeader("Content-Type", "text/plain");
+ httpPut.addHeader("Accept", "application/json");
+ httpPut.setEntity(new StringEntity("FOOOO"));
+ response = client.execute(httpPut);
+ logger.info("/engine/topics/sources/ueb/{}/events response code: {}", UEB_TOPIC, response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/switches/lock");
+ response = client.execute(httpPut);
+ logger.info("/engine/topics/switches/lock response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/events");
+ httpPut.addHeader("Content-Type", "text/plain");
+ httpPut.addHeader("Accept", "application/json");
+ httpPut.setEntity(new StringEntity("FOOOO"));
+ response = client.execute(httpPut);
+ logger.info("/engine/topics/sources/ueb/{}/events response code: {}", UEB_TOPIC, response.getStatusLine().getStatusCode());
+ assertEquals(406, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/topics/switches/lock");
+ response = client.execute(httpDelete);
+ logger.info("/engine/topics/switches/lock response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/switches/lock");
+ response = client.execute(httpPut);
+ logger.info("/engine/topics/sources/ueb/{}/switches/lock: {}", UEB_TOPIC, response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/switches/lock");
+ response = client.execute(httpDelete);
+ logger.info("/engine/topics/sources/ueb/{}/switches/lock: {}", UEB_TOPIC, response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/switches/lock");
+ response = client.execute(httpPut);
+ logger.info("/engine/topics/sources/dmaap/{}/switches/lock: {}", DMAAP_TOPIC, response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/switches/lock");
+ response = client.execute(httpDelete);
+ logger.info("/engine/topics/sources/dmaap/{}/switches/lock: {}", DMAAP_TOPIC, response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+
+ httpPut = new HttpPut(HOST_URL + "/engine/switches/activation");
+ response = client.execute(httpPut);
+ logger.info("/engine/switches/activation response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpPut.releaseConnection();
+
+ httpDelete = new HttpDelete(HOST_URL + "/engine/switches/activation");
+ response = client.execute(httpDelete);
+ logger.info("/engine/switches/activation response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpDelete.releaseConnection();
+ }
+
+
+ @Test
+ public void getTest() throws ClientProtocolException, IOException, InterruptedException {
+
HttpGet httpGet;
CloseableHttpResponse response;
String responseBody;
@@ -561,6 +641,12 @@ public class RestManagerTest {
assertEquals(200, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
+ httpGet = new HttpGet(HOST_URL + "/engine/tools/loggers/ROOT");
+ response = client.execute(httpGet);
+ logger.info("engine/tools/loggers/ROOT response code: {}", response.getStatusLine().getStatusCode());
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ httpGet.releaseConnection();
+
}