# HG changeset patch # User Jiri Vanek # Date 1452763694 -3600 # Node ID e017136a9c454647e34567ee69a9760f82787192 # Parent 834746c2a271c677eceed0fb9560e102c6ba7e83 Added reprodcuer for NoClassDeffFoundError behavior diff -r 834746c2a271 -r e017136a9c45 ChangeLog --- a/ChangeLog Thu Jan 07 15:33:12 2016 +0100 +++ b/ChangeLog Thu Jan 14 10:28:14 2016 +0100 @@ -1,3 +1,18 @@ +2016-01-07 Jiri Vanek + + Added reprodcuer for NoClassDeffFoundError behavior + * tests/reproducers/custom/NoClassDeff/srcs/NoClassDeff.java: small app including + inner class, which is missing in deployed jar. Then calling this class on demand + * tests/reproducers/custom/NoClassDeff/srcs/.Makefile: responsible for removing + the compiled inner class before jarring + * tests/reproducers/custom/NoClassDeff/testcases/NoClassDeffTest.java: + testing behavior when ClassNotFound/NoClassDefFound is thrown in various stages + * tests/reproducers/custom/NoClassDeff/resources/NoClassDeff.html.in: + * tests/reproducers/custom/NoClassDeff/resources/NoClassDeffApp.jnlp.in: + * tests/reproducers/custom/NoClassDeff/resources/NoClassDeffApplet.jnlp.in: + * tests/reproducers/custom/NoClassDeff/resources/NoClassDeffJnlpHref.html.in: + templates to launch app with instruction when to call LostClass and how to deal with it + 2016-01-07 David Cantrell Jiri Vanek Andrew John Hughes diff -r 834746c2a271 -r e017136a9c45 tests/reproducers/custom/NoClassDeff/resources/NoClassDeff.html.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/NoClassDeff/resources/NoClassDeff.html.in Thu Jan 14 10:28:14 2016 +0100 @@ -0,0 +1,47 @@ + + + + + + + + + + + diff -r 834746c2a271 -r e017136a9c45 tests/reproducers/custom/NoClassDeff/resources/NoClassDeffApp.jnlp.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/NoClassDeff/resources/NoClassDeffApp.jnlp.in Thu Jan 14 10:28:14 2016 +0100 @@ -0,0 +1,56 @@ + + + + + + NoClassDeff + IcedTea + + PR2219 + + + + + + + + DIE_ON_STAGE + CATCH_ERROR + + diff -r 834746c2a271 -r e017136a9c45 tests/reproducers/custom/NoClassDeff/resources/NoClassDeffApplet.jnlp.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/NoClassDeff/resources/NoClassDeffApplet.jnlp.in Thu Jan 14 10:28:14 2016 +0100 @@ -0,0 +1,60 @@ + + + + + + NoClassDeff + IcedTea + + PR2219 + + + + + + + + + + + diff -r 834746c2a271 -r e017136a9c45 tests/reproducers/custom/NoClassDeff/resources/NoClassDeffJnlpHref.html.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/NoClassDeff/resources/NoClassDeffJnlpHref.html.in Thu Jan 14 10:28:14 2016 +0100 @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff -r 834746c2a271 -r e017136a9c45 tests/reproducers/custom/NoClassDeff/srcs/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/NoClassDeff/srcs/Makefile Thu Jan 14 10:28:14 2016 +0100 @@ -0,0 +1,33 @@ +TESTNAME=NoClassDeff + +SRC_FILES=NoClassDeff +ENTRYPOINT_CLASSES=NoClassDeff + +JAVAC_CLASSPATH=$(TEST_EXTENSIONS_DIR):$(NETX_DIR)/lib/classes.jar +JAVAC=$(EXPORTED_JAVAC) +JAR=$(EXPORTED_JAR) + +TMPDIR:=$(shell mktemp -d) + +prepare-reproducer: + echo PREPARING REPRODUCER $(TESTNAME); + pwd; + ls ; + $(JAVAC) -d $(TMPDIR) -classpath $(JAVAC_CLASSPATH) *.java; + #now the hack, remove inner class so we can later die on CNFE or NCDFE + ls $(TMPDIR)/ + rm $(TMPDIR)/*\$$* ; + ls $(TMPDIR)/ + cp ../resources/* $(REPRODUCERS_TESTS_SERVER_DEPLOYDIR); \ + for CLASS in $(ENTRYPOINT_CLASSES); \ + do \ + cd $(TMPDIR); \ + $(JAR) cfe "$$CLASS.jar" "$$CLASS" "$$CLASS.class"; \ + cd -;\ + mv $(TMPDIR)/"$$CLASS.jar" $(REPRODUCERS_TESTS_SERVER_DEPLOYDIR); \ + done; \ + echo PREPARED REPRODUCER $(TESTNAME), removing $(TMPDIR) ; \ + rm -rf $(TMPDIR) + +clean-reproducer: + echo NOTHING TO CLEAN FOR $(TESTNAME) diff -r 834746c2a271 -r e017136a9c45 tests/reproducers/custom/NoClassDeff/srcs/NoClassDeff.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/NoClassDeff/srcs/NoClassDeff.java Thu Jan 14 10:28:14 2016 +0100 @@ -0,0 +1,154 @@ +/* ExtensionJnlpTestApplet.java + Copyright (C) 2013 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 java.applet.*; +import java.awt.Graphics; + +public class NoClassDeff extends Applet { + + private static final String appletCloseString = "*** APPLET FINISHED ***"; + private static String stage = null; + private static boolean catchError = false; + + private static void checkStage() { + if (stage == null) { + throw new NullPointerException("satge cant be null"); + } + System.out.println(stage); + System.out.println("catchError: " + catchError); + } + + private static void lostClass() { + System.out.println("Loading LostClass"); + System.out.flush(); + if (catchError) { + try { + LostClass l = new LostClass(); + } catch (Throwable ex) {// vs exception + System.out.println("EX: " + ex.toString()); + System.out.flush(); + ex.printStackTrace(); + } + } else { + try { + LostClass l = new LostClass(); + } catch (Exception ex) {// vs throwable + System.out.println("EX: " + ex.toString()); + System.out.flush(); + ex.printStackTrace(); + } + } + } + + private static class LostClass { + + } + + public static void main(String[] args) { + stage = args[0]; + catchError = Boolean.valueOf(args[1]); + checkStage(); + System.out.println("main1"); + if (stage.equalsIgnoreCase("main")) { + lostClass(); + } + System.out.println("main2"); + System.out.println(appletCloseString); + System.out.flush(); + System.out.println("some garbage"); + } + + @Override + public void init() { + stage = getParameter("die"); + catchError = Boolean.valueOf(getParameter("catchError")); + System.out.println("init1"); + if (stage.equalsIgnoreCase("init")) { + lostClass(); + } + System.out.println("init2"); + } + + @Override + public void start() { + checkStage(); + System.out.println("start1"); + if (stage.equalsIgnoreCase("start")) { + lostClass(); + } + System.out.println("start2"); + } + + @Override + public void stop() { + checkStage(); + System.out.println("stop1"); + if (stage.equalsIgnoreCase("stop")) { + lostClass(); + } + System.out.println("stop2"); + System.out.flush(); + System.out.println("some garbage"); + } + + @Override + public void destroy() { + checkStage(); + System.out.println("destroy1"); + if (stage.equalsIgnoreCase("destroy")) { + lostClass(); + } + System.out.println("destroy2"); + System.out.flush(); + System.out.println("some garbage"); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + checkStage(); + System.out.println("paint1"); + if (stage.equalsIgnoreCase("paint")) { + lostClass(); + } + System.out.println("paint2"); + System.out.println(appletCloseString); + System.out.flush(); + System.out.println("some garbage"); + } + +} diff -r 834746c2a271 -r e017136a9c45 tests/reproducers/custom/NoClassDeff/testcases/NoClassDeffTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/NoClassDeff/testcases/NoClassDeffTest.java Thu Jan 14 10:28:14 2016 +0100 @@ -0,0 +1,727 @@ +/* NoClassDeffTest.java + Copyright (C) 2013 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 java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import net.sourceforge.jnlp.OptionsDefinitions; +import net.sourceforge.jnlp.ProcessResult; +import net.sourceforge.jnlp.ServerAccess; +import net.sourceforge.jnlp.annotations.Bug; +import net.sourceforge.jnlp.annotations.NeedsDisplay; +import net.sourceforge.jnlp.annotations.TestInBrowsers; +import net.sourceforge.jnlp.browsertesting.BrowserTest; +import net.sourceforge.jnlp.browsertesting.Browsers; +import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener; +import net.sourceforge.jnlp.closinglisteners.StringBasedClosingListener; +import net.sourceforge.jnlp.util.FileUtils; + +import org.junit.Assert; +import org.junit.Test; + +@Bug(id = "PR2219") +/** + * + * When NoClassDefFound is thrown from ITW. Current behaviour: javaws app + * correctly dies browsers and -html correctly dies + * + * javaws applet SURVIVES init and start throwing this. But correctly dies in + * paint + * + * + */ +public class NoClassDeffTest extends BrowserTest { + + private class NoClassDefFoundErrorClosingListener extends StringBasedClosingListener { + + public NoClassDefFoundErrorClosingListener() { + super(NoClassDefFoundError.class.getSimpleName()); + } + + } + + private static final String appletCloseString = AutoOkClosingListener.MAGICAL_OK_CLOSING_STRING; + private static final String[] HTMLA = new String[]{OptionsDefinitions.OPTIONS.HTML.option}; + private static final List HTMLL = Arrays.asList(HTMLA); + + private static final String JNLPAPP = "NoClassDeffApp.jnlp"; + private static final String JNLPAPPLET = "NoClassDeffApplet.jnlp"; + private static final String HTML = "NoClassDeff.html"; + private static final String HTMLHREF = "NoClassDeffJnlpHref.html"; + + //jnlp app OK run + @Test + @NeedsDisplay + public void noClassDeffTestWorksJnlp1() throws Exception { + prepare("okRun", false); + ProcessResult pr = server.executeJavaws(JNLPAPP, new AutoOkClosingListener(), null); + Assert.assertFalse(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("main1")); + Assert.assertTrue(pr.stdout.contains("main2")); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertFalse(pr.stdout.contains("EX: ")); + } + + //jnlp bad run 1 + @Test + @NeedsDisplay + public void noClassDeffTestThrowJnlp1() throws Exception { + prepare("main", false); + ProcessResult pr = server.executeJavaws(JNLPAPP, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("main1")); + Assert.assertFalse(pr.stdout.contains("main2")); + Assert.assertFalse(pr.stdout.contains(appletCloseString)); + Assert.assertFalse(pr.stdout.contains("EX: ")); + } + + //jnlp bad run 2 + @Test + @NeedsDisplay + public void noClassDeffTestThrowCatchJnlp1() throws Exception { + prepare("main", true); + ProcessResult pr = server.executeJavaws(JNLPAPP, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("main1")); + Assert.assertTrue(pr.stdout.contains("main2")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + //applets OK run + //opera should go correctly up to destroy WITHOUT paint + //epiphany only start and init + //midori up to paint + //firefox, no data + //-html and jnlp applet get init, start, paint + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestWorksHtml1() throws Exception { + prepare("okRun", false); + ProcessResult pr = server.executeBrowser(HTML, new AutoOkClosingListener(), null); + Assert.assertFalse(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); +// Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestWorksHtml2() throws Exception { + prepare("okRun", false); + ProcessResult pr = server.executeBrowser(HTMLHREF, new AutoOkClosingListener(), null); + Assert.assertFalse(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); +// Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + public void noClassDeffTestWorksJnlp2() throws Exception { + prepare("okRun", false); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), null); + Assert.assertFalse(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); + Assert.assertTrue(pr.stdout.contains("paint1")); + Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestWorksJavawsHtml1() throws Exception { + prepare("okRun", false); + ProcessResult pr = server.executeJavaws(HTMLL, HTML, new AutoOkClosingListener(), null); + Assert.assertFalse(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestWorksJavawsHtml2() throws Exception { + prepare("okRun", false); + ProcessResult pr = server.executeJavaws(HTMLL, HTMLHREF, new AutoOkClosingListener(), null); + Assert.assertFalse(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + //jnlp applets crashes + //they behave a bit differently form browser ones + @Test + @NeedsDisplay + public void noClassDeffTestThrowsInitJnlp2() throws Exception { + prepare("init", false); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), new NoClassDefFoundErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertFalse(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertFalse(pr.stdout.contains("init2")); + Assert.assertFalse(pr.stdout.contains("start1")); + Assert.assertFalse(pr.stdout.contains("start2")); + Assert.assertTrue(pr.stdout.contains("paint1")); + Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + public void noClassDeffTestThrowsStartJnlp2() throws Exception { + prepare("start", false); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), new NoClassDefFoundErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertFalse(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertFalse(pr.stdout.contains("start2")); + Assert.assertTrue(pr.stdout.contains("paint1")); + Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + public void noClassDeffTestThrowsPaintJnlp2() throws Exception { + prepare("paint", false); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), new NoClassDefFoundErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); + Assert.assertTrue(pr.stdout.contains("paint1")); + Assert.assertFalse(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertFalse(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + public void noClassDeffTestThrowsCatchInitJnlp2() throws Exception { + prepare("init", true); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); + Assert.assertTrue(pr.stdout.contains("paint1")); + Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + public void noClassDeffTestThrowsCatchStartJnlp2() throws Exception { + prepare("start", true); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); + Assert.assertTrue(pr.stdout.contains("paint1")); + Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + public void noClassDeffTestThrowsCatchPaintJnlp2() throws Exception { + prepare("paint", true); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); + Assert.assertTrue(pr.stdout.contains("paint1")); + Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + //-html and browser crashes + // + //applets crash init 1 + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsInitHtml1() throws Exception { + prepare("init", false); + ProcessResult pr = server.executeBrowser(HTML, null, new NoClassDefFoundErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertFalse(pr.stdout.contains("init2")); + Assert.assertFalse(pr.stdout.contains("start1")); + Assert.assertFalse(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); +// Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsInitHtml2() throws Exception { + prepare("init", false); + ProcessResult pr = server.executeBrowser(HTMLHREF, null, new NoClassDefFoundErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertFalse(pr.stdout.contains("init2")); + Assert.assertFalse(pr.stdout.contains("start1")); + Assert.assertFalse(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); +// Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsInitJavawsHtml1() throws Exception { + prepare("init", false); + ProcessResult pr = server.executeJavaws(HTMLL, HTML, null, new NoClassDefFoundErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertFalse(pr.stdout.contains("init2")); + Assert.assertFalse(pr.stdout.contains("start1")); + Assert.assertFalse(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsInitJavawsHtml2() throws Exception { + prepare("init", false); + ProcessResult pr = server.executeJavaws(HTMLL, HTMLHREF, null, new NoClassDefFoundErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertFalse(pr.stdout.contains("init2")); + Assert.assertFalse(pr.stdout.contains("start1")); + Assert.assertFalse(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertFalse(pr.stdout.contains(appletCloseString)); + } + + //applets crash start 1 + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsStartHtml1() throws Exception { + prepare("start", false); + ProcessResult pr = server.executeBrowser(HTML, null, new NoClassDefFoundErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertFalse(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); +// Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsStartHtml2() throws Exception { + prepare("start", false); + ProcessResult pr = server.executeBrowser(HTMLHREF, null, new NoClassDefFoundErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertFalse(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); +// Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsStartJavawsHtml1() throws Exception { + prepare("start", false); + ProcessResult pr = server.executeJavaws(HTMLL, HTML, null, new NoClassDefFoundErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertFalse(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsStartJavawsHtml2() throws Exception { + prepare("start", false); + ProcessResult pr = server.executeJavaws(HTMLL, HTMLHREF, null, new NoClassDefFoundErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertFalse(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertFalse(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertFalse(pr.stdout.contains(appletCloseString)); + } + + private void prepare(String when, boolean catchError) throws IOException { + File dir = ServerAccess.getInstance().getDir(); + String[] files = new String[]{"NoClassDeffApp.jnlp", "NoClassDeff.html", "NoClassDeffApplet.jnlp", "NoClassDeffJnlpHref.html"}; + for (String file : files) { + String s = FileUtils.loadFileAsString(new File(dir, file + ".in")); + s = s.replaceAll("DIE_ON_STAGE", when); + s = s.replaceAll("CATCH_ERROR", String.valueOf(catchError)); + FileUtils.saveFile(s, new File(dir, file)); + } + } + + //applets crash init 2 + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsCatchInitHtml1() throws Exception { + prepare("init", true); + ProcessResult pr = server.executeBrowser(HTML, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); +// Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsCatchInitHtml2() throws Exception { + prepare("init", true); + ProcessResult pr = server.executeBrowser(HTMLHREF, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); +// Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsCatchInitJavawsHtml1() throws Exception { + prepare("init", true); + ProcessResult pr = server.executeJavaws(HTMLL, HTML, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsCatchInitJavawsHtml2() throws Exception { + prepare("init", true); + ProcessResult pr = server.executeJavaws(HTMLL, HTMLHREF, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + //applets crash start 2 + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsCatchStartHtml1() throws Exception { + prepare("start", true); + ProcessResult pr = server.executeBrowser(HTML, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); +// Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsCatchStartHtml2() throws Exception { + prepare("start", true); + ProcessResult pr = server.executeBrowser(HTMLHREF, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); +// Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsCatchStartJavawsHtml1() throws Exception { + prepare("start", true); + ProcessResult pr = server.executeJavaws(HTMLL, HTML, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + } + + @Test + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + public void noClassDeffTestThrowsCatchStartJavawsHtml2() throws Exception { + prepare("start", true); + ProcessResult pr = server.executeJavaws(HTMLL, HTMLHREF, new AutoOkClosingListener(), null); + Assert.assertTrue(pr.stdout.contains("Loading LostClass")); + Assert.assertTrue(pr.stdout.contains("EX: ")); + Assert.assertTrue(pr.stderr.contains(NoClassDefFoundError.class.getSimpleName())); + Assert.assertTrue(pr.stdout.contains("init1")); + Assert.assertTrue(pr.stdout.contains("init2")); + Assert.assertTrue(pr.stdout.contains("start1")); + Assert.assertTrue(pr.stdout.contains("start2")); +// Assert.assertTrue(pr.stdout.contains("paint1")); +// Assert.assertTrue(pr.stdout.contains("paint2")); +// Assert.assertTrue(pr.stdout.contains("stop1")); +// Assert.assertTrue(pr.stdout.contains("stop2")); +// Assert.assertTrue(pr.stdout.contains("destroy1")); +// Assert.assertTrue(pr.stdout.contains("destroy2")); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + } + + + +}