From: <zy...@us...> - 2010-08-14 17:17:27
|
Revision: 7090 http://jython.svn.sourceforge.net/jython/?rev=7090&view=rev Author: zyasoft Date: 2010-08-14 17:17:21 +0000 (Sat, 14 Aug 2010) Log Message: ----------- Our JSR223 engine factory now publishes a list of sort-of well known MIME types (as authoritative as these things ever get). Fixes #1555. Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java Added Paths: ----------- trunk/jython/Lib/test/test_jsr223.py Added: trunk/jython/Lib/test/test_jsr223.py =================================================================== --- trunk/jython/Lib/test/test_jsr223.py (rev 0) +++ trunk/jython/Lib/test/test_jsr223.py 2010-08-14 17:17:21 UTC (rev 7090) @@ -0,0 +1,55 @@ +# test for ScriptEngine, otherwise we are not in Java 6/JSR223 support added + +# test each feature + +import sys +import unittest +from javax.script import ScriptEngine, ScriptEngineManager +from test import test_support + + +class JSR223TestCase(unittest.TestCase): + def setUp(self): + self.engine = ScriptEngineManager().getEngineByName("python") + + def test_eval(self): + engine = self.engine + engine.put("a", 42) + engine.eval("b = a/6") + self.assertEqual(engine.get("b"), 7) + + def test_factory(self): + f = self.engine.factory + language_version = ".".join(str(comp) for comp in sys.version_info[0:2]) # such as "2.5" + impl_version = ".".join(str(comp) for comp in sys.version_info[0:3]) # such as "2.5.2" + + self.assertNotEqual(f.scriptEngine, self.engine) # we don't pool engines + + self.assertEqual(f.engineName, "jython") + self.assertEqual(f.engineVersion, impl_version) + self.assertEqual(set(f.extensions), set(['py'])) + self.assertEqual(f.languageName, "python") + self.assertEqual(f.languageVersion, language_version) + self.assertEqual(set(f.names), set(["python", "jython"])) + self.assertEqual(set(f.mimeTypes), set(["text/python", "application/python", "text/x-python", "application/x-python"])) + + # variants + self.assertEqual(f.getParameter(ScriptEngine.ENGINE), "jython") + self.assertEqual(f.getParameter(ScriptEngine.ENGINE_VERSION), impl_version) + self.assertEqual(f.getParameter(ScriptEngine.NAME), "jython") + self.assertEqual(f.getParameter(ScriptEngine.LANGUAGE), "python") + self.assertEqual(f.getParameter(ScriptEngine.LANGUAGE_VERSION), language_version) + + self.assertEqual(f.getOutputStatement("abc"), "print u'abc'") + self.assertEqual(f.getProgram("x = 42", "y = 'abc'"), "x = 42\ny = 'abc'\n") + + + + +def test_main(): + test_support.run_unittest( + JSR223TestCase) + + +if __name__ == "__main__": + test_main() Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-08-10 02:53:20 UTC (rev 7089) +++ trunk/jython/NEWS 2010-08-14 17:17:21 UTC (rev 7090) @@ -2,6 +2,7 @@ Jython 2.5.2b2 Bugs Fixed + - [ 1555 ] Jython does not publish MIME types via JSR 223 (ScriptEngine.getFactory().getMimeTypes() is empty). - [ 1632 ] cPickle.Unpickler does not allow assignment of find_global - [ 1395 ] PyList.indexOf() and PyTuple.indexOf() do not function properly - [ 1373 ] Jython ClassLoader getResource does not work Modified: trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java =================================================================== --- trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java 2010-08-10 02:53:20 UTC (rev 7089) +++ trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java 2010-08-14 17:17:21 UTC (rev 7090) @@ -85,9 +85,9 @@ return new PyScriptEngine(this); } - @SuppressWarnings("unchecked") public List<String> getMimeTypes() { - return Collections.EMPTY_LIST; + return Collections.unmodifiableList(Arrays.asList( + "text/python", "application/python", "text/x-python", "application/x-python")); } public List<String> getNames() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |