Author: antelder Date: Sat Mar 21 22:22:15 2009 New Revision: 757037 URL: http://svn.apache.org/viewvc?rev=757037&view=rev Log: Add a testcase for using JRuby 1.2.0
Added: jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/ (with props) jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/pom.xml jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/ jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/main/ jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/ jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/java/ jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/java/org/ jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/java/org/apache/ jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/java/org/apache/bsf/ jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/java/org/apache/bsf/testing/ jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/java/org/apache/bsf/testing/javascript/ jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/java/org/apache/bsf/testing/javascript/RubyTestcase.java jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/resources/ Propchange: jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Mar 21 22:22:15 2009 @@ -0,0 +1,20 @@ +target +work +dojo +*.iws +*.ipr +*.iml +derby.log +maven.log +maven-eclipse.xml +build.xml +build-dependency.xml +velocity.log* +junit*.properties +surefire*.properties +.project +.classpath +.settings +.deployables +.wtpmodules +.externalToolBuilders Added: jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/pom.xml URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/pom.xml?rev=757037&view=auto ============================================================================== --- jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/pom.xml (added) +++ jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/pom.xml Sat Mar 21 22:22:15 2009 @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <parent> + <groupId>org.apache.bsf</groupId> + <artifactId>parent</artifactId> + <version>3.0-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <packaging>jar</packaging> + <groupId>org.apache.bsf.testing</groupId> + <artifactId>bsf-testing-ruby</artifactId> + <name>Apache BSF testing for Ruby</name> + <description>Apache BSF testing for Ruby</description> + + <dependencies> + <dependency> + <groupId>org.apache.bsf</groupId> + <artifactId>bsf-all</artifactId> + <version>3.0-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jruby</groupId> + <artifactId>jruby-complete</artifactId> + <version>1.2.0</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + +</project> Added: jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/java/org/apache/bsf/testing/javascript/RubyTestcase.java URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/java/org/apache/bsf/testing/javascript/RubyTestcase.java?rev=757037&view=auto ============================================================================== --- jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/java/org/apache/bsf/testing/javascript/RubyTestcase.java (added) +++ jakarta/bsf/trunk/bsf3/testing/jruby-1.2.0/src/test/java/org/apache/bsf/testing/javascript/RubyTestcase.java Sat Mar 21 22:22:15 2009 @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.bsf.testing.javascript; + +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; + +import junit.framework.TestCase; + + +public class RubyTestcase extends TestCase { + +// public void testEval() throws ScriptException { +// ScriptEngineManager manager = new ScriptEngineManager(); +// ScriptEngine engine = manager.getEngineByExtension("js"); +// assertTrue(((Boolean)engine.eval("true;")).booleanValue()); +// assertFalse(((Boolean)engine.eval("false;")).booleanValue()); +// } + + public void testInvokeFunction() throws ScriptException, NoSuchMethodException { + ScriptEngineManager manager = new ScriptEngineManager(); + ScriptEngine engine = manager.getEngineByExtension("rb"); + engine.eval("def hello(s)\n return \"Hello \" + s\nend" ); + assertTrue(engine instanceof Invocable); + Invocable invocableScript = (Invocable) engine; + assertEquals("Hello petra", invocableScript.invokeFunction("hello", new Object[]{"petra"})); + } + +// public void testInvokeMethod() throws ScriptException { +// ScriptEngineManager manager = new ScriptEngineManager(); +// ScriptEngine engine = manager.getEngineByExtension("js"); +// engine.eval("function hello(s) { return 'Hello ' + s; }" ); +// assertTrue(engine instanceof Invocable); +// Invocable invocableScript = (Invocable) engine; +// +// Object thiz = engine.eval("this;"); +// assertEquals("Hello petra", invocableScript.invokeMethod(thiz, "hello", new Object[]{"petra"})); +// } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: bsf-dev-unsubscr...@jakarta.apache.org For additional commands, e-mail: bsf-dev-h...@jakarta.apache.org