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 org.junit.Assert.assertEquals;
12 import com.google.common.util.concurrent.ThreadFactoryBuilder;
13 import com.google.inject.AbstractModule;
14 import com.google.inject.Provides;
15 import java.io.IOException;
16 import java.net.URISyntaxException;
17 import javax.inject.Inject;
18 import javax.inject.Singleton;
19 import org.junit.Ignore;
20 import org.junit.Rule;
21 import org.junit.Test;
22 import org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration;
23 import org.opendaylight.aaa.web.WebServer;
24 import org.opendaylight.aaa.web.testutils.TestWebClient;
25 import org.opendaylight.aaa.web.testutils.WebTestModule;
26 import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
27 import org.opendaylight.controller.config.threadpool.util.ScheduledThreadPoolWrapper;
28 import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
29 import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
30 import org.opendaylight.restconf.nb.rfc8040.RestconfApplication;
31 import org.opendaylight.restconf.nb.rfc8040.Rfc8040RestConfWiring;
32 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
33 import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapper;
34 import org.opendaylight.restconf.nb.rfc8040.streams.Configuration;
35 import org.opendaylight.restconf.nb.rfc8040.test.incubate.InMemoryMdsalModule;
36 import org.opendaylight.restconf.nb.rfc8040.web.WebInitializer;
37 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
40 * Tests if the {@link Rfc8040RestConfWiring} works.
42 * @author Michael Vorburger.ch
45 public class Rfc8040RestConfWiringTest {
47 public static class TestModule extends AbstractModule {
49 private static final Configuration SAMPLE_SSE_CONFIGURATION
50 = new Configuration(8192, 5000, 30000, true);
53 protected void configure() {
54 bind(Rfc8040RestConfWiring.class).asEagerSingleton();
55 bind(RestconfApplication.class).asEagerSingleton();
56 bind(WebInitializer.class).asEagerSingleton();
57 bind(CustomFilterAdapterConfiguration.class).toInstance(listener -> { });
58 bind(Configuration.class).toInstance(SAMPLE_SSE_CONFIGURATION);
62 @Singleton ServicesWrapper getServicesWrapper(final Rfc8040RestConfWiring wiring) {
63 return wiring.getServicesWrapper();
67 @Singleton ScheduledThreadPool getScheduledThreadPool() {
68 return new ScheduledThreadPoolWrapper(8, new ThreadFactoryBuilder().build());
72 public @Rule GuiceRule guice = new GuiceRule(TestModule.class,
73 InMemoryMdsalModule.class, WebTestModule.class, AnnotationsModule.class);
75 @Inject WebServer webServer;
76 @Inject TestWebClient webClient;
78 @Inject EffectiveModelContextProvider schemaContextProvider;
79 @Inject SchemaContextHandler schemaContextHandler;
82 public void testWiring() throws IOException, InterruptedException, URISyntaxException {
83 schemaContextHandler.onModelContextUpdated(schemaContextProvider.getEffectiveModelContext());
84 assertEquals(200, webClient.request("GET", "/rests/yang-library-version").statusCode());