2 * Copyright © 2020 Orange Labs, 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.transportpce.pce.gnpy;
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertTrue;
13 import java.io.IOException;
14 import java.nio.charset.StandardCharsets;
15 import java.nio.file.Files;
16 import java.nio.file.Paths;
17 import javax.ws.rs.core.Application;
18 import org.glassfish.jersey.server.ResourceConfig;
19 import org.glassfish.jersey.test.JerseyTest;
20 import org.junit.Test;
22 public class ConnectToGnpyServerTest extends JerseyTest {
24 //we must hardcode port because it's hardcoded in ConnectToGnpyServer
25 System.setProperty("jersey.config.test.container.port", "8008");
29 protected Application configure() {
30 return new ResourceConfig(GnpyStub.class);
34 public void isGnpyURLExistTest() throws GnpyException, IOException {
35 ConnectToGnpyServer connectToGnpy = new ConnectToGnpyServer();
36 assertTrue(connectToGnpy.isGnpyURLExist());
40 public void returnGnpyResponseTest() throws GnpyException, IOException {
41 ConnectToGnpyServer connectToGnpy = new ConnectToGnpyServer();
42 String result = connectToGnpy.returnGnpyResponse(Files.readString(
43 Paths.get("src", "test", "resources", "gnpy", "gnpy_request.json"), StandardCharsets.US_ASCII));
44 assertNotNull("result should not be null", result);
45 assertTrue("Result should not be empty", !result.isEmpty());