Skip to content

Commit

Permalink
Merge pull request #44913 from holly-cummins/fix-test-that-needs-network
Browse files Browse the repository at this point in the history
Add guard on test that network is available
  • Loading branch information
gastaldi authored Dec 4, 2024
2 parents 6a487f0 + 87817c6 commit 0773bf5
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;

import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand All @@ -35,7 +38,8 @@ class GeneratedResourceBuildItemTest {
Dependency.of("org.apache.cxf", "cxf-rt-bindings-soap", "3.4.3")));

@Test
public void testXMLResourceWasMerged() throws IOException {
public void testXMLResourceWasMerged() {
Assumptions.assumeTrue(isOnline());
assertThat(runner.getStartupConsoleOutput()).contains("RESOURCES: 1",
"<entry key=\"xml-javax.wsdl.Port\">org.apache.cxf.binding.xml.wsdl11.HttpAddressPlugin</entry>",
"<entry key=\"xml-javax.wsdl.Binding\">org.apache.cxf.binding.xml.wsdl11.XmlBindingPlugin</entry>",
Expand All @@ -58,4 +62,13 @@ public static void main(String[] args) throws IOException {
}
}
}

boolean isOnline() {
try {
InetAddress resolved = InetAddress.getByName("sun.com");
return resolved != null;
} catch (UnknownHostException e) {
return false;
}
}
}

0 comments on commit 0773bf5

Please sign in to comment.