Skip to content
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

[SUREFIRE-2220] SurefireForkChannel#getForkNodeConnectionString() ret… #697

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions maven-surefire-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
</includes>
<systemPropertyVariables>
<jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
<java.net.preferIPv6Addresses>true</java.net.preferIPv6Addresses>
</systemPropertyVariables>
</configuration>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketOption;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousServerSocketChannel;
Expand Down Expand Up @@ -112,7 +114,19 @@ public void tryConnectToClient() {

@Override
public String getForkNodeConnectionString() {
return "tcp://" + localHost + ":" + localPort + (isBlank(sessionId) ? "" : "?sessionId=" + sessionId);
try {
URI uri = new URI(
"tcp",
null,
localHost,
localPort,
null,
isBlank(sessionId) ? null : "sessionId=" + sessionId,
null);
return uri.toASCIIString();
} catch (URISyntaxException e) {
throw new IllegalStateException(e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,16 @@ public Object getConsoleLock() {
assertThat(channel.getCountdownCloseablePermits()).isEqualTo(3);

String localHost = InetAddress.getLoopbackAddress().getHostAddress();
assertThat(channel.getForkNodeConnectionString())
.startsWith("tcp://" + localHost + ":")
.isNotEqualTo("tcp://" + localHost + ":")
.endsWith("?sessionId=" + sessionId);

URI uri = new URI(channel.getForkNodeConnectionString());

String connectionString = channel.getForkNodeConnectionString();
URI uri = new URI(connectionString);
assertThat(uri.getScheme()).isEqualTo("tcp");
String uriHost = uri.getHost();
if (uriHost.startsWith("[") && uriHost.endsWith("]")) {
uriHost = uriHost.substring(1, uriHost.length() - 1);
}
assertThat(uriHost).isEqualTo(localHost);
assertThat(uri.getPort()).isPositive();
assertThat(uri.getQuery()).isEqualTo("sessionId=" + sessionId);

final TestLessInputStreamBuilder builder = new TestLessInputStreamBuilder();
TestLessInputStream commandReader = builder.build();
Expand Down