KickJava   Java API By Example, From Geeks To Geeks.

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


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 ECMA 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: EcmaLoadTest.java,v 1.3 2004/08/18 07:16:38 vhardy Exp $
28  */

29 public class EcmaLoadTest extends DefaultTestSuite {
30     public EcmaLoadTest() {
31         String JavaDoc scripts = "text/ecmascript";
32         String JavaDoc[] scriptSource = {"ecmaCheckLoadAny",
33                                  "ecmaCheckLoadSameAsDocument",
34                                  "ecmaCheckLoadEmbed",
35                                  "ecmaCheckLoadEmbedAttr",
36         };
37         boolean[] secure = {true, false};
38         String JavaDoc[][] scriptOrigin = {{"any"},
39                                    {"any", "document"},
40                                    {"any", "document", "embeded"},
41                                    {"any", "document", "embeded"},
42                                    };;
43
44         //
45
// <!> Need to make restricted {true/false}
46
//
47

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