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

emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 28c965885a GROOVY-11046: add test case
28c965885a is described below

commit 28c965885a045ca3f6f789d21b1e03c7557dcae2
Author: Eric Milles <[email protected]>
AuthorDate: Thu Dec 21 15:41:16 2023 -0600

    GROOVY-11046: add test case
---
 src/test/groovy/bugs/Groovy11046.groovy | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/test/groovy/bugs/Groovy11046.groovy 
b/src/test/groovy/bugs/Groovy11046.groovy
index e405cf1337..2240dd5a3e 100644
--- a/src/test/groovy/bugs/Groovy11046.groovy
+++ b/src/test/groovy/bugs/Groovy11046.groovy
@@ -21,14 +21,30 @@ package groovy.bugs
 import org.junit.Test
 
 import static groovy.test.GroovyAssert.assertScript
+import static groovy.test.GroovyAssert.shouldFail
 
 final class Groovy11046 {
+
     @Test
-    void testGrabErrorForMissingDependency() {
+    void testMissingDependency1() {
         // throws NoClassDefFoundError: 
com.lmax.disruptor.EventTranslatorVararg
         assertScript '''
             @Grab('org.apache.logging.log4j:log4j-core:2.22.0')
             org.apache.logging.log4j.core.async.AsyncLogger log
         '''
     }
+
+    @Test
+    void testMissingDependency2() {
+        def err = shouldFail '''
+            @Grab('org.apache.logging.log4j:log4j-core:2.22.0')
+            org.apache.logging.log4j.core.async.AsyncLogger log
+            System.setProperty('Log4jContextSelector',
+                
'org.apache.logging.log4j.core.async.AsyncLoggerContextSelector')
+            log = org.apache.logging.log4j.LogManager.getLogger(getClass()) 
//XXX
+        '''
+        assert err instanceof NoClassDefFoundError // 
CompilationFailedException (previously)
+        assert err =~ /com.lmax.disruptor.EventTranslatorVararg/
+        assert err.asString() =~ /at 
org.apache.logging.log4j.LogManager.getLogger\(/ : 'script should have failed 
at runtime'
+    }
 }

Reply via email to