Skip to content

Commit

Permalink
simplify assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
eze210 committed Sep 23, 2024
1 parent 3644e6e commit 303eda1
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

import static java.lang.String.format;

import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;

import org.mule.extension.http.api.HttpResponseAttributes;
import org.mule.extension.http.api.error.HttpError;
Expand Down Expand Up @@ -157,18 +157,10 @@ public void timeout() throws Exception {

@Test
public void connectivity() throws Exception {
String errorMessageGrizzly = getErrorMessage(": Connection refused", unusedPort) + " connectivity";
String errorMessageNetty =
getErrorMessage(": Connection refused: localhost/127.0.0.1:" + unusedPort.getNumber(), unusedPort) + " connectivity";
String errorMessageReactorNetty =
getErrorMessage(": Connection refused: localhost/[0:0:0:0:0:0:0:1]:" + unusedPort.getNumber(), unusedPort)
+ " connectivity";
String errorMessageGrizzlyWindows =
getErrorMessage(": Connection refused: no further information", unusedPort) + " connectivity";

CoreEvent result = getFlowRunner("handled", unusedPort.getNumber()).run();
assertThat(result.getMessage(), hasPayload(anyOf(equalTo(errorMessageNetty), equalTo(errorMessageGrizzly),
equalTo(errorMessageReactorNetty), equalTo(errorMessageGrizzlyWindows))));

// The exact message depends on the OS and the underlying framework, but all contain "Connection refused".
assertThat(result.getMessage(), hasPayload(containsString("Connection refused")));
}

@Test
Expand Down

0 comments on commit 303eda1

Please sign in to comment.