KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > loom > xmlpolicy > verifier > test > VerifierTestCase


1 /*
2  * Copyright (C) The Spice Group. All rights reserved.
3  *
4  * This software is published under the terms of the Spice
5  * Software License version 1.1, a copy of which has been included
6  * with this distribution in the LICENSE.txt file.
7  */

8 package org.codehaus.loom.xmlpolicy.verifier.test;
9
10 import org.codehaus.loom.xmlpolicy.metadata.PolicyMetaData;
11 import org.codehaus.loom.xmlpolicy.test.AbstractPolicyTestCase;
12 import org.codehaus.loom.xmlpolicy.verifier.PolicyVerifier;
13
14 /**
15  * TestCase for {@link org.codehaus.loom.xmlpolicy.reader.PolicyReader}.
16  *
17  * @author Peter Donald
18  */

19 public class VerifierTestCase
20     extends AbstractPolicyTestCase
21 {
22     public VerifierTestCase( final String JavaDoc name )
23     {
24         super( name );
25     }
26
27     public void testConfig1()
28         throws Exception JavaDoc
29     {
30         try
31         {
32             verifyResource( "config1.xml" );
33         }
34         catch( final Throwable JavaDoc t )
35         {
36             return;
37         }
38
39         fail( "Expected verify to fail as specified " +
40               "bad name for keyStore" );
41     }
42
43     public void testConfig2()
44         throws Exception JavaDoc
45     {
46         try
47         {
48             verifyResource( "config2.xml" );
49         }
50         catch( final Throwable JavaDoc t )
51         {
52             return;
53         }
54
55         fail( "Expected verify to fail as permission " +
56               "references non existent keystore" );
57     }
58
59     public void testConfig3()
60         throws Exception JavaDoc
61     {
62         try
63         {
64             verifyResource( "config3.xml" );
65         }
66         catch( final Throwable JavaDoc t )
67         {
68             return;
69         }
70
71         fail( "Expected verify to fail as grant " +
72               "references non existent keystore" );
73     }
74
75     public void testConfig4()
76         throws Exception JavaDoc
77     {
78         try
79         {
80             verifyResource( "config4.xml" );
81         }
82         catch( final Throwable JavaDoc t )
83         {
84             return;
85         }
86
87         fail( "Expected verify to fail as specified " +
88               "action with null target" );
89     }
90
91     public void testConfig5()
92         throws Exception JavaDoc
93     {
94         try
95         {
96             verifyResource( "config5.xml" );
97         }
98         catch( final Throwable JavaDoc t )
99         {
100             fail( "Expected to pass when not specifying keystore" );
101         }
102     }
103
104     public void testConfig6()
105         throws Exception JavaDoc
106     {
107         try
108         {
109             verifyResource( "config6.xml" );
110         }
111         catch( final Throwable JavaDoc t )
112         {
113             return;
114         }
115
116         fail( "Expected verify to fail as specified " +
117               "empty name for keyStore" );
118     }
119
120     public void testConfig7()
121         throws Exception JavaDoc
122     {
123         try
124         {
125             verifyResource( "config7.xml" );
126         }
127         catch( final Throwable JavaDoc t )
128         {
129             return;
130         }
131
132         fail( "Expected verify to fail as specified " +
133               "bad character in center of name for keyStore" );
134     }
135
136     public void testConfig8()
137         throws Exception JavaDoc
138     {
139         try
140         {
141             verifyResource( "config8.xml" );
142         }
143         catch( final Throwable JavaDoc t )
144         {
145             fail( "Expected verify to pass as specified " +
146                   "good name for keyStore" );
147         }
148     }
149
150     public void testConfig9()
151         throws Exception JavaDoc
152     {
153         try
154         {
155             verifyResource( "config9.xml" );
156         }
157         catch( final Throwable JavaDoc t )
158         {
159             fail( "Expected verify to pass as specified " +
160                   "valid reference for keyStore" );
161         }
162     }
163
164     public void testConfig10()
165         throws Exception JavaDoc
166     {
167         try
168         {
169             verifyResource( "config10.xml" );
170         }
171         catch( final Throwable JavaDoc t )
172         {
173             return;
174         }
175         fail( "Expected verify to fail as specified " +
176               "invalid reference for keyStore" );
177     }
178
179     private void verifyResource( final String JavaDoc resource )
180         throws Exception JavaDoc
181     {
182         final PolicyMetaData defs = buildFromResource( resource );
183         final PolicyVerifier verifier = new PolicyVerifier();
184         verifier.verifyPolicy( defs );
185     }
186 }
187
Popular Tags