</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>
*/
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
+++ /dev/null
-/*
- * 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();
- }
-}
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;
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);
}
}
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;
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;
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;
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;
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
}