diff options
author | Danesh Dadachanji <[email protected]> | 2012-03-16 14:17:36 -0400 |
---|---|---|
committer | Danesh Dadachanji <[email protected]> | 2012-03-16 14:17:36 -0400 |
commit | 213c12dcb273ba9923a2cc7742ceac6ab91eadf1 (patch) | |
tree | 0a070f300322464ccde872f13c4e44842a75120d /tests/jnlp_tests/simple | |
parent | 6b070376f754d27eb53536e6add664c860d742ce (diff) |
Fix JNLP parser to halt when required title and vendor elements are missing.
Diffstat (limited to 'tests/jnlp_tests/simple')
5 files changed, 283 insertions, 0 deletions
diff --git a/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/InformationParser.jnlp b/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/InformationParser.jnlp new file mode 100644 index 0000000..aabd685 --- /dev/null +++ b/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/InformationParser.jnlp @@ -0,0 +1,47 @@ +<!-- + +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="InformationParser.jnlp" codebase="."> + <!-- information tag missing --> + <resources> + <j2se version="1.4+"/> + <jar href="simpletest1.jar"/> + </resources> + <application-desc main-class="TitleVendorParser"> + </application-desc> +</jnlp> diff --git a/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/TitleParser.jnlp b/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/TitleParser.jnlp new file mode 100644 index 0000000..64a7e28 --- /dev/null +++ b/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/TitleParser.jnlp @@ -0,0 +1,52 @@ +<!-- + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +IcedTea is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + + --> +<?xml version="1.0" encoding="utf-8"?> +<jnlp spec="1.0" href="TitleParser.jnlp" codebase="."> + <information> + <vendor>IcedTea</vendor> + <homepage href="http://jnlp.sourceforge.net/netx/"/> + <description>Title tag missing</description> + <offline/> + </information> + <resources> + <j2se version="1.4+"/> + <jar href="simpletest1.jar"/> + </resources> + <application-desc main-class="TitleVendorParser"> + </application-desc> +</jnlp> diff --git a/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/TitleVendorParser.jnlp b/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/TitleVendorParser.jnlp new file mode 100644 index 0000000..faf52cb --- /dev/null +++ b/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/TitleVendorParser.jnlp @@ -0,0 +1,51 @@ +<!-- + +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="TitleVendorParser.jnlp" codebase="."> + <information> + <homepage href="http://jnlp.sourceforge.net/netx/"/> + <description>Title/Vendor tags missing</description> + <offline/> + </information> + <resources> + <j2se version="1.4+"/> + <jar href="simpletest1.jar"/> + </resources> + <application-desc main-class="TitleVendorParser"> + </application-desc> +</jnlp> diff --git a/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/VendorParser.jnlp b/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/VendorParser.jnlp new file mode 100644 index 0000000..e201bf0 --- /dev/null +++ b/tests/jnlp_tests/simple/InformationTitleVendorParser/resources/VendorParser.jnlp @@ -0,0 +1,52 @@ +<!-- + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +IcedTea is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + + --> +<?xml version="1.0" encoding="utf-8"?> +<jnlp spec="1.0" href="VendorParser.jnlp" codebase="."> + <information> + <title>VendorParser</title> + <homepage href="http://jnlp.sourceforge.net/netx/"/> + <description>Vendor tag missing</description> + <offline/> + </information> + <resources> + <j2se version="1.4+"/> + <jar href="simpletest1.jar"/> + </resources> + <application-desc main-class="TitleVendorParser"> + </application-desc> +</jnlp> diff --git a/tests/jnlp_tests/simple/InformationTitleVendorParser/testcases/InformationTitleVendorParserTest.java b/tests/jnlp_tests/simple/InformationTitleVendorParser/testcases/InformationTitleVendorParserTest.java new file mode 100644 index 0000000..c34bdd3 --- /dev/null +++ b/tests/jnlp_tests/simple/InformationTitleVendorParser/testcases/InformationTitleVendorParserTest.java @@ -0,0 +1,81 @@ +/* InformationTitleVendorParserTest.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 InformationTitleVendorParserTest { + + private static ServerAccess server = new ServerAccess(); + + public void runTest(String jnlpName, String exceptionMessage) throws Exception { + System.out.println("connecting InformationTitleVendorParser request, testing " + jnlpName); + System.err.println("connecting InformationTitleVendorParser request, testing " + jnlpName); + ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/" + jnlpName + ".jnlp"); + System.out.println(pr.stdout); + System.err.println(pr.stderr); + String s1 = "Good simple javaws exapmle"; + Assert.assertFalse("test" + jnlpName + " stdout should not contain " + s1 + " but did.", pr.stdout.contains(s1)); + // Looking for "Could not read or parse the JNLP file. (${DESCRIPTION})" + String s2 = "(?s).*Could not read or parse the JNLP file.{0,5}" + exceptionMessage + "(?s).*"; + Assert.assertTrue("testForTitle stderr should match " + s2 + " but did not.", pr.stderr.matches(s2)); + Assert.assertFalse(pr.wasTerminated); + Assert.assertEquals((Integer)0, pr.returnValue); + } + + @Test + public void testInformationeParser() throws Exception { + runTest("InformationParser", "No information section defined"); + } + + @Test + public void testTitleParser() throws Exception { + runTest("TitleParser", "The title section has not been defined in the JNLP file."); + } + @Test + public void testVendorParser() throws Exception { + runTest("VendorParser", "The vendor section has not been defined in the JNLP file."); + } + + @Test + public void testTitleVendorParser() throws Exception { + // Note that the title message missing causes an immediate exception, regardless of Vendor. + runTest("TitleVendorParser", "The title section has not been defined in the JNLP file."); + } +} |