/hg/icedtea-web: Added strict test
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Fri Sep 7 04:47:53 PDT 2012
changeset 0db02eca94bf in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=0db02eca94bf
author: Jiri Vanek <jvanek at redhat.com>
date: Fri Sep 07 13:52:23 2012 +0200
Added strict test
diffstat:
ChangeLog | 15 ++
tests/reproducers/simple/simpletest1/testcases/SimpleTest1Test.java | 72 ++++++++-
2 files changed, 77 insertions(+), 10 deletions(-)
diffs (114 lines):
diff -r 83032226f86a -r 0db02eca94bf ChangeLog
--- a/ChangeLog Thu Sep 06 14:09:09 2012 +0200
+++ b/ChangeLog Fri Sep 07 13:52:23 2012 +0200
@@ -1,3 +1,18 @@
+2012-09-07 Jiri Vanek <jvanek at redhat.com>
+
+ Added strict test
+ * tests/reproducers/simple/simpletest1/testcases/SimpleTest1Test.java:
+ Removed deprecated ServerAccess.ProcessResult
+ (testSimpletest1lunchOk) extracted asserting code
+ (checkLaunched) family of methods to evaluate output of application
+ (createStrictFile) method to prepare file which will pass strict checking
+ (testSimpletest1lunchOkStrictJnlp) new test, ensuring that even strict
+ file can be read without strict option
+ (testSimpletest1lunchNotOkJnlpStrict) new test ensuring that strictly
+ read no-strict file will fail
+ (testSimpletest1lunchOkStrictJnlpStrict) new test ensuring that strictly
+ read strict file will pass
+
2012-09-06 Jiri Vanek <jvanek at redhat.com>
Fixing several typos from previous push
diff -r 83032226f86a -r 0db02eca94bf tests/reproducers/simple/simpletest1/testcases/SimpleTest1Test.java
--- a/tests/reproducers/simple/simpletest1/testcases/SimpleTest1Test.java Thu Sep 06 14:09:09 2012 +0200
+++ b/tests/reproducers/simple/simpletest1/testcases/SimpleTest1Test.java Fri Sep 07 13:52:23 2012 +0200
@@ -35,7 +35,14 @@
exception statement from your version.
*/
-
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+import net.sourceforge.jnlp.ProcessResult;
import net.sourceforge.jnlp.ServerAccess;
import org.junit.Assert;
@@ -44,18 +51,63 @@
public class SimpleTest1Test {
private static ServerAccess server = new ServerAccess();
+ private static final List<String> strict = Arrays.asList(new String[]{"-strict", ServerAccess.VERBOSE_OPTION});
-
+ private void checkLaunched(ProcessResult pr) {
+ checkLaunched(pr, false);
+ }
+
+ private void checkLaunched(ProcessResult pr, boolean negate) {
+ String s = "Good simple javaws exapmle";
+ if (negate) {
+ Assert.assertFalse("testSimpletest1lunchOk stdout should NOT contains " + s + " bud did", pr.stdout.contains(s));
+ } else {
+ Assert.assertTrue("testSimpletest1lunchOk stdout should contains " + s + " bud didn't", pr.stdout.contains(s));
+ }
+ String ss = "xception";
+ if (negate) {
+ Assert.assertTrue("testSimpletest1lunchOk stderr should contains " + ss + " but didn't", pr.stderr.contains(ss));
+ } else {
+ Assert.assertFalse("testSimpletest1lunchOk stderr should not contains " + ss + " but did", pr.stderr.contains(ss));
+ }
+ Assert.assertFalse(pr.wasTerminated);
+ Assert.assertEquals((Integer) 0, pr.returnValue);
+ }
@Test
public void testSimpletest1lunchOk() throws Exception {
- ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/simpletest1.jnlp");
- String s="Good simple javaws exapmle";
- Assert.assertTrue("testSimpletest1lunchOk stdout should contains "+s+" bud didn't",pr.stdout.contains(s));
- String ss="xception";
- Assert.assertFalse("testSimpletest1lunchOk stderr should not contains "+ss+" but did",pr.stderr.contains(ss));
- Assert.assertFalse(pr.wasTerminated);
- Assert.assertEquals((Integer)0, pr.returnValue);
+ ProcessResult pr = server.executeJavawsHeadless(null, "/simpletest1.jnlp");
+ checkLaunched(pr);
}
- }
+ @Test
+ public void testSimpletest1lunchNotOkJnlpStrict() throws Exception {
+ ProcessResult pr = server.executeJavawsHeadless(strict, "/simpletest1.jnlp");
+ checkLaunched(pr, true);
+ }
+
+ @Test
+ public void testSimpletest1lunchOkStrictJnlp() throws Exception {
+ String originalResourceName = "simpletest1.jnlp";
+ String newResourceName = "simpletest1_strict.jnlp";
+ createStrictFile(originalResourceName, newResourceName, server.getUrl(""));
+ ProcessResult pr = server.executeJavawsHeadless(null, "/" + newResourceName);
+ checkLaunched(pr);
+ }
+
+ @Test
+ public void testSimpletest1lunchOkStrictJnlpStrict() throws Exception {
+ String originalResourceName = "simpletest1.jnlp";
+ String newResourceName = "simpletest1_strict.jnlp";
+ createStrictFile(originalResourceName, newResourceName, server.getUrl(""));
+ ProcessResult pr = server.executeJavawsHeadless(strict, "/" + newResourceName);
+ checkLaunched(pr);
+ }
+
+ private void createStrictFile(String originalResourceName, String newResourceName, URL codebase) throws MalformedURLException, IOException {
+ String originalContent = ServerAccess.getContentOfStream(new FileInputStream(new File(server.getDir(), originalResourceName)));
+ String nwContent1 = originalContent.replaceAll("href=\""+originalResourceName+"\"", "href=\""+newResourceName+"\"");
+ String nwContent = nwContent1.replaceAll("codebase=\".\"", "codebase=\"" + codebase + "\"");
+ ServerAccess.saveFile(nwContent, new File(server.getDir(), newResourceName));
+ }
+}
More information about the distro-pkg-dev
mailing list