From 63a4151dbd13596467a4ea9aef0a95e05fbcb245 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Wed, 20 Jun 2018 13:53:35 +0200 Subject: [PATCH] improve NeutronSecurityRuleTests to cover 404 on modify of non-existant in preparation of supporting 442 not just for create but also modify. JIRA: NEUTRON-158 Change-Id: I84c1656fdd84d9e1e6adf5f10a4ccb5414507ced Signed-off-by: Michael Vorburger --- .../java/org/opendaylight/neutron/e2etest/HttpUtils.java | 6 +++++- .../neutron/e2etest/NeutronSecurityRuleTests.java | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/HttpUtils.java b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/HttpUtils.java index 5ce5b6358..bee5779e1 100644 --- a/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/HttpUtils.java +++ b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/HttpUtils.java @@ -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); } diff --git a/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronSecurityRuleTests.java b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronSecurityRuleTests.java index 0324bd65a..8d0018197 100644 --- a/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronSecurityRuleTests.java +++ b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronSecurityRuleTests.java @@ -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(); -- 2.36.6