@@ -0,0 +1,1873 @@
+/*%0ALicensed to the Apache Software Foundation (ASF) under one%0Aor more contributor license agreements.  See the NOTICE file%0Adistributed with this work for additional information%0Aregarding copyright ownership.  The ASF licenses this file%0Ato you under the Apache License, Version 2.0 (the%0A%22License%22); you may not use this file except in compliance%0Awith the License.  You may obtain a copy of the License at%0A%0A  http://www.apache.org/licenses/LICENSE-2.0%0A%0AUnless required by applicable law or agreed to in writing,%0Asoftware distributed under the License is distributed on an%0A%22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0AKIND, either express or implied.  See the License for the%0Aspecific language governing permissions and limitations%0Aunder the License.%0A*/%0Apackage org.apache.edgent.test.console.server;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assume.assumeTrue;%0A%0Aimport java.io.IOException;%0Aimport java.net.Socket;%0A%0Aimport org.apache.edgent.console.server.HttpServer;%0Aimport org.junit.Test;%0A%0A/**%0A * This is a separate test because the HttpServer implementation%0A * precludes changing the console port within a jvm instance.%0A */%0Apublic class HttpServerTestPort %7B%0A%09%0A%09  int getAvailablePort() throws IOException %7B%0A%09    try (Socket s = new Socket()) %7B%0A%09      s.bind(null);%0A%09      return s.getLocalPort();%0A%09    %7D%0A%09  %7D%0A%0A    @Test%0A    public void overridePortNumber() throws Exception %7B%0A      // count on the OS not immediately reusing an available local port.%0A    %09int port = getAvailablePort();%0A      int port2 = getAvailablePort();%0A      assumeTrue(port != port2);%0A      %0A      System.setProperty(%22edgent.console.port%22, String.valueOf(port));%0A      HttpServer myHttpServer = HttpServer.getInstance();%0A      myHttpServer.startServer();%0A      %0A      int portNum = myHttpServer.getConsolePortNumber();%0A      assertEquals(port, portNum);%0A    %7D%0A%0A%7D%0A

add console port override test