2013-02-27 11:52:44 +00:00
|
|
|
var ScriptContext = javax.script.ScriptContext;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (key == undefined || key != 'engine value') {
|
|
|
|
throw "unexpected engine scope value";
|
|
|
|
}
|
|
|
|
|
|
|
|
// pre-defined context variable refers to current ScriptContext
|
2013-02-27 11:52:44 +00:00
|
|
|
if (context.getAttribute('key', ScriptContext.GLOBAL_SCOPE) != 'global value') {
|
2007-12-01 00:00:00 +00:00
|
|
|
throw "unexpected global scope value";
|
|
|
|
}
|
|
|
|
|
|
|
|
// change the engine scope value
|
|
|
|
key = 'new engine value';
|
|
|
|
|
2013-02-27 11:52:44 +00:00
|
|
|
if (context.getAttribute('key', ScriptContext.GLOBAL_SCOPE) != 'global value') {
|
2007-12-01 00:00:00 +00:00
|
|
|
throw "global scope should not change here";
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete engine scope value
|
|
|
|
delete key;
|
|
|
|
|
2013-02-27 11:52:44 +00:00
|
|
|
if (key == undefined && key != 'global value') {
|
2007-12-01 00:00:00 +00:00
|
|
|
throw 'global scope should be visible after engine scope removal';
|
|
|
|
}
|