Package org.codehaus.loom.xmlpolicy.verifier.test

Source Code of org.codehaus.loom.xmlpolicy.verifier.test.VerifierTestCase

/*
* Copyright (C) The Spice Group. All rights reserved.
*
* This software is published under the terms of the Spice
* Software License version 1.1, a copy of which has been included
* with this distribution in the LICENSE.txt file.
*/
package org.codehaus.loom.xmlpolicy.verifier.test;

import org.codehaus.loom.xmlpolicy.metadata.PolicyMetaData;
import org.codehaus.loom.xmlpolicy.test.AbstractPolicyTestCase;
import org.codehaus.loom.xmlpolicy.verifier.PolicyVerifier;

/**
* TestCase for {@link org.codehaus.loom.xmlpolicy.reader.PolicyReader}.
*
* @author Peter Donald
*/
public class VerifierTestCase
    extends AbstractPolicyTestCase
{
    public VerifierTestCase( final String name )
    {
        super( name );
    }

    public void testConfig1()
        throws Exception
    {
        try
        {
            verifyResource( "config1.xml" );
        }
        catch( final Throwable t )
        {
            return;
        }

        fail( "Expected verify to fail as specified " +
              "bad name for keyStore" );
    }

    public void testConfig2()
        throws Exception
    {
        try
        {
            verifyResource( "config2.xml" );
        }
        catch( final Throwable t )
        {
            return;
        }

        fail( "Expected verify to fail as permission " +
              "references non existent keystore" );
    }

    public void testConfig3()
        throws Exception
    {
        try
        {
            verifyResource( "config3.xml" );
        }
        catch( final Throwable t )
        {
            return;
        }

        fail( "Expected verify to fail as grant " +
              "references non existent keystore" );
    }

    public void testConfig4()
        throws Exception
    {
        try
        {
            verifyResource( "config4.xml" );
        }
        catch( final Throwable t )
        {
            return;
        }

        fail( "Expected verify to fail as specified " +
              "action with null target" );
    }

    public void testConfig5()
        throws Exception
    {
        try
        {
            verifyResource( "config5.xml" );
        }
        catch( final Throwable t )
        {
            fail( "Expected to pass when not specifying keystore" );
        }
    }

    public void testConfig6()
        throws Exception
    {
        try
        {
            verifyResource( "config6.xml" );
        }
        catch( final Throwable t )
        {
            return;
        }

        fail( "Expected verify to fail as specified " +
              "empty name for keyStore" );
    }

    public void testConfig7()
        throws Exception
    {
        try
        {
            verifyResource( "config7.xml" );
        }
        catch( final Throwable t )
        {
            return;
        }

        fail( "Expected verify to fail as specified " +
              "bad character in center of name for keyStore" );
    }

    public void testConfig8()
        throws Exception
    {
        try
        {
            verifyResource( "config8.xml" );
        }
        catch( final Throwable t )
        {
            fail( "Expected verify to pass as specified " +
                  "good name for keyStore" );
        }
    }

    public void testConfig9()
        throws Exception
    {
        try
        {
            verifyResource( "config9.xml" );
        }
        catch( final Throwable t )
        {
            fail( "Expected verify to pass as specified " +
                  "valid reference for keyStore" );
        }
    }

    public void testConfig10()
        throws Exception
    {
        try
        {
            verifyResource( "config10.xml" );
        }
        catch( final Throwable t )
        {
            return;
        }
        fail( "Expected verify to fail as specified " +
              "invalid reference for keyStore" );
    }

    private void verifyResource( final String resource )
        throws Exception
    {
        final PolicyMetaData defs = buildFromResource( resource );
        final PolicyVerifier verifier = new PolicyVerifier();
        verifier.verifyPolicy( defs );
    }
}
TOP

Related Classes of org.codehaus.loom.xmlpolicy.verifier.test.VerifierTestCase

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.