KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > bridge > JarLoadTest


1 /*
2
3    Copyright 2004 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.bridge;
19
20 import org.apache.batik.test.*;
21
22 /**
23  * Checks that JAR Scripts which should be loaded are indeed
24  * loaded.
25  *
26  * @author <a HREF="mailto:vincent.hardy@sun.com">Vincent Hardy</a>
27  * @version $Id: JarLoadTest.java,v 1.2 2004/08/18 07:16:38 vhardy Exp $
28  */

29 public class JarLoadTest extends DefaultTestSuite {
30     public JarLoadTest() {
31         String JavaDoc scripts = "application/java-archive";
32         // Note: base64 encoding of jar content is not supported.
33
String JavaDoc[] scriptSource = {"jarCheckLoadAny",
34                                  "jarCheckLoadSameAsDocument"};
35         boolean[] secure = {true, false};
36         String JavaDoc[] scriptOrigin = {"any", "document", "embeded"};
37
38         //
39
// <!> Need to make restricted {true/false}
40
//
41

42         //
43
// An jar script can be loaded if JAR is listed
44
// as an allowed script _and_ the loaded script
45
// has an origin allowed by the scriptOrigin setting.
46
// All other security settings should not have an
47
// influence on whether or not the script can be loaded.
48
//
49
for (int i=0; i<scriptSource.length; i++) {
50             for (int j=0; j<=i; j++) {
51                 for (int k=0; k<secure.length; k++) {
52                     ScriptSelfTest t= buildTest(scripts, scriptSource[i],
53                                                 scriptOrigin[j],
54                                                 secure[k]);
55                     addTest(t);
56                 }
57             }
58         }
59     }
60
61     ScriptSelfTest buildTest(String JavaDoc scripts, String JavaDoc id, String JavaDoc origin, boolean secure) {
62         ScriptSelfTest t = new ScriptSelfTest();
63         String JavaDoc desc =
64             "(scripts=" + scripts +
65             ")(scriptOrigin=" + origin +
66             ")(secure=" + secure + ")";
67         
68         t.setId(id + desc);
69         t.setScriptOrigin(origin);
70         t.setSecure(secure);
71         t.setScripts(scripts);
72
73         return t;
74     }
75                              
76 }
77
Popular Tags