Skip to content

Commit

Permalink
Resolve the exception type based on the current operating system for …
Browse files Browse the repository at this point in the history
…OkHttp and thus enable the test on Windows.
  • Loading branch information
SamBarker committed Jul 31, 2024
1 parent 2ee636f commit ff287b7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

import io.fabric8.kubernetes.client.http.AbstractHttpPostTest;
import io.fabric8.kubernetes.client.http.HttpClient;
import org.junit.jupiter.api.condition.OS;

import java.io.InterruptedIOException;
import java.net.ConnectException;

@SuppressWarnings("java:S2187")
Expand All @@ -29,6 +31,10 @@ protected HttpClient.Factory getHttpClientFactory() {

@Override
protected Class<? extends Exception> getConnectionFailedExceptionType() {
return ConnectException.class;
if (OS.WINDOWS.equals(OS.current())) {
return InterruptedIOException.class;
} else {
return ConnectException.class;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

import io.fabric8.kubernetes.client.http.AbstractHttpPutTest;
import io.fabric8.kubernetes.client.http.HttpClient;
import org.junit.jupiter.api.condition.OS;

import java.io.InterruptedIOException;
import java.net.ConnectException;

@SuppressWarnings("java:S2187")
Expand All @@ -29,6 +31,10 @@ protected HttpClient.Factory getHttpClientFactory() {

@Override
protected Class<? extends Exception> getConnectionFailedExceptionType() {
return ConnectException.class;
if (OS.WINDOWS.equals(OS.current())) {
return InterruptedIOException.class;
} else {
return ConnectException.class;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -160,7 +158,6 @@ public void expectContinue() throws Exception {
}

@Test
@DisabledOnOs(OS.WINDOWS)
public void expectFailure() throws IOException, URISyntaxException {
try (final ServerSocket serverSocket = new ServerSocket(0)) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -96,7 +94,6 @@ public void putInputStreamBody() throws Exception {
}

@Test
@DisabledOnOs(OS.WINDOWS)
public void expectFailure() throws IOException, URISyntaxException {
try (final ServerSocket serverSocket = new ServerSocket(0)) {

Expand Down

0 comments on commit ff287b7

Please sign in to comment.