changeset 533:6e622e87010e

Add automatic closing to AppletBaseURL tests
author Adam Domurad <adomurad@redhat.com>
date Tue, 16 Oct 2012 17:18:52 -0400
parents ede3d73b7e24
children 14528918a200
files tests/reproducers/simple/AppletBaseURLTest/srcs/AppletBaseURL.java tests/reproducers/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java
diffstat 2 files changed, 15 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/tests/reproducers/simple/AppletBaseURLTest/srcs/AppletBaseURL.java	Tue Oct 16 16:55:52 2012 -0400
+++ b/tests/reproducers/simple/AppletBaseURLTest/srcs/AppletBaseURL.java	Tue Oct 16 17:18:52 2012 -0400
@@ -37,28 +37,13 @@
 
 import java.applet.Applet;
 public class AppletBaseURL extends Applet {
-
-    private class Killer extends Thread {
-
-        public int n = 1000;
-
-        @Override
-        public void run() {
-            try {
-                Thread.sleep(n);
-                System.out.println("Aplet killing himself after " + n + " ms of life");
-                System.exit(0);
-            } catch (Exception ex) {
-            }
-        }
-    }
-    private Killer killer;
-
     @Override
     public void init() {
         System.out.println("Document base is " + getDocumentBase() + " for this applet");
         System.out.println("Codebase is " + getCodeBase() + " for this applet");
-        killer = new Killer();
-        killer.start();
+        System.out.println("*** APPLET FINISHED ***");
+
+        // Exits JNLP-launched applets, throws exception on normal applet:
+        System.exit(0);
     }
 }
--- a/tests/reproducers/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java	Tue Oct 16 16:55:52 2012 -0400
+++ b/tests/reproducers/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java	Tue Oct 16 17:18:52 2012 -0400
@@ -35,7 +35,8 @@
 exception statement from your version.
  */
 
-import net.sourceforge.jnlp.ServerAccess.ProcessResult;
+import net.sourceforge.jnlp.ProcessResult;
+import net.sourceforge.jnlp.ServerAccess.AutoClose;
 import net.sourceforge.jnlp.annotations.Bug;
 import net.sourceforge.jnlp.annotations.NeedsDisplay;
 import net.sourceforge.jnlp.annotations.TestInBrowsers;
@@ -48,18 +49,18 @@
 public class AppletBaseURLTest extends BrowserTest{
 
     private void evaluateApplet(ProcessResult pr, String baseName) {
-        String s8 = "(?s).*Codebase is http://localhost:[0-9]{5}/ for this applet(?s).*";
-        Assert.assertTrue("AppletBaseURL stdout should match" + s8 + " but didn't", pr.stdout.matches(s8));
-        String s9 = "(?s).*Document base is http://localhost:[0-9]{5}/" + baseName + " for this applet(?s).*";
-        Assert.assertTrue("AppletBaseURL stdout should match" + s9 + " but didn't", pr.stdout.matches(s9));
-        String ss = "xception";
-        Assert.assertFalse("AppletBaseURL stderr should not contain" + ss + " but did", pr.stderr.contains(ss));
+        String codebaseRule = "(?s).*Codebase is http://localhost:[0-9]{5}/ for this applet(?s).*";
+        Assert.assertTrue("AppletBaseURL stdout should match" + codebaseRule + " but didn't", 
+                pr.stdout.matches(codebaseRule));
+        String documentbaseRule = "(?s).*Document base is http://localhost:[0-9]{5}/" + baseName + " for this applet(?s).*";
+        Assert.assertTrue("AppletBaseURL stdout should match" + documentbaseRule + " but didn't", 
+                pr.stdout.matches(documentbaseRule));
     }
 
     @NeedsDisplay
     @Test
     public void AppletWebstartBaseURLTest() throws Exception {
-        ProcessResult pr = server.executeJavaws(null, "/AppletBaseURLTest.jnlp");
+        ProcessResult pr = server.executeJavaws("/AppletBaseURLTest.jnlp");
         evaluateApplet(pr, "");
         Assert.assertFalse(pr.wasTerminated);
         Assert.assertEquals((Integer) 0, pr.returnValue);
@@ -70,7 +71,7 @@
     @Test
     @TestInBrowsers(testIn={Browsers.one})
     public void AppletInFirefoxTest() throws Exception {
-        ProcessResult pr = server.executeBrowser("/AppletBaseURLTest.html");
+        ProcessResult pr = server.executeBrowser("/AppletBaseURLTest.html", AutoClose.CLOSE_ON_BOTH);
         pr.process.destroy();
         evaluateApplet(pr, "AppletBaseURLTest.html");
         Assert.assertTrue(pr.wasTerminated);
@@ -81,7 +82,7 @@
     @Test
     @TestInBrowsers(testIn={Browsers.one})
     public void AppletWithJNLPHrefTest() throws Exception {
-        ProcessResult pr = server.executeBrowser("/AppletJNLPHrefBaseURLTest.html");
+        ProcessResult pr = server.executeBrowser("/AppletJNLPHrefBaseURLTest.html", AutoClose.CLOSE_ON_BOTH);
         pr.process.destroy();
         evaluateApplet(pr, "AppletJNLPHrefBaseURLTest.html");
         Assert.assertTrue(pr.wasTerminated);