Refactor OLM timers management
[transportpce.git] / lighty / src / test / java / io / lighty / controllers / tpce / MaintTest.java
1 /*
2  * Copyright © 2020 Orange, 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
9 package io.lighty.controllers.tpce;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.fail;
12
13 import java.io.File;
14 import org.eclipse.jetty.client.HttpClient;
15 import org.eclipse.jetty.client.api.ContentResponse;
16 import org.junit.After;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 public class MaintTest {
23     private static final Logger LOG = LoggerFactory.getLogger(MaintTest.class);
24     private Main main = new Main();
25     private HttpClient client = new HttpClient();
26
27     @Before
28     @SuppressWarnings("checkstyle:Illegalcatch")
29     public void init() {
30         try {
31             client.start();
32         } catch (Exception e) {
33             LOG.error("An error occured during test init", e);
34             fail("cannot init test ");
35         }
36     }
37
38     @After
39     @SuppressWarnings("checkstyle:Illegalcatch")
40     public void stop() {
41         try {
42             main.shutdown();
43             client.stop();
44         } catch (Exception e) {
45             LOG.error("An error occured during test shutdown", e);
46         }
47     }
48
49     @Test
50     public void startNoConfigFileTest() throws Exception {
51         main.start(null, false, "3000", "2000", true);
52         ContentResponse response = client.GET("http://localhost:8181/restconf/config/ietf-network:networks/network/openroadm-topology");
53         assertEquals("Response code should be 200", 200, response.getStatus());
54     }
55
56     @Test
57     public void startConfigFileTest() throws Exception {
58         File configFile = new File("src/test/resources/config.json");
59         main.start(configFile.getAbsolutePath(), false, "3000", "2000", true);
60         ContentResponse response = client.GET("http://localhost:8888/restconfCustom/config/ietf-network:networks/network/openroadm-topology");
61         assertEquals("Response code should be 200", 200, response.getStatus());
62     }
63 }