improve NeutronSecurityRuleTests to cover 404 on modify of non-existant 46/73246/1
authorMichael Vorburger <vorburger@redhat.com>
Wed, 20 Jun 2018 11:53:35 +0000 (13:53 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Wed, 20 Jun 2018 11:53:35 +0000 (13:53 +0200)
in preparation of supporting 442 not just for create but also modify.

JIRA: NEUTRON-158
Change-Id: I84c1656fdd84d9e1e6adf5f10a4ccb5414507ced
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/HttpUtils.java
integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronSecurityRuleTests.java

index 5ce5b635817235e5dd5be68106e7a926bbefe667..bee5779e1635820a196e89c87ea9d71d4c3ea461 100644 (file)
@@ -84,10 +84,14 @@ public final class HttpUtils {
     }
 
     static void test_modify(String urlStr, String content, String context) {
+        test_modify(urlStr, 200, content, context);
+    }
+
+    static void test_modify(String urlStr, int responseCode, String content, String context) {
         try {
             URL url = new URL(urlStr);
             HttpURLConnection httpConn = httpURLConnectionFactoryPut(url, content);
-            Assert.assertEquals(context, 200, httpConn.getResponseCode());
+            Assert.assertEquals(context, responseCode, httpConn.getResponseCode());
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }
index 0324bd65a7281c048a95842343c5a0886230045e..8d0018197267c1247573f4da8965dae6de19e004 100644 (file)
@@ -70,14 +70,14 @@ public class NeutronSecurityRuleTests {
         HttpUtils.test_create(url, content, "Security Rule Multiple Post Failed");
     }
 
-    private void singleton_sr_modify_test() {
+    private void singleton_sr_modify_test(int responseCode) {
         String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
         String content = " {\"security_group_rule\": " + "{\"remote_group_id\": null, \"direction\": \"egress\", "
                 + "\"remote_ip_prefix\": null, \"protocol\": \"tcp\", " + "\"ethertype\": \"IPv6\", \"tenant_id\": "
                 + "\"00f340c7c3b34ab7be1fc690c05a0275\", \"port_range_max\": 77, " + "\"port_range_min\": 77, "
                 + "\"id\": \"9b4be7fa-e56e-40fb-9516-1f0fa9185669\", " + "\"security_group_id\": "
                 + "\"" + TEST_SECURITY_GROUP_ID + "\"}}";
-        HttpUtils.test_modify(url, content, "Security Rule Singleton Put Failed");
+        HttpUtils.test_modify(url, responseCode, content, "Security Rule Singleton Put Failed");
     }
 
     private void sr_element_get_test() {
@@ -152,11 +152,12 @@ public class NeutronSecurityRuleTests {
         NeutronSecurityRuleTests securityRuleTester = new NeutronSecurityRuleTests(base);
         securityRuleTester.singleton_sr_without_groupid_create_test(500);
         securityRuleTester.singleton_sr_create_test(HttpUtils.HTTP_MISSING_DEPENDENCY);
+        securityRuleTester.singleton_sr_modify_test(404);
         new NeutronSecurityGroupTests(base).singleton_sg_create(TEST_SECURITY_GROUP_ID);
         String createJsonString = securityRuleTester.singleton_sr_create_test(201);
         securityRuleTester.singleton_sr_get_with_one_query_item_test(createJsonString);
         securityRuleTester.multiple_sr_create_test();
-        securityRuleTester.singleton_sr_modify_test();
+        securityRuleTester.singleton_sr_modify_test(200);
         securityRuleTester.sr_element_get_test();
         securityRuleTester.sr_element_get_with_query_test();
         securityRuleTester.securityRule_collection_get_test();