aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJana Fabrikova <[email protected]>2013-04-10 14:07:14 +0200
committerJana Fabrikova <[email protected]>2013-04-10 14:07:14 +0200
commit57d16b5a35eba22d390b859d7a5c11e5dc29005e (patch)
tree9245ea1b01050943ab3edb140d0ad15c960a1909
parenta04f235440f4f21079d8f4093c515867eb986dc6 (diff)
adding JSToJFuncReturn reproducer (testing Liveconnect JS->J function return types)
-rw-r--r--ChangeLog14
-rw-r--r--tests/reproducers/simple/JSToJFuncReturn/resources/JSToJFuncReturn.html26
-rw-r--r--tests/reproducers/simple/JSToJFuncReturn/resources/JSToJava_FuncReturn.js17
-rw-r--r--tests/reproducers/simple/JSToJFuncReturn/resources/jstoj-funcreturn.jnlp23
-rw-r--r--tests/reproducers/simple/JSToJFuncReturn/srcs/JSToJFuncReturn.java142
-rw-r--r--tests/reproducers/simple/JSToJFuncReturn/testcases/JSToJFuncReturnTest.java242
6 files changed, 464 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 260a975..5937f1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2013-04-10 Jana Fabrikova <[email protected]>
+
+ * /tests/reproducers/simple/JToJSFuncReturn/testcases/JToJSFuncReturnTest.java:
+ adding 5 testcases based on the interactive Liveconnect JS->Java
+ function return type tests
+ * /tests/reproducers/simple/JToJSFuncReturn/srcs/JToJSFuncReturn.java:
+ the applet that calls JS functions
+ * tests/reproducers/simple/JToJSFuncReturn/resources/JToJS_FuncReturn.js:
+ auxiliary JavaScript code
+ * /tests/reproducers/simple/JToJSFuncReturn/resources/jtojs-funcreturn.jnlp:
+ jnlp file for displaying applet in the html page
+ * /tests/reproducers/simple/JToJSFuncReturn/resources/JToJSFuncReturn.html:
+ the html page where the applet calling JS functions is embedded
+
2013-04-08 Jiri Vanek <[email protected]>
* tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/Epiphany.java:
diff --git a/tests/reproducers/simple/JSToJFuncReturn/resources/JSToJFuncReturn.html b/tests/reproducers/simple/JSToJFuncReturn/resources/JSToJFuncReturn.html
new file mode 100644
index 0000000..6e2cbf6
--- /dev/null
+++ b/tests/reproducers/simple/JSToJFuncReturn/resources/JSToJFuncReturn.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html lang="en-US">
+ <head>
+ <title>JavaScript to Java LiveConnect - Function return values from applet</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
+ <script language="JavaScript" src="JSToJava_FuncReturn.js"></script>
+
+ </head>
+ <body>
+
+ <h2> The JSToJFuncReturn html page</h2>
+
+
+ <applet code="JSToJFuncReturn" width="1000" height="100" id="jstojFuncReturnApplet" MAYSCRIPT>
+ <param name="jnlp_href" value="jstoj-funcreturn.jnlp">
+ </applet>
+
+ <div id="messageDiv"></div>
+
+ <script laguage="javascript">
+ doFuncReturnTests();
+ </script>
+
+ </body>
+</html>
diff --git a/tests/reproducers/simple/JSToJFuncReturn/resources/JSToJava_FuncReturn.js b/tests/reproducers/simple/JSToJFuncReturn/resources/JSToJava_FuncReturn.js
new file mode 100644
index 0000000..2ec4869
--- /dev/null
+++ b/tests/reproducers/simple/JSToJFuncReturn/resources/JSToJava_FuncReturn.js
@@ -0,0 +1,17 @@
+function doFuncReturnTests(){
+ var urlArgs = document.URL.split("?");
+ var applet = document.getElementById('jstojFuncReturnApplet');
+ var method = urlArgs[1];
+
+ eval('var value = applet.' + method + '()');
+
+ var checked_string = typeof(value)+' ';
+ if( method === '_JSObject'){
+ checked_string = checked_string +value.key1;
+ }else{
+ checked_string = checked_string +value;
+ }
+
+ applet.printStringAndFinish(checked_string);
+}
+
diff --git a/tests/reproducers/simple/JSToJFuncReturn/resources/jstoj-funcreturn.jnlp b/tests/reproducers/simple/JSToJFuncReturn/resources/jstoj-funcreturn.jnlp
new file mode 100644
index 0000000..2b7b08b
--- /dev/null
+++ b/tests/reproducers/simple/JSToJFuncReturn/resources/jstoj-funcreturn.jnlp
@@ -0,0 +1,23 @@
+
+<?xml version="1.0" encoding="UTF-8"?>
+<jnlp spec="1.0+" codebase="" href="jstoj-funcreturn.jnlp">
+ <information>
+ <title>JavaScript to Java LiveConnect - FuncReturn</title>
+ <vendor>RedHat</vendor>
+ <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web"/>
+ <description>LiveConnect - tests to process various return types from Java side function calls.</description>
+ </information>
+ <resources>
+ <!-- Application Resources -->
+ <j2se version="1.6+"
+ href="http://java.sun.com/products/autodl/j2se"/>
+ <jar href="JSToJFuncReturn.jar" main="true" />
+
+ </resources>
+ <applet-desc
+ name="JS to J FuncReturn"
+ main-class="JSToJFuncReturn"
+ width="1000"
+ height="100">
+ </applet-desc>
+</jnlp>
diff --git a/tests/reproducers/simple/JSToJFuncReturn/srcs/JSToJFuncReturn.java b/tests/reproducers/simple/JSToJFuncReturn/srcs/JSToJFuncReturn.java
new file mode 100644
index 0000000..68572da
--- /dev/null
+++ b/tests/reproducers/simple/JSToJFuncReturn/srcs/JSToJFuncReturn.java
@@ -0,0 +1,142 @@
+import java.applet.Applet;
+import java.awt.Label;
+import java.awt.BorderLayout;
+import netscape.javascript.JSObject;
+
+public class JSToJFuncReturn extends Applet {
+
+ private Label statusLabel;
+
+ public int _int() {
+ int i = 1;
+ return i;
+ }
+
+ public double _double() {
+ double d = 1.1;
+ return d;
+ }
+
+ public float _float() {
+ float f = 1.1F;
+ return f;
+ }
+
+ public long _long() {
+ long l = 10000L;
+ return l;
+ }
+
+ public boolean _boolean() {
+ boolean b = true;
+ return b;
+ }
+
+ public char _char() {
+ char c = 'a';
+ return c;
+ }
+
+ public byte _byte() {
+ byte by = 10;
+ return by;
+ }
+
+ public char _charArrayElement(){
+ char[] ca = new char[]{'a', 'b', 'c'};
+
+ return ca[0];
+ }
+
+ public char[] _charArray() {
+ char[] ca = new char[]{'a', 'b', 'c'};
+
+ return ca;
+ }
+
+ public String _regularString() {
+ String rs = "test";
+ return rs;
+ }
+
+ public String _specialString() {
+ String ss = "𠁎〒£$ǣ€𝍖";
+ return ss;
+ }
+
+ public void _void() {
+ }
+
+ public Object _null() {
+ return null;
+ }
+
+ public Integer _Integer() {
+ Integer I = 1;
+ return I;
+ }
+
+ public Double _Double() {
+ Double D = 1.1;
+ return D;
+ }
+
+ public Float _Float() {
+ Float F = 1.1F;
+ return F;
+ }
+
+ public Long _Long() {
+ Long L = 10000L;
+ return L;
+ }
+
+ public Boolean _Boolean() {
+ Boolean B = true;
+ return B;
+ }
+
+ public Character _CharacterArrayElement(){
+ Character[] Ca = new Character[]{'A', 'B', 'C'};
+
+ return Ca[0];
+ }
+
+ public Character _Character() {
+ Character C = 'A';
+ return C;
+ }
+
+ public Byte _Byte() {
+ Byte By = 10;
+ return By;
+ }
+
+ public Character[] _CharacterArray() {
+ Character[] Ca = new Character[]{'A', 'B', 'C'};
+
+ return Ca;
+ }
+
+ public JSObject _JSObject(){
+ JSObject win = JSObject.getWindow(this);
+ JSObject jso = (JSObject) win.getMember("document");
+ jso.setMember("key1","value1");
+
+ return jso;
+ }
+
+ public void init() {
+ setLayout(new BorderLayout());
+ statusLabel = new Label();
+ add(statusLabel);
+ String initStr = "JSToJFuncReturn applet initialized.";
+ System.out.println(initStr);
+ statusLabel.setText(initStr);
+ }
+
+ public void printStringAndFinish(String str){
+ System.out.println(str);
+ System.out.println("afterTests");
+ }
+}
diff --git a/tests/reproducers/simple/JSToJFuncReturn/testcases/JSToJFuncReturnTest.java b/tests/reproducers/simple/JSToJFuncReturn/testcases/JSToJFuncReturnTest.java
new file mode 100644
index 0000000..7d437ed
--- /dev/null
+++ b/tests/reproducers/simple/JSToJFuncReturn/testcases/JSToJFuncReturnTest.java
@@ -0,0 +1,242 @@
+/* JSToJFuncReturnTest.java
+Copyright (C) 2012 Red Hat, Inc.
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+ */
+
+import net.sourceforge.jnlp.ProcessResult;
+import net.sourceforge.jnlp.ServerAccess;
+import net.sourceforge.jnlp.browsertesting.BrowserTest;
+import net.sourceforge.jnlp.browsertesting.Browsers;
+import net.sourceforge.jnlp.closinglisteners.CountingClosingListener;
+import net.sourceforge.jnlp.annotations.KnownToFail;
+import net.sourceforge.jnlp.annotations.NeedsDisplay;
+import net.sourceforge.jnlp.annotations.TestInBrowsers;
+import org.junit.Assert;
+
+import org.junit.Test;
+
+public class JSToJFuncReturnTest extends BrowserTest {
+
+ private final String initStr = "JSToJFuncReturn applet initialized.";
+ private final String afterStr = "afterTests";
+
+ private class CountingClosingListenerImpl extends CountingClosingListener {
+
+ @Override
+ protected boolean isAlowedToFinish(String s) {
+
+ return (s.contains(initStr) && s.contains(afterStr));
+ }
+ }
+
+ private void evaluateStdoutContents(String expectedStdout, ProcessResult pr) {
+ // Assert that the applet was initialized.
+ Assert.assertTrue("JSToJFuncReturnTest stdout should contain "+ initStr + " but it didnt.", pr.stdout.contains(initStr));
+
+ // Assert that the tests have passed.
+ Assert.assertTrue("JSToJFuncReturnTest stdout should contain "+ expectedStdout + " but it didnt.", pr.stdout.contains(expectedStdout));
+ }
+
+
+ private void jsToJavaFuncReturnNormalTest(String methodStr, String expectedStdout) throws Exception {
+ String strURL = "/JSToJFuncReturn.html?" + methodStr;
+ ProcessResult pr = server.executeBrowser(strURL, new CountingClosingListenerImpl(), new CountingClosingListenerImpl());
+ evaluateStdoutContents(expectedStdout, pr);
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_int_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_int", "number 1");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_double_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_double", "number 1.1");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_float_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_float", "number 1.1");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_long_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_long", "number 10000");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_boolean_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_boolean", "boolean true");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_char_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_char", "number 97"); //'a'
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_byte_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_byte", "number 10");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_charArrayElement_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_charArrayElement", "number 97");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_void_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_void", "undefined undefined");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_regularString_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_regularString", "string test");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_specialCharsString_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_specialString", "string 𠁎〒£$ǣ€𝍖");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_null_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_null", "object null");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ @KnownToFail
+ public void AppletJSToJFuncReturn_Integer_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_Integer", "object 1");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ @KnownToFail
+ public void AppletJSToJFuncReturn_Double_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_Double", "object 1.1");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ @KnownToFail
+ public void AppletJSToJFuncReturn_Float_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_Float", "object 1.1");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ @KnownToFail
+ public void AppletJSToJFuncReturn_Long_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_Long", "object 10000");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ @KnownToFail
+ public void AppletJSToJFuncReturn_Boolean_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_Boolean", "object true");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ @KnownToFail
+ public void AppletJSToJFuncReturn_Character_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_Character", "object A");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ @KnownToFail
+ public void AppletJSToJFuncReturn_Byte_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_Byte", "object 10");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ @KnownToFail
+ public void AppletJSToJFuncReturn_CharArrayElement_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_CharacterArrayElement", "object A");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_CharFullArray_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_CharacterArray", "object [Ljava.lang.Character;@");
+ }
+
+ @Test
+ @TestInBrowsers(testIn = { Browsers.all })
+ @NeedsDisplay
+ public void AppletJSToJFuncReturn_JSObject_Test() throws Exception {
+ jsToJavaFuncReturnNormalTest("_JSObject", "object value1");
+ }
+
+
+}