File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed
maven-surefire-common/src
main/java/org/apache/maven/plugin/surefire/extensions
test/java/org/apache/maven/surefire/extensions Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change 2525import java .net .InetAddress ;
2626import java .net .InetSocketAddress ;
2727import java .net .SocketOption ;
28+ import java .net .URI ;
29+ import java .net .URISyntaxException ;
2830import java .nio .Buffer ;
2931import java .nio .ByteBuffer ;
3032import java .nio .channels .AsynchronousServerSocketChannel ;
@@ -112,7 +114,19 @@ public void tryConnectToClient() {
112114
113115 @ Override
114116 public String getForkNodeConnectionString () {
115- return "tcp://" + localHost + ":" + localPort + (isBlank (sessionId ) ? "" : "?sessionId=" + sessionId );
117+ try {
118+ URI uri = new URI (
119+ "tcp" ,
120+ null ,
121+ localHost ,
122+ localPort ,
123+ null ,
124+ isBlank (sessionId ) ? null : "sessionId=" + sessionId ,
125+ null );
126+ return uri .toASCIIString ();
127+ } catch (URISyntaxException e ) {
128+ throw new IllegalStateException (e );
129+ }
116130 }
117131
118132 @ Override
Original file line number Diff line number Diff line change @@ -121,14 +121,16 @@ public Object getConsoleLock() {
121121 assertThat (channel .getCountdownCloseablePermits ()).isEqualTo (3 );
122122
123123 String localHost = InetAddress .getLoopbackAddress ().getHostAddress ();
124- assertThat (channel .getForkNodeConnectionString ())
125- .startsWith ("tcp://" + localHost + ":" )
126- .isNotEqualTo ("tcp://" + localHost + ":" )
127- .endsWith ("?sessionId=" + sessionId );
128-
129- URI uri = new URI (channel .getForkNodeConnectionString ());
130-
124+ String connectionString = channel .getForkNodeConnectionString ();
125+ URI uri = new URI (connectionString );
126+ assertThat (uri .getScheme ()).isEqualTo ("tcp" );
127+ String uriHost = uri .getHost ();
128+ if (uriHost .startsWith ("[" ) && uriHost .endsWith ("]" )) {
129+ uriHost = uriHost .substring (1 , uriHost .length () - 1 );
130+ }
131+ assertThat (uriHost ).isEqualTo (localHost );
131132 assertThat (uri .getPort ()).isPositive ();
133+ assertThat (uri .getQuery ()).isEqualTo ("sessionId=" + sessionId );
132134
133135 final TestLessInputStreamBuilder builder = new TestLessInputStreamBuilder ();
134136 TestLessInputStream commandReader = builder .build ();
You can’t perform that action at this time.
0 commit comments