-
Notifications
You must be signed in to change notification settings - Fork 32
Add clickable server URL to dev mode port info output #529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
venmanyarun
merged 4 commits into
OpenLiberty:main
from
venmanyarun:port-info-clickable-url
Aug 13, 2026
+243
−3
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ee72a46
Add clickable server URL to dev mode port info output
venmanyarun 6d519c1
Address review: rename 'URL:' label to 'Liberty server URL:' / 'Liber…
venmanyarun 5142c4f
changed label to Liberty welcome page:
venmanyarun c104d05
added fields for container tests
venmanyarun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
187 changes: 187 additions & 0 deletions
187
src/test/java/io/openliberty/tools/common/plugins/util/DevUtilPrintPortInfoTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,187 @@ | ||
| /** | ||
| * (C) Copyright IBM Corporation 2025, 2026. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.openliberty.tools.common.plugins.util; | ||
|
|
||
| import static org.junit.Assert.assertTrue; | ||
| import static org.junit.Assert.assertFalse; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| /** | ||
| * Tests that printPortInfo outputs a Liberty welcome page URL alongside each port line, | ||
| * for both non-container (server) and container modes. | ||
| */ | ||
| public class DevUtilPrintPortInfoTest extends BaseDevUtilTest { | ||
|
|
||
| private DevTestUtil newUtil() throws Exception { | ||
| return (DevTestUtil) getNewDevUtil(null); | ||
| } | ||
|
|
||
| // ----------------------------------------------------------------------- | ||
| // Non-container: HTTP port | ||
| // ----------------------------------------------------------------------- | ||
|
|
||
| @Test | ||
| public void testServerHttpPortUrlPrinted() throws Exception { | ||
| DevTestUtil util = newUtil(); | ||
| int portPrefixIndex = util.parseHostName( | ||
| "Web application available (default_host): http://myhostname:9080/myapp/"); | ||
| util.parseHttpPort( | ||
| "Web application available (default_host): http://myhostname:9080/myapp/", portPrefixIndex); | ||
|
|
||
| util.printPortInfo(true); | ||
|
|
||
| assertTrue("Expected HTTP port line to be printed", | ||
| util.hasMessage("Liberty server HTTP port: [ 9080 ]")); | ||
| assertTrue("Expected HTTP URL to be printed", | ||
| util.hasMessage("Liberty welcome page: http://myhostname:9080/")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testServerHttpPortUrlUsesActualHostname() throws Exception { | ||
| DevTestUtil util = newUtil(); | ||
| // Simulate Liberty bound to a real IP address (not localhost) | ||
| int portPrefixIndex = util.parseHostName( | ||
| "Web application available (default_host): http://192.168.1.26:9080/myapp/"); | ||
| util.parseHttpPort( | ||
| "Web application available (default_host): http://192.168.1.26:9080/myapp/", portPrefixIndex); | ||
|
|
||
| util.printPortInfo(true); | ||
|
|
||
| assertTrue("Expected URL with actual IP address", | ||
| util.hasMessage("Liberty welcome page: http://192.168.1.26:9080/")); | ||
| assertFalse("localhost should not appear in URL when server bound to IP", | ||
| util.hasMessage("Liberty welcome page: http://localhost:9080/")); | ||
| } | ||
|
|
||
| // ----------------------------------------------------------------------- | ||
| // Non-container: HTTPS port | ||
| // ----------------------------------------------------------------------- | ||
|
|
||
| @Test | ||
| public void testServerHttpsPortUrlPrinted() throws Exception { | ||
| DevTestUtil util = newUtil(); | ||
| int portPrefixIndex = util.parseHostName( | ||
| "Web application available (default_host): http://myhostname:9080/myapp/"); | ||
| util.parseHttpPort( | ||
| "Web application available (default_host): http://myhostname:9080/myapp/", portPrefixIndex); | ||
|
|
||
| List<String> tcpMessages = new ArrayList<>(); | ||
| tcpMessages.add("CWWKO0219I: TCP Channel defaultHttpEndpoint-ssl has been started and is now listening for requests on host myhostname port 9443."); | ||
| util.parseHttpsPort(tcpMessages); | ||
|
|
||
| util.printPortInfo(true); | ||
|
|
||
| assertTrue("Expected HTTPS port line to be printed", | ||
| util.hasMessage("Liberty server HTTPS port: [ 9443 ]")); | ||
| assertTrue("Expected HTTPS URL to be printed", | ||
| util.hasMessage("Liberty welcome page: https://myhostname:9443/")); | ||
| } | ||
|
|
||
| // ----------------------------------------------------------------------- | ||
| // Non-container: no port — no URL printed | ||
| // ----------------------------------------------------------------------- | ||
|
|
||
| @Test | ||
| public void testNoUrlPrintedWhenNoPortAvailable() throws Exception { | ||
| DevTestUtil util = newUtil(); | ||
| // Do not parse any port — httpPort and httpsPort remain null | ||
|
|
||
| util.printPortInfo(true); | ||
|
|
||
| assertFalse("No URL should be printed when no port is available", | ||
| util.hasMessage("Liberty welcome page: http://")); | ||
| assertFalse("No URL should be printed when no port is available", | ||
| util.hasMessage("Liberty welcome page: https://")); | ||
| } | ||
|
|
||
| // ----------------------------------------------------------------------- | ||
| // Non-container: non-default port | ||
| // ----------------------------------------------------------------------- | ||
|
|
||
| @Test | ||
| public void testServerNonDefaultHttpPortUrl() throws Exception { | ||
| DevTestUtil util = newUtil(); | ||
| int portPrefixIndex = util.parseHostName( | ||
| "Web application available (default_host): http://myhostname:9085/myapp/"); | ||
| util.parseHttpPort( | ||
| "Web application available (default_host): http://myhostname:9085/myapp/", portPrefixIndex); | ||
|
|
||
| util.printPortInfo(true); | ||
|
|
||
| assertTrue("Expected HTTP port line with non-default port", | ||
| util.hasMessage("Liberty server HTTP port: [ 9085 ]")); | ||
| assertTrue("Expected HTTP URL with non-default port", | ||
| util.hasMessage("Liberty welcome page: http://myhostname:9085/")); | ||
| } | ||
|
|
||
| // ----------------------------------------------------------------------- | ||
| // Non-container: localhost | ||
| // ----------------------------------------------------------------------- | ||
|
|
||
| @Test | ||
| public void testServerLocalhostHttpPortUrl() throws Exception { | ||
| DevTestUtil util = newUtil(); | ||
| int portPrefixIndex = util.parseHostName( | ||
| "Web application available (default_host): http://localhost:9080/myapp/"); | ||
| util.parseHttpPort( | ||
| "Web application available (default_host): http://localhost:9080/myapp/", portPrefixIndex); | ||
|
|
||
| util.printPortInfo(true); | ||
|
|
||
| assertTrue("Expected HTTP URL with localhost", | ||
| util.hasMessage("Liberty welcome page: http://localhost:9080/")); | ||
| } | ||
|
|
||
| // ----------------------------------------------------------------------- | ||
| // Container: HTTP port | ||
| // ----------------------------------------------------------------------- | ||
|
|
||
| @Test | ||
| public void testContainerHttpPortUrlPrinted() throws Exception { | ||
| DevTestUtil util = getNewContainerUtil(); | ||
| // Internal container port 9080 mapped to host port 9080 | ||
| util.setContainerPorts("9080", "9080", null, null); | ||
|
|
||
| util.printPortInfo(true); | ||
|
|
||
| assertTrue("Expected container HTTP port line to be printed", | ||
| util.hasMessage("Internal container HTTP port [ 9080 ] is mapped to container host port [ 9080 ]")); | ||
| assertTrue("Expected container HTTP welcome page URL to be printed", | ||
| util.hasMessage("Liberty welcome page: http://localhost:9080/")); | ||
| } | ||
|
|
||
| // ----------------------------------------------------------------------- | ||
| // Container: HTTPS port | ||
| // ----------------------------------------------------------------------- | ||
|
|
||
| @Test | ||
| public void testContainerHttpsPortUrlPrinted() throws Exception { | ||
| DevTestUtil util = getNewContainerUtil(); | ||
| // Internal container port 9443 mapped to host port 9443 | ||
| util.setContainerPorts(null, null, "9443", "9443"); | ||
|
|
||
| util.printPortInfo(true); | ||
|
|
||
| assertTrue("Expected container HTTPS port line to be printed", | ||
| util.hasMessage("Internal container HTTPS port [ 9443 ] is mapped to container host port [ 9443 ]")); | ||
| assertTrue("Expected container HTTPS welcome page URL to be printed", | ||
| util.hasMessage("Liberty welcome page: https://localhost:9443/")); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.