replace TestHttpClient with upstream TestWebClient
authorMichael Vorburger <mike@vorburger.ch>
Thu, 10 Jan 2019 03:14:00 +0000 (04:14 +0100)
committerMichael Vorburger <mike@vorburger.ch>
Wed, 1 Jul 2020 23:38:23 +0000 (01:38 +0200)
requires https://git.opendaylight.org/gerrit/#/c/79382/

Signed-off-by: Michael Vorburger <mike@vorburger.ch>
pom.xml
src/main/java/org/opendaylight/infrautils/web/WebModule.java
src/test/java/org/opendaylight/infrautils/testutils/TestHttpClient.java [deleted file]
src/test/java/org/opendaylight/neutron/simple/test/NeutronModuleTest.java
src/test/java/org/opendaylight/openflowplugin/simple/test/OpenFlowPluginModuleTest.java
src/test/java/org/opendaylight/restconf/simple/test/RestConfModuleTest.java

diff --git a/pom.xml b/pom.xml
index b76c3f5e149e3050dbedd62491fe030fb3fbb6e6..ac7e025375a345ef7ee83279254bd517a32960b8 100644 (file)
--- a/pom.xml
+++ b/pom.xml
     </dependency>
 
     <!-- Now <scope>test... -->
+    <dependency>
+      <groupId>org.opendaylight.aaa.web</groupId>
+      <artifactId>testutils</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.infrautils</groupId>
       <artifactId>infrautils-testutils</artifactId>
index 1885228400e5dff47c60ef3036f01675e4296a2c..32ad205ef186316c05b89d2cc4994f2855edc634 100644 (file)
@@ -21,6 +21,8 @@ import org.opendaylight.aaa.web.servlet.jersey2.JerseyServletSupport;
  */
 public class WebModule extends AbstractModule {
 
+    // TODO note (new) org.opendaylight.aaa.web.testutils.WebTestModule .. integrate?
+
     @Override
     protected void configure() {
         // TODO read port from a -D parameter or configuration file instead of hard-coding
diff --git a/src/test/java/org/opendaylight/infrautils/testutils/TestHttpClient.java b/src/test/java/org/opendaylight/infrautils/testutils/TestHttpClient.java
deleted file mode 100644 (file)
index f15dffb..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2018 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.infrautils.testutils;
-
-import java.io.IOException;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.aaa.web.WebServer;
-import org.opendaylight.infrautils.testutils.web.TestWebClient;
-import org.opendaylight.infrautils.testutils.web.TestWebClient.Method;
-
-/**
- * HTTP Client.
- *
- * @author Michael Vorburger.ch
- */
-@Singleton
-public class TestHttpClient {
-
-    private final TestWebClient webClient;
-
-    @Inject
-    public TestHttpClient(WebServer webServer) {
-        this.webClient = new TestWebClient(webServer.getBaseURL());
-    }
-
-    public int responseCode(Method httpMethod, String path) throws IOException {
-        return webClient.request(httpMethod, path).getStatus();
-    }
-}
index b5a032852d6ea23fc9efc03f755dda048b1e2fc1..74f4ab981057c6bf4ffb028a9055a7078526f6c3 100644 (file)
@@ -15,11 +15,11 @@ import javax.inject.Inject;
 import org.junit.Rule;
 import org.junit.Test;
 import org.opendaylight.aaa.web.WebServer;
+import org.opendaylight.aaa.web.testutils.TestWebClient;
 import org.opendaylight.controller.simple.InMemoryControllerModule;
 import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
 import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
 import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
-import org.opendaylight.infrautils.testutils.TestHttpClient;
 import org.opendaylight.infrautils.web.WebModule;
 import org.opendaylight.neutron.simple.NeutronModule;
 
@@ -34,9 +34,9 @@ public class NeutronModuleTest extends AbstractSimpleDistributionTest {
             NeutronModule.class, InMemoryControllerModule.class, WebModule.class, AnnotationsModule.class);
 
     @Inject WebServer webServer;
-    @Inject TestHttpClient http;
+    @Inject TestWebClient http;
 
     @Test public void testNeutron() throws IOException {
-        assertThat(http.responseCode(GET, "/controller/nb/v2/neutron/networks")).isEqualTo(200);
+        assertThat(http.request(GET, "/controller/nb/v2/neutron/networks").getStatus()).isEqualTo(200);
     }
 }
index 58a0902b4de1454e964570d7d555843d95d1d00c..221da56aca2ad78f502bfcccb2a94d94cea1c21a 100644 (file)
@@ -12,6 +12,7 @@ import static com.google.common.truth.Truth.assertThat;
 import javax.inject.Inject;
 import org.junit.Rule;
 import org.junit.Test;
+import org.opendaylight.aaa.web.testutils.WebTestModule;
 import org.opendaylight.controller.simple.InMemoryControllerModule;
 import org.opendaylight.infrautils.inject.guice.GuiceClassPathBinder;
 import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
@@ -19,7 +20,6 @@ import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
 import org.opendaylight.infrautils.ready.guice.ReadyModule;
 import org.opendaylight.infrautils.simple.DiagStatusModule;
 import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
-import org.opendaylight.infrautils.web.WebModule;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
 import org.opendaylight.openflowplugin.simple.OpenFlowPluginModule;
 import org.opendaylight.serviceutils.simple.ServiceUtilsModule;
@@ -31,7 +31,7 @@ public class OpenFlowPluginModuleTest extends AbstractSimpleDistributionTest {
     private static final GuiceClassPathBinder CLASS_PATH_BINDER = new GuiceClassPathBinder("org.opendaylight");
 
     public @Rule GuiceRule guice = new GuiceRule(new OpenFlowPluginModule(CLASS_PATH_BINDER),
-            new ServiceUtilsModule(), new InMemoryControllerModule(), new DiagStatusModule(), new WebModule(),
+            new ServiceUtilsModule(), new InMemoryControllerModule(), new DiagStatusModule(), new WebTestModule(),
             new ReadyModule(), new AnnotationsModule());
 
     @Inject OpenFlowPluginProvider ofpProvider;
index 76b51ed6522d6e99e35a64e6507d3253c53ba2e2..b03a38af9a4390dc11253af3bff98a6d6c644774 100644 (file)
@@ -15,11 +15,11 @@ import javax.inject.Inject;
 import org.junit.Rule;
 import org.junit.Test;
 import org.opendaylight.aaa.web.WebServer;
+import org.opendaylight.aaa.web.testutils.TestWebClient;
 import org.opendaylight.controller.simple.InMemoryControllerModule;
 import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
 import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
 import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
-import org.opendaylight.infrautils.testutils.TestHttpClient;
 import org.opendaylight.infrautils.web.WebModule;
 import org.opendaylight.restconf.simple.RestConfModule;
 
@@ -34,10 +34,10 @@ public class RestConfModuleTest extends AbstractSimpleDistributionTest {
             RestConfModule.class, InMemoryControllerModule.class, WebModule.class, AnnotationsModule.class);
 
     @Inject WebServer webServer;
-    @Inject TestHttpClient http;
+    @Inject TestWebClient http;
 
     @Test public void testRestConf() throws IOException {
-        assertThat(http.responseCode(GET, "/restconf/modules/")).isEqualTo(200);
+        assertThat(http.request(GET, "/restconf/modules/").getStatus()).isEqualTo(200);
 
         // TODO test security; add auth support to TestHttpClient, check that w.o. auth it's 401
     }