1 18 package org.apache.batik.bridge; 19 20 import org.apache.batik.test.*; 21 22 import org.apache.batik.test.svg.SVGOnLoadExceptionTest; 23 24 31 public class EcmaNoLoadTest extends DefaultTestSuite { 32 public EcmaNoLoadTest() { 33 String scripts = "application/java-archive"; 34 String [] scriptSource = {"bridge/ecmaCheckNoLoadAny", 35 "bridge/ecmaCheckNoLoadSameAsDocument", 36 "bridge/ecmaCheckNoLoadEmbed", 37 "bridge/ecmaCheckNoLoadEmbedAttr", 38 }; 39 boolean[] secure = {true, false}; 40 String [] scriptOrigin = {"ANY", "DOCUMENT", "EMBEDED", "NONE"}; 41 42 for (int i=0; i<scriptSource.length; i++) { 48 for (int j=0; j<secure.length; j++) { 49 for (int k=0; k<scriptOrigin.length; k++) { 50 SVGOnLoadExceptionTest t = buildTest(scripts, 51 scriptSource[i], 52 scriptOrigin[k], 53 secure[j], 54 false, 55 false); 56 addTest(t); 57 } 58 } 59 } 60 61 scripts = "text/ecmascript"; 67 for (int i=0; i<scriptSource.length; i++) { 68 for (int k=0; k<scriptOrigin.length; k++) { 69 boolean expectSuccess = ((i>=2) && (k <= 2)); 70 SVGOnLoadExceptionTest t = buildTest(scripts, 71 scriptSource[i], 72 scriptOrigin[k], 73 true, 74 true, 75 expectSuccess); 76 addTest(t); 77 } 78 } 79 80 for (int j=0; j<scriptOrigin.length; j++) { 87 int max = j; 88 if (j == scriptOrigin.length - 1) { 89 max = j+1; 90 } 91 for (int i=0; i<max; i++) { 92 for (int k=0; k<secure.length; k++) { 93 SVGOnLoadExceptionTest t= buildTest(scripts, scriptSource[i], 94 scriptOrigin[j], 95 secure[k], 96 false, 97 false); 98 addTest(t); 99 } 100 } 101 } 102 } 103 104 SVGOnLoadExceptionTest buildTest(String scripts, String id, String origin, 105 boolean secure, boolean restricted, 106 boolean successExpected) { 107 SVGOnLoadExceptionTest t = new SVGOnLoadExceptionTest(); 108 String desc = 109 "(scripts=" + scripts + 110 ")(scriptOrigin=" + origin + 111 ")(secure=" + secure + 112 ")(restricted=" + restricted + ")"; 113 114 t.setId(id + desc); 115 t.setScriptOrigin(origin); 116 t.setSecure(secure); 117 t.setScripts(scripts); 118 if (successExpected) 119 t.setExpectedExceptionClass(null); 120 else 121 t.setExpectedExceptionClass("java.lang.SecurityException"); 122 t.setRestricted(restricted); 123 124 return t; 125 } 126 127 } 128 | Popular Tags |