aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2012-03-19 17:25:09 +0100
committerJiri Vanek <[email protected]>2012-03-19 17:25:09 +0100
commit1cc283b4a384c659a413006adb471441491ddf5d (patch)
tree8e427b310c1a9e6f3fe3f73f9665af9d03c2b7c2 /tests
parent213c12dcb273ba9923a2cc7742ceac6ab91eadf1 (diff)
added splash screen tests for upcoming splashscreen
Diffstat (limited to 'tests')
-rw-r--r--tests/jnlp_tests/signed/CacheReproducer/testcases/CacheReproducerTest.java2
-rw-r--r--tests/jnlp_tests/simple/AppletTest/resources/appletAutoTests.html44
-rw-r--r--tests/jnlp_tests/simple/AppletTest/resources/appletViewTest.html52
-rw-r--r--tests/jnlp_tests/simple/AppletTest/testcases/AppletTestTests.java27
-rw-r--r--tests/jnlp_tests/simple/simpletest1/resources/simpletestCustomSplash.jnlp55
-rw-r--r--tests/jnlp_tests/simple/simpletest1/resources/simpletestMegaSlow.jnlp53
-rw-r--r--tests/jnlp_tests/simple/simpletest1/resources/simpletestSlow.jnlp53
-rw-r--r--tests/jnlp_tests/simple/simpletest1/resources/simpletestSlowBrokenCustomSplash.jnlp54
-rw-r--r--tests/jnlp_tests/simple/simpletest1/resources/simpletestSlowSlowCustomSplash.jnlp54
-rw-r--r--tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ContentReaderListener.java8
-rw-r--r--tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java48
-rw-r--r--tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java258
12 files changed, 689 insertions, 19 deletions
diff --git a/tests/jnlp_tests/signed/CacheReproducer/testcases/CacheReproducerTest.java b/tests/jnlp_tests/signed/CacheReproducer/testcases/CacheReproducerTest.java
index bf89fff..2631001 100644
--- a/tests/jnlp_tests/signed/CacheReproducer/testcases/CacheReproducerTest.java
+++ b/tests/jnlp_tests/signed/CacheReproducer/testcases/CacheReproducerTest.java
@@ -56,7 +56,7 @@ import org.junit.Test;
public class CacheReproducerTest {
private static final ServerAccess server = new ServerAccess();
- private static final List<String> clear = Arrays.asList(new String[]{server.getJavawsLocation(), "-Xclearcache"});
+ private static final List<String> clear = Arrays.asList(new String[]{server.getJavawsLocation(), "-Xclearcache", ServerAccess.HEADLES_OPTION});
private static final List<String> trusted = Arrays.asList(new String[]{"-Xtrustall", ServerAccess.HEADLES_OPTION});
private static final String home = System.getProperty("user.home");
private static final String name = System.getProperty("user.name");
diff --git a/tests/jnlp_tests/simple/AppletTest/resources/appletAutoTests.html b/tests/jnlp_tests/simple/AppletTest/resources/appletAutoTests.html
new file mode 100644
index 0000000..3a2da42
--- /dev/null
+++ b/tests/jnlp_tests/simple/AppletTest/resources/appletAutoTests.html
@@ -0,0 +1,44 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+ -->
+<html><head></head><body bgcolor="blue">
+<p><applet code="AppletTest.class" archive="XslowXAppletTest.jar" codebase="." width=800 height=600>
+ <param name="key1" value="value1">
+ <param name="key2" value="#value2">
+</applet></p>
+</body>
+</html>
diff --git a/tests/jnlp_tests/simple/AppletTest/resources/appletViewTest.html b/tests/jnlp_tests/simple/AppletTest/resources/appletViewTest.html
new file mode 100644
index 0000000..0b489c8
--- /dev/null
+++ b/tests/jnlp_tests/simple/AppletTest/resources/appletViewTest.html
@@ -0,0 +1,52 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+ -->
+ <html><head>
+<title>ok applet</title>
+</head><body bgcolor="blue">
+<h1>ok applet</h1>
+<p align="center">
+<applet code="AppletTest.class" archive="XslowXAppletTest.jar" codebase="." width=100 height=100>
+</applet></p>
+<h1>ok applet</h1>
+<h1>bad applet</h1>
+<p align="center">
+<applet code="AppletTest.classsss" archive="XslowXAppletTest.jar" codebase="." width=800 height=600>
+</applet></p>
+<h1>bad applet</h1>
+</body>
+</html>
diff --git a/tests/jnlp_tests/simple/AppletTest/testcases/AppletTestTests.java b/tests/jnlp_tests/simple/AppletTest/testcases/AppletTestTests.java
index 9d83915..bba36ce 100644
--- a/tests/jnlp_tests/simple/AppletTest/testcases/AppletTestTests.java
+++ b/tests/jnlp_tests/simple/AppletTest/testcases/AppletTestTests.java
@@ -36,6 +36,7 @@ exception statement from your version.
*/
import net.sourceforge.jnlp.ServerAccess;
+import net.sourceforge.jnlp.ServerAccess.ProcessResult;
import org.junit.Assert;
import org.junit.Test;
@@ -51,6 +52,12 @@ public class AppletTestTests {
ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/AppletTest.jnlp");
System.out.println(pr.stdout);
System.err.println(pr.stderr);
+ evaluateApplet(pr);
+ Assert.assertFalse(pr.wasTerminated);
+ Assert.assertEquals((Integer) 0, pr.returnValue);
+ }
+
+ private void evaluateApplet(ProcessResult pr) {
String s3 = "applet was initialised";
Assert.assertTrue("AppletTest stdout should contains " + s3 + " bud didn't", pr.stdout.contains(s3));
String s0 = "applet was started";
@@ -67,7 +74,23 @@ public class AppletTestTests {
Assert.assertFalse("AppletTest stderr should not contains " + ss + " but did", pr.stderr.contains(ss));
String s7 = "Aplet killing himself after 2000 ms of life";
Assert.assertTrue("AppletTest stdout should contains " + s7 + " bud didn't", pr.stdout.contains(s7));
- Assert.assertFalse(pr.wasTerminated);
- Assert.assertEquals((Integer) 0, pr.returnValue);
+ }
+
+ @Test
+ public void AppletInFirefoxTest() throws Exception {
+ System.out.println("connecting AppletInFirefoxTest request");
+ System.err.println("connecting AppletInFirefoxTest request");
+ server.PROCESS_TIMEOUT = 30 * 1000;
+ try {
+ ServerAccess.ProcessResult pr = server.executeBrowser("/appletAutoTests.html");
+ System.out.println(pr.stdout);
+ System.err.println(pr.stderr);
+ pr.process.destroy();
+ evaluateApplet(pr);
+ Assert.assertTrue(pr.wasTerminated);
+ //Assert.assertEquals((Integer) 0, pr.returnValue); due to destroy is null
+ } finally {
+ server.PROCESS_TIMEOUT = 20 * 1000; //back to normal
+ }
}
}
diff --git a/tests/jnlp_tests/simple/simpletest1/resources/simpletestCustomSplash.jnlp b/tests/jnlp_tests/simple/simpletest1/resources/simpletestCustomSplash.jnlp
new file mode 100644
index 0000000..8b53626
--- /dev/null
+++ b/tests/jnlp_tests/simple/simpletest1/resources/simpletestCustomSplash.jnlp
@@ -0,0 +1,55 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+ -->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="simpletestCustomSplash.jnlp" codebase=".">
+ <information>
+ <title>simpletest1</title>
+ <vendor>NetX</vendor>
+ <homepage href="http://jnlp.sourceforge.net/netx/"/>
+ <description>simpletest1</description>
+ <icon kind="splash" href="netxPlugin.png"/>
+ <offline/>
+ </information>
+ <resources>
+ <j2se version="1.4+"/>
+ <!--<jar href="XslowXsimpletest1.jar"/>-->
+ <jar href="XslowXdeadlocktest.jar"/>
+ </resources>
+ <application-desc main-class="SimpleTest1">
+ </application-desc>
+</jnlp>
diff --git a/tests/jnlp_tests/simple/simpletest1/resources/simpletestMegaSlow.jnlp b/tests/jnlp_tests/simple/simpletest1/resources/simpletestMegaSlow.jnlp
new file mode 100644
index 0000000..3911307
--- /dev/null
+++ b/tests/jnlp_tests/simple/simpletest1/resources/simpletestMegaSlow.jnlp
@@ -0,0 +1,53 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+ -->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="XslowXsimpletestMegaSlow.jnlp" codebase=".">
+ <information>
+ <title>simpletest1</title>
+ <vendor>NetX</vendor>
+ <homepage href="http://jnlp.sourceforge.net/netx/"/>
+ <description>simpletest1</description>
+ <offline/>
+ </information>
+ <resources>
+ <j2se version="1.4+"/>
+ <jar href="XslowXsimpletest1.jar"/>
+ </resources>
+ <application-desc main-class="SimpleTest1">
+ </application-desc>
+</jnlp>
diff --git a/tests/jnlp_tests/simple/simpletest1/resources/simpletestSlow.jnlp b/tests/jnlp_tests/simple/simpletest1/resources/simpletestSlow.jnlp
new file mode 100644
index 0000000..4bdde3d
--- /dev/null
+++ b/tests/jnlp_tests/simple/simpletest1/resources/simpletestSlow.jnlp
@@ -0,0 +1,53 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+ -->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="simpletestSlow.jnlp" codebase=".">
+ <information>
+ <title>simpletest1</title>
+ <vendor>NetX</vendor>
+ <homepage href="http://jnlp.sourceforge.net/netx/"/>
+ <description>simpletest1</description>
+ <offline/>
+ </information>
+ <resources>
+ <j2se version="1.4+"/>
+ <jar href="XslowXsimpletest1.jar"/>
+ </resources>
+ <application-desc main-class="SimpleTest1">
+ </application-desc>
+</jnlp>
diff --git a/tests/jnlp_tests/simple/simpletest1/resources/simpletestSlowBrokenCustomSplash.jnlp b/tests/jnlp_tests/simple/simpletest1/resources/simpletestSlowBrokenCustomSplash.jnlp
new file mode 100644
index 0000000..b0108ed
--- /dev/null
+++ b/tests/jnlp_tests/simple/simpletest1/resources/simpletestSlowBrokenCustomSplash.jnlp
@@ -0,0 +1,54 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+ -->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="simpletestSlowBrokenCustomSplash.jnlp" codebase=".">
+ <information>
+ <title>simpletest1</title>
+ <vendor>NetX</vendor>
+ <homepage href="http://jnlp.sourceforge.net/netx/"/>
+ <icon kind="splash" href="netxPlugin.pngggg"/>
+ <description>simpletest1</description>
+ <offline/>
+ </information>
+ <resources>
+ <j2se version="1.4+"/>
+ <jar href="XslowXsimpletest1.jar"/>
+ </resources>
+ <application-desc main-class="SimpleTest1">
+ </application-desc>
+</jnlp>
diff --git a/tests/jnlp_tests/simple/simpletest1/resources/simpletestSlowSlowCustomSplash.jnlp b/tests/jnlp_tests/simple/simpletest1/resources/simpletestSlowSlowCustomSplash.jnlp
new file mode 100644
index 0000000..0220d96
--- /dev/null
+++ b/tests/jnlp_tests/simple/simpletest1/resources/simpletestSlowSlowCustomSplash.jnlp
@@ -0,0 +1,54 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+ -->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="simpletestSlowSlowCustomSplash.jnlp" codebase=".">
+ <information>
+ <title>simpletest1</title>
+ <vendor>NetX</vendor>
+ <homepage href="http://jnlp.sourceforge.net/netx/"/>
+ <icon kind="splash" href="XslowXnetxPlugin.png"/>
+ <description>simpletest1</description>
+ <offline/>
+ </information>
+ <resources>
+ <j2se version="1.4+"/>
+ <jar href="XslowXsimpletest1.jar"/>
+ </resources>
+ <application-desc main-class="SimpleTest1">
+ </application-desc>
+</jnlp>
diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ContentReaderListener.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ContentReaderListener.java
new file mode 100644
index 0000000..9981a31
--- /dev/null
+++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ContentReaderListener.java
@@ -0,0 +1,8 @@
+package net.sourceforge.jnlp;
+
+public interface ContentReaderListener {
+
+ public void charReaded(char ch);
+ public void lineReaded(String s);
+
+}
diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java
index 9057157..63d6210 100644
--- a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java
+++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java
@@ -87,4 +87,52 @@ public class ResourcesTest {
}
}
+
+ @Test
+ public void testListeners() throws Exception {
+ final StringBuilder o1=new StringBuilder();
+ final StringBuilder e1=new StringBuilder();
+ final StringBuilder o2=new StringBuilder();
+ final StringBuilder e2=new StringBuilder();
+ final ContentReaderListener lo=new ContentReaderListener() {
+
+ @Override
+ public void charReaded(char ch) {
+ //System.out.println("OO recieved char: "+ch);
+ o1.append(ch);
+ }
+
+ @Override
+ public void lineReaded(String s) {
+ //System.out.println("OO recieved line: "+s);
+ o2.append(s).append("\n");
+ }
+ };
+ ContentReaderListener le=new ContentReaderListener() {
+
+ @Override
+ public void charReaded(char ch) {
+ //System.out.println("EE recieved char: "+ch);
+ e1.append(ch);
+ }
+
+ @Override
+ public void lineReaded(String s) {
+ //System.out.println("EE recieved line: "+s);
+ e2.append(s).append("\n");
+ }
+ };
+ ServerAccess.ProcessResult pr=server.executeBrowser("simpletest1.jnlp",le,lo);
+ pr.process.destroy();
+// System.out.println("total o");
+// System.out.println(pr.stdout);
+// System.out.println("total e");
+// System.out.println(pr.stderr);
+ Assert.assertEquals(pr.stdout, o1.toString());
+ Assert.assertEquals(pr.stderr, e1.toString());
+ //the last \n is mandatory as las tline is flushed also when proces dies
+ Assert.assertEquals(pr.stdout.replace("\n", ""), o2.toString().replace("\n", ""));
+ Assert.assertEquals(pr.stderr.replace("\n", ""), e2.toString().replace("\n", ""));
+
+ }
}
diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java
index 5b1bc2c..a7527b9 100644
--- a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java
+++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java
@@ -53,6 +53,7 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.SocketException;
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
@@ -91,6 +92,9 @@ public class ServerAccess {
* java property which value containig path to installed (makefile by) javaws binary
*/
public static final String JAVAWS_BUILD_BIN = "javaws.build.bin";
+ /** property to set the different then default browser
+ */
+ public static final String USED_BROWSER_COMMAND = "used.browser.command";
public static final String DEFAULT_LOCALHOST_NAME = "localhost";
/**
* server instance singeton
@@ -117,11 +121,27 @@ public class ServerAccess {
/**
* main method of thos class prints out random free port
+ * or runs server
+ * param "port" prints out the port
+ * nothing or number will run sefrver on random(or on number specified)
+ * port in -Dtest.server.dir
*/
- public static void main(String[] args) throws IOException {
- int i = findFreePort();
- System.out.println(i);
+ public static void main(String[] args) throws Exception {
+ if (args.length > 0 && args[0].equalsIgnoreCase("port")) {
+ int i = findFreePort();
+ System.out.println(i);
+ System.exit(0);
+ } else {
+ int port = 44321;
+ if (args.length > 0) {
+ port=new Integer(args[0]);
+ }
+ getIndependentInstance(port);
+ while (true) {
+ Thread.sleep(1000);
+ }
+ }
}
/**
@@ -167,7 +187,22 @@ public class ServerAccess {
*/
public static ServerLauncher getIndependentInstance() {
String dir = (System.getProperty(TEST_SERVER_DIR));
- return getIndependentInstance(dir);
+ try{
+ return getIndependentInstance(dir, findFreePort());
+ }catch (Exception ex){
+ throw new RuntimeException(ex);
+ }
+ }
+
+
+ /**
+ *
+ * @return new not cached iserver instance on random port,
+ * usefull for testing application loading from different url then base
+ */
+ public static ServerLauncher getIndependentInstance(int port) {
+ String dir = (System.getProperty(TEST_SERVER_DIR));
+ return getIndependentInstance(dir,port);
}
/**
@@ -175,14 +210,13 @@ public class ServerAccess {
* @return new not cached iserver instance on random port upon custom www root directory,
* usefull for testing application loading from different url then base
*/
- public static ServerLauncher getIndependentInstance(String dir) {
+ public static ServerLauncher getIndependentInstance(String dir, int port) {
if (dir == null || dir.trim().length() == 0 || !new File(dir).exists() || !new File(dir).isDirectory()) {
throw new RuntimeException("test.server.dir property must be set to valid directory!");
}
try {
- int port = findFreePort();
ServerLauncher lServerLuncher = new ServerLauncher(port, new File(dir));
new Thread(lServerLuncher).start();
return lServerLuncher;
@@ -200,6 +234,16 @@ public class ServerAccess {
return System.getProperty(JAVAWS_BUILD_BIN);
}
+ /**
+ *
+ * @return - value passed inside as javaws binary location. See JAVAWS_BUILD_BIN
+ */
+ public String getBrowserLocation() {
+ String s=System.getProperty(USED_BROWSER_COMMAND);
+ if (s==null) s="firefox";
+ return s;
+ }
+
/**
*
* @return - value passed inside as javaws binary location as file. See JAVAWS_BUILD_BIN
@@ -314,6 +358,13 @@ public class ServerAccess {
Assert.assertEquals(new File(dirUrlContent.trim()), server.getDir());
Assert.assertEquals(new Integer(portUrlContent.trim()), server.getPort());
+ URL fastUrl = new URL("http", "localhost", server.getPort(), "/simpletest1.jnlp");
+ URL slowUrl = new URL("http", "localhost", server.getPort(), "/XslowXsimpletest1.jnlp");
+
+ String fastUrlcontent = getContentOfStream(fastUrl.openConnection().getInputStream());
+ String slowUrlContent = getContentOfStream(slowUrl.openConnection().getInputStream());
+ Assert.assertEquals(fastUrlcontent, slowUrlContent);
+
}
/**
@@ -501,7 +552,10 @@ public class ServerAccess {
public ProcessResult executeJavawsHeadless(String resource) throws Exception {
return executeJavawsHeadless(null, resource);
}
-
+ public ProcessResult executeJavawsHeadless(String resource,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception {
+ return executeJavawsHeadless(null, resource,stdoutl,stderrl);
+ }
+
/**
* wrapping method to executeProcess (eg: javaws arg arg -headless http://localhost:port/resource)
* will execute default javaws (@see JAVAWS_BUILD_BIN) upon default url upon cached server (@see SERVER_NAME @see getPort(), @see getInstance())
@@ -512,14 +566,18 @@ public class ServerAccess {
* @throws Exception
*/
public ProcessResult executeJavawsHeadless(List<String> otherargs, String resource) throws Exception {
+ return executeJavawsHeadless(otherargs, resource,null,null);
+ }
+ public ProcessResult executeJavawsHeadless(List<String> otherargs, String resource,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception {
if (otherargs == null) {
otherargs = new ArrayList<String>(1);
}
List<String> headlesList = new ArrayList<String>(otherargs);
headlesList.add(HEADLES_OPTION);
- return executeJavaws(headlesList, resource);
+ return executeJavaws(headlesList, resource,stdoutl,stderrl);
}
+
/**
* wrapping method to executeProcess (eg: javaws http://localhost:port/resource)
* will execute default javaws (@see JAVAWS_BUILD_BIN) upon default url upon cached server (@see SERVER_NAME @see getPort(), @see getInstance())
@@ -530,6 +588,15 @@ public class ServerAccess {
public ProcessResult executeJavaws(String resource) throws Exception {
return executeJavaws(null, resource);
}
+ public ProcessResult executeJavaws(String resource,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception {
+ return executeJavaws(null, resource,stdoutl,stderrl);
+ }
+ public ProcessResult executeBrowser(String resource) throws Exception {
+ return executeBrowser(null, resource);
+ }
+ public ProcessResult executeBrowser(String resource,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception {
+ return executeBrowser(null, resource,stderrl,stdoutl);
+ }
/**
* wrapping method to executeProcess (eg: javaws arg arg http://localhost:port/resource)
@@ -540,7 +607,27 @@ public class ServerAccess {
* @throws Exception
*/
public ProcessResult executeJavaws(List<String> otherargs, String resource) throws Exception {
- return executeProcessUponURL(getJavawsLocation(), otherargs, new URL("http", server.getServerName(), getPort(), resource));
+ return executeProcessUponURL(getJavawsLocation(), otherargs, getUrlUponThisInstance(resource));
+ }
+ public ProcessResult executeJavaws(List<String> otherargs, String resource,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception {
+ return executeProcessUponURL(getJavawsLocation(), otherargs, getUrlUponThisInstance(resource),stdoutl,stderrl);
+ }
+
+ public ProcessResult executeBrowser(List<String> otherargs, String resource) throws Exception {
+ return executeProcessUponURL(getBrowserLocation(), otherargs, getUrlUponThisInstance(resource));
+ }
+ public ProcessResult executeBrowser(List<String> otherargs, String resource,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception {
+ return executeProcessUponURL(getBrowserLocation(), otherargs, getUrlUponThisInstance(resource),stdoutl,stderrl);
+ }
+
+ /**
+ * Ctreate resource on http, on 'localhost' on port on which this instance is running
+ * @param resource
+ * @return
+ * @throws MalformedURLException
+ */
+ private URL getUrlUponThisInstance(String resource) throws MalformedURLException {
+ return new URL("http", server.getServerName(), getPort(), resource);
}
/**
@@ -554,6 +641,9 @@ public class ServerAccess {
public ProcessResult executeJavawsUponUrl(List<String> otherargs, URL u) throws Exception {
return executeProcessUponURL(getJavawsLocation(), otherargs, u);
}
+ public ProcessResult executeJavawsUponUrl(List<String> otherargs, URL u,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception {
+ return executeProcessUponURL(getJavawsLocation(), otherargs, u,stdoutl,stderrl);
+ }
/**
* wrapping utility method to executeProcess (eg: any_binary arg arg arg url)
@@ -565,6 +655,10 @@ public class ServerAccess {
* @throws Exception
*/
public static ProcessResult executeProcessUponURL(String toBeExecuted, List<String> otherargs, URL u) throws Exception {
+ return executeProcessUponURL(toBeExecuted, otherargs, u,null,null);
+ }
+
+ public static ProcessResult executeProcessUponURL(String toBeExecuted, List<String> otherargs, URL u,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception {
Assert.assertNotNull(u);
Assert.assertNotNull(toBeExecuted);
Assert.assertTrue(toBeExecuted.trim().length() > 1);
@@ -574,12 +668,15 @@ public class ServerAccess {
List<String> urledArgs = new ArrayList<String>(otherargs);
urledArgs.add(0, toBeExecuted);
urledArgs.add(u.toString());
- return executeProcess(urledArgs);
+ return executeProcess(urledArgs, stdoutl, stderrl);
}
public static ProcessResult executeProcess(final List<String> args) throws Exception {
return executeProcess(args, null);
}
+ public static ProcessResult executeProcess(final List<String> args,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception {
+ return executeProcess(args, null,stdoutl,stderrl);
+ }
/**
* utility method to lunch process, get its stdou/stderr, its return value and to kill it if runing to long (@see PROCESS_TIMEOUT)
*
@@ -597,6 +694,10 @@ public class ServerAccess {
* @throws Exception
*/
public static ProcessResult executeProcess(final List<String> args,File dir) throws Exception {
+ return executeProcess(args, dir, null, null);
+ }
+
+ public static ProcessResult executeProcess(final List<String> args,File dir,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception {
ThreadedProcess t = new ThreadedProcess(args,dir);
ProcessAssasin pa = new ProcessAssasin(t, PROCESS_TIMEOUT);
@@ -605,8 +706,8 @@ public class ServerAccess {
while (t.getP() == null) {
Thread.sleep(100);
}
- ContentReader crs = new ContentReader(t.getP().getInputStream());
- ContentReader cre = new ContentReader(t.getP().getErrorStream());
+ ContentReader crs = new ContentReader(t.getP().getInputStream(),stdoutl);
+ ContentReader cre = new ContentReader(t.getP().getErrorStream(),stderrl);
OutputStream out = t.getP().getOutputStream();
if (out != null) {
@@ -782,6 +883,9 @@ public class ServerAccess {
/**
* based on http://www.mcwalter.org/technology/java/httpd/tiny/index.html
* Very small implementation of http return headers for our served resources
+ *
+ * When resource starts with XslowX prefix, then resouce (without XslowX)
+ * is returned, but its delivery is delayed
*/
private class TinyHttpdImpl extends Thread {
@@ -789,6 +893,7 @@ public class ServerAccess {
private final File dir;
private final int port;
private boolean canRun = true;
+ private static final String XSX="/XslowX";
public void setCanRun(boolean canRun) {
this.canRun = canRun;
@@ -819,7 +924,9 @@ public class ServerAccess {
if (s.startsWith("GET")) {
StringTokenizer t = new StringTokenizer(s, " ");
t.nextToken();
- String p = t.nextToken();
+ String op = t.nextToken();
+ String p = op;
+ if (p.startsWith(XSX))p=p.replace(XSX, "/");
System.err.println("Getting: "+p);
p=URLDecoder.decode(p, "UTF-8");
System.err.println("Serving: "+p);
@@ -832,9 +939,20 @@ public class ServerAccess {
f.read(b);
o.writeBytes("HTTP/1.0 200 OK\nConten"
+ "t-Length:" + l + "\n\n");
+ if (op.startsWith(XSX)){
+ byte[][] bb=ServerAccess.splitArray(b,10);
+ for (int j = 0; j < bb.length; j++) {
+ Thread.sleep(2000);
+ byte[] bs = bb[j];
+ o.write(bs, 0, bs.length);
+ }
+ }else{
o.write(b, 0, l);
+ }
}
}
+ }catch (SocketException e) {
+ e.printStackTrace();
} catch (Exception e) {
o.writeBytes("HTTP/1.0 404 ERROR\n\n\n");
e.printStackTrace();
@@ -847,6 +965,92 @@ public class ServerAccess {
}
}
+
+ /**
+ * This function splits input array to severasl pieces
+ * from byte[length] splitt to n pieces s is retrunrd byte[n][length/n], except
+ * last piece which contains length%n
+ *
+ * @param input - array to be splitted
+ * @param pieces - to how many pieces it should be broken
+ * @return inidividual pices of original array, which concatet again givs original array
+ */
+ public static byte[][] splitArray(byte[] input, int pieces) {
+ int rest = input.length;
+ int rowLength = rest / pieces;
+ if (rest % pieces > 0) rowLength++;
+ if (pieces * rowLength >= rest + rowLength) pieces--;
+ int i = 0, j = 0;
+ byte[][] array = new byte[pieces][];
+ array[0] = new byte[rowLength];
+ for (byte b : input) {
+ if (i >= rowLength) {
+ i = 0;
+ array[++j] = new byte[Math.min(rowLength, rest)];
+ }
+ array[j][i++] = b;
+ rest--;
+ }
+ return array;
+ }
+
+
+ @Test
+ public void splitArrayTest0() throws Exception {
+ byte[] b={1,2,3,4,5,6,7,8,9,10,11,12,13,14};
+ byte[][] bb=splitArray(b, 3);
+ //printArrays(bb);
+ byte[] b1={1,2,3,4,5};
+ byte[] b2={6,7,8,9,10};
+ byte[] b3={11,12,13,14};
+ Assert.assertEquals(3,bb.length);
+ Assert.assertArrayEquals(b1,bb[0]);
+ Assert.assertArrayEquals(b2,bb[1]);
+ Assert.assertArrayEquals(b3,bb[2]);
+ }
+
+ @Test
+ public void splitArrayTest1() throws Exception {
+ byte[] b={1,2,3,4,5,6,7,8,9,10,11,12,13};
+ byte[][] bb=splitArray(b, 3);
+ //printArrays(bb);
+ byte[] b1={1,2,3,4,5};
+ byte[] b2={6,7,8,9,10};
+ byte[] b3={11,12,13};
+ Assert.assertEquals(3,bb.length);
+ Assert.assertArrayEquals(b1,bb[0]);
+ Assert.assertArrayEquals(b2,bb[1]);
+ Assert.assertArrayEquals(b3,bb[2]);
+ }
+
+ @Test
+ public void splitArrayTest2() throws Exception {
+ byte[] b={1,2,3,4,5,6,7,8,9,10,11,12};
+ byte[][] bb=splitArray(b, 3);
+ //printArrays(bb);
+ byte[] b1={1,2,3,4};
+ byte[] b2={5,6,7,8};
+ byte[] b3={9,10,11,12};
+ Assert.assertEquals(3,bb.length);
+ Assert.assertArrayEquals(b1,bb[0]);
+ Assert.assertArrayEquals(b2,bb[1]);
+ Assert.assertArrayEquals(b3,bb[2]);
+ }
+
+ private void printArrays(byte[][] bb) {
+ System.out.println("[][] l=" + bb.length);
+ for (int i = 0; i < bb.length; i++) {
+ byte[] bs = bb[i];
+ System.out.println(i + ": l=" + bs.length);
+ for (int j = 0; j < bs.length; j++) {
+ byte c = bs[j];
+ System.out.print(" " + j + ":" + c + " ");
+ }
+ System.out.println("");
+ }
+ }
+
+
/**
* class which timeout any ThreadedProcess. This killing of 'theread with process' replaced not working process.destroy().
*/
@@ -902,6 +1106,7 @@ public class ServerAccess {
while (!terminated.contains(p)) {
Thread.sleep(100);
}
+ //p.p.destroy()??
System.err.println("Timeouted " + p.toString() + " " + p.getP().toString() + " .. killed " + p.getCommandLine());
System.err.flush();
break;
@@ -952,6 +1157,7 @@ public class ServerAccess {
StringBuilder sb = new StringBuilder();
private final InputStream is;
private boolean done;
+ ContentReaderListener listener;
public String getContent() {
return sb.toString();
@@ -960,6 +1166,19 @@ public class ServerAccess {
public ContentReader(InputStream is) throws IOException {
this.is = is;
}
+ public ContentReader(InputStream is,ContentReaderListener l) throws IOException {
+ this.is = is;
+ this.listener=l;
+ }
+
+ public void setListener(ContentReaderListener listener) {
+ this.listener = listener;
+ }
+
+ public ContentReaderListener getListener() {
+ return listener;
+ }
+
/**
* Blocks until the copy is complete, or until the thread is interrupted
@@ -982,14 +1201,21 @@ public class ServerAccess {
public void run() {
try {
Reader br = new InputStreamReader(is, "UTF-8");
-
+ StringBuilder line=new StringBuilder();
while (true) {
int s = br.read();
if (s < 0) {
+ if (line.length()>0 && listener!=null) listener.lineReaded(line.toString());
break;
}
-
- sb.append(((char) s));
+ char ch=((char) s);
+ sb.append(ch);
+ line.append(ch);
+ if (ch=='\n'){
+ if (listener!=null) listener.lineReaded(line.toString());
+ line=new StringBuilder();
+ }
+ if (listener!=null) listener.charReaded(ch);
}
//do not want to bother output with terminations