| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (

This example Groovy source code file ( is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

class, classnotfoundexception, classnotfoundexception, exception, exception, securitytestsupport, signedjartest, signedjartest, test, test

The Groovy source code


import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;

 * Read a .groovy file from a signed jar and verify that a policy file grant with a signedBy field
 * works.  The following steps were used to create and manage the keys used to sign and read the jar:
 * <ol>
 * <li>keytool -genkey -alias groovy -keypass keypass -keystore groovystore -storepass storepass -validity 7000
 * <li>keytool -export -keystore groovystore -alias groovy -file GroovyDev.cer
 * <li>keytool -import -alias groovy -file GroovyDev.cer -keystore groovykeys
 * </ol>
 * Once the keys are constructed, creat the jar and sign:
 * <ol>
 * <li>jar -cvf Groovy.jar groovy
 * <li>jarsigner -keystore groovystore -signedjar GroovyJarTest.jar Groovy.jar groovy
 * </ol>
 * Add the keystore to the policy file and write the grant:
 * <ol>
 * <li>keystore "file:${user.dir}/src/test/groovy/security/groovykeys";
 * </ol>
public class SignedJarTest extends SecurityTestSupport {

    public static void main(String[] args) {;

    public static Test suite() {
        return new TestSuite(SignedJarTest.class);

    public void testReadSignedJar() throws Exception {
        if (!isSecurityAvailable() || (notYetImplemented())) return;

        //spg 2006-02-09 The GroovyClassLoader code that checked jar files
        //for source files was removed last July.  This test will not function
        //without that capability.
        Class c = loader.loadClass("");  // ClassNotFoundException !
        executeTest(c, null);


Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.