[cvs] / jsr166 / src / test / tck / AbstractExecutorServiceTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/AbstractExecutorServiceTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14, Thu Jan 15 14:51:33 2004 UTC revision 1.15, Tue Jan 20 20:20:56 2004 UTC
# Line 115  Line 115 
115       * A submitted privileged action to completion       * A submitted privileged action to completion
116       */       */
117      public void testSubmitPrivilegedAction() {      public void testSubmitPrivilegedAction() {
118          Policy savedPolicy = Policy.getPolicy();          Policy savedPolicy = null;
119            try {
120                savedPolicy = Policy.getPolicy();
121          AdjustablePolicy policy = new AdjustablePolicy();          AdjustablePolicy policy = new AdjustablePolicy();
122          policy.addPermission(new RuntimePermission("getContextClassLoader"));          policy.addPermission(new RuntimePermission("getContextClassLoader"));
123          policy.addPermission(new RuntimePermission("setContextClassLoader"));          policy.addPermission(new RuntimePermission("setContextClassLoader"));
124          Policy.setPolicy(policy);          Policy.setPolicy(policy);
125            } catch(AccessControlException ok) {
126                return;
127            }
128          try {          try {
129              ExecutorService e = new DirectExecutorService();              ExecutorService e = new DirectExecutorService();
130              Future future = e.submit(Executors.callable(new PrivilegedAction() {              Future future = e.submit(Executors.callable(new PrivilegedAction() {
# Line 137  Line 142 
142              unexpectedException();              unexpectedException();
143          }          }
144          finally {          finally {
145                try {
146              Policy.setPolicy(savedPolicy);              Policy.setPolicy(savedPolicy);
147                } catch(AccessControlException ok) {
148                    return;
149                }
150          }          }
151      }      }
152    
# Line 145  Line 154 
154       * A submitted a privileged exception action runs to completion       * A submitted a privileged exception action runs to completion
155       */       */
156      public void testSubmitPrivilegedExceptionAction() {      public void testSubmitPrivilegedExceptionAction() {
157          Policy savedPolicy = Policy.getPolicy();          Policy savedPolicy = null;
158            try {
159                savedPolicy = Policy.getPolicy();
160          AdjustablePolicy policy = new AdjustablePolicy();          AdjustablePolicy policy = new AdjustablePolicy();
161          policy.addPermission(new RuntimePermission("getContextClassLoader"));          policy.addPermission(new RuntimePermission("getContextClassLoader"));
162          policy.addPermission(new RuntimePermission("setContextClassLoader"));          policy.addPermission(new RuntimePermission("setContextClassLoader"));
163          Policy.setPolicy(policy);          Policy.setPolicy(policy);
164            } catch(AccessControlException ok) {
165                return;
166            }
167    
168          try {          try {
169              ExecutorService e = new DirectExecutorService();              ExecutorService e = new DirectExecutorService();
170              Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {              Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
# Line 175  Line 190 
190       * A submitted failed privileged exception action reports exception       * A submitted failed privileged exception action reports exception
191       */       */
192      public void testSubmitFailedPrivilegedExceptionAction() {      public void testSubmitFailedPrivilegedExceptionAction() {
193          Policy savedPolicy = Policy.getPolicy();          Policy savedPolicy = null;
194            try {
195                savedPolicy = Policy.getPolicy();
196          AdjustablePolicy policy = new AdjustablePolicy();          AdjustablePolicy policy = new AdjustablePolicy();
197          policy.addPermission(new RuntimePermission("getContextClassLoader"));          policy.addPermission(new RuntimePermission("getContextClassLoader"));
198          policy.addPermission(new RuntimePermission("setContextClassLoader"));          policy.addPermission(new RuntimePermission("setContextClassLoader"));
199          Policy.setPolicy(policy);          Policy.setPolicy(policy);
200            } catch(AccessControlException ok) {
201                return;
202            }
203    
204    
205          try {          try {
206              ExecutorService e = new DirectExecutorService();              ExecutorService e = new DirectExecutorService();
207              Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {              Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8