changeset 260:e54277aefdaf

added engine for lunching reproducers
author Jiri Vanek <jvanek@redhat.com>
date Sun, 19 Jun 2011 18:48:22 +0200
parents 7ae04e8d830a
children 463e43653db5
files AUTHORS ChangeLog Makefile.am tests/jnlp_tests/README tests/jnlp_tests/simple/deadlocktest/resources/deadlocktest.jnlp tests/jnlp_tests/simple/deadlocktest/srcs/DeadlockTest.java tests/jnlp_tests/simple/deadlocktest/testcases/DeadLockTestTest.java tests/jnlp_tests/simple/simpletest1/resources/simpletest1.jnlp tests/jnlp_tests/simple/simpletest1/srcs/SimpleTest1.java tests/jnlp_tests/simple/simpletest1/testcases/SimpleTest1Test.java tests/jnlp_tests/simple/simpletest2/resources/simpletest2.jnlp tests/jnlp_tests/simple/simpletest2/srcs/SimpleTest2.java tests/jnlp_tests/simple/simpletest2/testcases/SimpleTest2Test.java tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java
diffstat 15 files changed, 1569 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/AUTHORS	Thu Jun 16 16:23:26 2011 +0200
+++ b/AUTHORS	Sun Jun 19 18:48:22 2011 +0200
@@ -14,6 +14,7 @@
 Saad Mohammad <smohammad@redhat.com>
 Andrew Su <asu@redhat.com>
 Joshua Sumali <jsumali@redhat.com>
+Jiri Vanek <jvanek@redhat.com>
 Mark Wielaard <mark@klomp.org>
 Man Lung Wong <mwong@redhat.com>
 
--- a/ChangeLog	Thu Jun 16 16:23:26 2011 +0200
+++ b/ChangeLog	Sun Jun 19 18:48:22 2011 +0200
@@ -1,3 +1,31 @@
+2011-06-17 Jiri Vanek <jvanek@redhat.com>
+
+	* tests/jnlp_tests: directory for reproducers
+	* tests/jnlp_tests/advanced: reproducers which must care about
+	 deploying and compiling thmselves
+	* tests/jnlp_tests/simple: reproducers compiled, jared and deployed
+	automatically 
+	* tests/jnlp_tests/simple/name/srcs|testcases|resources/: sourcefiles,
+	resources and testaces for simple reproducers
+	* tests/jnlp_tests/simple/deadlocktest: test for tracing not-killable
+	javaws
+	* tests/jnlp_tests/simple/simpletest1: tutorial test
+	* tests/jnlp_tests/simple/simpletest2: tutorial test with exception
+	* tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java:
+	tests for server basic functionality
+	* tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java:
+	implementation of server to produce jnlps and resources. Implementation
+	of helpers to run javaws process.
+	Makefile.am: new variables pointing to structure above; 
+	(junit-jnlp-dist-dirs.txt): prepare destination directory structure
+	(stamps/netx-dist-tests-prepare-reproducers.stamp):compile tescascases of simple reproducers
+	(netx-dist-tests-source-files.txt): lookup for server and helping classes
+	(stamps/netx-dist-tests-compile.stamp): compile server and helping classes
+	(stamps/netx-dist-tests-compile-testcases.stamp): compile, jar and deploy all simple testcases and their resources
+	(run-netx-dist-tests): after make install run junit testsuite upon reproducers on virtual server
+	(clean-netx-tests): added dependence on  clean-netx-dist-tests
+	(clean-netx-dist-tests): deleting  of reproducers
+
 2011-06-16 Jiri Vanek <jvanek@redhat.com>
 
 	* tests/report-styles/index.js: fast navigation functions
--- a/Makefile.am	Thu Jun 16 16:23:26 2011 +0200
+++ b/Makefile.am	Sun Jun 19 18:48:22 2011 +0200
@@ -17,6 +17,12 @@
 JUNIT_RUNNER_DIR=$(TESTS_DIR)/junit-runner
 JUNIT_RUNNER_SRCDIR=$(TESTS_SRCDIR)/junit-runner
 
+JNLP_TESTS_ENGINE_SRCDIR=$(TESTS_SRCDIR)/netx/jnlp_testsengine
+JNLP_TESTS_SRCDIR=$(TESTS_SRCDIR)/jnlp_tests
+JNLP_TESTS_ENGINE_DIR=$(TESTS_DIR)/netx/jnlp_testsengine
+JNLP_TESTS_SERVER_DEPLOYDIR=$(TESTS_DIR)/jnlp_test_server
+JNLP_TESTS_DIR=$(TESTS_DIR)/jnlp_tests
+
 JUNIT_RUNNER_JAR=$(abs_top_builddir)/junit-runner.jar
 
 # Build directories
@@ -449,6 +455,69 @@
 	  @junit-runner-source-files.txt && \
 	$(BOOT_DIR)/bin/jar cf $@  -C $(JUNIT_RUNNER_DIR) .
 
+junit-jnlp-dist-dirs.txt:
+	mkdir -p $(JNLP_TESTS_SERVER_DEPLOYDIR)
+	mkdir -p $(JNLP_TESTS_DIR)
+	mkdir -p $(JNLP_TESTS_ENGINE_DIR)
+	cd $(JNLP_TESTS_SRCDIR)/simple/ ; \
+	find .  -maxdepth 1 -mindepth 1 | sed "s/.\/*//" > $(abs_top_builddir)/$@
+
+stamps/netx-dist-tests-prepare-reproducers.stamp: junit-jnlp-dist-dirs.txt
+	simpleReproducers=(`cat $(abs_top_builddir)/junit-jnlp-dist-dirs.txt `); \
+	for dir in "$${simpleReproducers[@]}" ; do \
+	  mkdir -p $(JNLP_TESTS_DIR)/$$dir ; \
+	  $(BOOT_DIR)/bin/javac -d  $(JNLP_TESTS_DIR)/$$dir/ $(JNLP_TESTS_SRCDIR)/simple/$$dir/srcs/* ; \
+	  d=`pwd` ; \
+	  cd $(JNLP_TESTS_DIR)/$$dir/ ; \
+	    $(BOOT_DIR)/bin/jar cf $(JNLP_TESTS_SERVER_DEPLOYDIR)/$$dir.jar * ; \
+	  cd $$d ; \
+	  cp -R $(JNLP_TESTS_SRCDIR)/simple/$$dir/resources/*  $(JNLP_TESTS_SERVER_DEPLOYDIR)/ ; \
+	done ; \
+	mkdir -p stamps && \
+	touch $@
+
+netx-dist-tests-source-files.txt:
+	find $(JNLP_TESTS_ENGINE_SRCDIR) -name '*.java' | sort > $@
+
+stamps/netx-dist-tests-compile.stamp: stamps/netx.stamp \
+ junit-jnlp-dist-dirs.txt netx-dist-tests-source-files.txt
+	$(BOOT_DIR)/bin/javac $(IT_JAVACFLAGS) \
+	 -d $(JNLP_TESTS_ENGINE_DIR) \
+	 -classpath $(JUNIT_JAR):$(NETX_DIR)/lib/classes.jar \
+	 @netx-dist-tests-source-files.txt && \
+	mkdir -p stamps && \
+	touch $@
+
+stamps/netx-dist-tests-compile-testcases.stamp: stamps/netx.stamp junit-jnlp-dist-dirs.txt\
+ netx-dist-tests-source-files.txt stamps/netx-dist-tests-compile.stamp
+	simpleReproducers=(`cat $(abs_top_builddir)/junit-jnlp-dist-dirs.txt `); \
+	for dir in "$${simpleReproducers[@]}" ; do \
+	  $(BOOT_DIR)/bin/javac $(IT_JAVACFLAGS) \
+	  -d $(JNLP_TESTS_ENGINE_DIR) \
+	  -classpath $(JUNIT_JAR):$(NETX_DIR)/lib/classes.jar:$(JNLP_TESTS_ENGINE_DIR) \
+	  $(JNLP_TESTS_SRCDIR)/simple/$$dir/testcases/* ; \
+	done ; \
+	mkdir -p stamps && \
+	touch $@
+
+run-netx-dist-tests: all-local stamps/netx.stamp junit-jnlp-dist-dirs.txt stamps/netx-dist-tests-prepare-reproducers.stamp \
+ stamps/netx-dist-tests-compile.stamp stamps/netx-dist-tests-compile-testcases.stamp $(JUNIT_RUNNER_JAR)
+	cd $(JNLP_TESTS_ENGINE_DIR) ; \
+	class_names= ; \
+	for test in `find -type f` ; do \
+	  class_name=`echo $$test | sed -e 's|\.class$$||' -e 's|^\./||'` ; \
+	  class_name=`echo $$class_name | sed -e 's|/|.|g' ` ; \
+	  class_names="$$class_names $$class_name" ; \
+	done ; \
+	echo $$class_names ; \
+	CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):. \
+	  $(BOOT_DIR)/bin/java -Dtest.server.dir=$(JNLP_TESTS_SERVER_DEPLOYDIR) -Djavaws.build.bin=$(DESTDIR)$(bindir)/javaws \
+	 -Xbootclasspath:$(RUNTIME) CommandLine $$class_names \
+	  > stdout.log 2> stderr.log ; \
+	 cat stdout.log ; \
+	 cat stderr.log >&2
+	-xsltproc $(TESTS_SRCDIR)/$(REPORT_STYLES_DIRNAME)/jreport.xsl $(JNLP_TESTS_ENGINE_DIR)/tests-output.xml > $(TESTS_DIR)/index_reproducers.html
+
 netx-unit-tests-source-files.txt:
 	find $(NETX_UNIT_TEST_SRCDIR) -name '*.java' | sort > $@
 
@@ -483,9 +552,9 @@
 	  > stdout.log 2> stderr.log ; \
 	cat stdout.log ; \
 	cat stderr.log >&2
-	-xsltproc $(TESTS_SRCDIR)/$(REPORT_STYLES_DIRNAME)/jreport.xsl $(TESTS_DIR)/netx/unit/tests-output.xml > $(TESTS_DIR)/index_unit.html
+	-xsltproc $(TESTS_SRCDIR)/$(REPORT_STYLES_DIRNAME)/jreport.xsl $(NETX_UNIT_TEST_DIR)/tests-output.xml > $(TESTS_DIR)/index_unit.html
 
-clean-netx-tests: clean-netx-unit-tests clean-junit-runner
+clean-netx-tests: clean-netx-unit-tests clean-junit-runner clean-netx-dist-tests
 	if [ -e $(TESTS_DIR)/netx ]; then \
 	  rmdir $(TESTS_DIR)/netx ; \
 	fi
@@ -504,6 +573,16 @@
 	rm -rf  $(TESTS_DIR)/$(REPORT_STYLES_DIRNAME)/
 	rm -f  $(TESTS_DIR)/index*.html
 
+clean-netx-dist-tests:
+	rm -f netx-dist-tests-source-files.txt
+	rm -rf $(JNLP_TESTS_DIR)
+	rm -rf $(JNLP_TESTS_SERVER_DEPLOYDIR)
+	rm -rf $(JNLP_TESTS_ENGINE_DIR)
+	rm -f stamps/netx-dist-tests-compile.stamp
+	rm -f stamps/netx-dist-tests-prepare-reproducers.stamp
+	rm -f stamps/netx-dist-tests-compile-testcases.stamp
+	rm -f junit-jnlp-dist-dirs.txt
+
 # plugin tests
 
 if ENABLE_PLUGIN
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/README	Sun Jun 19 18:48:22 2011 +0200
@@ -0,0 +1,1 @@
+Each file in directory simple must follows naming convention and is compiled/jared automatically into server's working directory and content of resources likewise. The name of jnlp is independent, and there can be even more jnlps for each future jar.  Files in advanced directory have to care about themselves, but even those can have some parts inside simple directory, so some parts of them are processed automatically.  There are three reproducers – simpletest1, simpletest2 and deadlocktest, which tests test’s suite itself and serve as examples of behaviour.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/deadlocktest/resources/deadlocktest.jnlp	Sun Jun 19 18:48:22 2011 +0200
@@ -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="deadlocktest.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="deadlocktest.jar"/>
+  </resources>
+  <application-desc main-class="DeadlockTest">
+  </application-desc>
+</jnlp>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/deadlocktest/srcs/DeadlockTest.java	Sun Jun 19 18:48:22 2011 +0200
@@ -0,0 +1,51 @@
+/* DeadlockTest.java
+Copyright (C) 2011 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.
+ */
+
+public class DeadlockTest{
+
+    public static void main(String[] args) throws Exception{
+        long startTime=System.nanoTime()/1000000l;
+while(true){
+long now=System.nanoTime()/1000000l;
+Thread.sleep(10);
+if (now-startTime>30000){
+    System.out.println("This process is hanging more then 30s. Should be killed");
+    System.exit(5);
+}
+}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/deadlocktest/testcases/DeadLockTestTest.java	Sun Jun 19 18:48:22 2011 +0200
@@ -0,0 +1,64 @@
+/* DeadLockTestTest.java
+Copyright (C) 2011 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.ServerAccess;
+import org.junit.Assert;
+
+import org.junit.Test;
+
+public class DeadLockTestTest {
+
+    private static ServerAccess server = new ServerAccess();
+
+  
+
+   @Test
+    public void testDeadLockTestTerminated() throws Exception {
+        System.out.println("connecting deadlocktest request");
+        ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/deadlocktest.jnlp");
+        System.out.println(pr.stdout);
+        System.err.println(pr.stderr);
+        Assert.assertFalse(pr.stdout.contains("This process is hanging more then 30s. Should be killed"));
+//        Assert.assertTrue(pr.stderr.contains("xception"));, exception is thrown by engine,not by application
+        Assert.assertTrue(pr.wasTerminated);
+        Assert.assertEquals(null, pr.returnValue);//killed process have no value
+    }
+
+ 
+
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/simpletest1/resources/simpletest1.jnlp	Sun Jun 19 18:48:22 2011 +0200
@@ -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="simpletest1.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="simpletest1.jar"/>
+  </resources>
+  <application-desc main-class="SimpleTest1">
+  </application-desc>
+</jnlp>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/simpletest1/srcs/SimpleTest1.java	Sun Jun 19 18:48:22 2011 +0200
@@ -0,0 +1,43 @@
+/* SimpleTest1.java
+Copyright (C) 2011 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.
+ */
+
+public class SimpleTest1{
+
+    public static void main(String[] args){
+        System.out.println("Good simple javaws exapmle");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/simpletest1/testcases/SimpleTest1Test.java	Sun Jun 19 18:48:22 2011 +0200
@@ -0,0 +1,66 @@
+/* SimpleTest1Test.java
+Copyright (C) 2011 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.ServerAccess;
+import org.junit.Assert;
+
+import org.junit.Test;
+
+public class SimpleTest1Test {
+
+    private static ServerAccess server = new ServerAccess();
+
+  
+
+    @Test
+    public void testSimpletest1lunchOk() throws Exception {
+        System.out.println("connecting simpletest1 request");
+        ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/simpletest1.jnlp");
+        System.out.println(pr.stdout);
+        System.err.println(pr.stderr);
+        Assert.assertTrue(pr.stdout.contains("Good simple javaws exapmle"));
+        Assert.assertFalse(pr.stderr.contains("xception"));
+        Assert.assertFalse(pr.wasTerminated);
+        Assert.assertEquals((Integer)0, pr.returnValue);
+    }
+
+  
+
+
+
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/simpletest2/resources/simpletest2.jnlp	Sun Jun 19 18:48:22 2011 +0200
@@ -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="simpletest2.jnlp" codebase=".">
+  <information>
+    <title>simpletest2</title>
+    <vendor>NetX</vendor>
+    <homepage href="http://jnlp.sourceforge.net/netx/"/>
+    <description>simpletest2</description>
+    <offline/>
+  </information>
+  <resources>
+    <j2se version="1.4+"/>
+    <jar href="simpletest2.jar"/>
+  </resources>
+  <application-desc main-class="SimpleTest2">
+  </application-desc>
+</jnlp>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/simpletest2/srcs/SimpleTest2.java	Sun Jun 19 18:48:22 2011 +0200
@@ -0,0 +1,44 @@
+/* SimpleTest2.java
+Copyright (C) 2011 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.
+ */
+
+public class SimpleTest2{
+
+    public static void main(String[] args){
+throw new RuntimeException("Correct exception");
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/simple/simpletest2/testcases/SimpleTest2Test.java	Sun Jun 19 18:48:22 2011 +0200
@@ -0,0 +1,63 @@
+/* SimpleTest2Test.java
+Copyright (C) 2011 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.ServerAccess;
+import org.junit.Assert;
+
+import org.junit.Test;
+
+public class SimpleTest2Test {
+
+    private static ServerAccess server = new ServerAccess();
+
+
+    @Test
+    public void testSimpletest2lunchException() throws Exception {
+        System.out.println("connecting simpletest2 request");
+        ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/simpletest2.jnlp");
+        System.out.println(pr.stdout);
+        System.err.println(pr.stderr);
+        Assert.assertTrue(pr.stdout.trim().length() < 1);
+        Assert.assertTrue(pr.stderr.contains("Correct exception"));
+        Assert.assertTrue(pr.stderr.contains("Exception"));
+        Assert.assertFalse(pr.wasTerminated);
+        //Assert.assertFalse(0==pr.returnValue);exception and still returned 0?
+    }
+
+
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java	Sun Jun 19 18:48:22 2011 +0200
@@ -0,0 +1,84 @@
+/* ResourcesTestl.java
+Copyright (C) 2011 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.
+ */
+package net.sourceforge.jnlp;
+
+import java.io.File;
+import java.io.FileFilter;
+import org.junit.Assert;
+
+import org.junit.Test;
+
+public class ResourcesTest {
+
+    private static ServerAccess server = new ServerAccess();
+    
+
+    @Test
+    public void testResourcesExists() throws Exception {
+        File[] simpleContent = server.getDir().listFiles(new FileFilter() {
+
+            public boolean accept(File file) {
+                if (!file.isDirectory()) {
+                    return true;
+                } else {
+                    return false;
+                }
+            }
+        });
+        Assert.assertNotNull(simpleContent);
+        Assert.assertTrue(simpleContent.length > 5);
+
+        for (int i = 0; i < simpleContent.length; i++) {
+            File file = simpleContent[i];
+            System.err.println(file.getName());
+            if (file.getName().toLowerCase().endsWith(".jnlp")) {
+                String c = server.getResourceAsString("/" + file.getName());
+                Assert.assertTrue(c.contains("<"));
+                Assert.assertTrue(c.contains(">"));
+                Assert.assertTrue(c.contains("jnlp"));
+                Assert.assertTrue(c.contains("resources"));
+                Assert.assertTrue(c.replaceAll("\\s*", "").contains("</jnlp>"));
+
+            } else {
+                byte[] c = server.getResourceAsBytes("/" + file.getName()).toByteArray();
+                Assert.assertEquals(c.length, file.length());
+            }
+
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java	Sun Jun 19 18:48:22 2011 +0200
@@ -0,0 +1,884 @@
+/* ServerAccess.java
+Copyright (C) 2011 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.
+ */
+package net.sourceforge.jnlp;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.HttpURLConnection;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * This class provides access to virtual server and stuff arround.
+ * It can find unoccupied port, start server, provides its singleton instantion, lunch paralel instantions,
+ * read location of installed (tested javaws) see javaws.build.bin java poperty,
+ * location of server www root on filesystem (see test.server.dir java property),
+ * stubs for lunching javaws and for locating resources and read resources.
+ *
+ * It can also execute processes with timeout (@see PROCESS_TIMEOUT) (used during lunching javaws)
+ * Some protected apis are exported because public clases in this package are put to be tested by makefile.
+ *
+ * There are inclued tescases which show some basic usages.
+ *
+ *
+ */
+public class ServerAccess {
+
+    /**
+     * java property which value containig path to default (makefile by) directory with deployed resources
+     */
+    public static final String TEST_SERVER_DIR = "test.server.dir";
+    /**
+     * java property which value containig path to installed (makefile by) javaws binary
+     */
+    public static final String JAVAWS_BUILD_BIN = "javaws.build.bin";
+    /**
+     * server instance singeton
+     */
+    private static ServerLuncher server;
+    /**
+     * inner version if engine
+     */
+    private static final String version = "3";
+    /**
+     * timeout to read 'remote' resources
+     * This can be changed in runtime, but will affect all following tasks
+     */
+    public static int READ_TIMEOUT = 1000;
+    /**
+     * default url name part.
+     * This can be changed in runtime, but will affect all following tasks
+     */
+    public static String SERVER_NAME = "localhost";
+    /**
+     * timeout to let process to finish, before assasin wil kill it.
+     * This can be changed in runtime, but will affect all following tasks
+     */
+    public static long PROCESS_TIMEOUT = 10 * 1000;//ms
+    /**
+     * all terminated processes are stored here. As wee need to 'wait' to termination to be finished.
+     */
+    private static Set<Thread> terminated = new HashSet<Thread>();
+
+    /**
+     * main method of thos class prints out random free port
+     */
+    public static void main(String[] args) throws IOException {
+        int i = findFreePort();
+        System.out.println(i);
+
+    }
+
+    /**
+     * utility method to find random free port
+     *
+     * @return - foud random free port
+     * @throws IOException - if socket can't be openned or no free port exists
+     */
+    public static int findFreePort()
+            throws IOException {
+        ServerSocket findPortTestingSocket = new ServerSocket(0);
+        int port = findPortTestingSocket.getLocalPort();
+        findPortTestingSocket.close();
+        return port;
+    }
+
+    /**
+     * we would like to have an singleton instance asap
+     */
+    public ServerAccess() {
+
+        getInstance();
+
+
+    }
+
+    /**
+     *
+     * @return cahed instance. If none, then creates new
+     */
+    public static ServerLuncher getInstance() {
+        if (server == null) {
+            server = getIndependentInstance();
+        }
+        return server;
+    }
+
+    /**
+     *
+     * @return new not cached iserver instance on random port,
+     * usefull for testing application loading from different url then base
+     */
+    public static ServerLuncher getIndependentInstance() {
+        String dir = (System.getProperty(TEST_SERVER_DIR));
+        return getIndependentInstance(dir);
+    }
+
+    /**
+     *
+     * @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 ServerLuncher getIndependentInstance(String dir) {
+
+
+        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();
+            ServerLuncher lServerLuncher = new ServerLuncher(port, new File(dir));
+            new Thread(lServerLuncher).start();
+            return lServerLuncher;
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+
+    }
+
+    /**
+     *
+     * @return - value passed inside as javaws binary location. See JAVAWS_BUILD_BIN
+     */
+    public String getJavawsLocation() {
+        return System.getProperty(JAVAWS_BUILD_BIN);
+    }
+
+    /**
+     *
+     * @return - value passed inside as javaws binary location as file. See JAVAWS_BUILD_BIN
+     */
+    public File getJavawsFile() {
+        return new File(System.getProperty(JAVAWS_BUILD_BIN));
+    }
+
+    @Test
+    public void ensureJavaws() throws Exception {
+        String javawsValue = getJavawsLocation();
+        Assert.assertNotNull(javawsValue);
+        Assert.assertTrue(javawsValue.trim().length() > 2);
+        File javawsFile = getJavawsFile();
+        Assert.assertTrue(javawsFile.exists());
+        Assert.assertFalse(javawsFile.isDirectory());
+
+
+    }
+
+    @Test
+    public void ensureServer() throws Exception {
+
+        Assert.assertNotNull(server.getPort());
+        Assert.assertNotNull(server.getDir());
+        Assert.assertTrue(server.getPort() > 999);
+        Assert.assertTrue(server.getDir().toString().trim().length() > 2);
+
+        Assert.assertTrue(server.getDir().exists());
+        Assert.assertTrue(server.getDir().isDirectory());
+
+        File portFile = new File(server.getDir(), "server.port");
+        File dirFile = new File(server.getDir(), "server.dir");
+
+        saveFile(server.getDir().getAbsolutePath(), dirFile);
+        saveFile(server.getPort().toString(), portFile);
+        saveFile(server.getPort().toString(), portFile);
+
+        Assert.assertTrue(portFile.exists());
+        Assert.assertTrue(dirFile.exists());
+        Assert.assertTrue(server.getDir().listFiles().length > 1);
+
+        String portFileContent = getContentOfStream(new FileInputStream(portFile));
+        String dirFileContent = getContentOfStream(new FileInputStream(dirFile));
+
+
+
+        URL portUrl = new URL("http", "localhost", server.getPort(), "/server.port");
+        URL dirUrl = new URL("http", "localhost", server.getPort(), "/server.dir");
+
+
+        String portUrlContent = getContentOfStream(portUrl.openConnection().getInputStream());
+        String dirUrlContent = getContentOfStream(dirUrl.openConnection().getInputStream());
+
+
+        Assert.assertEquals(portUrlContent.trim(), portFileContent.trim());
+        Assert.assertEquals(dirUrlContent.trim(), dirFileContent.trim());
+        Assert.assertEquals(new File(dirUrlContent.trim()), server.getDir());
+        Assert.assertEquals(new Integer(portUrlContent.trim()), server.getPort());
+
+
+
+
+    }
+
+    /**
+     *
+     * @return port on which is runing cached server. If non singleton instance is runnig, new is created.
+     */
+    public int getPort() {
+        if (server == null) {
+            getInstance();
+        }
+        //if (!server.isRunning()) throw new RuntimeException("Server mysteriously died");
+        return server.getPort();
+
+    }
+
+    /**
+     *
+     * @return directory upon which is runing cached server. If non singleton instance is runnig, new is created.
+     */
+    public File getDir() {
+        if (server == null) {
+            getInstance();
+        }
+        // if (!server.isRunning()) throw new RuntimeException("Server mysteriously died");
+        return server.getDir();
+
+    }
+
+    /**
+     *
+     * @return weather cached server is alive. If non singleton instance is runnig, new is created.
+     */
+    public boolean isRunning() {
+        if (server == null) {
+            getInstance();
+        }
+        //if (!server.isRunning()) throw new RuntimeException("Server mysteriously died");
+        return server.isRunning();
+
+    }
+
+    /**
+     * Return resource from cached server
+     * 
+     * @param resource to be located on cached server
+     * @return individual bytes of resource
+     * @throws IOException if connection cant be established or resource do not exists
+     */
+    public ByteArrayOutputStream getResourceAsBytes(String resource) throws IOException {
+        URL u = new URL("http", SERVER_NAME, getPort(), resource);
+        return getResourceAsBytes(u);
+
+    }
+
+    /**
+     * Return resource from cached server
+     * 
+     * @param resource to be located on cached server
+     * @return string constructed from  resource
+     * @throws IOException if connection cant be established or resource do not exists
+     */
+    public String getResourceAsString(String resource) throws IOException {
+        URL u = new URL("http", SERVER_NAME, getPort(), resource);
+        return getResourceAsString(u);
+
+    }
+
+    /**
+     * utility method which can read bytes of any stream
+     * 
+     * @param input stream to be read
+     * @return individual bytes of resource
+     * @throws IOException if connection cant be established or resource do not exists
+     */
+    public static ByteArrayOutputStream getBytesFromStream(InputStream is) throws IOException {
+        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        int nRead;
+        byte[] data = new byte[16384];
+        while ((nRead = is.read(data, 0, data.length)) != -1) {
+            buffer.write(data, 0, nRead);
+        }
+        buffer.flush();
+        return buffer;
+    }
+
+    /**
+     * utility method which can read from any stream as one long String
+     * 
+     * @param input stream
+     * @return stream as string
+     * @throws IOException if connection cant be established or resource do not exists
+     */
+    public static String getContentOfStream(InputStream is) throws IOException {
+        try {
+            BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+            StringBuilder sb = new StringBuilder();
+            while (true) {
+                String s = br.readLine();
+                if (s == null) {
+                    break;
+                }
+                sb.append(s).append("\n");
+
+            }
+            return sb.toString();
+        } finally {
+            is.close();
+        }
+
+    }
+
+    /**
+     * utility method which can read bytes of resource from any url
+     * 
+     * @param resource to be located on any url
+     * @return individual bytes of resource
+     * @throws IOException if connection cant be established or resource do not exists
+     */
+    public static ByteArrayOutputStream getResourceAsBytes(URL u) throws IOException {
+        HttpURLConnection connection = (HttpURLConnection) u.openConnection();
+        connection = (HttpURLConnection) u.openConnection();
+        connection.setRequestMethod("GET");
+        connection.setDoOutput(true);
+        connection.setReadTimeout(READ_TIMEOUT);
+        connection.connect();
+        return getBytesFromStream(connection.getInputStream());
+
+    }
+
+    /**
+     * utility method which can read string of resource from any url
+     * 
+     * @param resource to be located onany url
+     * @return resource as string
+     * @throws IOException if connection cant be established or resource do not exists
+     */
+    public static String getResourceAsString(URL u) throws IOException {
+        HttpURLConnection connection = (HttpURLConnection) u.openConnection();
+        connection = (HttpURLConnection) u.openConnection();
+        connection.setRequestMethod("GET");
+        connection.setDoOutput(true);
+        connection.setReadTimeout(READ_TIMEOUT);
+        connection.connect();
+        return getContentOfStream(connection.getInputStream());
+    }
+
+    /**
+     * helping dummy  method to save String as file
+     * 
+     * @param content
+     * @param f
+     * @throws IOException
+     */
+    private static void saveFile(String content, File f) throws IOException {
+        Writer output = new BufferedWriter(new FileWriter(f));
+        output.write(content);
+        output.flush();
+        output.close();
+    }
+
+    /**
+     * wrapping method to executeProcess (eg: javaws -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())
+     * with parameter -headles (no gui, no asking)
+     * @param resource  name of resource
+     * @return result what left after running this process
+     * @throws Exception
+     */
+    public ProcessResult executeJavawsHeadless(String resource) throws Exception {
+        return executeJavawsHeadless(null, resource);
+    }
+
+    /**
+     * 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())
+     * with parameter -headles (no gui, no asking)
+     * @param resource  name of resource
+     * @param otherargs other arguments to be added to hedales one
+     * @return result what left after running this process
+     * @throws Exception
+     */
+    public ProcessResult executeJavawsHeadless(List<String> otherargs, String resource) throws Exception {
+        if (otherargs == null) {
+            otherargs = new ArrayList<String>(1);
+        }
+        List<String> headlesList = new ArrayList<String>(otherargs);
+        headlesList.add("-headless");
+        return executeJavaws(headlesList, resource);
+    }
+
+    /**
+     * 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())
+     * @param resource  name of resource
+     * @return result what left after running this process
+     * @throws Exception
+     */
+    public ProcessResult executeJavaws(String resource) throws Exception {
+        return executeJavaws(null, resource);
+    }
+
+    /**
+     *  wrapping method to executeProcess (eg: javaws arg arg 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()))
+     * @param resource  name of resource
+     * @param otherargs other arguments to be added
+     * @return result what left after running this process
+     * @throws Exception
+     */
+    public ProcessResult executeJavaws(List<String> otherargs, String resource) throws Exception {
+        return executeProcessUponURL(getJavawsLocation(), otherargs, new URL("http", SERVER_NAME, getPort(), resource));
+    }
+
+    /**
+     * wrapping method to executeProcess (eg: javaws arg arg arg url)
+     * will execute default javaws (@see JAVAWS_BUILD_BIN) upon any server
+     * @param u url of resource upon any server
+     * @param javaws arguments
+     * @return result what left after running this process
+     * @throws Exception
+     */
+    public ProcessResult executeJavawsUponUrl(List<String> otherargs, URL u) throws Exception {
+        return executeProcessUponURL(getJavawsLocation(), otherargs, u);
+    }
+
+    /**
+     * wrapping utility method to executeProcess (eg: any_binary arg arg arg url)
+     *
+     * will execute  any process upon  url upon any server
+     * @param u url of resource upon any server
+     * @param javaws arguments
+     * @return result what left after running this process
+     * @throws Exception
+     */
+    public static ProcessResult executeProcessUponURL(String toBeExecuted, List<String> otherargs, URL u) throws Exception {
+        Assert.assertNotNull(u);
+        Assert.assertNotNull(toBeExecuted);
+        Assert.assertTrue(toBeExecuted.trim().length() > 1);
+        if (otherargs == null) {
+            otherargs = new ArrayList<String>(1);
+        }
+        List<String> urledArgs = new ArrayList<String>(otherargs);
+        urledArgs.add(0, toBeExecuted);
+        urledArgs.add(u.toString());
+        return executeProcess(urledArgs);
+    }
+
+
+
+    /**
+     * utility method to lunch process, get its stdou/stderr, its return value and to kill it if runing to long (@see PROCESS_TIMEOUT)
+     *
+     *
+     * Small bacground:
+     * This method creates thread inside which exec will be executed. Then creates assasin thread with given timeout to kill the previously created thread if necessary.
+     * Starts assasin thread, starts process thread. Wait untill process is running, then starts content readers.
+     * Closes input of process.
+     * Wait until process is running (no metter if it teminate itself (correctly or badly), or is terminated by its assasin.
+     * Construct result from readed stdout, stderr, process return value, assasin sucessfulity
+     *
+     * @param args binary with args to be executed
+     * @return what left from process - proces sitself, its stdout, stderr and return value and weather it was terminated by assasin.
+     * @throws Exception
+     */
+    public static ProcessResult executeProcess(final List<String> args) throws Exception {
+
+        ThreadedProcess t = new ThreadedProcess(args);
+        ProcessAssasin pa = new ProcessAssasin(t, PROCESS_TIMEOUT);
+        pa.start();
+        t.start();
+        while (t.getP() == null) {
+            Thread.sleep(100);
+        }
+        ContentReader crs = new ContentReader(t.getP().getInputStream());
+        ContentReader cre = new ContentReader(t.getP().getErrorStream());
+
+        OutputStream out = t.getP().getOutputStream();
+        if (out != null) {
+            out.close();
+        }
+
+        new Thread(crs).start();
+        new Thread(cre).start();
+        while (t.isRunning()) {
+            Thread.sleep(100);
+        }
+        pa.setCanRun(false);
+        // System.out.println(t.getP().exitValue()); when process is killed, this throws exception
+
+        return new ProcessResult(crs.getContent(), cre.getContent(), t.getP(), pa.wasTerminated(), t.getExitCode());
+    }
+
+
+    /**
+     *
+     * wrapper arround Runtime.getRuntime().exec(...) which ensures taht process is run inside its own, by us controlled, thread.
+     * Proces sbuilder caused som einexpected and wired behaviour:/
+     */
+
+    private static class ThreadedProcess extends Thread {
+
+        Process p = null;
+        List<String> args;
+        Integer exitCode;
+        Boolean running;
+
+        public Boolean isRunning() {
+            return running;
+        }
+
+        public Integer getExitCode() {
+            return exitCode;
+        }
+
+        public ThreadedProcess(List<String> args) {
+
+            this.args = args;
+        }
+
+        public Process getP() {
+            return p;
+        }
+
+        @Override
+        public void run() {
+            try {
+                running = true;
+                Runtime r = Runtime.getRuntime();
+                p = r.exec(args.toArray(new String[0]));
+                exitCode = p.waitFor();
+            } catch (Exception ex) {
+                if (ex instanceof InterruptedException) {
+                    //add to the set of terminated threadedproceses
+                    terminated.add(this);
+                } else {
+                    throw new RuntimeException(ex);
+                }
+            } finally {
+                running = false;
+            }
+        }
+    }
+
+    /**
+     * wrapper arround tiny http server to separate lunch configgurations and servers.
+     * to allow terminations and stuff arround.
+     */
+
+    static class ServerLuncher implements Runnable {
+
+        private boolean running;
+        private final Integer port;
+        private final File dir;
+
+        public ServerLuncher(Integer portt, File dirr) {
+            port = portt;
+            dir = dirr;
+            System.err.println("port: " + port);
+            System.err.println("dir: " + dir);
+        }
+
+        public boolean isRunning() {
+            return running;
+        }
+
+        public Integer getPort() {
+            return port;
+        }
+
+        public File getDir() {
+            return dir;
+        }
+
+        public ServerLuncher(File dir) {
+            this(8181, dir);
+        }
+
+        public ServerLuncher(Integer port) {
+
+            this(port, new File(System.getProperty("user.dir")));
+        }
+
+        public ServerLuncher() {
+            this(8181, new File(System.getProperty("user.dir")));
+
+        }
+
+        public void run() {
+            running = true;
+            try {
+                ServerSocket s = new ServerSocket(
+                        port);
+                while (running) {
+                    new TinyHttpdImpl(s.accept(), dir, port);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                running = false;
+            }
+
+        }
+
+
+
+        /**
+         * based on http://www.mcwalter.org/technology/java/httpd/tiny/index.html
+         * Very small implementation of http return headers for our served resources
+         */
+        private class TinyHttpdImpl extends Thread {
+
+            Socket c;
+            private final File dir;
+            private final int port;
+            private boolean canRun = true;
+
+            public void setCanRun(boolean canRun) {
+                this.canRun = canRun;
+            }
+
+            public TinyHttpdImpl(Socket s, File f, int port) {
+                c = s;
+                this.dir = f;
+                this.port = port;
+                start();
+            }
+
+            public int getPort() {
+                return port;
+            }
+
+            @Override
+            public void run() {
+                try {
+                    BufferedReader i = new BufferedReader(new InputStreamReader(c.getInputStream()));
+                    DataOutputStream o = new DataOutputStream(c.getOutputStream());
+                    try {
+                        while (canRun) {
+                            String s = i.readLine();
+                            if (s.length() < 1) {
+                                break;
+                            }
+                            if (s.startsWith("GET")) {
+                                StringTokenizer t = new StringTokenizer(s, " ");
+                                t.nextToken();
+                                String p = t.nextToken();
+                                p = (".".concat(((p.endsWith("/")) ? p.concat(
+                                        "index.html") : p))).replace('/', File.separatorChar);
+                                File pp = new File(dir, p);
+                                int l = (int) pp.length();
+                                byte[] b = new byte[l];
+                                FileInputStream f = new FileInputStream(pp);
+                                f.read(b);
+                                o.writeBytes("HTTP/1.0 200 OK\nConten"
+                                        + "t-Length:" + l + "\n\n");
+                                o.write(b, 0, l);
+                            }
+                        }
+                    } catch (Exception e) {
+                        o.writeBytes("HTTP/1.0 404 ERROR\n\n\n");
+                        e.printStackTrace();
+                    }
+                    o.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+
+    /**
+     * class which timeout any ThreadedProcess. This killing of 'theread with process' replaced not working process.destroy().
+     */
+    private static class ProcessAssasin extends Thread {
+
+        long timeout;
+        private final ThreadedProcess p;
+        //false == is disabled:(
+        private boolean canRun = true;
+        private boolean wasTerminated = false;
+
+        /**
+         *
+         * @param p
+         * @param timeout - time to die in milis
+         */
+        public ProcessAssasin(ThreadedProcess p, long timeout) {
+            this.p = (p);
+            this.timeout = timeout;
+
+
+        }
+
+        public void setCanRun(boolean canRun) {
+            this.canRun = canRun;
+        }
+
+        public boolean isCanRun() {
+            return canRun;
+        }
+
+        public boolean wasTerminated() {
+            return wasTerminated;
+        }
+
+        @Override
+        public void run() {
+
+            long startTime = System.nanoTime() / 1000000l;
+            while (canRun) {
+                try {
+
+                    long time = System.nanoTime() / 1000000l;
+                    //System.out.println(time - startTime);
+                    //System.out.println((time - startTime) > timeout);
+                    if ((time - startTime) > timeout) {
+                        System.err.println("Timeouted " + p.toString() + " .. killing");
+                        System.err.flush();
+                        wasTerminated = true;
+                        p.interrupt();
+                        while (!terminated.contains(p)) {
+                            Thread.sleep(100);
+                        }
+                        System.err.println("Timeouted " + p.toString() + " .. killed");
+                        System.err.flush();
+                        break;
+
+
+                    }
+                } catch (Exception ex) {
+                    ex.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * artefacts what are left by finished process
+     */
+    public static class ProcessResult {
+
+        public final String stdout;
+        public final String stderr;
+        public final Process process;
+        public final Integer returnValue;
+        public final boolean wasTerminated;
+
+        public ProcessResult(String stdout, String stderr, Process process, boolean wasTerminated, Integer r) {
+            this.stdout = stdout;
+            this.stderr = stderr;
+            this.process = process;
+            this.wasTerminated = wasTerminated;
+            this.returnValue = r;
+        }
+    }
+
+    /**
+     * Class to read content of stdou/err of process, and to cooperate with its running/terminated/finished statuses.
+     */
+    private static class ContentReader implements Runnable {
+
+        StringBuilder sb = new StringBuilder();
+        private final InputStream is;
+        private boolean done;
+
+        public String getContent() {
+            return sb.toString();
+        }
+
+        public ContentReader(InputStream is) throws IOException {
+            this.is = is;
+        }
+
+        /**
+         * Blocks until the copy is complete, or until the thread is interrupted
+         */
+        public synchronized void waitUntilDone() throws InterruptedException {
+            boolean interrupted = false;
+
+            // poll interrupted flag, while waiting for copy to complete
+            while (!(interrupted = Thread.interrupted()) && !done) {
+                wait(1000);
+            }
+
+            if (interrupted) {
+                System.out.println("Stream copier: throwing InterruptedException");
+                //throw new InterruptedException();
+            }
+        }
+
+        @Override
+        public void run() {
+            try {
+                Reader br = new InputStreamReader(is, "UTF-8");
+
+                while (true) {
+                    int s = br.read();
+                    if (s < 0) {
+                        break;
+                    }
+
+                    sb.append(((char) s));
+
+                }
+                //do not want to bother output with terminations
+            } catch (Exception ex) {
+                //ex.printStackTrace();
+            } finally {
+                try {
+                    is.close();
+                } catch (Exception ex) {
+                    // ex.printStackTrace();
+                } finally {
+                    done = true;
+                }
+            }
+
+        }
+    }
+}