ITNeutronE2E: refactor test_fetch 09/36509/2
authorIsaku Yamahata <isaku.yamahata@intel.com>
Mon, 21 Mar 2016 17:32:25 +0000 (10:32 -0700)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Mon, 21 Mar 2016 22:44:35 +0000 (15:44 -0700)
refactor test_fetch method.

Change-Id: I009968c1342a94cf6bd0ed40fe0c9b006b97c5cd
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
integration/test/src/test/java/org/opendaylight/neutron/e2etest/ITNeutronE2E.java

index 09b1af0e7d78ccdf92d223047b70681e1072e9ae..72d2b6fe95cdaad5f4c0e58d8955629728b019ca 100644 (file)
@@ -197,30 +197,24 @@ public class ITNeutronE2E {
         }
     }
 
-    static void test_fetch(String url_s, String context) {
+    static void test_fetch(String url_s, int responseCode, String context) {
         try {
             URL url = new URL(url_s);
             HttpURLConnection httpConn = HttpURLConnectionFactoryGet(url);
-            Assert.assertEquals(context, 200, httpConn.getResponseCode());
+            Assert.assertEquals(context, responseCode, httpConn.getResponseCode());
         } catch (Exception e) {
             e.printStackTrace(); // temporary, remove me
             Assert.assertFalse("E2E Tests Failed", true);
         }
     }
 
+    static void test_fetch(String url_s, String context) {
+        test_fetch(url_s, 200, context);
+    }
+
     static void test_fetch(String url_s, boolean positiveTest, String context) {
-        try {
-            URL url = new URL(url_s);
-            HttpURLConnection httpConn = HttpURLConnectionFactoryGet(url);
-            if (positiveTest) {
-                Assert.assertEquals(context, 200, httpConn.getResponseCode());
-            } else {
-                Assert.assertEquals(context, 404, httpConn.getResponseCode());
-            }
-        } catch (Exception e) {
-            e.printStackTrace(); // temporary, remove me
-            Assert.assertFalse("E2E Tests Failed", true);
-        }
+        int responseCode = positiveTest ? 200 : 404;
+        test_fetch(url_s, responseCode, context);
     }
 
     static void test_delete(String url_s, String context) {