This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo-classloaders.git


The following commit(s) were added to refs/heads/main by this push:
     new 9444cc3  Tests invalid and missing allowed URL (#57)
9444cc3 is described below

commit 9444cc34c0711594f810c00b584cb9c08dcdd90c
Author: Keith Turner <[email protected]>
AuthorDate: Fri Jan 30 16:57:29 2026 -0800

    Tests invalid and missing allowed URL (#57)
    
    fixes #56
---
 .../LocalCachingContextClassLoaderFactoryTest.java   | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git 
a/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactoryTest.java
 
b/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactoryTest.java
index 8354376..694546d 100644
--- 
a/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactoryTest.java
+++ 
b/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactoryTest.java
@@ -48,6 +48,7 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
+import java.util.regex.PatternSyntaxException;
 import java.util.stream.Collectors;
 
 import org.apache.accumulo.classloader.lcc.TestUtils.TestClassInfo;
@@ -214,6 +215,25 @@ public class LocalCachingContextClassLoaderFactoryTest {
     assertTrue(ex.getCause().getCause().getCause() instanceof 
IllegalArgumentException);
     assertTrue(ex.getCause().getCause().getCause().getMessage().contains(
         "Resource location (" + badUrl + ")"), 
ex.getCause().getCause().getCause()::getMessage);
+
+    // case 4: invalid regex for allowed url
+    ConfigurationCopy acuConf2 = new ConfigurationCopy(
+        Map.of(CACHE_DIR_PROPERTY, 
baseCacheDir.toAbsolutePath().toUri().toURL().toExternalForm(),
+            ALLOWED_URLS_PATTERN, "file:[a-z.*"));
+    var factory2 = new LocalCachingContextClassLoaderFactory();
+    factory2.init(() -> new ConfigurationImpl(acuConf2));
+    ex = assertThrows(ContextClassLoaderException.class,
+        () -> factory2.getClassLoader(hdfsAllContext.toExternalForm()));
+    assertEquals(PatternSyntaxException.class, ex.getCause().getClass());
+
+    // case 5: no allowed pattern url is set
+    ConfigurationCopy acuConf3 = new ConfigurationCopy(
+        Map.of(CACHE_DIR_PROPERTY, 
baseCacheDir.toAbsolutePath().toUri().toURL().toExternalForm()));
+    var factory3 = new LocalCachingContextClassLoaderFactory();
+    factory3.init(() -> new ConfigurationImpl(acuConf3));
+    ex = assertThrows(ContextClassLoaderException.class,
+        () -> factory3.getClassLoader(hdfsAllContext.toExternalForm()));
+    assertTrue(ex.getMessage().contains(ALLOWED_URLS_PATTERN + " not set"), 
ex::getMessage);
   }
 
   @Test

Reply via email to