diff options
author | Egil Moeller <egil.moller@freecode.no> | 2010-03-22 00:16:53 +0100 |
---|---|---|
committer | Egil Moeller <egil.moller@freecode.no> | 2010-03-22 00:16:53 +0100 |
commit | fc00cfedd6c25d1634a1e0d28a7b7bc5f42e1cd7 (patch) | |
tree | 928419d6bfe794865e4b8f0634bd792f795c4b8a /trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java | |
parent | 0fdab3db005c4fa31fb8306b573c0b35073d3e56 (diff) | |
parent | d56b9b3b82cdebcaeb00eec0fcb4326ad21adaa8 (diff) | |
download | etherpad-fc00cfedd6c25d1634a1e0d28a7b7bc5f42e1cd7.tar.gz etherpad-fc00cfedd6c25d1634a1e0d28a7b7bc5f42e1cd7.tar.xz etherpad-fc00cfedd6c25d1634a1e0d28a7b7bc5f42e1cd7.zip |
Merge branch 'master' into plugin-framework
Diffstat (limited to 'trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java')
-rw-r--r-- | trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java b/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java deleted file mode 100644 index b6cf3ca..0000000 --- a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * - */ -package org.mozilla.javascript.tests; - -import junit.framework.TestCase; - -import org.mozilla.javascript.Context; -import org.mozilla.javascript.ContextAction; -import org.mozilla.javascript.ContextFactory; -import org.mozilla.javascript.NativeJavaObject; -import org.mozilla.javascript.Script; -import org.mozilla.javascript.tools.shell.Global; -import org.mozilla.javascript.tools.shell.ShellContextFactory; - -/** - * @author donnamalayeri - */ -public class JavaAcessibilityTest extends TestCase { - - protected final Global global = new Global(); - String importClass = "importClass(Packages.org.mozilla.javascript.tests.PrivateAccessClass)\n"; - - public JavaAcessibilityTest() { - global.init(contextFactory); - } - - private ContextFactory contextFactory = new ShellContextFactory() { - protected boolean hasFeature(Context cx, int featureIndex) { - if (featureIndex == Context.FEATURE_ENHANCED_JAVA_ACCESS) - return true; - return super.hasFeature(cx, featureIndex); - } - }; - - public void testAccessingFields() { - Object result = runScript(importClass + "PrivateAccessClass.staticPackagePrivateInt"); - assertEquals(new Integer(0), result); - - result = runScript(importClass + "PrivateAccessClass.staticPrivateInt"); - assertEquals(new Integer(1), result); - - result = runScript(importClass + "PrivateAccessClass.staticProtectedInt"); - assertEquals(new Integer(2), result); - - result = runScript(importClass + "new PrivateAccessClass().packagePrivateString"); - assertEquals("package private", ((NativeJavaObject) result).unwrap()); - - result = runScript(importClass + "new PrivateAccessClass().privateString"); - assertEquals("private", ((NativeJavaObject) result).unwrap()); - - result = runScript(importClass + "new PrivateAccessClass().protectedString"); - assertEquals("protected", ((NativeJavaObject) result).unwrap()); - - result = runScript(importClass + "new PrivateAccessClass.PrivateNestedClass().packagePrivateInt"); - assertEquals(new Integer(0), result); - - result = runScript(importClass + "new PrivateAccessClass.PrivateNestedClass().privateInt"); - assertEquals(new Integer(1), result); - - result = runScript(importClass + "new PrivateAccessClass.PrivateNestedClass().protectedInt"); - assertEquals(new Integer(2), result); - } - - public void testAccessingMethods() { - Object result = runScript(importClass + "PrivateAccessClass.staticPackagePrivateMethod()"); - assertEquals(new Integer(0), result); - - result = runScript(importClass + "PrivateAccessClass.staticPrivateMethod()"); - assertEquals(new Integer(1), result); - - result = runScript(importClass + "PrivateAccessClass.staticProtectedMethod()"); - assertEquals(new Integer(2), result); - - result = runScript(importClass + "new PrivateAccessClass().packagePrivateMethod()"); - assertEquals(new Integer(3), result); - - result = runScript(importClass + "new PrivateAccessClass().privateMethod()"); - assertEquals(new Integer(4), result); - - result = runScript(importClass + "new PrivateAccessClass().protectedMethod()"); - assertEquals(new Integer(5), result); - } - - public void testAccessingConstructors() { - runScript(importClass + "new PrivateAccessClass(\"foo\")"); - runScript(importClass + "new PrivateAccessClass(5)"); - runScript(importClass + "new PrivateAccessClass(5, \"foo\")"); - } - - private Object runScript(final String scriptSourceText) { - return this.contextFactory.call(new ContextAction() { - public Object run(Context context) { - Script script = context.compileString(scriptSourceText, "", 1, null); - return script.exec(context, global); - } - }); - } -} |