Skip to content

Commit

Permalink
Issue jetty#9167 - making assumption in flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Jan 16, 2023
1 parent 58f5e46 commit be3b8f0
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@

package org.eclipse.jetty.util.resource;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;

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

import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -62,16 +67,29 @@ public void testCustomUriSchemeRegistered()
}

@Test
public void testRegisterHttpsUrlFactory()
public void testRegisterHttpsUrlFactory() throws MalformedURLException
{
URI uri = URI.create("https://webtide.com/");

// Verify that environment can access the URI.
URL url = uri.toURL();
try
{
HttpURLConnection http = (HttpURLConnection)url.openConnection();
Assumptions.assumeTrue(http.getResponseCode() == HttpURLConnection.HTTP_OK);
}
catch (IOException e)
{
Assumptions.abort("Unable to connect to " + uri);
}

ResourceFactory.registerResourceFactory("https", new URLResourceFactory());
// Try as a normal String input
Resource resource = ResourceFactory.root().newResource("https://webtide.com/");
assertThat(resource.getURI(), is(URI.create("https://webtide.com/")));
assertThat(resource.getName(), is("https://webtide.com/"));

// Try as a formal URI object as input
URI uri = URI.create("https://webtide.com/");
resource = ResourceFactory.root().newResource(uri);
assertThat(resource.getURI(), is(URI.create("https://webtide.com/")));
assertThat(resource.getName(), is("https://webtide.com/"));
Expand Down

0 comments on commit be3b8f0

Please sign in to comment.