/hg/icedtea-web: 2 new changesets

adomurad at icedtea.classpath.org adomurad at icedtea.classpath.org
Thu Apr 25 07:33:01 PDT 2013


changeset 1da533f89607 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=1da533f89607
author: Adam Domurad <adomurad at redhat.com>
date: Thu Apr 25 10:33:21 2013 -0400

	Tests & test extensions for mocking the plugin input & output pipes.


changeset b0bef68756a6 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=b0bef68756a6
author: Adam Domurad <adomurad at redhat.com>
date: Thu Apr 25 10:28:08 2013 -0400

	Unit tests for AsyncCall test extension


diffstat:

 ChangeLog                                                 |  18 ++
 Makefile.am                                               |   2 +-
 plugin/icedteanp/java/sun/applet/PluginStreamHandler.java |   3 +-
 tests/netx/unit/net/sourceforge/jnlp/AsyncCallTest.java   |  93 +++++++++++++++
 4 files changed, 113 insertions(+), 3 deletions(-)

diffs (148 lines):

diff -r ca33c41c9f69 -r b0bef68756a6 ChangeLog
--- a/ChangeLog	Thu Apr 25 14:25:45 2013 +0200
+++ b/ChangeLog	Thu Apr 25 10:28:08 2013 -0400
@@ -1,3 +1,21 @@
+2013-04-25  Adam Domurad  <adomurad at redhat.com>
+
+	* tests/netx/unit/net/sourceforge/jnlp/AsyncCallTest.java: Unit tests for
+	AsyncCall test extension.
+
+2013-04-25  Adam Domurad  <adomurad at redhat.com>
+
+	Tests & test extensions for mocking the plugin input & output pipes.
+	* Makefile.am
+	(stamps/test-extensions-compile.stamp): Make plugin classes available
+	to test extensions
+	* tests/test-extensions/net/sourceforge/jnlp/AsyncCall.java: New, helper 
+	for doing asynchronous calls with an optional timeout.
+	* tests/netx/unit/sun/applet/PluginAppletViewerTest.java: New, uses
+	PluginPipeMock to test the javascript requests to the plugin.
+	* tests/test-extensions/sun/applet/mock/PluginPipeMock.java: New, helper
+	for getting the plugin requests and mocking the replies. 
+
 2013-04-25  Jiri Vanek <jvanek at redhat.com>	
 
 	Locking disabled on windows machines
diff -r ca33c41c9f69 -r b0bef68756a6 Makefile.am
--- a/Makefile.am	Thu Apr 25 14:25:45 2013 +0200
+++ b/Makefile.am	Thu Apr 25 10:28:08 2013 -0400
@@ -760,7 +760,7 @@
 	ln -s $(TEST_EXTENSIONS_DIR) $(TEST_EXTENSIONS_COMPATIBILITY_SYMLINK);
 	$(BOOT_DIR)/bin/javac $(IT_JAVACFLAGS) \
 	 -d $(TEST_EXTENSIONS_DIR) \
-	 -classpath $(JUNIT_JAR):$(NETX_DIR)/lib/classes.jar \
+	 -classpath $(JUNIT_JAR):$(NETX_DIR)/lib/classes.jar:$(abs_top_builddir)/liveconnect/lib/classes.jar \
 	 @test-extensions-source-files.txt && \
 	mkdir -p stamps && \
 	touch $@
diff -r ca33c41c9f69 -r b0bef68756a6 plugin/icedteanp/java/sun/applet/PluginStreamHandler.java
--- a/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java	Thu Apr 25 14:25:45 2013 +0200
+++ b/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java	Thu Apr 25 10:28:08 2013 -0400
@@ -62,8 +62,7 @@
     private volatile boolean shuttingDown = false;
 
 
-    public PluginStreamHandler(InputStream inputstream, OutputStream outputstream)
-            throws MalformedURLException, IOException {
+    public PluginStreamHandler(InputStream inputstream, OutputStream outputstream) {
 
         PluginDebug.debug("Current context CL=", Thread.currentThread().getContextClassLoader());
 
diff -r ca33c41c9f69 -r b0bef68756a6 tests/netx/unit/net/sourceforge/jnlp/AsyncCallTest.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/netx/unit/net/sourceforge/jnlp/AsyncCallTest.java	Thu Apr 25 10:28:08 2013 -0400
@@ -0,0 +1,93 @@
+package net.sourceforge.jnlp;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.concurrent.Callable;
+
+import org.junit.Test;
+
+public class AsyncCallTest {
+
+    @Test
+    public void timeOutTest() {
+        final boolean[] wasInterrupted = { false };
+
+        AsyncCall<Void> call = AsyncCall.startWithTimeOut(new Callable<Void>() {
+            @Override
+            public synchronized Void call() {
+                try {
+                    wait();
+                } catch (InterruptedException ie) {
+                    // Received on time-out
+                    wasInterrupted[0] = true;
+                }
+                return null;
+            }
+        }, 100 /* 100 millisecond time-out */);
+
+        boolean completedNormally = false;
+
+        try {
+            call.join();
+            completedNormally = true;
+        } catch (Exception e) {
+            ServerAccess.logErrorReprint(e.toString());
+            assertTrue(e instanceof AsyncCall.TimeOutException);
+        }
+
+        assertFalse(completedNormally);
+        assertTrue(wasInterrupted[0]);
+    }
+
+    @Test
+    public void normalReturnTest() {
+        AsyncCall<Integer> call = AsyncCall.startWithTimeOut(new Callable<Integer>() {
+            @Override
+            public Integer call() {
+                return 1;
+            }
+        });
+
+        Integer result = null;
+        boolean completedNormally = false;
+
+        try {
+            result = call.join();
+            completedNormally = true;
+        } catch (Exception e) {
+            ServerAccess.logErrorReprint(e.toString());
+        }
+
+        assertTrue(completedNormally);
+        assertEquals(Integer.valueOf(1), result);
+    }
+
+    @Test
+    public void thrownExceptionTest() {
+
+        @SuppressWarnings("serial")
+        class TestException extends RuntimeException {
+        }
+
+        AsyncCall<Void> call = AsyncCall.startWithTimeOut(new Callable<Void>() {
+            @Override
+            public Void call() {
+                throw new TestException();
+            }
+        });
+
+        boolean completedNormally = false;
+
+        try {
+            call.join();
+            completedNormally = true;
+        } catch (Exception e) {
+            ServerAccess.logErrorReprint(e.toString());
+            assertTrue(e instanceof TestException);
+        }
+
+        assertFalse(completedNormally);
+    }
+}
\ No newline at end of file



More information about the distro-pkg-dev mailing list