From 851e832e920447142d883e797a9548561ac90038 Mon Sep 17 00:00:00 2001 From: Chris Midgley Date: Sat, 16 Jul 2022 11:40:35 +0100 Subject: [PATCH] Add test confirming that method is protected or public. --- .../provider/UrlModuleSourceProviderTest.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/testsrc/org/mozilla/javascript/tests/commonjs/module/provider/UrlModuleSourceProviderTest.java b/testsrc/org/mozilla/javascript/tests/commonjs/module/provider/UrlModuleSourceProviderTest.java index 4924b1afd8..c05ae34596 100644 --- a/testsrc/org/mozilla/javascript/tests/commonjs/module/provider/UrlModuleSourceProviderTest.java +++ b/testsrc/org/mozilla/javascript/tests/commonjs/module/provider/UrlModuleSourceProviderTest.java @@ -4,8 +4,11 @@ package org.mozilla.javascript.tests.commonjs.module.provider; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.net.URI; -import java.net.URISyntaxException; +import java.net.URISyntaxException;; +import java.net.URLConnection; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.FileTime; @@ -67,6 +70,14 @@ public void testModuleModified() throws Exception { Assert.assertNotEquals("Modified", ModuleSourceProvider.NOT_MODIFIED, result); } + @Test + public void getCharacterEncodingCanBeModifiedInSubclass() throws NoSuchMethodException { + Method method = UrlModuleSourceProvider.class + .getDeclaredMethod("getCharacterEncoding", new Class[] { URLConnection.class }); + int mods = method.getModifiers(); + Assert.assertTrue(Modifier.isPublic(mods) || Modifier.isProtected(mods)); + } + private static URI getModuleURI(final Path filePath) throws URISyntaxException { final String uriString = filePath.toUri().toASCIIString(); return new URI(uriString.substring(0, uriString.lastIndexOf('.')));