2 * Copyright (c) 2019 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.restconf.nb.rfc8040.test;
10 import static com.google.common.truth.Truth.assertThat;
11 import static org.opendaylight.infrautils.testutils.web.TestWebClient.Method.GET;
13 import com.google.inject.AbstractModule;
14 import com.google.inject.Provides;
15 import java.io.IOException;
16 import javax.inject.Inject;
17 import javax.inject.Singleton;
18 import org.junit.Rule;
19 import org.junit.Test;
20 import org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration;
21 import org.opendaylight.aaa.web.WebServer;
22 import org.opendaylight.aaa.web.testutils.TestWebClient;
23 import org.opendaylight.aaa.web.testutils.WebTestModule;
24 import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
25 import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
26 import org.opendaylight.infrautils.testutils.LogRule;
27 import org.opendaylight.restconf.nb.rfc8040.RestconfApplication;
28 import org.opendaylight.restconf.nb.rfc8040.Rfc8040RestConfWiring;
29 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
30 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.JSONRestconfServiceRfc8040Impl;
31 import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapper;
32 import org.opendaylight.restconf.nb.rfc8040.test.incubate.InMemoryMdsalModule;
33 import org.opendaylight.restconf.nb.rfc8040.web.WebInitializer;
34 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
37 * Tests if the {@link Rfc8040RestConfWiring} works.
39 * @author Michael Vorburger.ch
41 public class Rfc8040RestConfWiringTest {
43 public static class TestModule extends AbstractModule {
45 protected void configure() {
46 bind(Rfc8040RestConfWiring.class).asEagerSingleton();
47 bind(RestconfApplication.class).asEagerSingleton();
48 bind(JSONRestconfServiceRfc8040Impl.class).asEagerSingleton();
49 bind(WebInitializer.class).asEagerSingleton();
50 bind(CustomFilterAdapterConfiguration.class).toInstance(listener -> { });
54 @Singleton ServicesWrapper getServicesWrapper(Rfc8040RestConfWiring wiring) {
55 return wiring.getServicesWrapper();
59 public @Rule LogRule logRule = new LogRule();
61 public @Rule GuiceRule guice = new GuiceRule(TestModule.class,
62 InMemoryMdsalModule.class, WebTestModule.class, AnnotationsModule.class);
64 @Inject WebServer webServer;
65 @Inject TestWebClient webClient;
67 @Inject SchemaContextProvider schemaContextProvider;
68 @Inject SchemaContextHandler schemaContextHandler;
71 public void testWiring() throws IOException {
72 schemaContextHandler.onGlobalContextUpdated(schemaContextProvider.getSchemaContext());
73 assertThat(webClient.request(GET, "/rests/yang-library-version").getStatus()).isEqualTo(200);