990453fa9f728c12bba995e895e8dcb068108d45
[netconf.git] / restconf / restconf-nb-bierman02 / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / Bierman02RestConfWiringTest.java
1 /*
2  * Copyright (c) 2019 Red Hat, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.restconf.impl.test;
9
10 import static org.junit.Assert.assertEquals;
11
12 import com.google.inject.AbstractModule;
13 import java.io.IOException;
14 import java.net.URISyntaxException;
15 import javax.inject.Inject;
16 import org.junit.Rule;
17 import org.junit.Test;
18 import org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration;
19 import org.opendaylight.aaa.web.WebServer;
20 import org.opendaylight.aaa.web.testutils.TestWebClient;
21 import org.opendaylight.aaa.web.testutils.WebTestModule;
22 import org.opendaylight.controller.sal.restconf.impl.test.incubate.InMemoryMdsalModule;
23 import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
24 import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
25 import org.opendaylight.netconf.sal.restconf.api.RestConfConfig;
26 import org.opendaylight.netconf.sal.restconf.impl.Bierman02RestConfWiring;
27
28 /**
29  * Tests if the {@link Bierman02RestConfWiring} works.
30  *
31  * @author Michael Vorburger.ch
32  */
33 public class Bierman02RestConfWiringTest {
34
35     public static class TestModule extends AbstractModule {
36         @Override
37         protected void configure() {
38             bind(Bierman02RestConfWiring.class).asEagerSingleton();
39             bind(RestConfConfig.class).toInstance(() -> 9090);
40             bind(CustomFilterAdapterConfiguration.class).toInstance(listener -> { });
41         }
42     }
43
44     public @Rule GuiceRule guice = new GuiceRule(TestModule.class,
45             InMemoryMdsalModule.class, WebTestModule.class, AnnotationsModule.class);
46
47     @Inject WebServer webServer;
48     @Inject TestWebClient webClient;
49
50     @Test
51     public void testWiring() throws IOException, InterruptedException, URISyntaxException {
52         assertEquals(200, webClient.request("GET", "/restconf/modules/").statusCode());
53     }
54 }