X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=lighty%2Fsrc%2Ftest%2Fjava%2Fio%2Flighty%2Fcontrollers%2Ftpce%2FMaintTest.java;fp=lighty%2Fsrc%2Ftest%2Fjava%2Fio%2Flighty%2Fcontrollers%2Ftpce%2FMaintTest.java;h=bbeb8c263bd01c00bf1c0285715df4f4a48071f8;hb=bfea62e2a8396424a527f0cad1521b8c16a13c90;hp=0000000000000000000000000000000000000000;hpb=1088f62da23159491f6d139e7ea5e51792d11f54;p=transportpce.git diff --git a/lighty/src/test/java/io/lighty/controllers/tpce/MaintTest.java b/lighty/src/test/java/io/lighty/controllers/tpce/MaintTest.java new file mode 100644 index 000000000..bbeb8c263 --- /dev/null +++ b/lighty/src/test/java/io/lighty/controllers/tpce/MaintTest.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2020 Orange, 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 io.lighty.controllers.tpce; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.File; + +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.api.ContentResponse; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MaintTest { + private static final Logger LOG = LoggerFactory.getLogger(MaintTest.class); + private Main main = new Main(); + private HttpClient client = new HttpClient(); + + @Before + @SuppressWarnings("checkstyle:Illegalcatch") + public void init() { + try { + client.start(); + } catch (Exception e) { + LOG.error("An error occured during test init", e); + fail("cannot init test "); + } + } + + @After + @SuppressWarnings("checkstyle:Illegalcatch") + public void stop() { + try { + main.shutdown(); + client.stop(); + } catch (Exception e) { + LOG.error("An error occured during test shutdown", e); + } + } + + @Test + public void startNoConfigFileTest() throws Exception { + main.start(new String[0], true); + ContentResponse response = client.GET("http://localhost:8181/restconf/config/ietf-network:networks/network/openroadm-topology"); + assertEquals("Response code should be 200", 200, response.getStatus()); + } + + @Test + public void startConfigFileTest() throws Exception { + File configFile = new File("src/test/resources/config.json"); + String[] args = {configFile.getAbsolutePath()}; + main.start(args, true); + ContentResponse response = client.GET("http://localhost:8888/restconfCustom/config/ietf-network:networks/network/openroadm-topology"); + assertEquals("Response code should be 200", 200, response.getStatus()); + } +} \ No newline at end of file