Skip to content

Fix PublicSuffixMatcherLoader#getDefault #621

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

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
@Contract(threading = ThreadingBehavior.SAFE)
public final class PublicSuffixMatcherLoader {

private static final String PUBLIC_SUFFIX_LIST = "org/publicsuffix/list/effective_tld_names.dat";
private static final String PUBLIC_SUFFIX_LIST = "/org/publicsuffix/list/effective_tld_names.dat";

private static final Logger LOG = LoggerFactory.getLogger(PublicSuffixMatcherLoader.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.List;

Expand All @@ -40,7 +39,6 @@
class TestPublicSuffixMatcher {

private static final String SOURCE_FILE = "suffixlistmatcher.txt";
private static final String PUBLIC_SUFFIX_LIST_FILE = "org/publicsuffix/list/effective_tld_names.dat";

private PublicSuffixMatcher matcher;
private PublicSuffixMatcher pslMatcher;
Expand All @@ -60,9 +58,7 @@ void setUp() throws Exception {
final List<PublicSuffixList> lists = PublicSuffixListParser.INSTANCE.parseByType(new InputStreamReader(in, StandardCharsets.UTF_8));
matcher = new PublicSuffixMatcher(lists);
}
final URL publicSuffixListUrl = classLoader.getResource(PUBLIC_SUFFIX_LIST_FILE);
Assertions.assertNotNull(publicSuffixListUrl, PUBLIC_SUFFIX_LIST_FILE);
pslMatcher = PublicSuffixMatcherLoader.load(publicSuffixListUrl);
pslMatcher = PublicSuffixMatcherLoader.getDefault();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

package org.apache.hc.client5.http.psl;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import org.junit.jupiter.api.Test;
Expand All @@ -38,7 +39,10 @@ class TestPublicSuffixMatcherLoader {

@Test
void testGetDefault() {
assertNotNull(PublicSuffixMatcherLoader.getDefault());
final PublicSuffixMatcher defaultMatcher = PublicSuffixMatcherLoader.getDefault();
assertNotNull(defaultMatcher);
// check for an expected-to-be-stable entry in the PUBLIC_SUFFIX_LIST
assertEquals("example.net", defaultMatcher.getDomainRoot("example.net", DomainType.ICANN));
}

}