Changeset 429 for trunk/icedtea-web/tests
- Timestamp:
- Sep 24, 2014, 9:34:21 PM (11 years ago)
- Location:
- trunk/icedtea-web/tests
- Files:
-
- 2 deleted
- 85 edited
- 127 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/icedtea-web/tests/junit-runner/CommandLine.java
r418 r429 27 27 public static void runMainAndExit(JUnitSystem system, String... args) { 28 28 new CommandLine().runMain(system, args); 29 system.exit(0);29 System.exit(0); 30 30 } 31 31 32 @Override33 32 public Result runMain(JUnitSystem system, String... args) { 34 33 List<Class<?>> classes = new ArrayList<Class<?>>(); … … 47 46 RunListener listener = new LessVerboseTextListener(system); 48 47 addListener(listener); 49 Result result = run(classes.toArray(new Class [0]));48 Result result = run(classes.toArray(new Class<?>[0])); 50 49 for (Failure each : missingClasses) { 51 50 result.getFailures().add(each); -
trunk/icedtea-web/tests/junit-runner/JunitLikeXmlOutputListener.java
r418 r429 21 21 import java.util.Map.Entry; 22 22 import java.util.Set; 23 import java.util.Arrays; 23 24 import java.util.concurrent.TimeUnit; 24 25 import net.sourceforge.jnlp.annotations.Bug; 25 26 import net.sourceforge.jnlp.annotations.KnownToFail; 27 import net.sourceforge.jnlp.annotations.Remote; 28 import net.sourceforge.jnlp.browsertesting.Browsers; 26 29 27 30 … … 50 53 private static final String BUG = "bug"; 51 54 private static final String K2F = "known-to-fail"; 55 private static final String REMOTE = "remote"; 52 56 private static final String TEST_NAME_ATTRIBUTE = "name"; 53 57 private static final String TEST_TIME_ATTRIBUTE = "time"; … … 77 81 private class ClassStat { 78 82 79 Class c;83 Class<?> c; 80 84 int total; 81 85 int failed; … … 173 177 testDone(description, testTime, testTimeSeconds, false); 174 178 } 175 179 180 181 @SuppressWarnings("unchecked") 176 182 private void testDone(Description description, long testTime, double testTimeSeconds, boolean ignored) throws Exception { 177 Class testClass = null;183 Class<?> testClass = null; 178 184 Method testMethod = null; 179 185 try { … … 198 204 testcaseAtts.put(TEST_IGNORED_ATTRIBUTE, Boolean.TRUE.toString()); 199 205 } 200 KnownToFail k2f=null; 201 try { 202 if (testClass != null && testMethod != null) { 203 k2f = testMethod.getAnnotation(KnownToFail.class); 204 if (k2f != null) { 205 testcaseAtts.put(K2F, Boolean.TRUE.toString()); 206 } 207 } 208 } catch (Exception ex) { 209 ex.printStackTrace(); 206 KnownToFail k2f = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), KnownToFail.class); 207 boolean thisTestIsK2F = false; 208 Remote remote = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), Remote.class); 209 if (k2f != null) { 210 //determine if k2f in the current browser 211 //?? 212 Browsers[] br = k2f.failsIn(); 213 if(0 == br.length){//the KnownToFail annotation without optional parameter 214 thisTestIsK2F = true; 215 }else{ 216 for(Browsers b : br){ 217 if(description.toString().contains(b.toString())){ 218 thisTestIsK2F = true; 219 } 220 } 221 } 222 } 223 if( thisTestIsK2F ) testcaseAtts.put(K2F, Boolean.TRUE.toString()); 224 if (remote != null) { 225 testcaseAtts.put(REMOTE, Boolean.TRUE.toString()); 226 210 227 } 211 228 openElement(TEST_ELEMENT, testcaseAtts); 212 229 if (testFailed != null) { 213 if ( k2f != null) {230 if (thisTestIsK2F) { 214 231 failedK2F++; 215 232 } … … 226 243 writeElement(TEST_ERROR_ELEMENT, testFailed.getTrace(), errorAtts); 227 244 } else { 228 if ( k2f != null) {245 if (thisTestIsK2F) { 229 246 if (ignored) { 230 247 ignoredK2F++; … … 265 282 } 266 283 classStat.total++; 267 if ( k2f != null) {284 if (thisTestIsK2F) { 268 285 classStat.totalK2F++; 269 286 } … … 272 289 if (ignored) { 273 290 classStat.ignored++; 274 if ( k2f != null) {291 if (thisTestIsK2F) { 275 292 classStat.ignoredK2F++; 276 293 } 277 294 } else { 278 295 classStat.passed++; 279 if ( k2f != null) {296 if (thisTestIsK2F) { 280 297 classStat.passedK2F++; 281 298 } … … 283 300 } else { 284 301 classStat.failed++; 285 if ( k2f != null) {302 if (thisTestIsK2F) { 286 303 classStat.failedK2F++; 287 304 } … … 290 307 291 308 @Override 309 @SuppressWarnings("unchecked") 292 310 public void testRunFinished(Result result) throws Exception { 293 311 … … 320 338 Bug b = null; 321 339 if (entry.getValue().c != null) { 322 b = (Bug)entry.getValue().c.getAnnotation(Bug.class);340 b = entry.getValue().c.getAnnotation(Bug.class); 323 341 } 324 342 if (b != null) { -
trunk/icedtea-web/tests/junit-runner/LessVerboseTextListener.java
r418 r429 7 7 */ 8 8 import java.io.PrintStream; 9 import java.lang.annotation.Annotation; 9 10 import java.lang.reflect.Method; 10 11 import net.sourceforge.jnlp.annotations.KnownToFail; 12 import net.sourceforge.jnlp.annotations.Remote; 13 import net.sourceforge.jnlp.browsertesting.Browsers; 11 14 12 15 import org.junit.internal.JUnitSystem; … … 38 41 writer.println("Ignored: " + description.getClassName() + "." + description.getMethodName()); 39 42 printK2F(writer, null, description); 43 printRemote(writer, description); 40 44 } 41 45 … … 46 50 writer.println("FAILED: " + failure.getTestHeader() + " " + failure.getMessage()); 47 51 printK2F(writer,true,failure.getDescription()); 52 printRemote(writer, failure.getDescription()); 48 53 } 49 54 … … 53 58 writer.println("Passed: " + description.getClassName() + "." + description.getMethodName()); 54 59 printK2F(writer,false,description); 60 printRemote(writer, description); 55 61 } 56 62 } … … 70 76 try { 71 77 KnownToFail k2f = getK2F(description); 72 if (k2f != null) { 78 boolean thisTestIsK2F = false; 79 if (k2f != null){ 80 //determine if k2f in the current browser 81 Browsers[] br = k2f.failsIn(); 82 if(0 == br.length){ //@KnownToFail with default optional parameter failsIn={} 83 thisTestIsK2F = true; 84 }else{ 85 for(Browsers b : br){ 86 if(description.toString().contains(b.toString())){ 87 thisTestIsK2F = true; 88 } 89 } 90 } 91 } 92 93 if( thisTestIsK2F ){ 73 94 totalK2F++; 74 95 if (failed != null) { … … 94 115 } 95 116 96 public static KnownToFail getK2F(Description description) { 117 118 @SuppressWarnings("unchecked") 119 public static <T extends Annotation> T getAnnotation(Class<?> q, String methodName, Class<T> a) { 97 120 try { 98 Class q = description.getTestClass();99 121 if (q != null) { 100 String qs = description.getMethodName(); 122 T rem = q.getAnnotation(a); 123 if (rem != null) { 124 return rem; 125 } 126 String qs = methodName; 101 127 if (qs.contains(" - ")) { 102 128 qs = qs.replaceAll(" - .*", ""); … … 104 130 Method qm = q.getMethod(qs); 105 131 if (qm != null) { 106 KnownToFail k2f = qm.getAnnotation(KnownToFail.class);107 return k2f;132 rem = qm.getAnnotation(a); 133 return rem; 108 134 109 135 } … … 115 141 } 116 142 143 public static KnownToFail getK2F(Description description) { 144 return getAnnotation(description.getTestClass(), description.getMethodName(), KnownToFail.class); 145 } 146 147 public static Remote getRemote(Description description) { 148 return getAnnotation(description.getTestClass(), description.getMethodName(), Remote.class); 149 150 } 151 152 private void printRemote(PrintStream writer, Description description) { 153 try { 154 Remote rem = getRemote(description); 155 if (rem != null) { 156 writer.println(" - This test is running remote content, note that failures may be caused by broken target application or connection"); 157 } 158 } catch (Exception ex) { 159 ex.printStackTrace(); 160 } 161 } 117 162 } -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/DefaultLaunchHandlerTest.java
r418 r429 43 43 import java.io.ByteArrayOutputStream; 44 44 import java.io.PrintStream; 45 import java.lang.reflect.Field; 46 import net.sourceforge.jnlp.util.logging.LogConfig; 47 import net.sourceforge.jnlp.util.logging.OutputController; 45 48 46 49 import org.junit.Test; … … 48 51 public class DefaultLaunchHandlerTest { 49 52 53 private static class LocalLogger extends OutputController { 54 55 private static class AccessibleStream extends PrintStream { 56 57 public AccessibleStream(ByteArrayOutputStream out) { 58 super(out); 59 } 60 61 public ByteArrayOutputStream getOut() { 62 return (ByteArrayOutputStream) out; 63 } 64 } 65 66 LocalLogger() { 67 super(new AccessibleStream(new ByteArrayOutputStream()), new AccessibleStream(new ByteArrayOutputStream())); 68 try{ 69 Field f = LogConfig.class.getDeclaredField("logToStreams"); 70 f.setAccessible(true); 71 f.set(LogConfig.getLogConfig(), true); 72 }catch(Exception ex){ 73 ServerAccess.logException(ex); 74 } 75 } 76 77 public String getStream1() { 78 return ((AccessibleStream) (super.getOut())).getOut().toString(); 79 } 80 81 public String getStream2() { 82 return ((AccessibleStream) (super.getErr())).getOut().toString(); 83 } 84 } 85 50 86 @Test 51 87 public void testBasicLaunch() { 52 ByteArrayOutputStream baos = new ByteArrayOutputStream();53 DefaultLaunchHandler handler = new DefaultLaunchHandler( new PrintStream(baos));88 LocalLogger l = new LocalLogger(); 89 DefaultLaunchHandler handler = new DefaultLaunchHandler(l); 54 90 55 91 // all no-ops with no output … … 58 94 handler.launchCompleted(null); 59 95 60 String output = baos.toString();61 assertEquals("", output);96 assertEquals("", l.getStream1()); 97 assertEquals("", l.getStream2()); 62 98 } 63 99 64 100 @Test 65 101 public void testLaunchWarning() { 66 ByteArrayOutputStream baos = new ByteArrayOutputStream();67 DefaultLaunchHandler handler = new DefaultLaunchHandler( new PrintStream(baos));102 LocalLogger l = new LocalLogger(); 103 DefaultLaunchHandler handler = new DefaultLaunchHandler(l); 68 104 69 105 LaunchException warning = new LaunchException(null, null, … … 72 108 73 109 assertTrue(continueLaunch); 74 String output = baos.toString(); 75 assertEquals("netx: warning type: test warning\n", output); 110 assertEquals("netx: warning type: test warning\n", l.getStream1()); 76 111 } 77 112 78 113 @Test 79 114 public void testLaunchError() { 80 ByteArrayOutputStream baos = new ByteArrayOutputStream();81 DefaultLaunchHandler handler = new DefaultLaunchHandler( new PrintStream(baos));115 LocalLogger l = new LocalLogger(); 116 DefaultLaunchHandler handler = new DefaultLaunchHandler(l); 82 117 83 118 LaunchException error = new LaunchException(null, null, … … 85 120 handler.launchError(error); 86 121 87 String output = baos.toString(); 88 assertEquals("netx: error type: test error\n", output); 122 assertEquals("netx: error type: test error\n", l.getStream1()); 89 123 } 90 124 91 125 @Test 92 126 public void testLaunchErrorWithCause() { 93 ByteArrayOutputStream baos = new ByteArrayOutputStream();94 DefaultLaunchHandler handler = new DefaultLaunchHandler( new PrintStream(baos));127 LocalLogger l = new LocalLogger(); 128 DefaultLaunchHandler handler = new DefaultLaunchHandler(l); 95 129 96 130 ParseException parse = new ParseException("no information element"); … … 99 133 handler.launchError(error); 100 134 101 String output = baos.toString(); 102 assertEquals("netx: error type: test error (no information element)\n", output); 135 assertEquals("netx: error type: test error (no information element)\n", l.getStream1()); 103 136 } 104 137 105 138 @Test 106 139 public void testLaunchErrorWithNestedCause() { 107 ByteArrayOutputStream baos = new ByteArrayOutputStream();108 DefaultLaunchHandler handler = new DefaultLaunchHandler( new PrintStream(baos));140 LocalLogger l = new LocalLogger(); 141 DefaultLaunchHandler handler = new DefaultLaunchHandler(l); 109 142 110 143 ParseException parse = new ParseException("no information element"); … … 114 147 handler.launchError(error); 115 148 116 String output = baos.toString(); 117 assertEquals("netx: error type: test error (programmer made a mistake (no information element))\n", output); 149 assertEquals("netx: error type: test error (programmer made a mistake (no information element))\n", l.getStream1()); 118 150 } 119 120 151 121 152 @Test 122 153 public void testValidationError() { 123 ByteArrayOutputStream baos = new ByteArrayOutputStream();124 DefaultLaunchHandler handler = new DefaultLaunchHandler( new PrintStream(baos));154 LocalLogger l = new LocalLogger(); 155 DefaultLaunchHandler handler = new DefaultLaunchHandler(l); 125 156 126 157 LaunchException error = new LaunchException(null, null, … … 128 159 handler.validationError(error); 129 160 130 String output = baos.toString(); 131 assertEquals("netx: validation-error type: test validation-error\n", output); 161 assertEquals("netx: validation-error type: test validation-error\n", l.getStream1()); 132 162 } 133 163 } -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java
r418 r429 38 38 package net.sourceforge.jnlp; 39 39 40 import java.io.ByteArrayInputStream; 41 import java.io.InputStream; 42 import java.net.MalformedURLException; 43 import java.net.URL; 40 44 import java.util.Locale; 45 import java.util.Map; 41 46 42 47 import net.sourceforge.jnlp.JNLPFile.Match; 48 import net.sourceforge.jnlp.annotations.Bug; 43 49 import net.sourceforge.jnlp.mock.MockJNLPFile; 50 import net.sourceforge.jnlp.util.logging.NoStdOutErrTest; 44 51 45 52 import org.junit.Assert; 46 53 import org.junit.Test; 47 54 48 public class JNLPFileTest {55 public class JNLPFileTest extends NoStdOutErrTest{ 49 56 Locale jvmLocale = new Locale("en", "CA", "utf8"); 50 57 MockJNLPFile file = new MockJNLPFile(jvmLocale); … … 104 111 file.localeMatches(jvmLocale, mismatchAvailable, Match.GENERALIZED)); 105 112 } 113 114 @Test 115 public void testCodebaseConstructorWithInputstreamAndCodebase() throws Exception { 116 String jnlpContext = "<?xml version=\"1.0\"?>\n" + 117 "<jnlp spec=\"1.5+\"\n" + 118 "href=\"EmbeddedJnlpFile.jnlp\"\n" + 119 "codebase=\"http://icedtea.claspath.org\"\n" + 120 ">\n" + 121 "" + 122 "<information>\n" + 123 "<title>Sample Test</title>\n" + 124 "<vendor>RedHat</vendor>\n" + 125 "<offline-allowed/>\n" + 126 "</information>\n" + 127 "\n" + 128 "<resources>\n" + 129 "<j2se version='1.6+' />\n" + 130 "<jar href='EmbeddedJnlpJarOne.jar' main='true'/>\n" + 131 "<jar href='EmbeddedJnlpJarTwo.jar' main='true'/>\n" + 132 "</resources>\n" + 133 "\n" + 134 "<applet-desc\n" + 135 "documentBase=\".\"\n" + 136 "name=\"redhat.embeddedjnlp\"\n" + 137 "main-class=\"redhat.embeddedjnlp\"\n" + 138 "width=\"0\"\n" + 139 "height=\"0\"\n" + 140 "/>\n" + 141 "</jnlp>"; 142 143 URL codeBase = new URL("http://www.redhat.com/"); 144 145 InputStream is = new ByteArrayInputStream(jnlpContext.getBytes()); 146 147 JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false,false,false)); 148 149 Assert.assertEquals("http://icedtea.claspath.org/", jnlpFile.getCodeBase().toExternalForm()); 150 Assert.assertEquals("redhat.embeddedjnlp", jnlpFile.getApplet().getMainClass()); 151 Assert.assertEquals("Sample Test", jnlpFile.getTitle()); 152 Assert.assertEquals(2, jnlpFile.getResources().getJARs().length); 153 } 154 155 @Test 156 public void testPropertyRestrictions() throws MalformedURLException, ParseException { 157 String jnlpContents = "<?xml version='1.0'?>\n" + 158 "<jnlp spec='1.5' href='foo' codebase='bar'>\n" + 159 " <information>\n" + 160 " <title>Parsing Test</title>\n" + 161 " <vendor>IcedTea</vendor>\n" + 162 " <offline-allowed/>\n" + 163 " </information>\n" + 164 " <resources>\n" + 165 " <property name='general' value='general'/>\n" + 166 " <property name='os' value='general'/>\n" + 167 " <property name='arch' value='general'/>\n" + 168 " </resources>\n" + 169 " <resources os='os1'>" + 170 " <property name='os' value='os1'/>\n" + 171 " </resources>\n" + 172 " <resources os='os1' arch='arch1'>" + 173 " <property name='arch' value='arch1'/>\n" + 174 " </resources>\n" + 175 " <resources os='os2' arch='arch2'>\n" + 176 " <property name='os' value='os2'/>\n" + 177 " <property name='arch' value='arch2'/>\n" + 178 " </resources>\n" + 179 " <installer-desc/>\n" + 180 "</jnlp>"; 181 182 URL codeBase = new URL("http://www.redhat.com/"); 183 InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); 184 JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false,false,false)); 185 186 ResourcesDesc resources; 187 Map<String,String> properties; 188 189 resources = jnlpFile.getResources(Locale.getDefault(), "os0", "arch0"); 190 properties = resources.getPropertiesMap(); 191 Assert.assertEquals("general", properties.get("general")); 192 Assert.assertEquals("general", properties.get("os")); 193 Assert.assertEquals("general", properties.get("arch")); 194 195 resources = jnlpFile.getResources(Locale.getDefault(), "os1", "arch0"); 196 properties = resources.getPropertiesMap(); 197 Assert.assertEquals("general", properties.get("general")); 198 Assert.assertEquals("os1", properties.get("os")); 199 Assert.assertEquals("general", properties.get("arch")); 200 201 resources = jnlpFile.getResources(Locale.getDefault(), "os1", "arch1"); 202 properties = resources.getPropertiesMap(); 203 Assert.assertEquals("general", properties.get("general")); 204 Assert.assertEquals("os1", properties.get("os")); 205 Assert.assertEquals("arch1", properties.get("arch")); 206 207 resources = jnlpFile.getResources(Locale.getDefault(), "os2", "arch2"); 208 properties = resources.getPropertiesMap(); 209 Assert.assertEquals("general", properties.get("general")); 210 Assert.assertEquals("os2", properties.get("os")); 211 Assert.assertEquals("arch2", properties.get("arch")); 212 } 213 214 @Bug(id={"PR1533"}) 215 @Test 216 public void testDownloadOptionsAppliedEverywhere() throws MalformedURLException, ParseException { 217 String os = System.getProperty("os.name"); 218 String arch = System.getProperty("os.arch"); 219 220 String jnlpContents = "<?xml version='1.0'?>\n" + 221 "<jnlp spec='1.5' href='foo' codebase='bar'>\n" + 222 " <information>\n" + 223 " <title>Parsing Test</title>\n" + 224 " <vendor>IcedTea</vendor>\n" + 225 " <offline-allowed/>\n" + 226 " </information>\n" + 227 " <resources>\n" + 228 " <property name='jnlp.packEnabled' value='false'/>" + 229 " <property name='jnlp.versionEnabled' value='false'/>" + 230 " </resources>\n" + 231 " <resources os='" + os + "'>" + 232 " <property name='jnlp.packEnabled' value='true'/>" + 233 " </resources>\n" + 234 " <resources arch='" + arch + "'>" + 235 " <property name='jnlp.versionEnabled' value='true'/>" + 236 " </resources>\n" + 237 " <installer-desc/>\n" + 238 "</jnlp>"; 239 240 URL codeBase = new URL("http://icedtea.classpath.org"); 241 InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); 242 JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false,false,false)); 243 DownloadOptions downloadOptions = jnlpFile.getDownloadOptions(); 244 245 Assert.assertTrue(downloadOptions.useExplicitPack()); 246 Assert.assertTrue(downloadOptions.useExplicitVersion()); 247 } 248 249 @Bug(id={"PR1533"}) 250 @Test 251 public void testDownloadOptionsFilteredOut() throws MalformedURLException, ParseException { 252 String jnlpContents = "<?xml version='1.0'?>\n" + 253 "<jnlp spec='1.5' href='foo' codebase='bar'>\n" + 254 " <information>\n" + 255 " <title>Parsing Test</title>\n" + 256 " <vendor>IcedTea</vendor>\n" + 257 " <offline-allowed/>\n" + 258 " </information>\n" + 259 " <resources>\n" + 260 " <property name='jnlp.packEnabled' value='false'/>" + 261 " <property name='jnlp.versionEnabled' value='false'/>" + 262 " </resources>\n" + 263 " <resources os='someOtherOs'>" + 264 " <property name='jnlp.packEnabled' value='true'/>" + 265 " </resources>\n" + 266 " <resources arch='someOtherArch'>" + 267 " <property name='jnlp.versionEnabled' value='true'/>" + 268 " </resources>\n" + 269 " <installer-desc/>\n" + 270 "</jnlp>"; 271 272 URL codeBase = new URL("http://icedtea.classpath.org"); 273 InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); 274 JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false,false,false)); 275 DownloadOptions downloadOptions = jnlpFile.getDownloadOptions(); 276 277 Assert.assertFalse(downloadOptions.useExplicitPack()); 278 Assert.assertFalse(downloadOptions.useExplicitVersion()); 279 } 280 281 282 public static final String minimalJnlp = "<?xml version='1.0'?>\n" 283 + "<jnlp spec='1.5' href='foo' codebase='.'>\n" 284 + " <information>\n" 285 + " <title>Parsing Test</title>\n" 286 + " <vendor>IcedTea</vendor>\n" 287 + " </information>\n" 288 + "<resources>\n" 289 + " </resources>\n" 290 + "SECURITY" 291 + "</jnlp>"; 292 293 @Test 294 public void testGetRequestedPermissionLevel1() throws MalformedURLException, ParseException { 295 String jnlpContents = minimalJnlp.replace("SECURITY", ""); 296 URL codeBase = new URL("http://icedtea.classpath.org"); 297 InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); 298 JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false, false, false)); 299 Assert.assertEquals(SecurityDesc.RequestedPermissionLevel.NONE, jnlpFile.getRequestedPermissionLevel()); 300 } 301 302 @Test 303 public void testGetRequestedPermissionLevel2() throws MalformedURLException, ParseException { 304 String jnlpContents = minimalJnlp.replace("SECURITY", "<security><"+SecurityDesc.RequestedPermissionLevel.ALL.toJnlpString()+"/></security>"); 305 306 URL codeBase = new URL("http://icedtea.classpath.org"); 307 InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); 308 JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false, false, false)); 309 Assert.assertEquals(SecurityDesc.RequestedPermissionLevel.ALL, jnlpFile.getRequestedPermissionLevel()); 310 } 311 312 @Test 313 public void testGetRequestedPermissionLevel3() throws MalformedURLException, ParseException { 314 String jnlpContents = minimalJnlp.replace("SECURITY", "<security></security>"); 315 316 URL codeBase = new URL("http://icedtea.classpath.org"); 317 InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); 318 JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false, false, false)); 319 Assert.assertEquals(SecurityDesc.RequestedPermissionLevel.NONE, jnlpFile.getRequestedPermissionLevel()); 320 } 321 322 @Test 323 public void testGetRequestedPermissionLevel4() throws MalformedURLException, ParseException { 324 String jnlpContents = minimalJnlp.replace("SECURITY", "<security>whatever</security>"); 325 326 URL codeBase = new URL("http://icedtea.classpath.org"); 327 InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); 328 JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false, false, false)); 329 Assert.assertEquals(SecurityDesc.RequestedPermissionLevel.NONE, jnlpFile.getRequestedPermissionLevel()); 330 } 331 332 @Test 333 public void testGetRequestedPermissionLevel5() throws MalformedURLException, ParseException { 334 String jnlpContents = minimalJnlp.replace("SECURITY", "<security><"+SecurityDesc.RequestedPermissionLevel.J2EE.toJnlpString()+"/></security>"); 335 336 URL codeBase = new URL("http://icedtea.classpath.org"); 337 InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); 338 JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false, false, false)); 339 Assert.assertEquals(SecurityDesc.RequestedPermissionLevel.J2EE, jnlpFile.getRequestedPermissionLevel()); 340 } 341 342 @Test 343 //unknown for jnlp 344 public void testGetRequestedPermissionLevel6() throws MalformedURLException, ParseException { 345 String jnlpContents = minimalJnlp.replace("SECURITY", "<security><" + SecurityDesc.RequestedPermissionLevel.SANDBOX.toHtmlString() + "/></security>"); 346 347 URL codeBase = new URL("http://icedtea.classpath.org"); 348 InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); 349 JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false, false, false)); 350 Assert.assertEquals(SecurityDesc.RequestedPermissionLevel.NONE, jnlpFile.getRequestedPermissionLevel()); 351 } 352 353 @Test 354 //unknown for jnlp 355 public void testGetRequestedPermissionLevel7() throws MalformedURLException, ParseException { 356 String jnlpContents = minimalJnlp.replace("SECURITY", "<security><" + SecurityDesc.RequestedPermissionLevel.DEFAULT.toHtmlString() + "/></security>"); 357 358 URL codeBase = new URL("http://icedtea.classpath.org"); 359 InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); 360 JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false, false, false)); 361 Assert.assertEquals(SecurityDesc.RequestedPermissionLevel.NONE, jnlpFile.getRequestedPermissionLevel()); 362 } 106 363 } -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/JNLPMatcherTest.java
r418 r429 72 72 "Testing by calling JNLPMatcher.match() multiple times. Checking to see if the returns value is consistent" }; 73 73 74 final ClassLoader cl = JNLPMatcherTest.class.getClassLoader();74 final ClassLoader cl = ClassLoader.getSystemClassLoader(); 75 75 76 76 private InputStreamReader getLaunchReader() { … … 467 467 } 468 468 469 @Test (timeout= 1000 /*ms*/)469 @Test (timeout=5000 /*ms*/) 470 470 public void testIsMatchDoesNotHangOnLargeData() throws JNLPMatcherException { 471 471 /* construct an alphabet containing characters 'a' to 'z' */ -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserBasic.java
r348 r429 38 38 package net.sourceforge.jnlp; 39 39 40 import java.io.ByteArrayInputStream;41 40 import java.io.InputStream; 42 41 import java.util.List; 43 44 import org.junit.After; 42 import net.sourceforge.jnlp.mock.DummyJNLPFile; 43 import net.sourceforge.jnlp.util.logging.NoStdOutErrTest; 44 45 45 import org.junit.Assert; 46 import org.junit.Before;47 46 import org.junit.BeforeClass; 48 47 import org.junit.Test; 49 48 50 49 /** Test that the parser works with basic jnlp files */ 51 public class ParserBasic {50 public class ParserBasic extends NoStdOutErrTest{ 52 51 53 52 private static Node root; … … 60 59 cl = ClassLoader.getSystemClassLoader(); 61 60 } 61 ParserSettings defaultParser = new ParserSettings(); 62 62 InputStream jnlpStream = cl.getResourceAsStream("net/sourceforge/jnlp/basic.jnlp"); 63 root = Parser.getRootNode(jnlpStream );64 parser = new Parser(n ull, null, root, false, false);63 root = Parser.getRootNode(jnlpStream, defaultParser); 64 parser = new Parser(new DummyJNLPFile(), null, root, defaultParser); 65 65 } 66 66 -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserCornerCases.java
r418 r429 51 51 /** Test various corner cases of the parser */ 52 52 public class ParserCornerCases { 53 private static final ParserSettings defaultParser = new ParserSettings(false, true,true); 53 54 54 55 @Test … … 64 65 Assert.assertTrue(target.getContent().contains("<entry key=\"key\">value</entry>")); 65 66 66 Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );67 Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 67 68 Assert.assertEquals("argument", node.getNodeName()); 68 69 String contents = node.getNodeValue(); … … 84 85 XMLElement elem = new XMLElement(); 85 86 elem.parseFromReader(new StringReader(data)); 86 XMLElement target = ( XMLElement) ((XMLElement)elem.enumerateChildren().nextElement()).enumerateChildren().nextElement();87 XMLElement target = (elem.enumerateChildren().nextElement()).enumerateChildren().nextElement(); 87 88 Assert.assertEquals("argument", target.getName()); 88 89 Assert.assertTrue("too small", target.getContent().length() > 20); … … 91 92 Assert.assertTrue(target.getContent().contains("<entry key=\"key\">value</entry>")); 92 93 93 Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );94 Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 94 95 node = node.getFirstChild().getFirstChild(); 95 96 Assert.assertEquals("argument", node.getNodeName()); … … 127 128 public void testUnsupportedSpecNumber() throws ParseException { 128 129 String malformedJnlp = "<?xml?><jnlp spec='11.11'></jnlp>"; 129 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()) );130 Parser parser = new Parser(null, null, root, false, false);130 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), defaultParser); 131 Parser parser = new Parser(null, null, root, defaultParser); 131 132 Assert.assertEquals("11.11", parser.getSpecVersion().toString()); 132 133 } … … 135 136 public void testApplicationAndComponent() throws ParseException { 136 137 String malformedJnlp = "<?xml?><jnlp><application-desc/><component-desc/></jnlp>"; 137 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()) );138 Parser parser = new Parser(null, null, root, false, false);138 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), defaultParser); 139 Parser parser = new Parser(null, null, root, defaultParser); 139 140 Assert.assertNotNull(parser.getLauncher(root)); 140 141 } … … 143 144 public void testCommentInElements() throws ParseException { 144 145 String malformedJnlp = "<?xml?><jnlp spec='1.0' <!-- comment -->> </jnlp>"; 145 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()) );146 Parser p = new Parser(null, null, root, false, false);146 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), defaultParser); 147 Parser p = new Parser(null, null, root, defaultParser); 147 148 Assert.assertEquals("1.0", p.getSpecVersion().toString()); 148 }149 150 @Test151 public void testCommentInElements2() throws ParseException {152 String malformedJnlp = "<?xml?><jnlp <!-- comment --> spec='1.0'> </jnlp>";153 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()));154 Parser p = new Parser(null, null, root, false, false);155 Assert.assertEquals("1.0", p.getSpecVersion().toString());156 }157 158 @Test159 @KnownToFail160 public void testCommentInAttributes() throws ParseException {161 String malformedJnlp = "<?xml?><jnlp spec='<!-- something -->'></jnlp>";162 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()));163 Parser p = new Parser(null, null, root, false, false);164 Assert.assertEquals("<!-- something -->", p.getSpecVersion().toString());165 149 } 166 150 … … 172 156 "<!-- outer <!-- inner --> -->" + 173 157 "</description></information></jnlp>"; 174 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()) );175 Parser p = new Parser(null, null, root, false, false);158 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), defaultParser); 159 Parser p = new Parser(null, null, root, defaultParser); 176 160 Assert.assertEquals(" -->", p.getInfo(root).get(0).getDescription()); 177 161 } … … 187 171 " <information/>" + 188 172 "</jnlp>"; 189 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes())); 190 Parser p = new Parser(null, null, root, false, false); 191 } 192 173 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), defaultParser); 174 Parser p = new Parser(null, null, root, defaultParser); 175 } 176 177 178 @Test 179 public void testCommentInElements2() throws ParseException { 180 String malformedJnlp = "<?xml?><jnlp <!-- comment --> spec='1.0'> </jnlp>"; 181 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), new ParserSettings(false, true,true)); 182 Parser p = new Parser(null, null, root, defaultParser); 183 //defaultis used 184 Assert.assertEquals("1.0+", p.getSpecVersion().toString()); 185 } 186 187 @Test 188 public void testCommentInElements2_malformedOff() throws ParseException { 189 String malformedJnlp = "<?xml?><jnlp <!-- comment --> spec='1.0'> </jnlp>"; 190 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), new ParserSettings(false, true,false)); 191 Parser p = new Parser(null, null, root, defaultParser); 192 Assert.assertEquals("1.0", p.getSpecVersion().toString()); 193 } 194 @Test 195 public void testCommentInAttributes() throws ParseException { 196 String malformedJnlp = "<?xml?><jnlp spec='<!-- something -->'></jnlp>"; 197 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), new ParserSettings(false, true,true)); 198 Parser p = new Parser(null, null, root, defaultParser); 199 Assert.assertEquals("<!-- something -->", p.getSpecVersion().toString()); 200 } 201 202 203 @Test 204 public void testCommentInAttributes_malformedOff() throws ParseException { 205 String malformedJnlp = "<?xml?><jnlp spec='<!-- something -->'></jnlp>"; 206 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), new ParserSettings(false, true,false)); 207 Parser p = new Parser(null, null, root, defaultParser); 208 //defaultis used 209 Assert.assertEquals("1.0+", p.getSpecVersion().toString()); 210 } 193 211 } -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserMalformedXml.java
r418 r429 52 52 53 53 private static String originalJnlp = null; 54 private static ParserSettings lenientParserSettings = new ParserSettings(false, true, true); 54 55 55 56 @BeforeClass … … 72 73 public void testMissingXmlDecleration() throws ParseException { 73 74 String malformedJnlp = originalJnlp.replaceFirst("<\\?xml.*\\?>", ""); 74 Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()) );75 Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), lenientParserSettings); 75 76 } 76 77 … … 79 80 public void testMalformedArguments() throws ParseException { 80 81 String malformedJnlp = originalJnlp.replace("arg2</argument", "arg2<argument"); 81 Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()) );82 Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), lenientParserSettings); 82 83 } 83 84 84 85 @Test 85 @KnownToFail86 86 public void testTagNotClosed() throws ParseException { 87 87 String malformedJnlp = originalJnlp.replace("</jnlp>", "<jnlp>"); 88 Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()) );88 Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), lenientParserSettings); 89 89 } 90 90 91 91 @Test 92 @KnownToFail93 92 public void testUnquotedAttributes() throws ParseException { 94 93 String malformedJnlp = originalJnlp.replace("'jnlp.jnlp'", "jnlp.jnlp"); 95 Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes())); 94 Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), lenientParserSettings); 95 } 96 97 @Test(expected = ParseException.class) 98 public void testTagNotClosedNoTagSoup() throws ParseException { 99 String malformedJnlp = originalJnlp.replace("</jnlp>", "<jnlp>"); 100 Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), new ParserSettings(false, true, false)); 101 } 102 103 @Test(expected = ParseException.class) 104 public void testUnquotedAttributesNoTagSoup() throws ParseException { 105 String malformedJnlp = originalJnlp.replace("'jnlp.jnlp'", "jnlp.jnlp"); 106 Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), new ParserSettings(false, true, false)); 96 107 } 97 108 -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserTest.java
r418 r429 39 39 40 40 import java.io.ByteArrayInputStream; 41 import java.net.URL; 41 42 import java.util.ArrayList; 42 43 import java.util.List; … … 58 59 private static final Locale ALL_LOCALE = new Locale(LANG, COUNTRY, VARIANT); 59 60 61 ParserSettings defaultParser=new ParserSettings(); 60 62 @Test(expected = MissingInformationException.class) 61 63 public void testMissingInfoFullLocale() throws ParseException { 62 64 String data = "<jnlp></jnlp>\n"; 63 65 64 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );65 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 66 67 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 68 Parser parser = new Parser(file, null, root, false, false);66 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 67 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 68 69 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 70 Parser parser = new Parser(file, null, root, defaultParser); 69 71 parser.getInfo(root); 70 72 } … … 77 79 + "</jnlp>\n"; 78 80 79 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );80 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 81 82 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 83 Parser parser = new Parser(file, null, root, false, false);81 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 82 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 83 84 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 85 Parser parser = new Parser(file, null, root, defaultParser); 84 86 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 85 87 infoDescs.addAll(parser.getInfo(root)); … … 100 102 + "</jnlp>\n"; 101 103 102 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );103 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 104 105 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 106 Parser parser = new Parser(file, null, root, false, false);104 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 105 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 106 107 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 108 Parser parser = new Parser(file, null, root, defaultParser); 107 109 List<InformationDesc> infoDescs = parser.getInfo(root); 108 110 … … 130 132 + "</jnlp>\n"; 131 133 132 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );133 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 134 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 135 Parser parser = new Parser(file, null, root, false, false);134 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 135 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 136 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 137 Parser parser = new Parser(file, null, root, defaultParser); 136 138 List<InformationDesc> infoDescs = parser.getInfo(root); 137 139 Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2); … … 157 159 + "</jnlp>\n"; 158 160 159 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );160 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 161 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 162 Parser parser = new Parser(file, null, root, false, false);161 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 162 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 163 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 164 Parser parser = new Parser(file, null, root, defaultParser); 163 165 List<InformationDesc> infoDescs = parser.getInfo(root); 164 166 Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2); … … 180 182 + "</jnlp>\n"; 181 183 182 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );183 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 184 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 185 Parser parser = new Parser(file, null, root, false, false);184 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 185 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 186 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 187 Parser parser = new Parser(file, null, root, defaultParser); 186 188 List<InformationDesc> infoDescs = parser.getInfo(root); 187 189 Assert.assertTrue("Exactly one info desc should be found", infoDescs.size() == 1); … … 211 213 + "</jnlp>\n"; 212 214 213 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );214 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 215 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 216 Parser parser = new Parser(file, null, root, false, false);215 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 216 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 217 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 218 Parser parser = new Parser(file, null, root, defaultParser); 217 219 List<InformationDesc> infoDescs = parser.getInfo(root); 218 220 Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3); … … 242 244 + "</jnlp>\n"; 243 245 244 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );245 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 246 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 247 Parser parser = new Parser(file, null, root, false, false);246 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 247 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 248 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 249 Parser parser = new Parser(file, null, root, defaultParser); 248 250 List<InformationDesc> infoDescs = parser.getInfo(root); 249 251 Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3); … … 272 274 + "</jnlp>\n"; 273 275 274 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );275 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 276 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 277 Parser parser = new Parser(file, null, root, false, false);276 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 277 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 278 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 279 Parser parser = new Parser(file, null, root, defaultParser); 278 280 List<InformationDesc> infoDescs = parser.getInfo(root); 279 281 Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3); … … 301 303 + "</jnlp>\n"; 302 304 303 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );304 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 305 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 306 Parser parser = new Parser(file, null, root, false, false);305 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 306 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 307 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 308 Parser parser = new Parser(file, null, root, defaultParser); 307 309 List<InformationDesc> infoDescs = parser.getInfo(root); 308 310 Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3); … … 329 331 + "</jnlp>\n"; 330 332 331 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );332 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 333 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 334 Parser parser = new Parser(file, null, root, false, false);333 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 334 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 335 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 336 Parser parser = new Parser(file, null, root, defaultParser); 335 337 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 336 338 infoDescs.addAll(parser.getInfo(root)); … … 356 358 + "</jnlp>\n"; 357 359 358 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );359 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 360 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 361 Parser parser = new Parser(file, null, root, false, false);360 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 361 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 362 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 363 Parser parser = new Parser(file, null, root, defaultParser); 362 364 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 363 365 infoDescs.addAll(parser.getInfo(root)); … … 380 382 + "</jnlp>\n"; 381 383 382 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );383 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 384 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 385 Parser parser = new Parser(file, null, root, false, false);384 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 385 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 386 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 387 Parser parser = new Parser(file, null, root, defaultParser); 386 388 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 387 389 infoDescs.addAll(parser.getInfo(root)); … … 404 406 + "</jnlp>\n"; 405 407 406 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );407 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 408 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 409 Parser parser = new Parser(file, null, root, false, false);408 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 409 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 410 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 411 Parser parser = new Parser(file, null, root, defaultParser); 410 412 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 411 413 infoDescs.addAll(parser.getInfo(root)); … … 426 428 + "</jnlp>\n"; 427 429 428 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );429 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 430 431 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 432 Parser parser = new Parser(file, null, root, false, false);430 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 431 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 432 433 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 434 Parser parser = new Parser(file, null, root, defaultParser); 433 435 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 434 436 infoDescs.addAll(parser.getInfo(root)); … … 449 451 + "</jnlp>\n"; 450 452 451 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );452 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 453 454 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 455 Parser parser = new Parser(file, null, root, false, false);453 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 454 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 455 456 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 457 Parser parser = new Parser(file, null, root, defaultParser); 456 458 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 457 459 infoDescs.addAll(parser.getInfo(root)); … … 488 490 + "</jnlp>\n"; 489 491 490 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );491 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 492 493 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 494 Parser parser = new Parser(file, null, root, false, false);492 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 493 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 494 495 MockJNLPFile file = new MockJNLPFile(ALL_LOCALE); 496 Parser parser = new Parser(file, null, root, defaultParser); 495 497 List<InformationDesc> infoDescs = parser.getInfo(root); 496 498 … … 511 513 String data = "<jnlp></jnlp>\n"; 512 514 513 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );514 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 515 516 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 517 Parser parser = new Parser(file, null, root, false, false);515 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 516 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 517 518 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 519 Parser parser = new Parser(file, null, root, defaultParser); 518 520 parser.getInfo(root); 519 521 } … … 526 528 + "</jnlp>\n"; 527 529 528 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );529 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 530 531 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 532 Parser parser = new Parser(file, null, root, false, false);530 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 531 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 532 533 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 534 Parser parser = new Parser(file, null, root, defaultParser); 533 535 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 534 536 infoDescs.addAll(parser.getInfo(root)); … … 549 551 + "</jnlp>\n"; 550 552 551 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );552 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 553 554 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 555 Parser parser = new Parser(file, null, root, false, false);553 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 554 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 555 556 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 557 Parser parser = new Parser(file, null, root, defaultParser); 556 558 List<InformationDesc> infoDescs = parser.getInfo(root); 557 559 … … 575 577 + "</jnlp>\n"; 576 578 577 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );578 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 579 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 580 Parser parser = new Parser(file, null, root, false, false);579 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 580 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 581 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 582 Parser parser = new Parser(file, null, root, defaultParser); 581 583 List<InformationDesc> infoDescs = parser.getInfo(root); 582 584 Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2); … … 602 604 + "</jnlp>\n"; 603 605 604 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );605 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 606 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 607 Parser parser = new Parser(file, null, root, false, false);606 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 607 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 608 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 609 Parser parser = new Parser(file, null, root, defaultParser); 608 610 List<InformationDesc> infoDescs = parser.getInfo(root); 609 611 Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2); … … 625 627 + "</jnlp>\n"; 626 628 627 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );628 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 629 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 630 Parser parser = new Parser(file, null, root, false, false);629 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 630 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 631 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 632 Parser parser = new Parser(file, null, root, defaultParser); 631 633 List<InformationDesc> infoDescs = parser.getInfo(root); 632 634 Assert.assertTrue("Exactly one info desc should be found", infoDescs.size() == 1); … … 656 658 + "</jnlp>\n"; 657 659 658 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );659 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 660 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 661 Parser parser = new Parser(file, null, root, false, false);660 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 661 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 662 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 663 Parser parser = new Parser(file, null, root, defaultParser); 662 664 List<InformationDesc> infoDescs = parser.getInfo(root); 663 665 Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3); … … 687 689 + "</jnlp>\n"; 688 690 689 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );690 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 691 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 692 Parser parser = new Parser(file, null, root, false, false);691 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 692 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 693 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 694 Parser parser = new Parser(file, null, root, defaultParser); 693 695 List<InformationDesc> infoDescs = parser.getInfo(root); 694 696 Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3); … … 717 719 + "</jnlp>\n"; 718 720 719 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );720 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 721 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 722 Parser parser = new Parser(file, null, root, false, false);721 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 722 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 723 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 724 Parser parser = new Parser(file, null, root, defaultParser); 723 725 List<InformationDesc> infoDescs = parser.getInfo(root); 724 726 Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3); … … 746 748 + "</jnlp>\n"; 747 749 748 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );749 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 750 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 751 Parser parser = new Parser(file, null, root, false, false);750 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 751 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 752 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 753 Parser parser = new Parser(file, null, root, defaultParser); 752 754 List<InformationDesc> infoDescs = parser.getInfo(root); 753 755 Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3); … … 774 776 + "</jnlp>\n"; 775 777 776 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );777 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 778 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 779 Parser parser = new Parser(file, null, root, false, false);778 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 779 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 780 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 781 Parser parser = new Parser(file, null, root, defaultParser); 780 782 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 781 783 infoDescs.addAll(parser.getInfo(root)); … … 801 803 + "</jnlp>\n"; 802 804 803 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );804 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 805 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 806 Parser parser = new Parser(file, null, root, false, false);805 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 806 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 807 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 808 Parser parser = new Parser(file, null, root, defaultParser); 807 809 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 808 810 infoDescs.addAll(parser.getInfo(root)); … … 825 827 + "</jnlp>\n"; 826 828 827 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );828 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 829 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 830 Parser parser = new Parser(file, null, root, false, false);829 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 830 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 831 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 832 Parser parser = new Parser(file, null, root, defaultParser); 831 833 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 832 834 infoDescs.addAll(parser.getInfo(root)); … … 849 851 + "</jnlp>\n"; 850 852 851 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );852 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 853 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 854 Parser parser = new Parser(file, null, root, false, false);853 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 854 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 855 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 856 Parser parser = new Parser(file, null, root, defaultParser); 855 857 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 856 858 infoDescs.addAll(parser.getInfo(root)); … … 871 873 + "</jnlp>\n"; 872 874 873 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );874 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 875 876 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 877 Parser parser = new Parser(file, null, root, false, false);875 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 876 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 877 878 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 879 Parser parser = new Parser(file, null, root, defaultParser); 878 880 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 879 881 infoDescs.addAll(parser.getInfo(root)); … … 894 896 + "</jnlp>\n"; 895 897 896 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );897 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 898 899 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 900 Parser parser = new Parser(file, null, root, false, false);898 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 899 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 900 901 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 902 Parser parser = new Parser(file, null, root, defaultParser); 901 903 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 902 904 infoDescs.addAll(parser.getInfo(root)); … … 933 935 + "</jnlp>\n"; 934 936 935 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );936 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 937 938 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 939 Parser parser = new Parser(file, null, root, false, false);937 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 938 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 939 940 MockJNLPFile file = new MockJNLPFile(LANG_COUNTRY_LOCALE); 941 Parser parser = new Parser(file, null, root, defaultParser); 940 942 List<InformationDesc> infoDescs = parser.getInfo(root); 941 943 … … 956 958 String data = "<jnlp></jnlp>\n"; 957 959 958 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );959 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 960 961 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 962 Parser parser = new Parser(file, null, root, false, false);960 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 961 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 962 963 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 964 Parser parser = new Parser(file, null, root, defaultParser); 963 965 parser.getInfo(root); 964 966 } … … 971 973 + "</jnlp>\n"; 972 974 973 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );974 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 975 976 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 977 Parser parser = new Parser(file, null, root, false, false);975 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 976 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 977 978 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 979 Parser parser = new Parser(file, null, root, defaultParser); 978 980 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 979 981 infoDescs.addAll(parser.getInfo(root)); … … 994 996 + "</jnlp>\n"; 995 997 996 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );997 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 998 999 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1000 Parser parser = new Parser(file, null, root, false, false);998 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 999 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1000 1001 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1002 Parser parser = new Parser(file, null, root, defaultParser); 1001 1003 List<InformationDesc> infoDescs = parser.getInfo(root); 1002 1004 … … 1016 1018 + "</jnlp>\n"; 1017 1019 1018 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1019 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1020 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1021 Parser parser = new Parser(file, null, root, false, false);1020 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1021 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1022 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1023 Parser parser = new Parser(file, null, root, defaultParser); 1022 1024 List<InformationDesc> infoDescs = parser.getInfo(root); 1023 1025 Assert.assertTrue("Exactly one info desc should be found", infoDescs.size() == 1); … … 1040 1042 + "</jnlp>\n"; 1041 1043 1042 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1043 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1044 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1045 Parser parser = new Parser(file, null, root, false, false);1044 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1045 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1046 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1047 Parser parser = new Parser(file, null, root, defaultParser); 1046 1048 List<InformationDesc> infoDescs = parser.getInfo(root); 1047 1049 Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2); … … 1063 1065 + "</jnlp>\n"; 1064 1066 1065 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1066 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1067 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1068 Parser parser = new Parser(file, null, root, false, false);1067 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1068 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1069 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1070 Parser parser = new Parser(file, null, root, defaultParser); 1069 1071 List<InformationDesc> infoDescs = parser.getInfo(root); 1070 1072 Assert.assertTrue("Exactly one info desc should be found", infoDescs.size() == 1); … … 1094 1096 + "</jnlp>\n"; 1095 1097 1096 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1097 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1098 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1099 Parser parser = new Parser(file, null, root, false, false);1098 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1099 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1100 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1101 Parser parser = new Parser(file, null, root, defaultParser); 1100 1102 List<InformationDesc> infoDescs = parser.getInfo(root); 1101 1103 Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3); … … 1125 1127 + "</jnlp>\n"; 1126 1128 1127 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1128 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1129 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1130 Parser parser = new Parser(file, null, root, false, false);1129 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1130 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1131 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1132 Parser parser = new Parser(file, null, root, defaultParser); 1131 1133 List<InformationDesc> infoDescs = parser.getInfo(root); 1132 1134 Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3); … … 1151 1153 + "</jnlp>\n"; 1152 1154 1153 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1154 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1155 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1156 Parser parser = new Parser(file, null, root, false, false);1155 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1156 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1157 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1158 Parser parser = new Parser(file, null, root, defaultParser); 1157 1159 List<InformationDesc> infoDescs = parser.getInfo(root); 1158 1160 Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2); … … 1179 1181 + "</jnlp>\n"; 1180 1182 1181 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1182 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1183 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1184 Parser parser = new Parser(file, null, root, false, false);1183 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1184 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1185 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1186 Parser parser = new Parser(file, null, root, defaultParser); 1185 1187 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 1186 1188 infoDescs.addAll(parser.getInfo(root)); … … 1206 1208 + "</jnlp>\n"; 1207 1209 1208 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1209 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1210 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1211 Parser parser = new Parser(file, null, root, false, false);1210 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1211 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1212 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1213 Parser parser = new Parser(file, null, root, defaultParser); 1212 1214 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 1213 1215 infoDescs.addAll(parser.getInfo(root)); … … 1230 1232 + "</jnlp>\n"; 1231 1233 1232 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1233 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1234 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1235 Parser parser = new Parser(file, null, root, false, false);1234 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1235 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1236 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1237 Parser parser = new Parser(file, null, root, defaultParser); 1236 1238 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 1237 1239 infoDescs.addAll(parser.getInfo(root)); … … 1254 1256 + "</jnlp>\n"; 1255 1257 1256 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1257 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1258 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1259 Parser parser = new Parser(file, null, root, false, false);1258 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1259 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1260 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1261 Parser parser = new Parser(file, null, root, defaultParser); 1260 1262 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 1261 1263 infoDescs.addAll(parser.getInfo(root)); … … 1276 1278 + "</jnlp>\n"; 1277 1279 1278 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1279 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1280 1281 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1282 Parser parser = new Parser(file, null, root, false, false);1280 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1281 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1282 1283 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1284 Parser parser = new Parser(file, null, root, defaultParser); 1283 1285 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 1284 1286 infoDescs.addAll(parser.getInfo(root)); … … 1299 1301 + "</jnlp>\n"; 1300 1302 1301 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1302 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1303 1304 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1305 Parser parser = new Parser(file, null, root, false, false);1303 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1304 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1305 1306 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1307 Parser parser = new Parser(file, null, root, defaultParser); 1306 1308 List<InformationDesc> infoDescs = new ArrayList<InformationDesc>(); 1307 1309 infoDescs.addAll(parser.getInfo(root)); … … 1338 1340 + "</jnlp>\n"; 1339 1341 1340 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()) );1341 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1342 1343 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1344 Parser parser = new Parser(file, null, root, false, false);1342 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1343 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1344 1345 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1346 Parser parser = new Parser(file, null, root, defaultParser); 1345 1347 List<InformationDesc> infoDescs = parser.getInfo(root); 1346 1348 … … 1356 1358 parser.checkForInformation(); 1357 1359 } 1360 1361 @Test 1362 public void testOverwrittenCodebaseWithValidJnlpCodebase() throws Exception { 1363 String data = "<?xml version=\"1.0\"?>\n" + 1364 "<jnlp spec=\"1.5+\"\n" + 1365 "href=\"EmbeddedJnlpFile.jnlp\"\n" + 1366 "codebase=\"http://www.redhat.com/\"\n" + 1367 ">\n" + 1368 "</jnlp>"; 1369 1370 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1371 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1372 URL overwrittenCodebase = new URL("http://icedtea.classpath.org"); 1373 1374 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1375 Parser parser = new Parser(file, null, root, defaultParser, overwrittenCodebase); 1376 1377 Assert.assertEquals("http://www.redhat.com/", parser.getCodeBase().toExternalForm()); 1378 } 1379 1380 @Test 1381 public void testOverwrittenCodebaseWithInvalidJnlpCodebase() throws Exception { 1382 String data = "<?xml version=\"1.0\"?>\n" + 1383 "<jnlp spec=\"1.5+\"\n" + 1384 "href=\"EmbeddedJnlpFile.jnlp\"\n" + 1385 "codebase=\"this codebase is incorrect\"\n" + 1386 ">\n" + 1387 "</jnlp>"; 1388 1389 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1390 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1391 URL overwrittenCodebase = new URL("http://icedtea.classpath.org"); 1392 1393 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1394 Parser parser = new Parser(file, null, root, defaultParser, overwrittenCodebase); 1395 1396 Assert.assertEquals(overwrittenCodebase.toExternalForm(), parser.getCodeBase().toExternalForm()); 1397 } 1398 1399 @Test 1400 public void testOverwrittenCodebaseWithNoJnlpCodebase() throws Exception { 1401 String data = "<?xml version=\"1.0\"?>\n" + 1402 "<jnlp spec=\"1.5+\"\n" + 1403 "href=\"EmbeddedJnlpFile.jnlp\"\n" + 1404 ">\n" + 1405 "</jnlp>"; 1406 1407 Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser); 1408 Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName()); 1409 URL overwrittenCodebase = new URL("http://icedtea.classpath.org"); 1410 1411 MockJNLPFile file = new MockJNLPFile(LANG_LOCALE); 1412 Parser parser = new Parser(file, null, root, defaultParser, overwrittenCodebase); 1413 1414 Assert.assertEquals(overwrittenCodebase.toExternalForm(), parser.getCodeBase().toExternalForm()); 1415 } 1358 1416 } -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java
r418 r429 28 28 import java.net.MalformedURLException; 29 29 import java.net.URL; 30 import java.util.ArrayList; 30 31 import java.util.HashMap; 32 import java.util.Map; 31 33 import java.util.Hashtable; 34 import java.util.List; 32 35 33 36 import net.sourceforge.jnlp.cache.UpdatePolicy; 37 import net.sourceforge.jnlp.util.replacements.BASE64Encoder; 38 import org.junit.Assert; 34 39 35 40 import org.junit.Test; … … 44 49 } 45 50 46 public JNLPFile create(URL location, Version version, boolean strict, 51 @Override 52 public JNLPFile create(URL location, Version version, ParserSettings settings, 47 53 UpdatePolicy policy, URL forceCodebase) throws IOException, ParseException { 48 54 JNLPHref = location; … … 61 67 } 62 68 69 static private PluginParameters createValidParamObject() { 70 Map<String, String> params = new HashMap<String, String>(); 71 params.put("code", ""); // Avoids an exception being thrown 72 return new PluginParameters(params); 73 } 74 63 75 @Test 64 76 public void testAbsoluteJNLPHref() throws MalformedURLException, Exception { 65 77 URL codeBase = new URL("http://undesired.absolute.codebase.com"); 66 78 String absoluteLocation = "http://absolute.href.com/test.jnlp"; 67 Hashtable<String, String> atts = new Hashtable<String, String>();68 atts.put("jnlp_href", absoluteLocation);69 MockJNLPCreator mockCreator = new MockJNLPCreator(); 70 PluginBridge pb = new PluginBridge(codeBase, null, "", "", 0, 0, atts, "", mockCreator);79 PluginParameters params = createValidParamObject(); 80 params.put("jnlp_href", absoluteLocation); 81 MockJNLPCreator mockCreator = new MockJNLPCreator(); 82 PluginBridge pb = new PluginBridge(codeBase, null, "", "", 0, 0, params, mockCreator); 71 83 assertEquals(absoluteLocation, mockCreator.getJNLPHref().toExternalForm()); 72 84 } … … 76 88 URL codeBase = new URL("http://desired.absolute.codebase.com/"); 77 89 String relativeLocation = "sub/dir/test.jnlp"; 78 Hashtable<String, String> atts = new Hashtable<String, String>();79 atts.put("jnlp_href", relativeLocation);80 MockJNLPCreator mockCreator = new MockJNLPCreator(); 81 PluginBridge pb = new PluginBridge(codeBase, null, "", "", 0, 0, atts, "", mockCreator);90 PluginParameters params = createValidParamObject(); 91 params.put("jnlp_href", relativeLocation); 92 MockJNLPCreator mockCreator = new MockJNLPCreator(); 93 PluginBridge pb = new PluginBridge(codeBase, null, "", "", 0, 0, params, mockCreator); 82 94 assertEquals(codeBase.toExternalForm() + relativeLocation, 83 95 mockCreator.getJNLPHref().toExternalForm()); 84 96 } 85 97 … … 89 101 URL codeBase = new URL(desiredDomain + "/undesired/sub/dir"); 90 102 String relativeLocation = "/app/test/test.jnlp"; 91 Hashtable<String, String> atts = new Hashtable<String, String>();92 atts.put("jnlp_href", relativeLocation);93 MockJNLPCreator mockCreator = new MockJNLPCreator(); 94 PluginBridge pb = new PluginBridge(codeBase, null, "", "", 0, 0, atts, "", mockCreator);103 PluginParameters params = createValidParamObject(); 104 params.put("jnlp_href", relativeLocation); 105 MockJNLPCreator mockCreator = new MockJNLPCreator(); 106 PluginBridge pb = new PluginBridge(codeBase, null, "", "", 0, 0, params, mockCreator); 95 107 assertEquals(desiredDomain + relativeLocation, 96 mockCreator.getJNLPHref().toExternalForm()); 97 } 98 108 mockCreator.getJNLPHref().toExternalForm()); 109 } 110 111 @Test 112 public void testGetRequestedPermissionLevel() throws MalformedURLException, Exception { 113 String desiredDomain = "http://desired.absolute.codebase.com"; 114 URL codeBase = new URL(desiredDomain + "/undesired/sub/dir"); 115 String relativeLocation = "/app/test/test.jnlp"; 116 PluginParameters params = createValidParamObject(); 117 params.put("jnlp_href", relativeLocation); 118 MockJNLPCreator mockCreator = new MockJNLPCreator(); 119 PluginBridge pb = new PluginBridge(codeBase, null, "", "", 0, 0, params, mockCreator); 120 assertEquals(pb.getRequestedPermissionLevel(), SecurityDesc.RequestedPermissionLevel.NONE); 121 122 params.put(SecurityDesc.RequestedPermissionLevel.PERMISSIONS_NAME,SecurityDesc.RequestedPermissionLevel.ALL.toHtmlString()); 123 pb = new PluginBridge(codeBase, null, "", "", 0, 0, params, mockCreator); 124 assertEquals(pb.getRequestedPermissionLevel(), SecurityDesc.RequestedPermissionLevel.ALL); 125 126 //unknown for applets! 127 params.put(SecurityDesc.RequestedPermissionLevel.PERMISSIONS_NAME, SecurityDesc.RequestedPermissionLevel.J2EE.toJnlpString()); 128 pb = new PluginBridge(codeBase, null, "", "", 0, 0, params, mockCreator); 129 assertEquals(pb.getRequestedPermissionLevel(), SecurityDesc.RequestedPermissionLevel.NONE); 130 131 params.put(SecurityDesc.RequestedPermissionLevel.PERMISSIONS_NAME, SecurityDesc.RequestedPermissionLevel.SANDBOX.toHtmlString()); 132 pb = new PluginBridge(codeBase, null, "", "", 0, 0, params, mockCreator); 133 assertEquals(pb.getRequestedPermissionLevel(), SecurityDesc.RequestedPermissionLevel.SANDBOX); 134 135 params.put(SecurityDesc.RequestedPermissionLevel.PERMISSIONS_NAME, SecurityDesc.RequestedPermissionLevel.DEFAULT.toHtmlString()); 136 pb = new PluginBridge(codeBase, null, "", "", 0, 0, params, mockCreator); 137 assertEquals(pb.getRequestedPermissionLevel(), SecurityDesc.RequestedPermissionLevel.NONE); 138 } 139 140 @Test 141 public void testBase64StringDecoding() throws Exception { 142 String actualFile = "This is a sample string that will be encoded to" + 143 "a Base64 string and then decoded using PluginBridge's" + 144 "decoding method and compared."; 145 146 BASE64Encoder encoder = new BASE64Encoder(); 147 String encodedFile = encoder.encodeBuffer(actualFile.getBytes()); 148 149 byte[] decodedBytes = PluginBridge.decodeBase64String(encodedFile); 150 String decodedString = new String(decodedBytes); 151 Assert.assertEquals(actualFile, decodedString); 152 } 153 154 @Test 155 public void testEmbeddedJnlpWithValidCodebase() throws Exception { 156 URL codeBase = new URL("http://icedtea.classpath.org"); 157 String relativeLocation = "/EmbeddedJnlpFile.jnlp"; 158 159 //Codebase within jnlp file is VALID 160 /** 161 <?xml version="1.0"?> 162 <jnlp spec="1.5+" 163 href="EmbeddedJnlpFile.jnlp" 164 codebase="http://www.redhat.com" 165 > 166 167 <information> 168 <title>Sample Test</title> 169 <vendor>RedHat</vendor> 170 <offline-allowed/> 171 </information> 172 173 <resources> 174 <j2se version='1.6+' /> 175 <jar href='EmbeddedJnlpJarOne.jar' main='true' /> 176 <jar href='EmbeddedJnlpJarTwo.jar' main='true' /> 177 </resources> 178 179 <applet-desc 180 documentBase="." 181 name="redhat.embeddedjnlp" 182 main-class="redhat.embeddedjnlp" 183 width="0" 184 height="0" 185 /> 186 </jnlp> 187 **/ 188 189 String jnlpFileEncoded = "ICAgICAgICA8P3htbCB2ZXJzaW9uPSIxLjAiPz4NCiAgICAgICAgICAgIDxqbmxwIHNwZWM9IjEu" + 190 "NSsiIA0KICAgICAgICAgICAgICBocmVmPSJFbWJlZGRlZEpubHBGaWxlLmpubHAiIA0KICAgICAg" + 191 "ICAgICAgICBjb2RlYmFzZT0iaHR0cDovL3d3dy5yZWRoYXQuY29tIiAgICANCiAgICAgICAgICAg" + 192 "ID4NCg0KICAgICAgICAgICAgPGluZm9ybWF0aW9uPg0KICAgICAgICAgICAgICAgIDx0aXRsZT5T" + 193 "YW1wbGUgVGVzdDwvdGl0bGU+DQogICAgICAgICAgICAgICAgPHZlbmRvcj5SZWRIYXQ8L3ZlbmRv" + 194 "cj4NCiAgICAgICAgICAgICAgICA8b2ZmbGluZS1hbGxvd2VkLz4NCiAgICAgICAgICAgIDwvaW5m" + 195 "b3JtYXRpb24+DQoNCiAgICAgICAgICAgIDxyZXNvdXJjZXM+DQogICAgICAgICAgICAgICAgPGoy" + 196 "c2UgdmVyc2lvbj0nMS42KycgLz4NCiAgICAgICAgICAgICAgICA8amFyIGhyZWY9J0VtYmVkZGVk" + 197 "Sm5scEphck9uZS5qYXInIG1haW49J3RydWUnIC8+DQogICAgICAgICAgICAgICAgPGphciBocmVm" + 198 "PSdFbWJlZGRlZEpubHBKYXJUd28uamFyJyBtYWluPSd0cnVlJyAvPg0KICAgICAgICAgICAgPC9y" + 199 "ZXNvdXJjZXM+DQoNCiAgICAgICAgICAgIDxhcHBsZXQtZGVzYw0KICAgICAgICAgICAgICAgIGRv" + 200 "Y3VtZW50QmFzZT0iLiINCiAgICAgICAgICAgICAgICBuYW1lPSJyZWRoYXQuZW1iZWRkZWRqbmxw" + 201 "Ig0KICAgICAgICAgICAgICAgIG1haW4tY2xhc3M9InJlZGhhdC5lbWJlZGRlZGpubHAiDQogICAg" + 202 "ICAgICAgICAgICAgd2lkdGg9IjAiDQogICAgICAgICAgICAgICAgaGVpZ2h0PSIwIg0KICAgICAg" + 203 "ICAgICAgLz4NCiAgICAgICAgICAgIDwvam5scD4="; 204 205 MockJNLPCreator mockCreator = new MockJNLPCreator(); 206 PluginParameters params = createValidParamObject(); 207 params.put("jnlp_href", relativeLocation); 208 params.put("jnlp_embedded", jnlpFileEncoded); 209 210 String jnlpCodebase = "http://www.redhat.com"; 211 PluginBridge pb = new PluginBridge(codeBase, null, "", "", 0, 0, params, mockCreator); 212 JARDesc[] jars = pb.getResources().getJARs(); 213 214 //Check if there are two jars cached 215 Assert.assertTrue(jars.length == 2); 216 217 //Resource can be in any order 218 List<String> resourceLocations = new ArrayList<String>(); 219 resourceLocations.add(jars[0].getLocation().toExternalForm()); 220 resourceLocations.add(jars[1].getLocation().toExternalForm()); 221 222 //Check URLs of jars 223 Assert.assertTrue(resourceLocations.contains(jnlpCodebase + "/EmbeddedJnlpJarOne.jar")); 224 Assert.assertTrue((resourceLocations.contains(jnlpCodebase + "/EmbeddedJnlpJarTwo.jar"))); 225 } 226 227 @Test 228 //http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/applet/codebase_determination.html 229 //example 3 230 public void testEmbeddedJnlpWithInvalidCodebase() throws Exception { 231 URL overwrittenCodebase = new URL("http://icedtea.classpath.org"); 232 String relativeLocation = "/EmbeddedJnlpFile.jnlp"; 233 234 //Codebase within jnlp file is INVALID 235 /** 236 <?xml version="1.0"?> 237 <jnlp spec="1.5+" 238 href="EmbeddedJnlpFile.jnlp" 239 codebase="invalidPath" 240 > 241 242 <information> 243 <title>Sample Test</title> 244 <vendor>RedHat</vendor> 245 <offline-allowed/> 246 </information> 247 248 <resources> 249 <j2se version='1.6+' /> 250 <jar href='EmbeddedJnlpJarOne.jar' main='true' /> 251 <jar href='EmbeddedJnlpJarTwo.jar' main='true' /> 252 </resources> 253 254 <applet-desc 255 documentBase="." 256 name="redhat.embeddedjnlp" 257 main-class="redhat.embeddedjnlp" 258 width="0" 259 height="0" 260 /> 261 </jnlp> 262 **/ 263 264 String jnlpFileEncoded = "ICAgICAgICA8P3htbCB2ZXJzaW9uPSIxLjAiPz4NCiAgICAgICAgICAgIDxqbmxwIHNwZWM9IjEu" + 265 "NSsiIA0KICAgICAgICAgICAgICBocmVmPSJFbWJlZGRlZEpubHBGaWxlLmpubHAiIA0KICAgICAg" + 266 "ICAgICAgICBjb2RlYmFzZT0iaW52YWxpZFBhdGgiICAgIA0KICAgICAgICAgICAgPg0KDQogICAg" + 267 "ICAgICAgICA8aW5mb3JtYXRpb24+DQogICAgICAgICAgICAgICAgPHRpdGxlPlNhbXBsZSBUZXN0" + 268 "PC90aXRsZT4NCiAgICAgICAgICAgICAgICA8dmVuZG9yPlJlZEhhdDwvdmVuZG9yPg0KICAgICAg" + 269 "ICAgICAgICAgIDxvZmZsaW5lLWFsbG93ZWQvPg0KICAgICAgICAgICAgPC9pbmZvcm1hdGlvbj4N" + 270 "Cg0KICAgICAgICAgICAgPHJlc291cmNlcz4NCiAgICAgICAgICAgICAgICA8ajJzZSB2ZXJzaW9u" + 271 "PScxLjYrJyAvPg0KICAgICAgICAgICAgICAgIDxqYXIgaHJlZj0nRW1iZWRkZWRKbmxwSmFyT25l" + 272 "LmphcicgbWFpbj0ndHJ1ZScgLz4NCiAgICAgICAgICAgICAgICA8amFyIGhyZWY9J0VtYmVkZGVk" + 273 "Sm5scEphclR3by5qYXInIG1haW49J3RydWUnIC8+DQogICAgICAgICAgICA8L3Jlc291cmNlcz4N" + 274 "Cg0KICAgICAgICAgICAgPGFwcGxldC1kZXNjDQogICAgICAgICAgICAgICAgZG9jdW1lbnRCYXNl" + 275 "PSIuIg0KICAgICAgICAgICAgICAgIG5hbWU9InJlZGhhdC5lbWJlZGRlZGpubHAiDQogICAgICAg" + 276 "ICAgICAgICAgbWFpbi1jbGFzcz0icmVkaGF0LmVtYmVkZGVkam5scCINCiAgICAgICAgICAgICAg" + 277 "ICB3aWR0aD0iMCINCiAgICAgICAgICAgICAgICBoZWlnaHQ9IjAiDQogICAgICAgICAgICAvPg0K" + 278 "ICAgICAgICAgICAgPC9qbmxwPg=="; 279 280 MockJNLPCreator mockCreator = new MockJNLPCreator(); 281 PluginParameters params = createValidParamObject(); 282 params.put("jnlp_href", relativeLocation); 283 params.put("jnlp_embedded", jnlpFileEncoded); 284 285 PluginBridge pb = new PluginBridge(overwrittenCodebase, null, "", "", 0, 0, params, mockCreator); 286 JARDesc[] jars = pb.getResources().getJARs(); 287 288 //Check if there are two jars cached 289 Assert.assertTrue(jars.length == 2); 290 291 //Resource can be in any order 292 List<String> resourceLocations = new ArrayList<String>(); 293 resourceLocations.add(jars[0].getLocation().toExternalForm()); 294 resourceLocations.add(jars[1].getLocation().toExternalForm()); 295 296 //Check URLs of jars 297 Assert.assertTrue(resourceLocations.contains(overwrittenCodebase + "/EmbeddedJnlpJarOne.jar")); 298 Assert.assertTrue((resourceLocations.contains(overwrittenCodebase + "/EmbeddedJnlpJarTwo.jar"))); 299 } 300 301 @Test 302 public void testInvalidEmbeddedJnlp() throws Exception { 303 URL overwrittenCodebase = new URL("http://icedtea.classpath.org"); 304 String relativeLocation = "/EmbeddedJnlpFile.jnlp"; 305 306 //Embedded jnlp is invalid 307 String jnlpFileEncoded = "thisContextIsInvalid"; 308 309 MockJNLPCreator mockCreator = new MockJNLPCreator(); 310 PluginParameters params = createValidParamObject(); 311 params.put("jnlp_href", relativeLocation); 312 params.put("jnlp_embedded", jnlpFileEncoded); 313 314 try { 315 new PluginBridge(overwrittenCodebase, null, "", "", 0, 0, params, mockCreator); 316 } catch (Exception e) { 317 return; 318 } 319 Assert.fail("PluginBridge was successfully created with an invalid embedded jnlp value"); 320 } 99 321 } -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/cache/CacheLRUWrapperTest.java
r418 r429 43 43 import net.sourceforge.jnlp.ServerAccess; 44 44 45 import net.sourceforge.jnlp. config.DeploymentConfiguration;46 import net.sourceforge.jnlp.runtime.JNLPRuntime;45 import net.sourceforge.jnlp.util.PropertiesFile; 46 import org.junit.AfterClass; 47 47 48 48 import org.junit.BeforeClass; … … 51 51 public class CacheLRUWrapperTest { 52 52 53 private final CacheLRUWrapper clw = CacheLRUWrapper.getInstance(); 54 private final String cacheDir = new File(JNLPRuntime.getConfiguration() 55 .getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR)).getPath(); 56 53 private static final CacheLRUWrapper clw = CacheLRUWrapper.getInstance(); 54 private static String cacheDirBackup; 55 private static PropertiesFile cacheOrderBackup; 57 56 // does no DeploymentConfiguration exist for this file name? 58 private final String cacheIndexFileName = "recently_used";57 private static final String cacheIndexFileName = CacheLRUWrapper.CACHE_INDEX_FILE_NAME + "_testing"; 59 58 60 59 private final int noEntriesCacheFile = 1000; … … 62 61 @BeforeClass 63 62 static public void setupJNLPRuntimeConfig() { 64 JNLPRuntime.getConfiguration().setProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR, System.getProperty("java.io.tmpdir")); 63 cacheDirBackup = clw.cacheDir; 64 cacheOrderBackup = clw.cacheOrder; 65 clw.cacheDir=System.getProperty("java.io.tmpdir"); 66 clw.cacheOrder = new PropertiesFile( new File(clw.cacheDir + File.separator + cacheIndexFileName)); 67 68 } 69 70 @AfterClass 71 static public void restoreJNLPRuntimeConfig() { 72 clw.cacheDir = cacheDirBackup; 73 clw.cacheOrder = cacheOrderBackup; 65 74 } 66 75 … … 68 77 public void testLoadStoreTiming() throws InterruptedException { 69 78 79 final File cacheIndexFile = new File(clw.cacheDir + File.separator + cacheIndexFileName); 80 cacheIndexFile.delete(); 81 //ensure it exists, so we can lock 82 clw.store(); 83 try{ 84 70 85 int noLoops = 1000; 71 86 … … 96 111 // wait more than 100 microseconds for noLoops = 1000 and noEntries=1000 is bad 97 112 assertTrue("load() must not take longer than 100 µs, but took in avg " + avg/1000 + "µs", avg < 100 * 1000); 98 99 clw.unlock(); 113 } finally { 114 clw.unlock(); 115 cacheIndexFile.delete(); 116 } 100 117 } 101 118 … … 104 121 // fill cache index file 105 122 for(int i = 0; i < noEntries; i++) { 106 String path = c acheDir + File.separatorChar + i + File.separatorChar + "test" + i + ".jar";123 String path = clw.cacheDir + File.separatorChar + i + File.separatorChar + "test" + i + ".jar"; 107 124 String key = clw.generateKey(path); 108 125 clw.addEntry(key, path); … … 113 130 public void testModTimestampAfterStore() throws InterruptedException { 114 131 115 final File cacheIndexFile = new File(cacheDir + File.separator + cacheIndexFileName); 116 132 final File cacheIndexFile = new File(clw.cacheDir + File.separator + cacheIndexFileName); 133 cacheIndexFile.delete(); 134 //ensure it exists, so we can lock 135 clw.store(); 136 try{ 117 137 clw.lock(); 118 138 119 139 // 1. clear cache entries + store 140 clw.addEntry("aa", "bb"); 141 clw.store(); 120 142 long lmBefore = cacheIndexFile.lastModified(); 143 Thread.sleep(1010); 121 144 clearCacheIndexFile(); 122 145 long lmAfter = cacheIndexFile.lastModified(); … … 124 147 125 148 // FIXME: wait a second, because of file modification timestamp only provides accuracy on seconds. 126 Thread.sleep(10 00);149 Thread.sleep(1010); 127 150 128 151 // 2. load cache file … … 139 162 assertTrue("modification timestamp hasn't changed! Before = " + lmBefore + " After = " + lmAfter, lmBefore < lmAfter); 140 163 141 clw.unlock(); 164 } finally { 165 cacheIndexFile.delete(); 166 clw.unlock(); 167 } 142 168 } 143 169 -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java
r418 r429 1 1 /* ResourceTrackerTest.java 2 Copyright (C) 2012 Red Hat, Inc.3 4 This file is part of IcedTea.5 6 IcedTea is free software; you can redistribute it and/or7 modify it under the terms of the GNU General Public License as published by8 the Free Software Foundation, version 2.9 10 IcedTea is distributed in the hope that it will be useful,11 but WITHOUT ANY WARRANTY; without even the implied warranty of12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13 General Public License for more details.14 15 You should have received a copy of the GNU General Public License16 along with IcedTea; see the file COPYING. If not, write to17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA18 02110-1301 USA.19 20 Linking this library statically or dynamically with other modules is21 making a combined work based on this library. Thus, the terms and22 conditions of the GNU General Public License cover the whole23 combination.24 25 As a special exception, the copyright holders of this library give you26 permission to link this library with independent modules to produce an27 executable, regardless of the license terms of these independent28 modules, and to copy and distribute the resulting executable under29 terms of your choice, provided that you also meet, for each linked30 independent module, the terms and conditions of the license of that31 module. An independent module is a module which is not derived from32 or based on this library. If you modify this library, you may extend33 this exception to your version of the library, but you are not34 obligated to do so. If you do not wish to do so, delete this35 exception statement from your version.2 Copyright (C) 2012 Red Hat, Inc. 3 4 This file is part of IcedTea. 5 6 IcedTea is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, version 2. 9 10 IcedTea is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with IcedTea; see the file COPYING. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 02110-1301 USA. 19 20 Linking this library statically or dynamically with other modules is 21 making a combined work based on this library. Thus, the terms and 22 conditions of the GNU General Public License cover the whole 23 combination. 24 25 As a special exception, the copyright holders of this library give you 26 permission to link this library with independent modules to produce an 27 executable, regardless of the license terms of these independent 28 modules, and to copy and distribute the resulting executable under 29 terms of your choice, provided that you also meet, for each linked 30 independent module, the terms and conditions of the license of that 31 module. An independent module is a module which is not derived from 32 or based on this library. If you modify this library, you may extend 33 this exception to your version of the library, but you are not 34 obligated to do so. If you do not wish to do so, delete this 35 exception statement from your version. 36 36 */ 37 37 package net.sourceforge.jnlp.cache; 38 38 39 import java.io.ByteArrayOutputStream; 40 import java.io.File; 41 import java.io.IOException; 42 import java.io.PrintStream; 39 43 import java.io.UnsupportedEncodingException; 44 import java.net.HttpURLConnection; 40 45 import java.net.MalformedURLException; 46 import java.net.URISyntaxException; 41 47 import java.net.URL; 48 import java.util.HashMap; 49 import net.sourceforge.jnlp.ServerAccess; 50 import net.sourceforge.jnlp.ServerLauncher; 51 import net.sourceforge.jnlp.Version; 52 import net.sourceforge.jnlp.runtime.JNLPRuntime; 53 import net.sourceforge.jnlp.util.logging.OutputController; 54 import net.sourceforge.jnlp.util.UrlUtils; 55 import org.junit.AfterClass; 42 56 import org.junit.Assert; 57 import org.junit.BeforeClass; 43 58 import org.junit.Test; 44 59 45 /** Test various corner cases of the parser */46 60 public class ResourceTrackerTest { 61 62 public static ServerLauncher testServer; 63 public static ServerLauncher testServerWithBrokenHead; 64 private static PrintStream[] backedUpStream = new PrintStream[4]; 65 private static ByteArrayOutputStream currentErrorStream; 66 private static final String nameStub1 = "itw-server"; 67 private static final String nameStub2 = "test-file"; 47 68 48 69 @Test … … 55 76 Assert.assertNull("first normalized url should be null", n[0]); 56 77 for (int i = 1; i < CHANGE_BORDER; i++) { 57 Assert.assertTrue("url " + i + " must be equals too norm laized url " + i, u[i].equals(n[i]));78 Assert.assertTrue("url " + i + " must be equals too normalized url " + i, u[i].equals(n[i])); 58 79 } 59 80 for (int i = CHANGE_BORDER; i < n.length; i++) { 60 Assert.assertFalse("url " + i + " must be normalized (and so not equals) too normlaized url " + i, u[i].equals(n[i])); 61 } 62 } 63 64 private static URL normalizeUrl(URL uRL) throws MalformedURLException, UnsupportedEncodingException { 65 return ResourceTracker.normalizeUrl(uRL, false); 66 } 67 public static final int CHANGE_BORDER = 7; 81 Assert.assertFalse("url " + i + " must be normalized (and so not equals) too normalized url " + i, u[i].equals(n[i])); 82 } 83 } 84 public static final int CHANGE_BORDER = 8; 68 85 69 86 public static URL[] getUrls() throws MalformedURLException { … … 71 88 /*constant*/ 72 89 null, 73 new URL("http://localhost:44321/Spaces%20Can%20Be%20Everyw%2Fhere1.jnlp"),74 90 new URL("file:///home/jvanek/Desktop/icedtea-web/tests.build/jnlp_test_server/Spaces%20can%20be%20everywhere2.jnlp"), 75 new URL("http://localhost/Spaces+Can+Be+Everywhere1.jnlp"),76 91 new URL("http://localhost:44321/SpacesCanBeEverywhere1.jnlp"), 77 92 new URL("http:///SpacesCanBeEverywhere1.jnlp"), 78 93 new URL("file://localhost/home/jvanek/Desktop/icedtea-web/tests.build/jnlp_test_server/Spaces can be everywhere2.jnlp"), 94 new URL("http://localhost:44321/testpage.jnlp?applicationID=25"), 95 new URL("http://localhost:44321/Spaces%20Can%20Be%20Everyw%2Fhere1.jnlp"), 96 new URL("http://localhost/Spaces+Can+Be+Everywhere1.jnlp"), 79 97 /*changing*/ 80 98 new URL("http://localhost/SpacesC anBeEverywhere1.jnlp?a=5&b=10#df"), … … 86 104 } 87 105 88 public static URL[] getNormalizedUrls() throws MalformedURLException, UnsupportedEncodingException {106 public static URL[] getNormalizedUrls() throws MalformedURLException, UnsupportedEncodingException, URISyntaxException { 89 107 URL[] u = getUrls(); 90 108 91 109 URL[] n = new URL[u.length]; 92 110 for (int i = 0; i < n.length; i++) { 93 n[i] = normalizeUrl(u[i]);111 n[i] = UrlUtils.normalizeUrl(u[i]); 94 112 } 95 113 return n; 96 114 97 115 } 116 117 @BeforeClass 118 //keeping silent outputs from launched jvm 119 public static void redirectErr() throws IOException { 120 for (int i = 0; i < backedUpStream.length; i++) { 121 if (backedUpStream[i] == null) { 122 switch (i) { 123 case 0: 124 backedUpStream[i] = System.out; 125 break; 126 case 1: 127 backedUpStream[i] = System.err; 128 break; 129 case 2: 130 backedUpStream[i] = OutputController.getLogger().getOut(); 131 break; 132 case 3: 133 backedUpStream[i] = OutputController.getLogger().getErr(); 134 break; 135 } 136 137 } 138 139 } 140 currentErrorStream = new ByteArrayOutputStream(); 141 System.setOut(new PrintStream(currentErrorStream)); 142 System.setErr(new PrintStream(currentErrorStream)); 143 OutputController.getLogger().setOut(new PrintStream(currentErrorStream)); 144 OutputController.getLogger().setErr(new PrintStream(currentErrorStream)); 145 146 147 } 148 149 @AfterClass 150 public static void redirectErrBack() throws IOException { 151 ServerAccess.logErrorReprint(currentErrorStream.toString("utf-8")); 152 System.setOut(backedUpStream[0]); 153 System.setErr(backedUpStream[1]); 154 OutputController.getLogger().setOut(backedUpStream[2]); 155 OutputController.getLogger().setErr(backedUpStream[3]); 156 157 158 } 159 160 @BeforeClass 161 public static void onDebug() { 162 JNLPRuntime.setDebug(true); 163 } 164 165 @AfterClass 166 public static void offDebug() { 167 JNLPRuntime.setDebug(false); 168 } 169 170 @BeforeClass 171 public static void startServer() throws Exception { 172 redirectErr(); 173 testServer = ServerAccess.getIndependentInstance(System.getProperty("java.io.tmpdir"), ServerAccess.findFreePort()); 174 redirectErrBack(); 175 } 176 177 @BeforeClass 178 public static void startServer2() throws Exception { 179 redirectErr(); 180 testServerWithBrokenHead = ServerAccess.getIndependentInstance(System.getProperty("java.io.tmpdir"), ServerAccess.findFreePort()); 181 testServerWithBrokenHead.setSupportingHeadRequest(false); 182 redirectErrBack(); 183 } 184 185 @AfterClass 186 public static void stopServer() { 187 testServer.stop(); 188 } 189 190 @AfterClass 191 public static void stopServer2() { 192 testServerWithBrokenHead.stop(); 193 } 194 195 @Test 196 public void getUrlResponseCodeTestWorkingHeadRequest() throws Exception { 197 redirectErr(); 198 try { 199 File f = File.createTempFile(nameStub1, nameStub2); 200 int i = ResourceTracker.getUrlResponseCode(testServer.getUrl(f.getName()), new HashMap<String, String>(), "HEAD"); 201 Assert.assertEquals(HttpURLConnection.HTTP_OK, i); 202 f.delete(); 203 i = ResourceTracker.getUrlResponseCode(testServer.getUrl(f.getName()), new HashMap<String, String>(), "HEAD"); 204 Assert.assertEquals(HttpURLConnection.HTTP_NOT_FOUND, i); 205 } finally { 206 redirectErrBack(); 207 } 208 } 209 210 @Test 211 public void getUrlResponseCodeTestNotWorkingHeadRequest() throws Exception { 212 redirectErr(); 213 try { 214 File f = File.createTempFile(nameStub1, nameStub2); 215 int i = ResourceTracker.getUrlResponseCode(testServerWithBrokenHead.getUrl(f.getName()), new HashMap<String, String>(), "HEAD"); 216 Assert.assertEquals(HttpURLConnection.HTTP_NOT_IMPLEMENTED, i); 217 f.delete(); 218 i = ResourceTracker.getUrlResponseCode(testServerWithBrokenHead.getUrl(f.getName()), new HashMap<String, String>(), "HEAD"); 219 Assert.assertEquals(HttpURLConnection.HTTP_NOT_IMPLEMENTED, i); 220 } finally { 221 redirectErrBack(); 222 } 223 } 224 225 @Test 226 public void getUrlResponseCodeTestGetRequestOnNotWorkingHeadRequest() throws Exception { 227 redirectErr(); 228 try { 229 File f = File.createTempFile(nameStub1, nameStub2); 230 int i = ResourceTracker.getUrlResponseCode(testServerWithBrokenHead.getUrl(f.getName()), new HashMap<String, String>(), "GET"); 231 Assert.assertEquals(HttpURLConnection.HTTP_OK, i); 232 f.delete(); 233 i = ResourceTracker.getUrlResponseCode(testServerWithBrokenHead.getUrl(f.getName()), new HashMap<String, String>(), "GET"); 234 Assert.assertEquals(HttpURLConnection.HTTP_NOT_FOUND, i); 235 } finally { 236 redirectErrBack(); 237 } 238 } 239 240 @Test 241 public void getUrlResponseCodeTestGetRequest() throws Exception { 242 redirectErr(); 243 try { 244 File f = File.createTempFile(nameStub1, nameStub2); 245 int i = ResourceTracker.getUrlResponseCode(testServer.getUrl(f.getName()), new HashMap<String, String>(), "GET"); 246 Assert.assertEquals(HttpURLConnection.HTTP_OK, i); 247 f.delete(); 248 i = ResourceTracker.getUrlResponseCode(testServer.getUrl(f.getName()), new HashMap<String, String>(), "GET"); 249 Assert.assertEquals(HttpURLConnection.HTTP_NOT_FOUND, i); 250 } finally { 251 redirectErrBack(); 252 } 253 } 254 255 @Test 256 public void getUrlResponseCodeTestWrongRequest() throws Exception { 257 redirectErr(); 258 try { 259 File f = File.createTempFile(nameStub1, nameStub2); 260 Exception exception = null; 261 try { 262 ResourceTracker.getUrlResponseCode(testServer.getUrl(f.getName()), new HashMap<String, String>(), "SomethingWrong"); 263 } catch (Exception ex) { 264 exception = ex; 265 } 266 Assert.assertNotNull(exception); 267 exception = null; 268 f.delete(); 269 try { 270 ResourceTracker.getUrlResponseCode(testServer.getUrl(f.getName()), new HashMap<String, String>(), "SomethingWrong"); 271 } catch (Exception ex) { 272 exception = ex; 273 } 274 Assert.assertNotNull(exception);; 275 } finally { 276 redirectErrBack(); 277 } 278 279 } 280 281 @Test 282 public void findBestUrltest() throws Exception { 283 redirectErr(); 284 try { 285 File fileForServerWithHeader = File.createTempFile(nameStub1, nameStub2); 286 File versionedFileForServerWithHeader = new File(fileForServerWithHeader.getParentFile(), fileForServerWithHeader.getName() + "-2.0"); 287 versionedFileForServerWithHeader.createNewFile(); 288 289 File fileForServerWithoutHeader = File.createTempFile(nameStub1, nameStub2); 290 File versionedFileForServerWithoutHeader = new File(fileForServerWithoutHeader.getParentFile(), fileForServerWithoutHeader.getName() + "-2.0"); 291 versionedFileForServerWithoutHeader.createNewFile(); 292 293 ResourceTracker rt = new ResourceTracker(); 294 Resource r1 = Resource.getResource(testServer.getUrl(fileForServerWithHeader.getName()), null, UpdatePolicy.NEVER); 295 Resource r2 = Resource.getResource(testServerWithBrokenHead.getUrl(fileForServerWithoutHeader.getName()), null, UpdatePolicy.NEVER); 296 Resource r3 = Resource.getResource(testServer.getUrl(versionedFileForServerWithHeader.getName()), new Version("1.0"), UpdatePolicy.NEVER); 297 Resource r4 = Resource.getResource(testServerWithBrokenHead.getUrl(versionedFileForServerWithoutHeader.getName()), new Version("1.0"), UpdatePolicy.NEVER); 298 assertOnServerWithHeader(rt.findBestUrl(r1)); 299 assertVersionedOneOnServerWithHeader(rt.findBestUrl(r3)); 300 assertOnServerWithoutHeader(rt.findBestUrl(r2)); 301 assertVersionedOneOnServerWithoutHeader(rt.findBestUrl(r4)); 302 303 fileForServerWithHeader.delete(); 304 Assert.assertNull(rt.findBestUrl(r1)); 305 assertVersionedOneOnServerWithHeader(rt.findBestUrl(r3)); 306 assertOnServerWithoutHeader(rt.findBestUrl(r2)); 307 assertVersionedOneOnServerWithoutHeader(rt.findBestUrl(r4)); 308 309 versionedFileForServerWithHeader.delete(); 310 Assert.assertNull(rt.findBestUrl(r1)); 311 Assert.assertNull(rt.findBestUrl(r3)); 312 assertOnServerWithoutHeader(rt.findBestUrl(r2)); 313 assertVersionedOneOnServerWithoutHeader(rt.findBestUrl(r4)); 314 315 versionedFileForServerWithoutHeader.delete(); 316 Assert.assertNull(rt.findBestUrl(r1)); 317 Assert.assertNull(rt.findBestUrl(r3)); 318 assertOnServerWithoutHeader(rt.findBestUrl(r2)); 319 Assert.assertNull(rt.findBestUrl(r4)); 320 321 322 fileForServerWithoutHeader.delete(); 323 Assert.assertNull(rt.findBestUrl(r1)); 324 Assert.assertNull(rt.findBestUrl(r3)); 325 Assert.assertNull(rt.findBestUrl(r2)); 326 Assert.assertNull(rt.findBestUrl(r4)); 327 } finally { 328 redirectErrBack(); 329 } 330 331 } 332 333 private void assertOnServerWithHeader(URL u) { 334 assertCommonComponentsOfUrl(u); 335 assertPort(u, testServer.getPort()); 336 } 337 338 private void assertVersionedOneOnServerWithHeader(URL u) { 339 assertCommonComponentsOfUrl(u); 340 assertPort(u, testServer.getPort()); 341 assertVersion(u); 342 } 343 344 private void assertOnServerWithoutHeader(URL u) { 345 assertCommonComponentsOfUrl(u); 346 assertPort(u, testServerWithBrokenHead.getPort()); 347 } 348 349 private void assertVersionedOneOnServerWithoutHeader(URL u) { 350 assertCommonComponentsOfUrl(u); 351 assertPort(u, testServerWithBrokenHead.getPort()); 352 assertVersion(u); 353 } 354 355 private void assertCommonComponentsOfUrl(URL u) { 356 Assert.assertTrue(u.getProtocol().equals("http")); 357 Assert.assertTrue(u.getHost().equals("localhost")); 358 Assert.assertTrue(u.getPath().contains(nameStub1)); 359 Assert.assertTrue(u.getPath().contains(nameStub2)); 360 ServerAccess.logOutputReprint(u.toExternalForm()); 361 } 362 363 private void assertPort(URL u, int port) { 364 Assert.assertTrue(u.getPort() == port); 365 } 366 367 private void assertVersion(URL u) { 368 Assert.assertTrue(u.getPath().contains("-2.0")); 369 Assert.assertTrue(u.getQuery().contains("version-id=1.0")); 370 } 98 371 } -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/runtime/CodeBaseClassLoaderTest.java
r418 r429 1 1 /* CodeBaseClassLoaderTest.java 2 Copyright (C) 2012 Red Hat, Inc. 3 4 This file is part of IcedTea. 5 6 IcedTea is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, version 2. 9 10 IcedTea is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with IcedTea; see the file COPYING. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 02110-1301 USA. 19 20 Linking this library statically or dynamically with other modules is 21 making a combined work based on this library. Thus, the terms and 22 conditions of the GNU General Public License cover the whole 23 combination. 24 25 As a special exception, the copyright holders of this library give you 26 permission to link this library with independent modules to produce an 27 executable, regardless of the license terms of these independent 28 modules, and to copy and distribute the resulting executable under 29 terms of your choice, provided that you also meet, for each linked 30 independent module, the terms and conditions of the license of that 31 module. An independent module is a module which is not derived from 32 or based on this library. If you modify this library, you may extend 33 this exception to your version of the library, but you are not 34 obligated to do so. If you do not wish to do so, delete this 35 exception statement from your version. 36 */ 37 2 Copyright (C) 2012 Red Hat, Inc. 3 4 This file is part of IcedTea. 5 6 IcedTea is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, version 2. 9 10 IcedTea is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with IcedTea; see the file COPYING. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 02110-1301 USA. 19 20 Linking this library statically or dynamically with other modules is 21 making a combined work based on this library. Thus, the terms and 22 conditions of the GNU General Public License cover the whole 23 combination. 24 25 As a special exception, the copyright holders of this library give you 26 permission to link this library with independent modules to produce an 27 executable, regardless of the license terms of these independent 28 modules, and to copy and distribute the resulting executable under 29 terms of your choice, provided that you also meet, for each linked 30 independent module, the terms and conditions of the license of that 31 module. An independent module is a module which is not derived from 32 or based on this library. If you modify this library, you may extend 33 this exception to your version of the library, but you are not 34 obligated to do so. If you do not wish to do so, delete this 35 exception statement from your version. 36 */ 38 37 package net.sourceforge.jnlp.runtime; 39 38 39 import net.sourceforge.jnlp.mock.DummyJNLPFile; 40 40 import static org.junit.Assert.assertFalse; 41 41 import static org.junit.Assert.assertTrue; 42 42 43 import java.io.IOException; 44 import java.net.MalformedURLException; 43 import java.lang.reflect.Field; 45 44 import java.net.URL; 46 45 import java.util.Locale; 47 46 48 47 import net.sourceforge.jnlp.JNLPFile; 49 import net.sourceforge.jnlp.LaunchException; 50 import net.sourceforge.jnlp.ParseException; 48 import net.sourceforge.jnlp.NullJnlpFileException; 51 49 import net.sourceforge.jnlp.ResourcesDesc; 52 50 import net.sourceforge.jnlp.SecurityDesc; 51 import net.sourceforge.jnlp.SecurityDescTest; 53 52 import net.sourceforge.jnlp.ServerAccess; 54 import net.sourceforge.jnlp.runtime.JNLPClassLoader;55 53 import net.sourceforge.jnlp.runtime.JNLPClassLoader.CodeBaseClassLoader; 56 54 import net.sourceforge.jnlp.annotations.Bug; 55 import net.sourceforge.jnlp.annotations.Remote; 56 import net.sourceforge.jnlp.config.DeploymentConfiguration; 57 import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel; 58 import net.sourceforge.jnlp.security.appletextendedsecurity.AppletStartupSecuritySettings; 59 import net.sourceforge.jnlp.util.logging.NoStdOutErrTest; 60 import org.junit.AfterClass; 61 import org.junit.Assert; 62 import org.junit.BeforeClass; 57 63 58 64 import org.junit.Test; 59 65 60 public class CodeBaseClassLoaderTest { 61 62 @Bug(id={"PR895", 63 "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-March/017626.html", 64 "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-March/017667.html"}) 65 @Test 66 public void testResourceLoadSuccessCaching() throws LaunchException, ClassNotFoundException, IOException, ParseException { 67 final URL JAR_URL = new URL("http://icedtea.classpath.org/netx/about.jar"); 68 final URL CODEBASE_URL = new URL("http://icedtea.classpath.org/netx/"); 69 70 JNLPFile dummyJnlpFile = new JNLPFile() { 71 @Override 72 public ResourcesDesc getResources() { 73 return new ResourcesDesc(null, new Locale[0], new String[0], new String[0]); 74 } 75 76 @Override 77 public URL getCodeBase() { 78 return CODEBASE_URL; 79 } 80 81 @Override 82 public SecurityDesc getSecurity() { 83 return new SecurityDesc(null, SecurityDesc.SANDBOX_PERMISSIONS, null); 84 } 85 }; 66 public class CodeBaseClassLoaderTest extends NoStdOutErrTest { 67 68 private static AppletSecurityLevel level; 69 70 @BeforeClass 71 public static void setPermissions() { 72 level = AppletStartupSecuritySettings.getInstance().getSecurityLevel(); 73 JNLPRuntime.getConfiguration().setProperty(DeploymentConfiguration.KEY_SECURITY_LEVEL, AppletSecurityLevel.ALLOW_UNSIGNED.toChars()); 74 } 75 76 @AfterClass 77 public static void resetPermissions() { 78 JNLPRuntime.getConfiguration().setProperty(DeploymentConfiguration.KEY_SECURITY_LEVEL, level.toChars()); 79 } 80 81 private static final String isWSA = "isWebstartApplication"; 82 83 static void setStaticField(Field field, Object newValue) throws Exception { 84 field.setAccessible(true); 85 field.set(null, newValue); 86 } 87 88 private void setWSA() throws Exception { 89 setStaticField(JNLPRuntime.class.getDeclaredField(isWSA), true); 90 } 91 92 private void setApplet() throws Exception { 93 setStaticField(JNLPRuntime.class.getDeclaredField(isWSA), false); 94 } 95 96 @AfterClass 97 public static void tearDown() throws Exception { 98 setStaticField(JNLPRuntime.class.getDeclaredField(isWSA), false); 99 100 101 } 102 103 @Bug(id = {"PR895", 104 "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-March/017626.html", 105 "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-March/017667.html"}) 106 @Test 107 @Remote 108 public void testClassResourceLoadSuccessCachingApplication() throws Exception { 109 setWSA(); 110 //we are testing new resource not in cache 111 testResourceCaching("net/sourceforge/jnlp/about/Main.class"); 112 } 113 114 @Test 115 @Remote 116 public void testClassResourceLoadSuccessCachingApplet() throws Exception { 117 setApplet(); 118 //so new resource again not in cache 119 testResourceCaching("net/sourceforge/jnlp/about/Main.class"); 120 } 121 122 @Test 123 @Remote 124 public void testResourceLoadSuccessCachingApplication() throws Exception { 125 setWSA(); 126 //we are testing new resource not in cache 127 testResourceCaching("net/sourceforge/jnlp/about/resources/about.html"); 128 } 129 130 @Test 131 @Remote 132 public void testResourceLoadSuccessCachingApplet() throws Exception { 133 setApplet(); 134 //so new resource again not in cache 135 testResourceCaching("net/sourceforge/jnlp/about/resources/about.html"); 136 } 137 138 public void testResourceCaching(String r) throws Exception { 139 testResourceCaching(r, true); 140 } 141 142 public void testResourceCaching(String r, boolean shouldExists) throws Exception { 143 JNLPFile dummyJnlpFile = new DummyJNLPFile(); 86 144 87 145 JNLPClassLoader parent = new JNLPClassLoader(dummyJnlpFile, null); 88 CodeBaseClassLoader classLoader = new CodeBaseClassLoader(new URL[] { JAR_URL, CODEBASE_URL }, parent); 89 146 CodeBaseClassLoader classLoader = new CodeBaseClassLoader(new URL[]{DummyJNLPFile.JAR_URL, DummyJNLPFile.CODEBASE_URL}, parent); 147 148 int level = 10; 149 if (shouldExists) { 150 //for found the "caching" is by internal logic.Always faster, but who knows how... 151 //to keep the test stabile keep the difference minimal 152 level = 1; 153 } 90 154 long startTime, stopTime; 91 155 92 156 startTime = System.nanoTime(); 93 classLoader.findResource("net/sourceforge/jnlp/about/Main.class"); 157 URL u1 = classLoader.findResource(r); 158 if (shouldExists) { 159 Assert.assertNotNull(u1); 160 } else { 161 Assert.assertNull(u1); 162 } 94 163 stopTime = System.nanoTime(); 95 164 long timeOnFirstTry = stopTime - startTime; 96 ServerAccess.logErrorReprint("" +timeOnFirstTry);165 ServerAccess.logErrorReprint("" + timeOnFirstTry); 97 166 98 167 startTime = System.nanoTime(); 99 classLoader.findResource("net/sourceforge/jnlp/about/Main.class"); 168 URL u2 = classLoader.findResource(r); 169 if (shouldExists) { 170 Assert.assertNotNull(u1); 171 } else { 172 Assert.assertNull(u2); 173 } 100 174 stopTime = System.nanoTime(); 101 175 long timeOnSecondTry = stopTime - startTime; 102 ServerAccess.logErrorReprint(""+timeOnSecondTry); 103 104 assertTrue(timeOnSecondTry < (timeOnFirstTry / 10)); 105 } 106 107 @Bug(id={"PR895", 108 "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-March/017626.html", 109 "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-March/017667.html"}) 110 @Test 111 public void testResourceLoadFailureCaching() throws LaunchException, ClassNotFoundException, IOException, ParseException { 112 final URL JAR_URL = new URL("http://icedtea.classpath.org/netx/about.jar"); 113 final URL CODEBASE_URL = new URL("http://icedtea.classpath.org/netx/"); 114 115 JNLPFile dummyJnlpFile = new JNLPFile() { 116 @Override 117 public ResourcesDesc getResources() { 118 return new ResourcesDesc(null, new Locale[0], new String[0], new String[0]); 119 } 120 121 @Override 122 public URL getCodeBase() { 123 return CODEBASE_URL; 124 } 125 126 @Override 127 public SecurityDesc getSecurity() { 128 return new SecurityDesc(null, SecurityDesc.SANDBOX_PERMISSIONS, null); 129 } 130 }; 131 132 JNLPClassLoader parent = new JNLPClassLoader(dummyJnlpFile, null); 133 CodeBaseClassLoader classLoader = new CodeBaseClassLoader(new URL[] { JAR_URL, CODEBASE_URL }, parent); 134 135 long startTime, stopTime; 136 137 startTime = System.nanoTime(); 138 classLoader.findResource("net/sourceforge/jnlp/about/Main_FOO_.class"); 139 stopTime = System.nanoTime(); 140 long timeOnFirstTry = stopTime - startTime; 141 ServerAccess.logErrorReprint(""+timeOnFirstTry); 142 143 startTime = System.nanoTime(); 144 classLoader.findResource("net/sourceforge/jnlp/about/Main_FOO_.class"); 145 stopTime = System.nanoTime(); 146 long timeOnSecondTry = stopTime - startTime; 147 ServerAccess.logErrorReprint(""+timeOnSecondTry); 148 149 assertTrue(timeOnSecondTry < (timeOnFirstTry / 10)); 150 } 151 152 @Test 153 public void testParentClassLoaderIsAskedForClasses() throws MalformedURLException, LaunchException { 154 final URL JAR_URL = new URL("http://icedtea.classpath.org/netx/about.jar"); 155 final URL CODEBASE_URL = new URL("http://icedtea.classpath.org/netx/"); 156 157 JNLPFile dummyJnlpFile = new JNLPFile() { 158 @Override 159 public ResourcesDesc getResources() { 160 return new ResourcesDesc(null, new Locale[0], new String[0], new String[0]); 161 } 162 163 @Override 164 public URL getCodeBase() { 165 return CODEBASE_URL; 166 } 167 168 @Override 169 public SecurityDesc getSecurity() { 170 return new SecurityDesc(null, SecurityDesc.SANDBOX_PERMISSIONS, null); 171 } 172 }; 176 ServerAccess.logErrorReprint("" + timeOnSecondTry); 177 178 assertTrue(timeOnSecondTry < (timeOnFirstTry / level)); 179 } 180 181 @Bug(id = {"PR895", 182 "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-March/017626.html", 183 "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-March/017667.html"}) 184 @Test 185 @Remote 186 public void testResourceLoadFailureCachingApplication() throws Exception { 187 setWSA(); 188 testResourceCaching("net/sourceforge/jnlp/about/Main_FOO_.class", false); 189 } 190 191 @Test 192 public void testResourceLoadFailureCachingApplet() throws Exception { 193 setApplet(); 194 testResourceCaching("net/sourceforge/jnlp/about/Main_FOO_.class", false); 195 } 196 197 @Test 198 @Remote 199 public void testParentClassLoaderIsAskedForClassesApplication() throws Exception { 200 setWSA(); 201 testParentClassLoaderIsAskedForClasses(); 202 } 203 204 @Test 205 @Remote 206 public void testParentClassLoaderIsAskedForClassesApplet() throws Exception { 207 setApplet(); 208 testParentClassLoaderIsAskedForClasses(); 209 } 210 211 public void testParentClassLoaderIsAskedForClasses() throws Exception { 212 JNLPFile dummyJnlpFile = new DummyJNLPFile(); 173 213 174 214 final boolean[] parentWasInvoked = new boolean[1]; … … 181 221 } 182 222 }; 183 CodeBaseClassLoader classLoader = new CodeBaseClassLoader(new URL[] { JAR_URL, CODEBASE_URL}, parent);223 CodeBaseClassLoader classLoader = new CodeBaseClassLoader(new URL[]{DummyJNLPFile.JAR_URL, DummyJNLPFile.CODEBASE_URL}, parent); 184 224 try { 185 225 classLoader.findClass("foo"); … … 189 229 assertTrue(parentWasInvoked[0]); 190 230 } 231 232 @Test 233 public void testNullFileSecurityDescApplication() throws Exception { 234 setWSA(); 235 Exception ex = null; 236 try { 237 testNullFileSecurityDesc(); 238 } catch (Exception exx) { 239 ex = exx; 240 } 241 Assert.assertTrue("was expected exception", ex != null); 242 Assert.assertTrue("was expected " + NullJnlpFileException.class.getName(), ex instanceof NullJnlpFileException); 243 } 244 245 @Test 246 @Remote 247 public void testNullFileSecurityDescApplet() throws Exception { 248 setApplet(); 249 Exception ex = null; 250 try { 251 testNullFileSecurityDesc(); 252 } catch (Exception exx) { 253 ex = exx; 254 } 255 Assert.assertTrue("was expected exception", ex != null); 256 Assert.assertTrue("was expected " + NullJnlpFileException.class.getName(), ex instanceof NullJnlpFileException); 257 } 258 259 public void testNullFileSecurityDesc() throws Exception { 260 JNLPFile dummyJnlpFile = new DummyJNLPFile() { 261 @Override 262 public SecurityDesc getSecurity() { 263 return new SecurityDesc(null, SecurityDesc.SANDBOX_PERMISSIONS, null); 264 } 265 }; 266 JNLPClassLoader parent = new JNLPClassLoader(dummyJnlpFile, null); 267 268 } 191 269 } -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/tools/JarCertVerifierTest.java
r418 r429 38 38 package net.sourceforge.jnlp.tools; 39 39 40 import static org.junit.Assert.*; 41 40 import static net.sourceforge.jnlp.runtime.Translator.R; 41 import static org.junit.Assert.assertFalse; 42 import static org.junit.Assert.assertTrue; 43 44 import java.security.CodeSigner; 45 import java.util.Date; 46 import java.util.List; 47 import java.util.Vector; 48 import java.util.jar.JarEntry; 49 50 import net.sourceforge.jnlp.JARDesc; 51 import net.sourceforge.jnlp.tools.JarCertVerifier.VerifyResult; 52 53 import org.junit.Assert; 54 import org.junit.BeforeClass; 42 55 import org.junit.Test; 43 56 … … 46 59 @Test 47 60 public void testIsMetaInfFile() { 48 final String METAINF = "META-INF";61 final String METAINF = "META-INF"; 49 62 assertFalse(JarCertVerifier.isMetaInfFile("some_dir/" + METAINF + "/filename")); 50 63 assertFalse(JarCertVerifier.isMetaInfFile(METAINF + "filename")); … … 52 65 } 53 66 67 class JarCertVerifierEntry extends JarEntry { 68 CodeSigner[] signers; 69 70 public JarCertVerifierEntry(String name, CodeSigner[] codesigners) { 71 super(name); 72 signers = codesigners; 73 } 74 75 public JarCertVerifierEntry(String name) { 76 this(name, null); 77 } 78 79 public CodeSigner[] getCodeSigners() { 80 return signers == null ? null : signers.clone(); 81 } 82 } 83 84 // Empty list to be used with JarCertVerifier constructor. 85 private static final List<JARDesc> emptyJARDescList = new Vector<JARDesc>(); 86 87 private static final String DNPARTIAL = ", OU=JarCertVerifier Unit Test, O=IcedTea, L=Toronto, ST=Ontario, C=CA"; 88 private static CodeSigner alphaSigner, betaSigner, charlieSigner, 89 expiredSigner, expiringSigner, notYetValidSigner, expiringAndNotYetValidSigner; 90 91 @BeforeClass 92 public static void setUp() throws Exception { 93 Date currentDate = new Date(); 94 Date pastDate = new Date(currentDate.getTime() - (1000L * 24L * 60L * 60L) - 1000L); // 1 day and 1 second in the past 95 Date futureDate = new Date(currentDate.getTime() + (1000L * 24L * 60L * 60L)); // 1 day in the future 96 alphaSigner = CodeSignerCreator.getOneCodeSigner("CN=Alpha Signer" + DNPARTIAL, currentDate, 365); 97 betaSigner = CodeSignerCreator.getOneCodeSigner("CN=Beta Signer" + DNPARTIAL, currentDate, 365); 98 charlieSigner = CodeSignerCreator.getOneCodeSigner("CN=Charlie Signer" + DNPARTIAL, currentDate, 365); 99 expiredSigner = CodeSignerCreator.getOneCodeSigner("CN=Expired Signer" + DNPARTIAL, pastDate, 1); 100 expiringSigner = CodeSignerCreator.getOneCodeSigner("CN=Expiring Signer" + DNPARTIAL, currentDate, 1); 101 notYetValidSigner = CodeSignerCreator.getOneCodeSigner("CN=Not Yet Valid Signer" + DNPARTIAL, futureDate, 365); 102 expiringAndNotYetValidSigner = CodeSignerCreator.getOneCodeSigner("CN=Expiring and Not Yet Valid Signer" + DNPARTIAL, futureDate, 3); 103 } 104 105 @Test 106 public void testNoManifest() throws Exception { 107 JarCertVerifier jcv = new JarCertVerifier(null); 108 VerifyResult result = jcv.verifyJarEntryCerts("", false, null); 109 110 Assert.assertEquals("No manifest should be considered unsigned.", 111 VerifyResult.UNSIGNED, result); 112 Assert.assertEquals("No manifest means no signers in the verifier.", 113 0, jcv.getCertsList().size()); 114 } 115 116 @Test 117 public void testNoSignableEntries() throws Exception { 118 JarCertVerifier jcv = new JarCertVerifier(null); 119 Vector<JarEntry> entries = new Vector<JarEntry>(); 120 entries.add(new JarCertVerifierEntry("OneDirEntry/")); 121 entries.add(new JarCertVerifierEntry("META-INF/MANIFEST.MF")); 122 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 123 124 Assert.assertEquals("No signable entry (only dirs/manifests) should be considered trivially signed.", 125 VerifyResult.SIGNED_OK, result); 126 Assert.assertEquals("No signable entry (only dirs/manifests) means no signers in the verifier.", 127 0, jcv.getCertsList().size()); 128 } 129 130 @Test 131 public void testSingleEntryNoSigners() throws Exception { 132 JarCertVerifier jcv = new JarCertVerifier(null); 133 Vector<JarEntry> entries = new Vector<JarEntry>(); 134 entries.add(new JarCertVerifierEntry("firstEntryWithoutSigner")); 135 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 136 137 Assert.assertEquals("One unsigned entry should be considered unsigned.", 138 VerifyResult.UNSIGNED, result); 139 Assert.assertEquals("One unsigned entry means no signers in the verifier.", 140 0, jcv.getCertsList().size()); 141 } 142 143 @Test 144 public void testManyEntriesNoSigners() throws Exception { 145 JarCertVerifier jcv = new JarCertVerifier(null); 146 Vector<JarEntry> entries = new Vector<JarEntry>(); 147 entries.add(new JarCertVerifierEntry("firstEntryWithoutSigner")); 148 entries.add(new JarCertVerifierEntry("secondEntryWithoutSigner")); 149 entries.add(new JarCertVerifierEntry("thirdEntryWithoutSigner")); 150 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 151 152 Assert.assertEquals("Many unsigned entries should be considered unsigned.", 153 VerifyResult.UNSIGNED, result); 154 Assert.assertEquals("Many unsigned entries means no signers in the verifier.", 0, 155 jcv.getCertsList().size()); 156 } 157 158 @Test 159 public void testSingleEntrySingleValidSigner() throws Exception { 160 JarCertVerifier jcv = new JarCertVerifier(null); 161 CodeSigner[] signers = { alphaSigner }; 162 Vector<JarEntry> entries = new Vector<JarEntry>(); 163 entries.add(new JarCertVerifierEntry("firstSignedByOne", signers)); 164 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 165 166 Assert.assertEquals("One signed entry should be considered signed and okay.", 167 VerifyResult.SIGNED_OK, result); 168 Assert.assertEquals("One signed entry means one signer in the verifier.", 169 1, jcv.getCertsList().size()); 170 Assert.assertTrue("One signed entry means one signer in the verifier.", 171 jcv.getCertsList().contains(alphaSigner.getSignerCertPath())); 172 } 173 174 @Test 175 public void testManyEntriesSingleValidSigner() throws Exception { 176 JarCertVerifier jcv = new JarCertVerifier(null); 177 CodeSigner[] signers = { alphaSigner }; 178 Vector<JarEntry> entries = new Vector<JarEntry>(); 179 entries.add(new JarCertVerifierEntry("firstSignedByOne", signers)); 180 entries.add(new JarCertVerifierEntry("secondSignedByOne", signers)); 181 entries.add(new JarCertVerifierEntry("thirdSignedByOne", signers)); 182 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 183 184 Assert.assertEquals("Three entries signed by one signer should be considered signed and okay.", 185 VerifyResult.SIGNED_OK, result); 186 Assert.assertEquals("Three entries signed by one signer means one signer in the verifier.", 187 1, jcv.getCertsList().size()); 188 Assert.assertTrue("Three entries signed by one signer means one signer in the verifier.", 189 jcv.getCertsList().contains(alphaSigner.getSignerCertPath())); 190 } 191 192 @Test 193 public void testSingleEntryMultipleValidSigners() throws Exception { 194 JarCertVerifier jcv = new JarCertVerifier(null); 195 CodeSigner[] signers = { alphaSigner, betaSigner, charlieSigner }; 196 Vector<JarEntry> entries = new Vector<JarEntry>(); 197 entries.add(new JarCertVerifierEntry("firstSignedByThree", signers)); 198 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 199 200 Assert.assertEquals("One entry signed by three signers should be considered signed and okay.", 201 VerifyResult.SIGNED_OK, result); 202 Assert.assertEquals("One entry signed by three means three signers in the verifier.", 203 3, jcv.getCertsList().size()); 204 Assert.assertTrue("One entry signed by three means three signers in the verifier.", 205 jcv.getCertsList().contains(alphaSigner.getSignerCertPath()) 206 && jcv.getCertsList().contains(betaSigner.getSignerCertPath()) 207 && jcv.getCertsList().contains(charlieSigner.getSignerCertPath())); 208 } 209 210 @Test 211 public void testManyEntriesMultipleValidSigners() throws Exception { 212 JarCertVerifier jcv = new JarCertVerifier(null); 213 CodeSigner[] signers = { alphaSigner, betaSigner, charlieSigner }; 214 Vector<JarEntry> entries = new Vector<JarEntry>(); 215 entries.add(new JarCertVerifierEntry("firstSignedByThree", signers)); 216 entries.add(new JarCertVerifierEntry("secondSignedByThree", signers)); 217 entries.add(new JarCertVerifierEntry("thirdSignedByThree", signers)); 218 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 219 220 Assert.assertEquals("Three entries signed by three signers should be considered signed and okay.", 221 VerifyResult.SIGNED_OK, result); 222 Assert.assertEquals("Three entries signed by three means three signers in the verifier.", 223 3, jcv.getCertsList().size()); 224 Assert.assertTrue("Three entries signed by three means three signers in the verifier.", 225 jcv.getCertsList().contains(alphaSigner.getSignerCertPath()) 226 && jcv.getCertsList().contains(betaSigner.getSignerCertPath()) 227 && jcv.getCertsList().contains(charlieSigner.getSignerCertPath())); 228 } 229 230 @Test 231 public void testOneCommonSigner() throws Exception { 232 JarCertVerifier jcv = new JarCertVerifier(null); 233 CodeSigner[] alphaSigners = { alphaSigner }; 234 CodeSigner[] betaSigners = { alphaSigner, betaSigner }; 235 CodeSigner[] charlieSigners = { alphaSigner, charlieSigner }; 236 Vector<JarEntry> entries = new Vector<JarEntry>(); 237 entries.add(new JarCertVerifierEntry("firstSignedByOne", alphaSigners)); 238 entries.add(new JarCertVerifierEntry("secondSignedByTwo", betaSigners)); 239 entries.add(new JarCertVerifierEntry("thirdSignedByTwo", charlieSigners)); 240 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 241 242 Assert.assertEquals("Three entries signed by at least one common signer should be considered signed and okay.", 243 VerifyResult.SIGNED_OK, result); 244 Assert.assertEquals("Three entries signed completely by only one signer means one signer in the verifier.", 245 1, jcv.getCertsList().size()); 246 Assert.assertTrue("Three entries signed completely by only one signer means one signer in the verifier.", 247 jcv.getCertsList().contains(alphaSigner.getSignerCertPath())); 248 } 249 250 @Test 251 public void testNoCommonSigner() throws Exception { 252 JarCertVerifier jcv = new JarCertVerifier(null); 253 CodeSigner[] alphaSigners = { alphaSigner }; 254 CodeSigner[] betaSigners = { betaSigner }; 255 CodeSigner[] charlieSigners = { charlieSigner }; 256 Vector<JarEntry> entries = new Vector<JarEntry>(); 257 entries.add(new JarCertVerifierEntry("firstSignedByAlpha", alphaSigners)); 258 entries.add(new JarCertVerifierEntry("secondSignedByBeta", betaSigners)); 259 entries.add(new JarCertVerifierEntry("thirdSignedByCharlie", charlieSigners)); 260 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 261 262 Assert.assertEquals("Three entries signed by no common signers should be considered unsigned.", 263 VerifyResult.UNSIGNED, result); 264 Assert.assertEquals("Three entries signed by no common signers means no signers in the verifier.", 265 0, jcv.getCertsList().size()); 266 } 267 268 @Test 269 public void testFewButNotAllCommonSigners() throws Exception { 270 JarCertVerifier jcv = new JarCertVerifier(null); 271 CodeSigner[] alphaSigners = { alphaSigner }; 272 CodeSigner[] betaSigners = { betaSigner }; 273 Vector<JarEntry> entries = new Vector<JarEntry>(); 274 entries.add(new JarCertVerifierEntry("firstSignedByAlpha", alphaSigners)); 275 entries.add(new JarCertVerifierEntry("secondSignedByAlpha", alphaSigners)); 276 entries.add(new JarCertVerifierEntry("thirdSignedByBeta", betaSigners)); 277 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 278 279 Assert.assertEquals("First two entries signed by alpha signer, third entry signed by beta signer should be considered unisgned.", 280 VerifyResult.UNSIGNED, result); 281 Assert.assertEquals("Three entries signed by some common signers but not all means no signers in the verifier.", 282 0, jcv.getCertsList().size()); 283 } 284 285 @Test 286 public void testNotAllEntriesSigned() throws Exception { 287 JarCertVerifier jcv = new JarCertVerifier(null); 288 CodeSigner[] alphaSigners = { alphaSigner }; 289 Vector<JarEntry> entries = new Vector<JarEntry>(); 290 entries.add(new JarCertVerifierEntry("firstSignedByAlpha", alphaSigners)); 291 entries.add(new JarCertVerifierEntry("secondSignedByAlpha", alphaSigners)); 292 entries.add(new JarCertVerifierEntry("thirdUnsigned")); 293 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 294 295 Assert.assertEquals("First two entries signed by alpha signer, third entry not signed, should be considered unisgned.", 296 VerifyResult.UNSIGNED, result); 297 Assert.assertEquals("First two entries signed by alpha signer, third entry not signed, means no signers in the verifier.", 298 0, jcv.getCertsList().size()); 299 } 300 301 @Test 302 public void testSingleEntryExpiredSigner() throws Exception { 303 JarCertVerifier jcv = new JarCertVerifier(null); 304 CodeSigner[] expiredSigners = { expiredSigner }; 305 Vector<JarEntry> entries = new Vector<JarEntry>(); 306 entries.add(new JarCertVerifierEntry("firstSignedByExpired", expiredSigners)); 307 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 308 309 Assert.assertEquals("One entry signed by expired cert, should be considered signed but not okay.", 310 VerifyResult.SIGNED_NOT_OK, result); 311 Assert.assertEquals("One entry signed by expired cert means one signer in the verifier.", 312 1, jcv.getCertsList().size()); 313 Assert.assertTrue("One entry signed by expired cert means one signer in the verifier.", 314 jcv.getCertsList().contains(expiredSigner.getSignerCertPath())); 315 } 316 317 @Test 318 public void testManyEntriesExpiredSigner() throws Exception { 319 JarCertVerifier jcv = new JarCertVerifier(null); 320 CodeSigner[] expiredSigners = { expiredSigner }; 321 Vector<JarEntry> entries = new Vector<JarEntry>(); 322 entries.add(new JarCertVerifierEntry("firstSignedByExpired", expiredSigners)); 323 entries.add(new JarCertVerifierEntry("secondSignedBExpired", expiredSigners)); 324 entries.add(new JarCertVerifierEntry("thirdSignedByExpired", expiredSigners)); 325 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 326 327 Assert.assertEquals("Three entries signed by expired cert, should be considered signed but not okay.", 328 VerifyResult.SIGNED_NOT_OK, result); 329 Assert.assertEquals("Three entries signed by expired cert means one signer in the verifier.", 330 1, jcv.getCertsList().size()); 331 Assert.assertTrue("Three entries signed by expired cert means one signer in the verifier.", 332 jcv.getCertsList().contains(expiredSigner.getSignerCertPath())); 333 } 334 335 @Test 336 public void testSingleEntryExpiringSigner() throws Exception { 337 JarCertVerifier jcv = new JarCertVerifier(null); 338 CodeSigner[] expiringSigners = { expiringSigner }; 339 Vector<JarEntry> entries = new Vector<JarEntry>(); 340 entries.add(new JarCertVerifierEntry("firstSignedByExpiring", expiringSigners)); 341 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 342 343 Assert.assertEquals("One entry signed by expiring cert, should be considered signed and okay.", 344 VerifyResult.SIGNED_OK, result); 345 Assert.assertEquals("One entry signed by expiring cert means one signer in the verifier.", 346 1, jcv.getCertsList().size()); 347 Assert.assertTrue("One entry signed by expiring cert means one signer in the verifier.", 348 jcv.getCertsList().contains(expiringSigner.getSignerCertPath())); 349 } 350 351 @Test 352 public void testManyEntriesExpiringSigner() throws Exception { 353 JarCertVerifier jcv = new JarCertVerifier(null); 354 CodeSigner[] expiringSigners = { expiringSigner }; 355 Vector<JarEntry> entries = new Vector<JarEntry>(); 356 entries.add(new JarCertVerifierEntry("firstSignedByExpiring", expiringSigners)); 357 entries.add(new JarCertVerifierEntry("secondSignedBExpiring", expiringSigners)); 358 entries.add(new JarCertVerifierEntry("thirdSignedByExpiring", expiringSigners)); 359 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 360 361 Assert.assertEquals("Three entries signed by expiring cert, should be considered signed and okay.", 362 VerifyResult.SIGNED_OK, result); 363 Assert.assertEquals("Three entries signed by expiring cert means one signer in the verifier.", 364 1, jcv.getCertsList().size()); 365 Assert.assertTrue("Three entries signed by expiring cert means one signer in the verifier.", 366 jcv.getCertsList().contains(expiringSigner.getSignerCertPath())); 367 } 368 369 @Test 370 public void testSingleEntryNotYetValidSigner() throws Exception { 371 JarCertVerifier jcv = new JarCertVerifier(null); 372 CodeSigner[] notYetValidSigners = { notYetValidSigner }; 373 Vector<JarEntry> entries = new Vector<JarEntry>(); 374 entries.add(new JarCertVerifierEntry("firstSignedByNotYetValid", notYetValidSigners)); 375 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 376 377 Assert.assertEquals("One entry signed by cert that is not yet valid, should be considered signed but not okay.", 378 VerifyResult.SIGNED_NOT_OK, result); 379 Assert.assertEquals("One entry signed by cert that is not yet valid means one signer in the verifier.", 380 1, jcv.getCertsList().size()); 381 Assert.assertTrue("One entry signed by cert that is not yet valid means one signer in the verifier.", 382 jcv.getCertsList().contains(notYetValidSigner.getSignerCertPath())); 383 } 384 385 @Test 386 public void testManyEntriesNotYetValidSigner() throws Exception { 387 JarCertVerifier jcv = new JarCertVerifier(null); 388 CodeSigner[] notYetValidSigners = { notYetValidSigner }; 389 Vector<JarEntry> entries = new Vector<JarEntry>(); 390 entries.add(new JarCertVerifierEntry("firstSignedByNotYetValid", notYetValidSigners)); 391 entries.add(new JarCertVerifierEntry("secondSignedByNotYetValid", notYetValidSigners)); 392 entries.add(new JarCertVerifierEntry("thirdSignedByNotYetValid", notYetValidSigners)); 393 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 394 395 Assert.assertEquals("Three entries signed by cert that is not yet valid, should be considered signed but not okay.", 396 VerifyResult.SIGNED_NOT_OK, result); 397 Assert.assertEquals("Three entries signed by cert that is not yet valid means one signer in the verifier.", 398 1, jcv.getCertsList().size()); 399 Assert.assertTrue("Three entries signed by cert that is not yet valid means one signer in the verifier.", 400 jcv.getCertsList().contains(notYetValidSigner.getSignerCertPath())); 401 } 402 403 @Test 404 public void testSingleEntryExpiringAndNotYetValidSigner() throws Exception { 405 JarCertVerifier jcv = new JarCertVerifier(null); 406 CodeSigner[] expiringAndNotYetValidSigners = { expiringAndNotYetValidSigner }; 407 Vector<JarEntry> entries = new Vector<JarEntry>(); 408 entries.add(new JarCertVerifierEntry("firstSignedByExpiringNotYetValid", expiringAndNotYetValidSigners)); 409 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 410 411 Assert.assertEquals("One entry signed by cert that is not yet valid but also expiring, should be considered signed but not okay.", 412 VerifyResult.SIGNED_NOT_OK, result); 413 Assert.assertEquals("One entry signed by cert that is not yet valid but also expiring means one signer in the verifier.", 414 1, jcv.getCertsList().size()); 415 Assert.assertTrue("One entry signed by cert that is not yet valid but also expiring means one signer in the verifier.", 416 jcv.getCertsList().contains(expiringAndNotYetValidSigner.getSignerCertPath())); 417 } 418 419 @Test 420 public void testManyEntryExpiringAndNotYetValidSigner() throws Exception { 421 JarCertVerifier jcv = new JarCertVerifier(null); 422 423 CodeSigner[] expiringAndNotYetValidSigners = { expiringAndNotYetValidSigner }; 424 Vector<JarEntry> entries = new Vector<JarEntry>(); 425 entries.add(new JarCertVerifierEntry("firstSignedByExpiringNotYetValid", expiringAndNotYetValidSigners)); 426 entries.add(new JarCertVerifierEntry("secondSignedByExpiringNotYetValid", expiringAndNotYetValidSigners)); 427 entries.add(new JarCertVerifierEntry("thirdSignedByExpiringNotYetValid", expiringAndNotYetValidSigners)); 428 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 429 430 Assert.assertEquals("Three entries signed by cert that is not yet valid but also expiring, should be considered signed but not okay.", 431 VerifyResult.SIGNED_NOT_OK, result); 432 Assert.assertEquals("Three entries signed by cert that is not yet valid but also expiring means one signer in the verifier.", 433 1, jcv.getCertsList().size()); 434 Assert.assertTrue("Three entries signed by cert that is not yet valid but also expiring means one signer in the verifier.", 435 jcv.getCertsList().contains(expiringAndNotYetValidSigner.getSignerCertPath())); 436 Assert.assertTrue("Three entries signed by cert that is not yet valid but also expiring means expiring issue should be in details list.", 437 jcv.getDetails(expiringAndNotYetValidSigner.getSignerCertPath()).contains(R("SHasExpiringCert"))); 438 } 439 440 @Test 441 public void testSingleEntryOneExpiredOneValidSigner() throws Exception { 442 JarCertVerifier jcv = new JarCertVerifier(null); 443 CodeSigner[] oneExpiredOneValidSigner = { expiredSigner, alphaSigner }; 444 Vector<JarEntry> entries = new Vector<JarEntry>(); 445 entries.add(new JarCertVerifierEntry("firstSignedByTwo", oneExpiredOneValidSigner)); 446 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 447 448 Assert.assertEquals("One entry signed by one expired cert and another valid cert, should be considered signed and okay.", 449 VerifyResult.SIGNED_OK, result); 450 Assert.assertEquals("One entry signed by one expired cert and another valid cert means two signers in the verifier.", 451 2, jcv.getCertsList().size()); 452 Assert.assertTrue("One entry signed by one expired cert and another valid cert means two signers in the verifier.", 453 jcv.getCertsList().contains(expiredSigner.getSignerCertPath()) 454 && jcv.getCertsList().contains(alphaSigner.getSignerCertPath())); 455 } 456 457 @Test 458 public void testManyEntriesOneExpiredOneValidSigner() throws Exception { 459 JarCertVerifier jcv = new JarCertVerifier(null); 460 CodeSigner[] oneExpiredOneValidSigner = { expiredSigner, alphaSigner }; 461 Vector<JarEntry> entries = new Vector<JarEntry>(); 462 entries.add(new JarCertVerifierEntry("firstSignedByTwo", oneExpiredOneValidSigner)); 463 entries.add(new JarCertVerifierEntry("secondSignedByTwo", oneExpiredOneValidSigner)); 464 entries.add(new JarCertVerifierEntry("thirdSignedByTwo", oneExpiredOneValidSigner)); 465 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 466 467 Assert.assertEquals("Three entries signed by one expired cert and another valid cert, should be considered signed and okay.", 468 VerifyResult.SIGNED_OK, result); 469 Assert.assertEquals("Three entries signed by one expired cert and another valid cert means two signers in the verifier.", 470 2, jcv.getCertsList().size()); 471 Assert.assertTrue("Three entries signed by one expired cert and another valid cert means two signers in the verifier.", 472 jcv.getCertsList().contains(expiredSigner.getSignerCertPath()) 473 && jcv.getCertsList().contains(alphaSigner.getSignerCertPath())); 474 } 475 476 @Test 477 public void testSomeExpiredEntries() throws Exception { 478 JarCertVerifier jcv = new JarCertVerifier(null); 479 CodeSigner[] oneExpiredOneValidSigners = { expiredSigner, alphaSigner }; 480 CodeSigner[] expiredSigners = { expiredSigner }; 481 482 Vector<JarEntry> entries = new Vector<JarEntry>(); 483 entries.add(new JarCertVerifierEntry("firstSignedByTwo", oneExpiredOneValidSigners)); 484 entries.add(new JarCertVerifierEntry("secondSignedByTwo", oneExpiredOneValidSigners)); 485 entries.add(new JarCertVerifierEntry("thirdSignedByExpired", expiredSigners)); 486 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 487 488 Assert.assertEquals("Two entries signed by one expired and one valid cert, third signed by just expired cert, should be considered signed but not okay.", 489 VerifyResult.SIGNED_NOT_OK, result); 490 Assert.assertEquals("Two entries signed by one expired and one valid cert, third signed by just expired cert means one signer in the verifier.", 491 1, jcv.getCertsList().size()); 492 Assert.assertTrue("Two entries signed by one expired and one valid cert, third signed by just expired cert means one signer in the verifier.", 493 jcv.getCertsList().contains(expiredSigner.getSignerCertPath())); 494 } 495 496 @Test 497 public void testManyInvalidOneValidStillSignedOkay() throws Exception { 498 JarCertVerifier jcv = new JarCertVerifier(null); 499 CodeSigner[] oneExpiredOneValidSigners = { alphaSigner, expiredSigner }; 500 CodeSigner[] oneNotYetValidOneValidSigners = { alphaSigner, notYetValidSigner }; 501 CodeSigner[] oneExpiringSigners = { alphaSigner, expiringSigner }; 502 503 Vector<JarEntry> entries = new Vector<JarEntry>(); 504 entries.add(new JarCertVerifierEntry("META-INF/MANIFEST.MF")); 505 entries.add(new JarCertVerifierEntry("firstSigned", oneExpiredOneValidSigners)); 506 entries.add(new JarCertVerifierEntry("secondSigned", oneNotYetValidOneValidSigners)); 507 entries.add(new JarCertVerifierEntry("thirdSigned", oneExpiringSigners)); 508 entries.add(new JarCertVerifierEntry("oneDir/")); 509 entries.add(new JarCertVerifierEntry("oneDir/fourthSigned", oneExpiredOneValidSigners)); 510 VerifyResult result = jcv.verifyJarEntryCerts("", true, entries); 511 512 Assert.assertEquals("Three entries sharing valid cert and others with issues, should be considered signed and okay.", 513 VerifyResult.SIGNED_OK, result); 514 Assert.assertEquals("Three entries sharing valid cert and others with issues means one signer in the verifier.", 515 1, jcv.getCertsList().size()); 516 Assert.assertTrue("Three entries sharing valid cert and others with issues means one signer in the verifier.", 517 jcv.getCertsList().contains(alphaSigner.getSignerCertPath())); 518 } 519 54 520 } -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/util/PropertiesFileTest.java
r418 r429 44 44 import java.nio.channels.FileLock; 45 45 import java.nio.channels.OverlappingFileLockException; 46 import net.sourceforge.jnlp.cache.CacheLRUWrapper; 46 47 47 48 import net.sourceforge.jnlp.config.DeploymentConfiguration; … … 62 63 63 64 // does no DeploymentConfiguration exist for this file name? 64 private final String cacheIndexFileName = "recently_used";65 private final String cacheIndexFileName = CacheLRUWrapper.CACHE_INDEX_FILE_NAME; 65 66 66 67 private final PropertiesFile cacheIndexFile = new PropertiesFile(new File(cacheDir + File.separatorChar + cacheIndexFileName)); -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/util/replacements/BASE64EncoderTest.java
r418 r429 49 49 public class BASE64EncoderTest { 50 50 51 privatestatic final String sSrc = "abcdefgHIJKLMNOPQrstuvwxyz1234567890\r\n"51 static final String sSrc = "abcdefgHIJKLMNOPQrstuvwxyz1234567890\r\n" 52 52 + "-=+_))(**&&&^^%%$$##@@!!~{}][\":'/\\.,><\n" 53 53 + "+ÄÅ¡ÄÄÅşÜáÃé=ů/úÄÅťšÄÅéÃáÄ"; 54 privatestatic final byte[] encoded = {89, 87, 74, 106, 90, 71, 86, 109, 90,54 static final byte[] encoded = {89, 87, 74, 106, 90, 71, 86, 109, 90, 55 55 48, 104, 74, 83, 107, 116, 77, 84, 85, 53, 80, 85, 70, 70, 121, 99, 51, 56 56 82, 49, 100, 110, 100, 52, 101, 88, 111, 120, 77, 106, 77, 48, 78, 84, … … 64 64 68, 113, 99, 79, 116, 119, 54, 72, 69, 106, 81, 61, 61, 10}; 65 65 66 public static final String sunClassE = "sun.misc.BASE64Encoder"; 67 public static final String sunClassD = "sun.misc.BASE64Decoder"; 66 private static final String sunClassD = "sun.misc.BASE64Decoder"; 68 67 69 68 @Test … … 98 97 byte[] encoded2 = out2.toByteArray(); 99 98 Object decoder = createInsatnce(sunClassD); 100 byte[] decoded = (byte[]) (getAndInvokeMethod(decoder, "decodeBuffer", new String(encoded , "utf-8")));99 byte[] decoded = (byte[]) (getAndInvokeMethod(decoder, "decodeBuffer", new String(encoded2, "utf-8"))); 101 100 Assert.assertArrayEquals(data, decoded); 102 101 Assert.assertEquals(sSrc, new String(decoded, "utf-8")); 103 104 105 106 102 } 103 104 @Test 105 public void testEmbededBase64EncoderAgainstEbededDecoder() throws Exception { 106 final byte[] data = sSrc.getBytes("utf-8"); 107 ByteArrayOutputStream out2 = new ByteArrayOutputStream(); 108 BASE64Encoder e2 = new BASE64Encoder(); 109 e2.encodeBuffer(data, out2); 110 byte[] encoded2 = out2.toByteArray(); 111 BASE64Decoder decoder = new BASE64Decoder(); 112 byte[] decoded = decoder.decodeBuffer(new String(encoded2, "utf-8")); 113 Assert.assertArrayEquals(data, decoded); 114 Assert.assertEquals(sSrc, new String(decoded, "utf-8")); 107 115 } 108 116 109 privatestatic Object createInsatnce(String ofCalss) throws ClassNotFoundException, InstantiationException, IllegalAccessException {117 static Object createInsatnce(String ofCalss) throws ClassNotFoundException, InstantiationException, IllegalAccessException { 110 118 111 Class classDefinition = Class.forName(ofCalss);119 Class<?> classDefinition = Class.forName(ofCalss); 112 120 return classDefinition.newInstance(); 113 121 114 122 } 115 123 116 privatestatic Object getAndInvokeMethod(Object instance, String methodName, Object... params) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {124 static Object getAndInvokeMethod(Object instance, String methodName, Object... params) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { 117 125 Class<?>[] cs = new Class<?>[params.length]; 118 126 for (int i = 0; i < params.length; i++) { -
trunk/icedtea-web/tests/report-styles/jreport.xsl
r418 r429 262 262 <xsl:choose> 263 263 <xsl:when test="@known-to-fail=true"> 264 < xsl:text>" - WARNING This test is known to fail, but have passed!</xsl:text>264 <b><xsl:text>" - WARNING This test is known to fail, but have passed!</xsl:text></b> 265 265 </xsl:when> 266 266 <xsl:otherwise> 267 < xsl:text> - This test is known to fail</xsl:text>267 <b><xsl:text> - This test is known to fail</xsl:text></b> 268 268 </xsl:otherwise> 269 269 </xsl:choose> 270 </xsl:when> 271 </xsl:choose> 272 <xsl:choose> 273 <xsl:when test="@remote"> 274 <i><xsl:text> - This test is running remote content, note that failures may be caused by broken target application or connection</xsl:text></i> 270 275 </xsl:when> 271 276 </xsl:choose> … … 277 282 <xsl:choose> 278 283 <xsl:when test="@known-to-fail"> 279 <xsl:text> - This test is known to fail</xsl:text> 284 <b><xsl:text> - This test is known to fail</xsl:text></b> 285 </xsl:when> 286 </xsl:choose> 287 <xsl:choose> 288 <xsl:when test="@remote"> 289 <i><xsl:text> - This test is running remote content, note that failures may be caused by broken target application or connection</xsl:text></i> 280 290 </xsl:when> 281 291 </xsl:choose> -
trunk/icedtea-web/tests/reproducers/custom/AppletFolderInArchiveTag/srcs/Makefile
r418 r429 1 1 TESTNAME=AppletFolderInArchiveTag 2 2 ARCHIVE_TEST_FOLDER=archive_tag_folder_test 3 JAVAC_CLASSPATH=$( JNLP_TESTS_ENGINE_DIR):$(NETX_DIR)/lib/classes.jar4 DEPLOY_SUBDIR=$( JNLP_TESTS_SERVER_DEPLOYDIR)/$(ARCHIVE_TEST_FOLDER)3 JAVAC_CLASSPATH=$(TEST_EXTENSIONS_DIR):$(NETX_DIR)/lib/classes.jar 4 DEPLOY_SUBDIR=$(REPRODUCERS_TESTS_SERVER_DEPLOYDIR)/$(ARCHIVE_TEST_FOLDER) 5 5 INDEX_HTML_BODY="<html><body><h1>Required to recognize folder structure</h1></body></html>" 6 6 -
trunk/icedtea-web/tests/reproducers/custom/AppletFolderInArchiveTag/testcases/AppletFolderInArchiveTagTests.java
r418 r429 36 36 */ 37 37 38 import net.sourceforge.jnlp. ServerAccess.ProcessResult;38 import net.sourceforge.jnlp.ProcessResult; 39 39 import net.sourceforge.jnlp.annotations.Bug; 40 40 import net.sourceforge.jnlp.annotations.NeedsDisplay; -
trunk/icedtea-web/tests/reproducers/custom/UnsignedContentInMETAINF/srcs/Makefile
r418 r429 1 1 TESTNAME=UnsignedContentInMETAINF 2 JAVAC_CLASSPATH=$( JNLP_TESTS_ENGINE_DIR):$(NETX_DIR)/lib/classes.jar3 DEPLOY_DIR=$( JNLP_TESTS_SERVER_DEPLOYDIR)2 JAVAC_CLASSPATH=$(TEST_EXTENSIONS_DIR):$(NETX_DIR)/lib/classes.jar 3 DEPLOY_DIR=$(REPRODUCERS_TESTS_SERVER_DEPLOYDIR) 4 4 JAVAC=$(BOOT_DIR)/bin/javac 5 5 JAR=$(BOOT_DIR)/bin/jar 6 ABS_SRC_PATH=$( JNLP_TESTS_SRCDIR)/custom/$(TESTNAME)/srcs6 ABS_SRC_PATH=$(REPRODUCERS_TESTS_SRCDIR)/custom/$(TESTNAME)/srcs 7 7 8 8 prepare-reproducer: -
trunk/icedtea-web/tests/reproducers/signed/AppletTestSigned/resources/AppletTestSigned.html
r418 r429 38 38 <html><head></head><body bgcolor="red"> 39 39 <p> 40 <applet code="AppletTestSigned.class" archive=" XslowXAppletTestSigned.jar" codebase="." width="100" height="100">40 <applet code="AppletTestSigned.class" archive="AppletTestSigned.jar" codebase="." width="100" height="100"> 41 41 <param name="key1" value="value1"> 42 42 <param name="key2" value="#value2"> -
trunk/icedtea-web/tests/reproducers/signed/AppletTestSigned/srcs/AppletTestSigned.java
r418 r429 49 49 Thread.sleep(n); 50 50 System.out.println("AppletTestSigned killing himself after " + n + " ms of life"); 51 System.out.println("*** APPLET FINISHED ***"); 51 52 System.exit(0); 52 53 } catch (Exception ex) { -
trunk/icedtea-web/tests/reproducers/signed/AppletTestSigned/testcases/AppletTestSignedTests.java
r418 r429 44 44 import net.sourceforge.jnlp.browsertesting.Browsers; 45 45 import net.sourceforge.jnlp.annotations.TestInBrowsers; 46 import net.sourceforge.jnlp.closinglisteners.Rule; 47 import net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener; 48 import static net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener.*; 46 49 import org.junit.Assert; 47 50 … … 51 54 52 55 private final List<String> l = Collections.unmodifiableList(Arrays.asList(new String[]{"-Xtrustall"})); 56 private static final String s0 = "AppletTestSigned was started"; 57 private static final String s1 = "value1"; 58 private static final String s2 = "value2"; 59 private static final String s3 = "AppletTestSigned was initialised"; 60 private static final String s7 = "AppletTestSigned killing himself after 2000 ms of life"; 61 private static final ContainsRule startedRule = new ContainsRule(s0); 62 private static final ContainsRule variable1Rule = new ContainsRule(s1); 63 private static final ContainsRule variable2Rule = new ContainsRule(s2); 64 private static final ContainsRule initialisedRule = new ContainsRule(s3); 65 private static final ContainsRule killedRule = new ContainsRule(s7); 66 private static final RulesFolowingClosingListener okListener=new RulesFolowingClosingListener(startedRule, variable1Rule, variable2Rule, initialisedRule, killedRule); 53 67 54 @Test68 // @Test 55 69 public void AppletTestSignedTest() throws Exception { 56 70 ProcessResult pr = server.executeJavawsHeadless(l, "/AppletTestSigned.jnlp"); … … 61 75 62 76 private void evaluateSignedApplet(ProcessResult pr, boolean javawsApplet) { 63 String s3 = "AppletTestSigned was initialised"; 64 Assert.assertTrue("AppletTestSigned stdout should contain " + s3 + " but didn't", pr.stdout.contains(s3)); 65 String s0 = "AppletTestSigned was started"; 66 Assert.assertTrue("AppletTestSigned stdout should contain " + s0 + " but didn't", pr.stdout.contains(s0)); 67 String s1 = "value1"; 68 Assert.assertTrue("AppletTestSigned stdout should contain " + s1 + " but didn't", pr.stdout.contains(s1)); 69 String s2 = "value2"; 70 Assert.assertTrue("AppletTestSigned stdout should contain " + s2 + " but didn't", pr.stdout.contains(s2)); 71 String ss = "xception"; 72 Assert.assertFalse("AppletTestSigned stderr should not contain " + ss + " but did", pr.stderr.contains(ss)); 73 String s7 = "AppletTestSigned killing himself after 2000 ms of life"; 74 Assert.assertTrue("AppletTestSigned stdout should contain " + s7 + " but didn't", pr.stdout.contains(s7)); 77 Assert.assertTrue("AppletTestSigned stdout " + initialisedRule.toPassingString() + " but didn't", initialisedRule.evaluate(pr.stdout)); 78 Assert.assertTrue("AppletTestSigned stdout " + startedRule.toPassingString() + " but didn't", startedRule.evaluate(pr.stdout)); 79 Assert.assertTrue("AppletTestSigned stdout " + variable1Rule.toPassingString() + " but didn't", variable1Rule.evaluate(pr.stdout)); 80 Assert.assertTrue("AppletTestSigned stdout " + variable2Rule.toPassingString() + " but didn't", variable2Rule.evaluate(pr.stdout)); 81 Assert.assertTrue("AppletTestSigned stdout " + killedRule.toPassingString() + " but didn't", killedRule.evaluate(pr.stdout)); 75 82 if (!javawsApplet) { 76 83 /*this is working correctly in most browser, but not in all. temporarily disabling … … 85 92 @Test 86 93 @TestInBrowsers(testIn = {Browsers.all}) 87 public void AppletTestSignedFirefoxTest () throws Exception {94 public void AppletTestSignedFirefoxTestXslowX() throws Exception { 88 95 ServerAccess.PROCESS_TIMEOUT = 30 * 1000; 89 96 try { 90 ProcessResult pr = server.executeBrowser("/AppletTestSigned .html");97 ProcessResult pr = server.executeBrowser("/AppletTestSigned2.html", okListener, null); 91 98 evaluateSignedApplet(pr, false); 92 Assert.assertTrue(pr.wasTerminated);99 //Assert.assertTrue(pr.wasTerminated); 93 100 //Assert.assertEquals((Integer) 0, pr.returnValue); due to destroy is null 94 101 } finally { … … 96 103 } 97 104 } 105 106 @Test 107 @TestInBrowsers(testIn = {Browsers.all}) 108 public void AppletTestSignedFirefoxTest() throws Exception { 109 ProcessResult pr = server.executeBrowser("/AppletTestSigned.html", ServerAccess.AutoClose.CLOSE_ON_CORRECT_END); 110 evaluateSignedApplet(pr, false); 111 //Assert.assertTrue(pr.wasTerminated); 112 //Assert.assertEquals((Integer) 0, pr.returnValue); due to destroy is null 113 } 98 114 } -
trunk/icedtea-web/tests/reproducers/signed/CacheReproducer/testcases/CacheReproducerTest.java
r418 r429 45 45 import java.util.Arrays; 46 46 import java.util.List; 47 import java.util.PropertyResourceBundle; 47 48 import java.util.regex.Matcher; 48 49 import java.util.regex.Pattern; 49 50 import net.sourceforge.jnlp.ServerAccess; 50 import net.sourceforge.jnlp. ServerAccess.ProcessResult;51 import net.sourceforge.jnlp.ProcessResult; 51 52 import net.sourceforge.jnlp.annotations.KnownToFail; 53 import net.sourceforge.jnlp.config.Defaults; 54 import net.sourceforge.jnlp.tools.MessageProperties; 52 55 import org.junit.AfterClass; 53 56 import org.junit.Assert; … … 61 64 private static final List<String> trustedVerboses = Arrays.asList(new String[]{"-Xtrustall", ServerAccess.HEADLES_OPTION,"-verbose"}); 62 65 private static final List<String> verbosed = Arrays.asList(new String[]{"-verbose", ServerAccess.HEADLES_OPTION}); 63 private static final String home = System.getProperty("user.home"); 64 private static final String name = System.getProperty("user.name"); 65 private static final String tmp = System.getProperty("java.io.tmpdir"); 66 private static final File icedteaDir = new File(home + "/" + ".icedtea"); 67 private static final File icedteaCache = new File(icedteaDir, "cache"); 68 private static final File icedteaCacheFile = new File(icedteaCache, "recently_used"); 69 private static final File netxLock = new File(tmp + "/" + name + "/netx/locks/netx_running"); 66 70 67 private static final String lre = "LruCacheException"; 71 68 private static final String ioobe = "IndexOutOfBoundsException"; … … 74 71 private static final String corruptString = "156dsf1562kd5"; 75 72 76 String testS = "#netx file\n" 77 + "#Mon Dec 12 16:20:46 CET 2011\n" 78 + "1323703236508,0=/home/xp13/.icedtea/cache/0/http/localhost/ReadPropertiesBySignedHack.jnlp\n" 79 + "1323703243086,2=/home/xp14/.icedtea/cache/2/http/localhost/ReadProperties.jar\n" 80 + "1323703243082,1=/home/xp15/.icedtea/cache/1/http/localhost/ReadPropertiesBySignedHack.jar"; 73 private static final File icedteaCache = new File(Defaults.USER_CACHE_HOME, "cache"); 74 private static final File icedteaCacheFile = new File(icedteaCache, "recently_used"); 75 private static final File netxLock = new File(System.getProperty("java.io.tmpdir"), 76 System.getProperty("user.name") + File.separator + 77 "netx" + File.separator + 78 "locks" + File.separator + 79 "netx_running"); 80 81 String testS = "#netx file\n" 82 + "#Mon Dec 12 16:20:46 CET 2011\n" 83 + "1323703236508,0=/home/xp13/.icedtea/cache/0/http/localhost/ReadPropertiesBySignedHack.jnlp\n" 84 + "1323703243086,2=/home/xp14/.icedtea/cache/2/http/localhost/ReadProperties.jar\n" 85 + "1323703243082,1=/home/xp15/.icedtea/cache/1/http/localhost/ReadPropertiesBySignedHack.jar"; 81 86 82 87 @Test … … 94 99 } 95 100 96 private class ParallelSimpleTestRunner extends Thread { 97 public boolean b=false; 98 @Override 99 public void run() { 100 try { 101 102 ServerAccess.ProcessResult pr = runSimpleTest1(); 103 evaluateSimpleTest1OkCache(pr); 104 b=true; 105 } catch (Exception ex) { 106 throw new RuntimeException(ex); 107 } 108 } 109 }; 101 private class ParallelSimpleTestRunner extends Thread { 102 public boolean b=false; 103 @Override 104 public void run() { 105 try { 106 ProcessResult pr = runSimpleTest1(); 107 evaluateSimpleTest1OkCache(pr); 108 b=true; 109 } catch (Exception ex) { 110 throw new RuntimeException(ex); 111 } 112 } 113 } 110 114 111 115 @Test … … 261 265 public void run() { 262 266 try { 263 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(verbosed, "/deadlocktest.jnlp");267 ProcessResult pr = server.executeJavawsHeadless(verbosed, "/deadlocktest.jnlp"); 264 268 } catch (Exception ex) { 265 269 throw new RuntimeException(ex); … … 270 274 Thread.sleep(1000); 271 275 pr = tryToClearcache(); 272 String q = "Can not clear cache at this time"; 273 Assert.assertTrue("Stderr should contain " + q + ", but did not.", pr.stderr.contains(q));274 assertCacheIsNotEmpty();275 }276 277 276 277 String cacheClearError = MessageProperties.getMessage("CCannotClearCache"); 278 Assert.assertTrue("Stderr should contain " + cacheClearError + ", but did not.", pr.stderr.contains(cacheClearError)); 279 assertCacheIsNotEmpty(); 280 } 281 278 282 //next four tests are designed to ensure, that corrupted cache will not break already loaded cached files 279 283 public static final String CR1 = "CacheReproducer1"; … … 338 342 if (netxLock.isFile()) { 339 343 boolean b = netxLock.delete(); 340 junit.framework.Assert.assertTrue(b);344 Assert.assertTrue(b); 341 345 } 342 346 … … 378 382 } 379 383 String sb = breakOne(s, 0); 380 junit.framework.Assert.assertEquals(s, sb);384 Assert.assertEquals(s, sb); 381 385 for (int x = 1; x <= 3; x++) { 382 386 String[] sx = breakOne(s, x).split("\n"); … … 427 431 428 432 private static String breakPaths(String s) { 429 return s.replaceAll( home+".*", "/ho");433 return s.replaceAll(System.getProperty("user.home") + ".*", "/ho"); 430 434 } 431 435 … … 448 452 } 449 453 450 private static ServerAccess.ProcessResult runSimpleTest1() throws Exception {454 private static ProcessResult runSimpleTest1() throws Exception { 451 455 return runSimpleTest1(verbosed, "simpletest1"); 452 456 } 453 457 454 private static ServerAccess.ProcessResult runSimpleTest1(List<String> args, String s) throws Exception {455 ServerAccess.ProcessResult pr2 = server.executeJavawsHeadless(args, "/" + s + ".jnlp");458 private static ProcessResult runSimpleTest1(List<String> args, String s) throws Exception { 459 ProcessResult pr2 = server.executeJavawsHeadless(args, "/" + s + ".jnlp"); 456 460 return pr2; 457 461 } 458 462 459 private static ServerAccess.ProcessResult runSimpleTest1Signed() throws Exception {463 private static ProcessResult runSimpleTest1Signed() throws Exception { 460 464 return runSimpleTestSigned("SimpletestSigned1"); 461 465 } 462 466 463 private static ServerAccess.ProcessResult runSimpleTestSigned(String id) throws Exception {467 private static ProcessResult runSimpleTestSigned(String id) throws Exception { 464 468 return runSimpleTest1(trustedVerboses, id); 465 469 } 466 470 467 private static void evaluateSimpleTest1OkCache( ServerAccess.ProcessResult pr2) throws Exception {471 private static void evaluateSimpleTest1OkCache(ProcessResult pr2) throws Exception { 468 472 String s = "Good simple javaws exapmle"; 469 473 Assert.assertTrue("test stdout should contain " + s + " but didn't", pr2.stdout.contains(s)); … … 473 477 474 478 private static ProcessResult tryToClearcache() throws Exception { 475 ServerAccess.ProcessResult pr1 = ServerAccess.executeProcess(clear);479 ProcessResult pr1 = ServerAccess.executeProcess(clear); 476 480 return pr1; 477 481 } -
trunk/icedtea-web/tests/reproducers/signed/ClasspathManifestTest/testcases/ClasspathManifestTest.java
r418 r429 39 39 import java.util.List; 40 40 41 import net.sourceforge.jnlp.ProcessResult; 41 42 import net.sourceforge.jnlp.ServerAccess; 42 import net.sourceforge.jnlp.ServerAccess.ProcessResult;43 import net.sourceforge.jnlp.annotations.Bug;44 43 import net.sourceforge.jnlp.annotations.KnownToFail; 45 44 import net.sourceforge.jnlp.annotations.NeedsDisplay; … … 51 50 import org.junit.Test; 52 51 53 @Bug(id = "PR975")54 52 public class ClasspathManifestTest extends BrowserTest { 55 53 … … 79 77 commands.add(ServerAccess.HEADLES_OPTION); 80 78 commands.add("ClasspathManifestApplicationTest.jnlp"); 81 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir());79 ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir()); 82 80 checkAppFails(pr, "ApplicationJNLPLocalTest"); 83 81 } … … 86 84 @Test 87 85 public void AppletJNLPRemoteTest() throws Exception { 88 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/ClasspathManifestAppletTest.jnlp");86 ProcessResult pr = server.executeJavawsHeadless(null, "/ClasspathManifestAppletTest.jnlp"); 89 87 checkAppFails(pr, "AppletJNLPRemoteTest"); 90 88 } … … 98 96 commands.add(ServerAccess.HEADLES_OPTION); 99 97 commands.add("ClasspathManifestAppletTest.jnlp"); 100 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir());98 ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir()); 101 99 checkAppFails(pr, "AppletJNLPRLocalTest"); 102 100 } … … 106 104 @Test 107 105 public void BrowserJNLPHrefRemoteTest() throws Exception { 108 ServerAccess.ProcessResult pr = server.executeBrowser("/ClasspathManifestJNLPHrefTest.html");106 ProcessResult pr = server.executeBrowser("/ClasspathManifestJNLPHrefTest.html"); 109 107 checkAppFails(pr, "BrowserJNLPHrefRemoteTest"); 110 108 } … … 118 116 commands.add(server.getBrowserLocation()); 119 117 commands.add("ClasspathManifestJNLPHrefTest.html"); 120 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir());118 ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir()); 121 119 checkAppFails(pr, "BrowserJNLPHrefLocalTest"); 122 120 } … … 126 124 @Test 127 125 public void BrowserAppletRemoteTest() throws Exception { 128 ServerAccess.ProcessResult pr = server.executeBrowser("/ClasspathManifestAppletTest.html");126 ProcessResult pr = server.executeBrowser("/ClasspathManifestAppletTest.html"); 129 127 Assert.assertTrue("ClasspathManifest.BrowserAppletRemoteTest stdout should contain " + s1 + " but didn't", pr.stdout.contains(s1)); 130 128 // Should be the only one to search manifest for classpath. 131 129 Assert.assertTrue("ClasspathManifest.BrowserAppletRemoteTest stdout should contain " + s2 + " but didn't", pr.stdout.contains(s2)); 132 Assert.assertFalse("ClasspathManifest.BrowserAppletRemoteTest stderr should not contain " + ss + " but did", pr.stderr.contains(ss));133 130 } 134 131 } -
trunk/icedtea-web/tests/reproducers/signed/ExtensionJnlp/testcases/ExtensionJnlpTest.java
r418 r429 39 39 import java.util.Collections; 40 40 import java.util.List; 41 import net.sourceforge.jnlp.ProcessResult; 41 42 import net.sourceforge.jnlp.ServerAccess; 42 43 import net.sourceforge.jnlp.annotations.Bug; … … 56 57 @Test 57 58 public void checkingForRequiredResources() throws Exception { 58 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJar.jnlp");59 ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJar.jnlp"); 59 60 Assert.assertTrue("Could not locate SignedJarResource class within SignedJarResource jar", pr.stdout.contains(jarOutput)); 60 61 … … 67 68 @Test 68 69 public void usingSignedExtension() throws Exception { 69 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJarExtension.jnlp");70 ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJarExtension.jnlp"); 70 71 Assert.assertTrue("Stdout should contain " + jarOutput + " but did not", pr.stdout.contains(jarOutput)); 71 72 } … … 74 75 @Test 75 76 public void mainJarInExtension() throws Exception { 76 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJnlpJarAndSignedJarExtension.jnlp");77 ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJnlpJarAndSignedJarExtension.jnlp"); 77 78 Assert.assertTrue("Stdout should contain " + jarOutput + " but did not", pr.stdout.contains(jarOutput)); 78 79 } … … 81 82 @Test 82 83 public void checkingSignedJnlpInExtension() throws Exception { 83 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJnlpExtension.jnlp");84 ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJnlpExtension.jnlp"); 84 85 Assert.assertTrue("Stdout should contain " + signedJnlpException + " but did not", pr.stderr.contains(signedJnlpException)); 85 86 } -
trunk/icedtea-web/tests/reproducers/signed/InternalClassloaderWithDownloadedResource/testcases/InternalClassloaderWithDownloadedResourceTest.java
r418 r429 40 40 import java.util.Collections; 41 41 import java.util.List; 42 import net.sourceforge.jnlp.ProcessResult; 42 43 import net.sourceforge.jnlp.ServerAccess; 43 import net.sourceforge.jnlp.ServerAccess.ProcessResult;44 44 import net.sourceforge.jnlp.annotations.Bug; 45 45 import net.sourceforge.jnlp.annotations.NeedsDisplay; … … 79 79 @Bug(id = {"RH816592","PR858"}) 80 80 public void launchInternalClassloaderWithDownloadedResourceAsJnlpApplication() throws Exception { 81 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-new.jnlp");81 ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-new.jnlp"); 82 82 evaluate(pr); 83 83 Assert.assertFalse("should not be terminated but was", pr.wasTerminated); … … 88 88 String ss = "Good simple javaws exapmle"; 89 89 Assert.assertTrue("Stdout should contains " + ss + " but didn't", pr.stdout.contains(ss)); 90 String s = "xception";91 Assert.assertFalse("Stderr should not contains " + s + " but did", pr.stderr.contains(s));92 90 } 93 91 … … 95 93 @Bug(id = {"RH816592","PR858"}) 96 94 public void launchInternalClassloaderWithDownloadedResourceAsJnlpApplet() throws Exception { 97 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-applet-new.jnlp");95 ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-applet-new.jnlp"); 98 96 evaluate(pr); 99 97 Assert.assertFalse("should not be terminated but was", pr.wasTerminated); … … 106 104 @TestInBrowsers(testIn={Browsers.all}) 107 105 public void launchInternalClassloaderWithDownloadedResourceAsHtmlApplet() throws Exception { 108 ServerAccess.ProcessResult pr = server.executeBrowser("/InternalClassloaderWithDownloadedResource-new.html");106 ProcessResult pr = server.executeBrowser("/InternalClassloaderWithDownloadedResource-new.html"); 109 107 evaluate(pr); 110 108 Assert.assertTrue("should be terminated but was not", pr.wasTerminated); … … 114 112 @Bug(id = {"http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-May/018737.html"}) 115 113 public void launchInternalClassloaderWithDownloadedResourceAsJnlpApplicationHack() throws Exception { 116 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-hack.jnlp");114 ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-hack.jnlp"); 117 115 evaluate(pr); 118 116 Assert.assertFalse("should not be terminated but was", pr.wasTerminated); … … 123 121 @Bug(id = {"http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-May/018737.html"}) 124 122 public void launchInternalClassloaderWithDownloadedResourceAsJnlpAppletHack() throws Exception { 125 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-applet-hack.jnlp");123 ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-applet-hack.jnlp"); 126 124 evaluate(pr); 127 125 Assert.assertFalse("should not be terminated but was", pr.wasTerminated); … … 134 132 @TestInBrowsers(testIn={Browsers.all}) 135 133 public void launchInternalClassloaderWithDownloadedResourceAsHtmlAppletHack() throws Exception { 136 ServerAccess.ProcessResult pr = server.executeBrowser("/InternalClassloaderWithDownloadedResource-hack.html");134 ProcessResult pr = server.executeBrowser("/InternalClassloaderWithDownloadedResource-hack.html"); 137 135 evaluate(pr); 138 136 Assert.assertTrue("should be terminated but was not", pr.wasTerminated); -
trunk/icedtea-web/tests/reproducers/signed/MissingJar/testcases/MissingJarTest.java
r418 r429 1 /* MissingJar .java1 /* MissingJarTest.java 2 2 Copyright (C) 2011 Red Hat, Inc. 3 3 … … 39 39 import java.util.Collections; 40 40 import java.util.List; 41 import net.sourceforge.jnlp.ProcessResult; 41 42 import net.sourceforge.jnlp.ServerAccess; 42 import net.sourceforge.jnlp.ServerAccess.ProcessResult; 43 43 44 import org.junit.Assert; 44 45 45 import org.junit.Test; 46 46 … … 61 61 @Test 62 62 public void MissingJarTest1() throws Exception { 63 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar.jnlp");63 ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar.jnlp"); 64 64 evaluateResult(pr); 65 65 } … … 67 67 @Test 68 68 public void MissingJarTest2() throws Exception { 69 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar2.jnlp");69 ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar2.jnlp"); 70 70 evaluateResult(pr); 71 71 } … … 73 73 @Test 74 74 public void MissingJarTest3() throws Exception { 75 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar3.jnlp");75 ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar3.jnlp"); 76 76 evaluateResult(pr); 77 77 } … … 79 79 @Test 80 80 public void MissingJarTest4() throws Exception { 81 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar4.jnlp");81 ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar4.jnlp"); 82 82 evaluateResult(pr); 83 83 } -
trunk/icedtea-web/tests/reproducers/signed/ReadPropertiesBySignedHack/testcases/ReadPropertiesBySignedHackTest.java
r418 r429 1 /* ReadProperties SignedTest.java1 /* ReadPropertiesBySignedHackTest.java 2 2 Copyright (C) 2011 Red Hat, Inc. 3 3 … … 36 36 */ 37 37 38 39 38 import java.util.Arrays; 40 39 import java.util.Collections; 41 40 import java.util.List; 41 import net.sourceforge.jnlp.ProcessResult; 42 42 import net.sourceforge.jnlp.ServerAccess; 43 43 44 import org.junit.Assert; 44 45 import org.junit.Test; … … 53 54 public void ReadPropertiesBySignedHackWithjoutXtrustAll() throws Exception { 54 55 //no request for permissions 55 ServerAccess.ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesBySignedHack.jnlp");56 ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesBySignedHack.jnlp"); 56 57 String s="java.lang.SecurityException: class \"ReadProperties\"'s signer information does not match signer information of other classes in the same package"; 57 58 Assert.assertTrue("Stderr should contains "+s+" but did not",pr.stderr.contains(s)); 58 59 String ss="ClassNotFoundException"; 59 60 Assert.assertFalse("Stderr should not contains "+ss+" but did",pr.stderr.contains(ss)); 60 Assert.assertTrue("stdout lenght should be <2 but was "+pr.stdout.length(),pr.stdout.length()<2); // /home/user or /root or eanything else :(61 61 Assert.assertFalse("should not be terminated but was",pr.wasTerminated); 62 62 Assert.assertEquals((Integer)0, pr.returnValue); -
trunk/icedtea-web/tests/reproducers/signed/ReadPropertiesSigned/testcases/ReadPropertiesSignedTest.java
r418 r429 36 36 */ 37 37 38 39 38 import java.util.Arrays; 40 39 import java.util.Collections; 41 40 import java.util.List; 41 import net.sourceforge.jnlp.ProcessResult; 42 42 import net.sourceforge.jnlp.ServerAccess; 43 43 44 import org.junit.Assert; 44 45 import org.junit.Test; … … 54 55 public void ReadSignedPropertiesWithoutPermissionsWithXtrustAll() throws Exception { 55 56 //no request for permissions 56 ServerAccess.ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesSigned1.jnlp");57 ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesSigned1.jnlp"); 57 58 Assert.assertTrue("Stderr should match "+accessMatcher+" but did not",pr.stderr.matches(accessMatcher)); 58 59 String ss="ClassNotFoundException"; 59 60 Assert.assertFalse("Stderr should not contains "+ss+" but did",pr.stderr.contains(ss)); 60 Assert.assertTrue("stdout lenght should be <2 but was "+pr.stdout.length(),pr.stdout.length()<2); // /home/user or /root or eanything else :(61 61 Assert.assertFalse("should not be terminated but was",pr.wasTerminated); 62 62 Assert.assertEquals((Integer)0, pr.returnValue); … … 66 66 public void ReadSignedPropertiesWithPermissionsWithXtrustAll() throws Exception { 67 67 //request for allpermissions 68 ServerAccess.ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesSigned2.jnlp");68 ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesSigned2.jnlp"); 69 69 Assert.assertFalse("Stderr should NOT match "+accessMatcher+" but did",pr.stderr.matches(accessMatcher)); 70 70 String ss="ClassNotFoundException"; 71 71 Assert.assertFalse("Stderr should not contains "+ss+" but did",pr.stderr.contains(ss)); 72 Assert.assertTrue("stdout lenght should be >= but was "+pr.stdout.length(),pr.stdout.length()>=4); // /home/user or /root or eanything else :(73 72 Assert.assertFalse("should not be terminated but was",pr.wasTerminated); 74 73 Assert.assertEquals((Integer)0, pr.returnValue); … … 77 76 @Test 78 77 public void EnsureXtrustallNotAffectingUnsignedBehaviour() throws Exception { 79 ServerAccess.ProcessResult pr=server.executeJavawsHeadless(l,"/ReadProperties1.jnlp");78 ProcessResult pr=server.executeJavawsHeadless(l,"/ReadProperties1.jnlp"); 80 79 Assert.assertTrue("Stderr should match "+accessMatcher+" but did not",pr.stderr.matches(accessMatcher)); 81 80 String ss="ClassNotFoundException"; 82 81 Assert.assertFalse("Stderr should not contains "+ss+" but did",pr.stderr.contains(ss)); 83 Assert.assertFalse("stdout lenght should not be >2 but was "+pr.stdout.length(),pr.stdout.length()>2);84 82 Assert.assertFalse("should not be terminated but was",pr.wasTerminated); 85 83 Assert.assertEquals((Integer)0, pr.returnValue); 86 ServerAccess.ProcessResult pr2=server.executeJavawsHeadless(null,"/ReadProperties1.jnlp");84 ProcessResult pr2=server.executeJavawsHeadless(null,"/ReadProperties1.jnlp"); 87 85 Assert.assertEquals(pr.stderr, pr2.stderr); 88 86 Assert.assertEquals(pr.stdout, pr2.stdout); 89 90 87 } 91 88 } -
trunk/icedtea-web/tests/reproducers/signed/SavingCookies/resources/CheckCookieAndGotoClear.html
r418 r429 38 38 39 39 <!-- Uses show-document to go to a page that clears the cookie --> 40 40 41 41 <html><head></head><body bgcolor="red"> 42 42 <p> 43 43 <applet code="CheckingCookies.class" archive="SavingCookies.jar" codebase="." width="100" height="100"> 44 44 45 45 <param name="show-document" value="ClearPersistentCookie.html"> 46 46 47 47 </applet> 48 48 </p> -
trunk/icedtea-web/tests/reproducers/signed/SavingCookies/resources/ClearPersistentCookie.html
r418 r429 41 41 42 42 <param name="persistent" value="no"> 43 43 44 44 <param name="cookie" value="TEST=deleted; Expires=Thu, 01 Jan 1970 00:00:01 GMT"> 45 45 -
trunk/icedtea-web/tests/reproducers/signed/SavingCookies/resources/SavePersistentCookie.html
r418 r429 41 41 42 42 <param name="persistent" value="yes"> 43 43 44 44 <param name="cookie" value="TEST=persistent"> 45 45 46 46 </applet> 47 47 </p> -
trunk/icedtea-web/tests/reproducers/signed/SavingCookies/resources/SavePersistentCookieAndGotoCheck.html
r418 r429 42 42 <param name="show-document" value="CheckCookieAndGotoClear.html"> 43 43 <param name="persistent" value="yes"> 44 44 45 45 <param name="cookie" value="TEST=persistent"> 46 46 -
trunk/icedtea-web/tests/reproducers/signed/SavingCookies/resources/SaveSessionCookie.html
r418 r429 41 41 42 42 <param name="persistent" value="no"> 43 43 44 44 <param name="cookie" value="TEST=session"> 45 45 -
trunk/icedtea-web/tests/reproducers/signed/SavingCookies/srcs/SavingCookies.java
r418 r429 1 1 /* SavingCookies.java 2 2 Store cookies in the java cookie store, and go to a page that confirms they are there. 3 3 4 4 Copyright (C) 2012 Red Hat, Inc. 5 5 -
trunk/icedtea-web/tests/reproducers/signed/SavingCookies/testcases/SavingCookiesTests.java
r418 r429 51 51 52 52 public class SavingCookiesTests extends BrowserTest { 53 53 54 54 static final String ENTERING_CHECK = "Entered CheckingCookies"; 55 55 static final String CHECKING_COMPLETION = "Finished CheckingCookies"; … … 86 86 }; 87 87 if (url.endsWith(".html")) { 88 pr = server.executeBrowser(url, stdoutListener, stdoutListener);88 pr = server.executeBrowser(url, stdoutListener, null); 89 89 } else if (url.endsWith(".jnlp")) { 90 pr = server.executeJavawsHeadless(TRUSTALL, url, stdoutListener, stdoutListener);90 pr = server.executeJavawsHeadless(TRUSTALL, url, stdoutListener, null, null); 91 91 } 92 92 } catch (Exception ex) { … … 106 106 final String COOKIE_SANITY_CHECK = "Found cookie: TEST="; 107 107 ProcessResult pr = server.executeBrowser("/CheckCookie.html"); 108 108 109 109 Assert.assertFalse("stdout should NOT contain '" + COOKIE_SANITY_CHECK + "' but did.", pr.stdout.contains(COOKIE_SANITY_CHECK)); 110 110 Assert.assertTrue("stdout should contain '" + CHECKING_COMPLETION + "' but did not.", pr.stdout.contains(CHECKING_COMPLETION)); 111 111 } 112 112 113 113 @Test 114 114 @TestInBrowsers(testIn = { Browsers.one }) … … 130 130 Thread.sleep(100); 131 131 } 132 132 133 133 ProcessResult check = server.executeBrowser("/CheckCookie.html"); 134 134 save.join(); 135 135 136 136 Assert.assertTrue("stdout should contain '" + ENTERING_CHECK + "' but did not.", save.pr.stdout.contains(ENTERING_CHECK)); 137 137 //XXX: It is necessary to check save.pr's stdout, because it does not show up in 'check.stdout' for some reason … … 155 155 public void AppletPersistentCookieShowDoc() throws Exception { 156 156 ProcessResult pr = server.executeBrowser("/SavePersistentCookieAndGotoCheck.html"); 157 157 158 158 Assert.assertTrue("stdout should contain '" + ENTERING_CHECK + "' but did not.", pr.stdout.contains(ENTERING_CHECK)); 159 159 Assert.assertTrue("stdout should contain '" + COOKIE_PERSISTENT_CHECK + "' but did not.", pr.stdout.contains(COOKIE_PERSISTENT_CHECK)); -
trunk/icedtea-web/tests/reproducers/signed/SignedJnlpApplication/testcases/SignedJnlpApplicationTest.java
r418 r429 39 39 import java.util.Collections; 40 40 import java.util.List; 41 import net.sourceforge.jnlp.ProcessResult; 41 42 import net.sourceforge.jnlp.ServerAccess; 43 42 44 import org.junit.Assert; 43 45 import org.junit.Test; … … 53 55 @Test 54 56 public void launchingFileMatchesSignedApplication1() throws Exception { 55 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication1.jnlp");57 ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication1.jnlp"); 56 58 String s = "Running signed application in main"; 57 59 Assert.assertTrue("Stdout should contains " + s + " but did not", pr.stdout.contains(s)); … … 63 65 @Test 64 66 public void launchingFileDoesNotMatchSignedApplication1() throws Exception { 65 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication2.jnlp");67 ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication2.jnlp"); 66 68 Assert.assertTrue("Stderr should contains " + signedException + " but did not", pr.stderr.contains(signedException)); 67 69 } … … 72 74 @Test 73 75 public void launchingFileDoesNotMatchSignedApplication2() throws Exception { 74 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication3.jnlp");76 ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication3.jnlp"); 75 77 Assert.assertTrue("Stderr should contains " + signedException + " but did not", pr.stderr.contains(signedException)); 76 78 } -
trunk/icedtea-web/tests/reproducers/signed/SignedJnlpCaseTestOne/testcases/SignedJnlpCaseOneTest.java
r418 r429 39 39 import java.util.Collections; 40 40 import java.util.List; 41 import net.sourceforge.jnlp.ProcessResult; 41 42 import net.sourceforge.jnlp.ServerAccess; 43 42 44 import org.junit.Assert; 43 45 import org.junit.Test; … … 50 52 @Test 51 53 public void launchingFileMatchesSigned() throws Exception { 52 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestOne1.jnlp");54 ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestOne1.jnlp"); 53 55 String s = "Running signed application in main"; 54 56 Assert.assertTrue("Stdout should contains " + s + " but did not", pr.stdout.contains(s)); … … 57 59 @Test 58 60 public void launchingFileDoesNotMatchSigned() throws Exception { 59 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestOne2.jnlp");61 ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestOne2.jnlp"); 60 62 String s = "net.sourceforge.jnlp.LaunchException: Fatal: Application Error: The signed " + 61 63 "JNLP file did not match the launching JNLP file. Missing Resource: Signed Application did not match " + -
trunk/icedtea-web/tests/reproducers/signed/SignedJnlpCaseTestTwo/testcases/SignedJnlpCaseTwoTest.java
r418 r429 39 39 import java.util.Collections; 40 40 import java.util.List; 41 import net.sourceforge.jnlp.ProcessResult; 41 42 import net.sourceforge.jnlp.ServerAccess; 42 43 import org.junit.Assert; … … 50 51 @Test 51 52 public void launchingFileMatchesSigned() throws Exception { 52 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestTwo1.jnlp");53 ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestTwo1.jnlp"); 53 54 String s = "Running signed application in main"; 54 55 Assert.assertTrue("Stdout should contains " + s + " but did not", pr.stdout.contains(s)); … … 57 58 @Test 58 59 public void launchingFileDoesNotMatchSigned() throws Exception { 59 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestTwo2.jnlp");60 ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestTwo2.jnlp"); 60 61 String s = "net.sourceforge.jnlp.LaunchException: Fatal: Application Error: The signed " + 61 62 "JNLP file did not match the launching JNLP file. Missing Resource: Signed Application did not match " + -
trunk/icedtea-web/tests/reproducers/signed/SignedJnlpTemplate/testcases/SignedJnlpTemplateTest.java
r418 r429 39 39 import java.util.Collections; 40 40 import java.util.List; 41 import net.sourceforge.jnlp.ProcessResult; 41 42 import net.sourceforge.jnlp.ServerAccess; 43 42 44 import org.junit.Assert; 43 45 import org.junit.Test; … … 53 55 @Test 54 56 public void launchingFileMatchesSignedTemplate1() throws Exception { 55 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate1.jnlp");57 ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate1.jnlp"); 56 58 String s = "Running signed application in main"; 57 59 Assert.assertTrue("Stdout should contains " + s + " but did not", pr.stdout.contains(s)); … … 63 65 @Test 64 66 public void launchingFileDoesNotMatchSignedTemplate2() throws Exception { 65 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate2.jnlp");67 ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate2.jnlp"); 66 68 Assert.assertTrue("Stderr should contains " + signedException + " but did not", pr.stderr.contains(signedException)); 67 69 } … … 72 74 @Test 73 75 public void launchingFileDoesNotMatchSignedTemplate3() throws Exception { 74 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate3.jnlp");76 ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate3.jnlp"); 75 77 Assert.assertTrue("Stderr should contains " + signedException + " but did not", pr.stderr.contains(signedException)); 76 78 } -
trunk/icedtea-web/tests/reproducers/signed/Spaces can be everywhere signed/testcases/SpacesCanBeEverywhereTestsSigned.java
r418 r429 38 38 import java.util.ArrayList; 39 39 import java.util.List; 40 import net.sourceforge.jnlp.ProcessResult; 40 41 import net.sourceforge.jnlp.ServerAccess; 41 42 import net.sourceforge.jnlp.annotations.Bug; … … 44 45 import net.sourceforge.jnlp.browsertesting.Browsers; 45 46 import net.sourceforge.jnlp.annotations.TestInBrowsers; 47 46 48 import org.junit.Assert; 47 48 49 import org.junit.Test; 49 50 50 51 @Bug(id={"http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2011-October/016127.html","PR804","PR811"}) 51 52 public class SpacesCanBeEverywhereTestsSigned extends BrowserTest { 52 53 53 54 54 @Bug(id="PR811") … … 83 83 * only on ocal files, and probably only from test run - it can be ignored 84 84 */ 85 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands); 86 String s="Signed spaces can be everywhere.jsr was launched correctly"; 87 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 88 String cc = "xception"; 89 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc)); 85 ProcessResult pr = ServerAccess.executeProcess(commands); 86 String s="Signed spaces can be everywhere.jsr was launched correctly"; 87 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 90 88 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated); 91 89 Assert.assertEquals((Integer) 0, pr.returnValue); … … 96 94 @NeedsDisplay 97 95 public void SpacesCanBeEverywhereRemoteAppletTestsJnlp2Signed() throws Exception { 98 ServerAccess.ProcessResult pr = server.executeJavaws("/NotOnly%20spaces%20can%20kill%20%C4%9B%C5%A1%C4%8D%C5%99%C5%BE%20too%20signed.jnlp"); 99 String s="Signed spaces can be everywhere.jsr was launched correctly"; 100 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 101 String cc = "xception"; 102 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc)); 96 ProcessResult pr = server.executeJavaws("/NotOnly%20spaces%20can%20kill%20%C4%9B%C5%A1%C4%8D%C5%99%C5%BE%20too%20signed.jnlp"); 97 String s="Signed spaces can be everywhere.jsr was launched correctly"; 98 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 103 99 Assert.assertFalse("should NOT be terminated, but was not", pr.wasTerminated); 104 100 } … … 109 105 @TestInBrowsers(testIn = {Browsers.one}) 110 106 public void SpacesCanBeEverywhereRemoteAppletTestsHtml2Signed() throws Exception { 111 ServerAccess.ProcessResult pr = server.executeBrowser("/spaces+applet+Tests+signed.html"); 112 String s="Signed spaces can be everywhere.jsr was launched correctly"; 113 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 114 String cc = "xception"; 115 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc)); 107 ProcessResult pr = server.executeBrowser("/spaces+applet+Tests+signed.html"); 108 String s="Signed spaces can be everywhere.jsr was launched correctly"; 109 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 116 110 Assert.assertTrue("should be terminated, but was not", pr.wasTerminated); 117 111 } … … 121 115 @Test 122 116 public void SpacesCanBeEverywhereRemoteTests1Signed() throws Exception { 123 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere1%20signed.jnlp");117 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere1%20signed.jnlp"); 124 118 String s = "Good simple javaws exapmle"; 125 119 Assert.assertTrue("stdout should contains `" + s + "`, but did not", pr.stdout.contains(s)); … … 133 127 @Test 134 128 public void SpacesCanBeEverywhereRemoteTests2Signed() throws Exception { 135 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2%20signed.jnlp");129 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2%20signed.jnlp"); 136 130 String s="Signed spaces can be everywhere.jsr was launched correctly"; 137 131 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); … … 145 139 @Test 146 140 public void SpacesCanBeEverywhereRemoteTests2Signed_withQuery1() throws Exception { 147 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2%20signed.jnlp?test=20");141 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2%20signed.jnlp?test=20"); 148 142 String s="Signed spaces can be everywhere.jsr was launched correctly"; 149 143 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); … … 157 151 @Test 158 152 public void SpacesCanBeEverywhereRemoteTests2Signed_withQuery2() throws Exception { 159 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2%20signed.jnlp?test%3D20");153 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2%20signed.jnlp?test%3D20"); 160 154 161 155 String s="Signed spaces can be everywhere.jsr was launched correctly"; … … 170 164 @Test 171 165 public void SpacesCanBeEverywhereRemoteTests3Signed() throws Exception { 172 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/SpacesCanBeEverywhere1signed.jnlp");166 ProcessResult pr = server.executeJavawsHeadless(null, "/SpacesCanBeEverywhere1signed.jnlp"); 173 167 String s="Signed spaces can be everywhere.jsr was launched correctly"; 174 168 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); … … 187 181 commands.add(ServerAccess.HEADLES_OPTION); 188 182 commands.add("Spaces can be everywhere1.jnlp"); 189 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());183 ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir()); 190 184 String s = "Good simple javaws exapmle"; 191 185 Assert.assertTrue("stdout should contains `" + s + "`, but did not", pr.stdout.contains(s)); … … 203 197 commands.add(ServerAccess.HEADLES_OPTION); 204 198 commands.add("Spaces can be everywhere2 signed.jnlp"); 205 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());199 ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir()); 206 200 String s="Signed spaces can be everywhere.jsr was launched correctly"; 207 201 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); … … 219 213 commands.add(ServerAccess.HEADLES_OPTION); 220 214 commands.add(server.getDir()+"/Spaces can be everywhere2 signed.jnlp"); 221 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands);215 ProcessResult pr = ServerAccess.executeProcess(commands); 222 216 String s="Signed spaces can be everywhere.jsr was launched correctly"; 223 217 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); … … 235 229 commands.add(ServerAccess.HEADLES_OPTION); 236 230 commands.add("SpacesCanBeEverywhere1signed.jnlp"); 237 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());231 ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir()); 238 232 String s="Signed spaces can be everywhere.jsr was launched correctly"; 239 233 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); -
trunk/icedtea-web/tests/reproducers/simple/AccessClassInPackage/testcases/AccessClassInPackageTest.java
r418 r429 38 38 import java.util.Arrays; 39 39 import java.util.List; 40 import net.sourceforge.jnlp.ProcessResult; 40 41 import net.sourceforge.jnlp.ServerAccess; 41 import net.sourceforge.jnlp.ServerAccess.ProcessResult; 42 42 43 import org.junit.Assert; 43 44 44 import org.junit.Test; 45 45 … … 73 73 private static final List<String> xta = Arrays.asList(new String[]{"-Xtrustall"}); 74 74 75 private void testShouldFail( ServerAccess.ProcessResult pr, String s) {75 private void testShouldFail(ProcessResult pr, String s) { 76 76 String c = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + s + ".*"; 77 77 Assert.assertTrue("stderr should match `" + c + "`, but didn't ", pr.stderr.matches(c)); 78 78 } 79 79 80 private void testShouldNOTFail( ServerAccess.ProcessResult pr, String s) {80 private void testShouldNOTFail(ProcessResult pr, String s) { 81 81 String c = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + s + ".*"; 82 82 Assert.assertFalse("stderr should NOT match `" + c + "`, but did ", pr.stderr.matches(c)); … … 90 90 } 91 91 92 private void testShouldPass( ServerAccess.ProcessResult pr, String s) {92 private void testShouldPass(ProcessResult pr, String s) { 93 93 String c = "Class was obtained: " + s; 94 94 Assert.assertTrue("stdout should contains `" + c + "`, but didn't ", pr.stdout.contains(c)); 95 95 } 96 96 97 private void testShouldNOTPass( ServerAccess.ProcessResult pr, String s) {97 private void testShouldNOTPass(ProcessResult pr, String s) { 98 98 String c = "Class was obtained: " + s; 99 99 Assert.assertFalse("stdout should not contains `" + c + "`, but did ", pr.stdout.contains(c)); … … 102 102 @Test 103 103 public void AccessClassInPackageJAVAXJNLP() throws Exception { 104 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[0]);104 ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[0]); 105 105 commonPitfall(pr); 106 106 testShouldPass(pr, pass[0]); … … 110 110 @Test 111 111 public void AccessClassInPackageSELF() throws Exception { 112 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[1]);112 ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[1]); 113 113 commonPitfall(pr); 114 114 testShouldPass(pr, pass[1]); … … 118 118 @Test 119 119 public void AccessClassInPackageNETSF() throws Exception { 120 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[2]);120 ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[2]); 121 121 commonPitfall(pr); 122 122 testShouldFail(pr, badExceptions[2]); … … 126 126 @Test 127 127 public void AccessClassInPackageSUNSEC() throws Exception { 128 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[3]);128 ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[3]); 129 129 commonPitfall(pr); 130 130 commonPitfall(pr); … … 136 136 @Test 137 137 public void AccessClassInPackageSignedJAVAXJNLP() throws Exception { 138 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[0]);138 ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[0]); 139 139 commonPitfall(pr); 140 140 testShouldPass(pr, pass[0]); … … 144 144 @Test 145 145 public void AccessClassInPackageSignedSELF() throws Exception { 146 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[1]);146 ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[1]); 147 147 commonPitfall(pr); 148 148 testShouldPass(pr, pass[1]); … … 152 152 @Test 153 153 public void AccessClassInPackageSignedNETSF() throws Exception { 154 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[2]);154 ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[2]); 155 155 commonPitfall(pr); 156 156 testShouldPass(pr, pass[2]); … … 160 160 @Test 161 161 public void AccessClassInPackageSignedSUNSEC() throws Exception { 162 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[3]);162 ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[3]); 163 163 commonPitfall(pr); 164 164 testShouldPass(pr, pass[3]); -
trunk/icedtea-web/tests/reproducers/simple/AddShutdownHook/srcs/AddShutdownHook.java
r418 r429 1 2 import java.applet.Applet; 3 1 4 /* AddShutdownHook.java 2 Copyright (C) 2011 Red Hat, Inc.5 Copyright (C) 2011 Red Hat, Inc. 3 6 4 This file is part of IcedTea.7 This file is part of IcedTea. 5 8 6 IcedTea is free software; you can redistribute it and/or7 modify it under the terms of the GNU General Public License as published by8 the Free Software Foundation, version 2.9 IcedTea is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, version 2. 9 12 10 IcedTea is distributed in the hope that it will be useful,11 but WITHOUT ANY WARRANTY; without even the implied warranty of12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13 General Public License for more details.13 IcedTea is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 General Public License for more details. 14 17 15 You should have received a copy of the GNU General Public License16 along with IcedTea; see the file COPYING. If not, write to17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA18 02110-1301 USA.18 You should have received a copy of the GNU General Public License 19 along with IcedTea; see the file COPYING. If not, write to 20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 02110-1301 USA. 19 22 20 Linking this library statically or dynamically with other modules is21 making a combined work based on this library. Thus, the terms and22 conditions of the GNU General Public License cover the whole23 combination.23 Linking this library statically or dynamically with other modules is 24 making a combined work based on this library. Thus, the terms and 25 conditions of the GNU General Public License cover the whole 26 combination. 24 27 25 As a special exception, the copyright holders of this library give you26 permission to link this library with independent modules to produce an27 executable, regardless of the license terms of these independent28 modules, and to copy and distribute the resulting executable under29 terms of your choice, provided that you also meet, for each linked30 independent module, the terms and conditions of the license of that31 module. An independent module is a module which is not derived from32 or based on this library. If you modify this library, you may extend33 this exception to your version of the library, but you are not34 obligated to do so. If you do not wish to do so, delete this35 exception statement from your version.28 As a special exception, the copyright holders of this library give you 29 permission to link this library with independent modules to produce an 30 executable, regardless of the license terms of these independent 31 modules, and to copy and distribute the resulting executable under 32 terms of your choice, provided that you also meet, for each linked 33 independent module, the terms and conditions of the license of that 34 module. An independent module is a module which is not derived from 35 or based on this library. If you modify this library, you may extend 36 this exception to your version of the library, but you are not 37 obligated to do so. If you do not wish to do so, delete this 38 exception statement from your version. 36 39 */ 40 public class AddShutdownHook extends Applet { 37 41 38 public class AddShutdownHook {39 42 public static void main(String[] args) { 40 43 41 Runtime.getRuntime().addShutdownHook(new Thread() { 42 public void run() { 43 // no op 44 } 45 }); 46 44 Runtime.getRuntime().addShutdownHook(new Thread() { 45 public void run() { 46 // no op 47 } 48 }); 49 50 } 51 52 @Override 53 public void start() { 54 main(null); 55 System.err.println("WRONG - ShutdownHook was probably added"); 47 56 } 48 57 } -
trunk/icedtea-web/tests/reproducers/simple/AddShutdownHook/testcases/AddShutdownHookTest.java
r418 r429 1 1 /* AddShutdownHookTest.java 2 Copyright (C) 2011 Red Hat, Inc.2 Copyright (C) 2011 Red Hat, Inc. 3 3 4 This file is part of IcedTea.4 This file is part of IcedTea. 5 5 6 IcedTea is free software; you can redistribute it and/or7 modify it under the terms of the GNU General Public License as published by8 the Free Software Foundation, version 2.6 IcedTea is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, version 2. 9 9 10 IcedTea is distributed in the hope that it will be useful,11 but WITHOUT ANY WARRANTY; without even the implied warranty of12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13 General Public License for more details.10 IcedTea is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 14 15 You should have received a copy of the GNU General Public License16 along with IcedTea; see the file COPYING. If not, write to17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA18 02110-1301 USA.15 You should have received a copy of the GNU General Public License 16 along with IcedTea; see the file COPYING. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 02110-1301 USA. 19 19 20 Linking this library statically or dynamically with other modules is21 making a combined work based on this library. Thus, the terms and22 conditions of the GNU General Public License cover the whole23 combination.20 Linking this library statically or dynamically with other modules is 21 making a combined work based on this library. Thus, the terms and 22 conditions of the GNU General Public License cover the whole 23 combination. 24 24 25 As a special exception, the copyright holders of this library give you26 permission to link this library with independent modules to produce an27 executable, regardless of the license terms of these independent28 modules, and to copy and distribute the resulting executable under29 terms of your choice, provided that you also meet, for each linked30 independent module, the terms and conditions of the license of that31 module. An independent module is a module which is not derived from32 or based on this library. If you modify this library, you may extend33 this exception to your version of the library, but you are not34 obligated to do so. If you do not wish to do so, delete this35 exception statement from your version.25 As a special exception, the copyright holders of this library give you 26 permission to link this library with independent modules to produce an 27 executable, regardless of the license terms of these independent 28 modules, and to copy and distribute the resulting executable under 29 terms of your choice, provided that you also meet, for each linked 30 independent module, the terms and conditions of the license of that 31 module. An independent module is a module which is not derived from 32 or based on this library. If you modify this library, you may extend 33 this exception to your version of the library, but you are not 34 obligated to do so. If you do not wish to do so, delete this 35 exception statement from your version. 36 36 */ 37 37 38 import net.sourceforge.jnlp.ServerAccess; 38 import net.sourceforge.jnlp.ClosingListener; 39 import net.sourceforge.jnlp.ProcessResult; 40 import net.sourceforge.jnlp.annotations.TestInBrowsers; 41 import net.sourceforge.jnlp.browsertesting.BrowserTest; 42 import net.sourceforge.jnlp.browsertesting.Browsers; 43 import net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener; 44 import net.sourceforge.jnlp.closinglisteners.StringMatchClosingListener; 39 45 import org.junit.Assert; 40 46 41 47 import org.junit.Test; 42 48 43 public class AddShutdownHookTest {49 public class AddShutdownHookTest extends BrowserTest { 44 50 45 private static ServerAccess server = new ServerAccess(); 51 public static final String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "shutdownHooks" + ".*"; 52 public static final String cnfString = "ClassNotFoundException"; 53 public static final String confirmFailure = "WRONG - ShutdownHook was probably added"; 54 public static final RulesFolowingClosingListener.MatchesRule mr = new RulesFolowingClosingListener.MatchesRule(s); 55 public static final RulesFolowingClosingListener.ContainsRule cnf = new RulesFolowingClosingListener.ContainsRule(cnfString); 56 public static final RulesFolowingClosingListener.ContainsRule cf = new RulesFolowingClosingListener.ContainsRule(confirmFailure); 57 public static final RulesFolowingClosingListener rfc = new RulesFolowingClosingListener(mr); 46 58 47 59 @Test 48 60 public void AddShutdownHookTestLunch1() throws Exception { 49 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/AddShutdownHook.jnlp"); 50 String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "shutdownHooks" + ".*"; 51 Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s)); 52 String cc="ClassNotFoundException"; 53 Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc)); 54 Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2); 55 Assert.assertFalse("AddShutdownHookTestLunch1 should not be terminated, but was",pr.wasTerminated); 61 ProcessResult pr = server.executeJavawsHeadless(null, "/AddShutdownHook.jnlp"); 62 Assert.assertTrue("stderr " + mr.toPassingString(), mr.evaluate(pr.stderr)); 63 Assert.assertFalse("stderr " + cnf.toFailingString(), cnf.evaluate(pr.stderr)); 64 Assert.assertFalse("AddShutdownHookTestLunch1 should not be terminated, but was", pr.wasTerminated); 65 Assert.assertFalse("stderr " + cf.toFailingString(), cf.evaluate(pr.stderr)); 56 66 Assert.assertEquals((Integer) 0, pr.returnValue); 57 67 } 68 69 @Test 70 @TestInBrowsers(testIn = Browsers.one) 71 public void AddShutdownHookApplet() throws Exception { 72 ProcessResult pr = server.executeBrowser("/AddShutdownHook.html", null, rfc); 73 74 if (server.getCurrentBrowsers() == Browsers.firefox) { 75 //lookslike only firefox is able to recieve this 76 Assert.assertTrue("stderr " + mr.toPassingString(), mr.evaluate(pr.stderr)); 77 } 78 Assert.assertFalse("stderr " + cnf.toFailingString(), cnf.evaluate(pr.stderr)); 79 Assert.assertFalse("stderr " + cf.toFailingString(), cf.evaluate(pr.stderr)); 80 } 58 81 } -
trunk/icedtea-web/tests/reproducers/simple/AllStackTraces/testcases/AllStackTracesTest.java
r418 r429 36 36 */ 37 37 38 import net.sourceforge.jnlp.ProcessResult; 38 39 import net.sourceforge.jnlp.ServerAccess; 39 40 import org.junit.Assert; … … 49 50 @Test 50 51 public void AllStackTracesTest1() throws Exception { 51 ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/AllStackTraces.jnlp");52 ProcessResult pr=server.executeJavawsHeadless(null,"/AllStackTraces.jnlp"); 52 53 String c = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "getStackTrace" + ".*"; 53 54 Assert.assertTrue("stderr should match `"+c+"`, but didn't ",pr.stderr.matches(c)); 54 55 String cc="ClassNotFoundException"; 55 56 Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did ",pr.stderr.contains(cc)); 56 Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);57 57 Assert.assertFalse("AllStackTracesTest1 should not be terminated, but was",pr.wasTerminated); 58 58 Assert.assertEquals((Integer)0, pr.returnValue); -
trunk/icedtea-web/tests/reproducers/simple/AppletBaseURLTest/srcs/AppletBaseURL.java
r418 r429 38 38 import java.applet.Applet; 39 39 public class AppletBaseURL extends Applet { 40 41 private class Killer extends Thread {42 43 public int n = 1000;44 45 @Override46 public void run() {47 try {48 Thread.sleep(n);49 System.out.println("Aplet killing himself after " + n + " ms of life");50 System.exit(0);51 } catch (Exception ex) {52 }53 }54 }55 private Killer killer;56 57 40 @Override 58 41 public void init() { 59 42 System.out.println("Document base is " + getDocumentBase() + " for this applet"); 60 43 System.out.println("Codebase is " + getCodeBase() + " for this applet"); 61 killer = new Killer(); 62 killer.start(); 44 System.out.println("*** APPLET FINISHED ***"); 45 46 // Exits JNLP-launched applets, throws exception on normal applet: 47 System.exit(0); 63 48 } 64 49 } -
trunk/icedtea-web/tests/reproducers/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java
r418 r429 36 36 */ 37 37 38 import net.sourceforge.jnlp.ServerAccess.ProcessResult; 38 import net.sourceforge.jnlp.ProcessResult; 39 import net.sourceforge.jnlp.ServerAccess.AutoClose; 39 40 import net.sourceforge.jnlp.annotations.Bug; 40 41 import net.sourceforge.jnlp.annotations.NeedsDisplay; … … 49 50 50 51 private void evaluateApplet(ProcessResult pr, String baseName) { 51 String s8= "(?s).*Codebase is http://localhost:[0-9]{5}/ for this applet(?s).*";52 Assert.assertTrue("AppletBaseURL stdout should match" + s8 + " but didn't", pr.stdout.matches(s8));53 String s9 = "(?s).*Document base is http://localhost:[0-9]{5}/" + baseName + " for this applet(?s).*";54 Assert.assertTrue("AppletBaseURL stdout should match" + s9 + " but didn't", pr.stdout.matches(s9));55 String ss = "xception";56 Assert.assertFalse("AppletBaseURL stderr should not contain" + ss + " but did", pr.stderr.contains(ss));52 String codebaseRule = "(?s).*Codebase is http://localhost:[0-9]{5}/ for this applet(?s).*"; 53 Assert.assertTrue("AppletBaseURL stdout should match" + codebaseRule + " but didn't", 54 pr.stdout.matches(codebaseRule)); 55 String documentbaseRule = "(?s).*Document base is http://localhost:[0-9]{5}/" + baseName + " for this applet(?s).*"; 56 Assert.assertTrue("AppletBaseURL stdout should match" + documentbaseRule + " but didn't", 57 pr.stdout.matches(documentbaseRule)); 57 58 } 58 59 … … 60 61 @Test 61 62 public void AppletWebstartBaseURLTest() throws Exception { 62 ProcessResult pr = server.executeJavaws( null,"/AppletBaseURLTest.jnlp");63 ProcessResult pr = server.executeJavaws("/AppletBaseURLTest.jnlp"); 63 64 evaluateApplet(pr, ""); 64 65 Assert.assertFalse(pr.wasTerminated); … … 71 72 @TestInBrowsers(testIn={Browsers.one}) 72 73 public void AppletInFirefoxTest() throws Exception { 73 ProcessResult pr = server.executeBrowser("/AppletBaseURLTest.html" );74 ProcessResult pr = server.executeBrowser("/AppletBaseURLTest.html", AutoClose.CLOSE_ON_BOTH); 74 75 pr.process.destroy(); 75 76 evaluateApplet(pr, "AppletBaseURLTest.html"); … … 82 83 @TestInBrowsers(testIn={Browsers.one}) 83 84 public void AppletWithJNLPHrefTest() throws Exception { 84 ProcessResult pr = server.executeBrowser("/AppletJNLPHrefBaseURLTest.html" );85 ProcessResult pr = server.executeBrowser("/AppletJNLPHrefBaseURLTest.html", AutoClose.CLOSE_ON_BOTH); 85 86 pr.process.destroy(); 86 87 evaluateApplet(pr, "AppletJNLPHrefBaseURLTest.html"); -
trunk/icedtea-web/tests/reproducers/simple/AppletReadsInvalidJar/testcases/AppletReadsInvalidJarTests.java
r418 r429 36 36 */ 37 37 38 import net.sourceforge.jnlp.ProcessResult; 38 39 import net.sourceforge.jnlp.ServerAccess; 39 40 import net.sourceforge.jnlp.annotations.TestInBrowsers; 40 41 import net.sourceforge.jnlp.browsertesting.BrowserTest; 41 42 import net.sourceforge.jnlp.browsertesting.Browsers; 43 42 44 import org.junit.Assert; 43 44 45 import org.junit.Test; 45 46 … … 53 54 @Test 54 55 public void AppletJNLPTest() throws Exception { 55 ServerAccess.ProcessResult pr = server.executeJavawsHeadless("/AppletReadsInvalidJar.jnlp");56 ProcessResult pr = server.executeJavawsHeadless("/AppletReadsInvalidJar.jnlp"); 56 57 57 58 Assert.assertFalse("AppletReadsInvalidJar stdout should NOT contain '" + CORRECT_EXECUTION + "', but did (applet should not have ran!).", pr.stdout.contains(CORRECT_EXECUTION)); … … 63 64 @TestInBrowsers(testIn={Browsers.one}) 64 65 public void AppletInFirefoxTest() throws Exception { 65 ServerAccess.ProcessResult pr = server.executeBrowser("/AppletReadsInvalidJar.html");66 ProcessResult pr = server.executeBrowser("/AppletReadsInvalidJar.html"); 66 67 67 68 Assert.assertTrue("AppletReadsInvalidJar stdout should contain '" + CORRECT_EXECUTION + "' but did not.", pr.stdout.contains(CORRECT_EXECUTION)); -
trunk/icedtea-web/tests/reproducers/simple/AppletTakesLastParam/srcs/AppletTakesLastParam.java
r418 r429 39 39 */ 40 40 public class AppletTakesLastParam extends Applet { 41 42 private class Killer extends Thread {43 44 public int n = 2000;45 46 @Override47 public void run() {48 try {49 Thread.sleep(n);50 System.out.println("Applet killing itself after " + n + " ms");51 System.exit(0);52 } catch (Exception ex) {53 }54 }55 }56 private Killer killer = new Killer();57 58 @Override59 41 public void init() { 60 42 System.out.println(getParameter("param")); 61 killer.start(); 43 System.out.println("*** APPLET FINISHED ***"); 44 45 // Exits JNLP-launched applets, throws exception on normal applet: 46 System.exit(0); 62 47 } 63 48 } -
trunk/icedtea-web/tests/reproducers/simple/AppletTakesLastParam/testcases/AppletTakesLastParamTests.java
r418 r429 1 /* AppletT estTests.java1 /* AppletTakesLastParamTests.java 2 2 Copyright (C) 2011 Red Hat, Inc. 3 3 … … 36 36 */ 37 37 38 import net.sourceforge.jnlp. ServerAccess;39 import net.sourceforge.jnlp.ServerAccess. ProcessResult;38 import net.sourceforge.jnlp.ProcessResult; 39 import net.sourceforge.jnlp.ServerAccess.AutoClose; 40 40 import net.sourceforge.jnlp.browsertesting.BrowserTest; 41 41 import net.sourceforge.jnlp.browsertesting.Browsers; … … 46 46 47 47 public class AppletTakesLastParamTests extends BrowserTest { 48 private void evaluate(ProcessResult pr) { 49 String firstParam = "value1"; 50 String secondParam = "value2"; 48 51 49 @Test 50 public void AppletTest() throws Exception { 51 ServerAccess.ProcessResult pr = server.executeJavaws(null, "/appletTakesLastParam.jnlp"); 52 evaluateApplet(pr); 53 } 54 55 private void evaluateApplet(ProcessResult pr) { 56 String s0 = "value1"; 57 Assert.assertTrue("AppletTakesLastParam stdout should not contain " + s0 + " but did.", !pr.stdout.contains(s0)); 58 String s1 = "value2"; 59 Assert.assertTrue("AppletTakesLastParam stdout should contain " + s1 + " but did not.", pr.stdout.contains(s1)); 52 Assert.assertFalse("AppletTakesLastParam stdout should not contain " + firstParam + " but did.", 53 pr.stdout.contains(firstParam)); 54 Assert.assertTrue("AppletTakesLastParam stdout should contain " + secondParam + " but did not.", 55 pr.stdout.contains(secondParam)); 60 56 } 61 57 62 58 @Test 63 59 @TestInBrowsers(testIn = {Browsers.one}) 64 public void AppletInFirefoxTest() throws Exception { 65 ServerAccess.ProcessResult pr = server.executeBrowser("/appletTakesLastParam.html"); 66 evaluateApplet(pr); 60 public void appletTakesLastParam() throws Exception { 61 ProcessResult pr = server.executeBrowser("/appletTakesLastParam.html", AutoClose.CLOSE_ON_BOTH); 62 evaluate(pr); 63 } 64 @Test 65 public void jnlpTakesLastParam() throws Exception { 66 ProcessResult pr = server.executeJavaws("/appletTakesLastParam.jnlp"); 67 evaluate(pr); 67 68 } 68 69 } -
trunk/icedtea-web/tests/reproducers/simple/AppletTest/testcases/AppletTestTests.java
r418 r429 1 /* AppletTestTests.java1 /* 2 2 Copyright (C) 2011 Red Hat, Inc. 3 3 … … 36 36 */ 37 37 38 import net.sourceforge.jnlp.closinglisteners.CountingClosingListener; 38 39 import net.sourceforge.jnlp.ProcessResult; 39 40 import net.sourceforge.jnlp.ServerAccess; … … 48 49 public class AppletTestTests extends BrowserTest { 49 50 51 private final String s7 = "Aplet killing himself after 2000 ms of life"; 52 private final String s2 = "value2"; 53 private final String s1 = "value1"; 54 private final String s0 = "applet was started"; 55 private final String s3 = "applet was initialised"; 56 57 private class CountingClosingListenerImpl extends CountingClosingListener { 58 59 @Override 60 protected boolean isAlowedToFinish(String s) { 61 return (s.contains(s0) && s.contains(s1) && s.contains(s2) && s.contains(s3) && s.contains(s7)); 62 } 63 } 64 50 65 @Test 51 66 @TestInBrowsers(testIn = {Browsers.googleChrome}) … … 56 71 //System.out.println("connecting AppletInFirefoxTest request in " + getBrowser().toString()); 57 72 //just verify loging is recording browser 58 ProcessResult pr1 = server.executeBrowser("/appletAutoTests .html");73 ProcessResult pr1 = server.executeBrowser("/appletAutoTests2.html", new CountingClosingListenerImpl(), new CountingClosingListenerImpl()); 59 74 if (pr1.process == null) { 60 75 Assert.assertTrue("If proces was null here, then google-chrome had to not exist, and so " … … 65 80 return; 66 81 } 67 evaluateApplet(pr1, false);82 evaluateApplet(pr1, false); 68 83 Assert.assertTrue(pr1.wasTerminated); 69 84 //System.out.println("connecting AppletInFirefoxTest request in " + getBrowser().toString()); 70 85 // just verify loging is recording browser 71 ServerAccess.ProcessResult pr = server.executeBrowser("/appletAutoTests.html");72 evaluateApplet(pr, false);86 ProcessResult pr = server.executeBrowser("/appletAutoTests2.html", new CountingClosingListenerImpl(), new CountingClosingListenerImpl()); 87 evaluateApplet(pr, false); 73 88 Assert.assertTrue(pr.wasTerminated); 74 89 } finally { … … 81 96 public void AppletTest() throws Exception { 82 97 ProcessResult pr = server.executeJavawsHeadless(null, "/AppletTest.jnlp"); 83 evaluateApplet(pr, true);98 evaluateApplet(pr, true); 84 99 Assert.assertFalse(pr.wasTerminated); 85 100 Assert.assertEquals((Integer) 0, pr.returnValue); … … 87 102 88 103 private void evaluateApplet(ProcessResult pr, boolean javawsApplet) { 89 String s3 = "applet was initialised";90 104 Assert.assertTrue("AppletTest stdout should contains " + s3 + " bud didn't", pr.stdout.contains(s3)); 91 String s0 = "applet was started";92 105 Assert.assertTrue("AppletTest stdout should contains " + s0 + " bud didn't", pr.stdout.contains(s0)); 93 String s1 = "value1";94 106 Assert.assertTrue("AppletTest stdout should contains " + s1 + " bud didn't", pr.stdout.contains(s1)); 95 String s2 = "value2";96 107 Assert.assertTrue("AppletTest stdout should contains " + s2 + " bud didn't", pr.stdout.contains(s2)); 97 String ss = "xception";98 Assert.assertFalse("AppletTest stderr should not contains " + ss + " but did", pr.stderr.contains(ss));99 String s7 = "Aplet killing himself after 2000 ms of life";100 108 Assert.assertTrue("AppletTest stdout should contains " + s7 + " bud didn't", pr.stdout.contains(s7)); 101 109 if (!javawsApplet) { 102 110 /*this is working correctly in most browser, but not in all. temporarily disabling 103 String s4 = "applet was stopped";104 Assert.assertTrue("AppletTest stdout should contains" + s4 + " bud did't", pr.stdout.contains(s4));105 String s5 = "applet will be destroyed";106 Assert.assertTrue("AppletTest stdout should contains" + s5 + " bud did't", pr.stdout.contains(s5));111 String s4 = "applet was stopped"; 112 Assert.assertTrue("AppletTest stdout should contain " + s4 + " bud did't", pr.stdout.contains(s4)); 113 String s5 = "applet will be destroyed"; 114 Assert.assertTrue("AppletTest stdout should contain " + s5 + " bud did't", pr.stdout.contains(s5)); 107 115 */ 108 116 } … … 117 125 ServerAccess.PROCESS_TIMEOUT = 30 * 1000; 118 126 try { 119 ProcessResult pr = server.executeBrowser("/appletAutoTests2.html" );120 evaluateApplet(pr, false);121 Assert.assertTrue(pr.wasTerminated);127 ProcessResult pr = server.executeBrowser("/appletAutoTests2.html", new CountingClosingListenerImpl(), new CountingClosingListenerImpl()); 128 evaluateApplet(pr, false); 129 //Assert.assertTrue(pr.wasTerminated); this checks asre evil 122 130 //Assert.assertEquals((Integer) 0, pr.returnValue); due to destroy is null 123 131 } finally { … … 133 141 ServerAccess.PROCESS_TIMEOUT = 30 * 1000; 134 142 try { 135 ProcessResult pr = server.executeBrowser("/appletAutoTests.html" );143 ProcessResult pr = server.executeBrowser("/appletAutoTests.html", new CountingClosingListenerImpl(), new CountingClosingListenerImpl()); 136 144 pr.process.destroy(); 137 evaluateApplet(pr, false);145 evaluateApplet(pr, false); 138 146 Assert.assertTrue(pr.wasTerminated); 139 147 //Assert.assertEquals((Integer) 0, pr.returnValue); due to destroy is null … … 142 150 } 143 151 } 152 153 154 @Test 155 @TestInBrowsers(testIn = {Browsers.one}) 156 @NeedsDisplay 157 public void appletZeroWH() throws Exception { 158 ProcessResult pr = server.executeBrowser("/appletZeroWH.html", new CountingClosingListenerImpl(), new CountingClosingListenerImpl()); 159 evaluateApplet(pr, false); 160 } 161 162 @Test 163 @TestInBrowsers(testIn = {Browsers.one}) 164 @NeedsDisplay 165 public void appletZeroW() throws Exception { 166 ProcessResult pr = server.executeBrowser("/appletZeroW.html", new CountingClosingListenerImpl(), new CountingClosingListenerImpl()); 167 evaluateApplet(pr, false); 168 } 169 170 @Test 171 @TestInBrowsers(testIn = {Browsers.one}) 172 @NeedsDisplay 173 public void appletZeroH() throws Exception { 174 ProcessResult pr = server.executeBrowser("/appletZeroH.html", new CountingClosingListenerImpl(), new CountingClosingListenerImpl()); 175 evaluateApplet(pr, false); 176 } 144 177 } -
trunk/icedtea-web/tests/reproducers/simple/CreateClassLoader/testcases/CreateClassLoaderTest.java
r418 r429 36 36 */ 37 37 38 import net.sourceforge.jnlp.ProcessResult; 38 39 import net.sourceforge.jnlp.ServerAccess; 40 39 41 import org.junit.Assert; 40 41 42 import org.junit.Test; 42 43 … … 47 48 @Test 48 49 public void CreateClassLoaderLunch1() throws Exception { 49 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/CreateClassLoader.jnlp");50 ProcessResult pr = server.executeJavawsHeadless(null, "/CreateClassLoader.jnlp"); 50 51 String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "createClassLoader" + ".*"; 51 52 Assert.assertTrue("Stderr should match "+s+" but didn't",pr.stderr.matches(s)); 52 53 String cc="ClassNotFoundException"; 53 54 Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc)); 54 Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);55 55 Assert.assertFalse("CreateClassLoaderLunch1 should not be terminated, but was",pr.wasTerminated); 56 56 Assert.assertEquals((Integer) 0, pr.returnValue); -
trunk/icedtea-web/tests/reproducers/simple/InformationTitleVendorParser/testcases/InformationTitleVendorParserTest.java
r418 r429 36 36 */ 37 37 38 39 38 import java.util.Arrays; 40 39 import java.util.List; 41 40 41 import net.sourceforge.jnlp.ProcessResult; 42 42 import net.sourceforge.jnlp.ServerAccess; 43 43 import org.junit.Assert; … … 50 50 public void runTest(String jnlpName, String exception) throws Exception { 51 51 List<String> verbosed = Arrays.asList(new String[] { "-verbose" }); 52 ServerAccess.ProcessResult pr=server.executeJavawsHeadless(verbosed, "/" + jnlpName + ".jnlp");52 ProcessResult pr=server.executeJavawsHeadless(verbosed, "/" + jnlpName + ".jnlp"); 53 53 String s1 = "Good simple javaws exapmle"; 54 54 Assert.assertFalse("test" + jnlpName + " stdout should not contain " + s1 + " but did.", pr.stdout.contains(s1)); -
trunk/icedtea-web/tests/reproducers/simple/LocalisedInformationElement/testcases/LocalisedInformationElementTest.java
r418 r429 63 63 Map<String, String> p = System.getenv(); 64 64 Set<Entry<String, String>> r = p.entrySet(); 65 List<Entry<String, String>> rr = new ArrayList (r);65 List<Entry<String, String>> rr = new ArrayList<Entry<String, String>>(r); 66 66 Collections.sort(rr, new Comparator<Entry<String, String>>() { 67 67 … … 94 94 String s = "LocalisedInformationElement launched"; 95 95 Assert.assertTrue(id + " stdout should contains " + s + " bud didn't", pr.stdout.contains(s)); 96 //to strict?97 //String ss = "xception";98 //Assert.assertFalse(id + " stderr should not contains " + ss + " but did", pr.stderr.contains(ss));99 96 String locMatch = "(?s).*default locale: \\w{2}.*"; 100 97 Assert.assertTrue(id + " stdout should match " + locMatch + " bud didn't", pr.stdout.matches(locMatch)); -
trunk/icedtea-web/tests/reproducers/simple/ManifestedJar1/testcases/ManifestedJar1Test.java
r418 r429 36 36 */ 37 37 38 import java.util.Arrays; 39 import net.sourceforge.jnlp.ProcessResult; 38 40 import net.sourceforge.jnlp.ServerAccess; 39 41 import net.sourceforge.jnlp.annotations.Bug; 42 import net.sourceforge.jnlp.runtime.Translator; 43 40 44 import org.junit.Assert; 41 42 45 import org.junit.Test; 43 46 … … 50 53 private static final String twoMainException = "net.sourceforge.jnlp.ParseException: Invalid XML document syntax"; 51 54 52 private void assertManifestedJar1(String id, ServerAccess.ProcessResult q) {55 private void assertManifestedJar1(String id, ProcessResult q) { 53 56 String s = "Hello from ManifestedJar1"; 54 57 Assert.assertTrue(id + " stdout should contains `" + s + "`, but didn't ", q.stdout.contains(s)); 55 58 } 56 59 57 private void assertManifestedJar2(String id, ServerAccess.ProcessResult q) {60 private void assertManifestedJar2(String id, ProcessResult q) { 58 61 String s = "Hello from ManifestedJar2"; 59 62 Assert.assertTrue(id + " stdout should contains `" + s + "`, but didn't ", q.stdout.contains(s)); 60 63 } 61 64 62 private void assertNotManifestedJar1(String id, ServerAccess.ProcessResult q) {65 private void assertNotManifestedJar1(String id, ProcessResult q) { 63 66 String s = "Hello from ManifestedJar1"; 64 67 Assert.assertFalse(id + " stdout should NOT contains `" + s + "`, but didn ", q.stdout.contains(s)); 65 68 } 66 private void assertAppError(String id, ServerAccess.ProcessResult q) {69 private void assertAppError(String id, ProcessResult q) { 67 70 Assert.assertTrue(id + " stderr should contains `" + nonLunchableMessage + "`, but didnn't ", q.stderr.contains(nonLunchableMessage)); 68 71 } 69 72 70 private void assertNotManifestedJar2(String id, ServerAccess.ProcessResult q) {73 private void assertNotManifestedJar2(String id, ProcessResult q) { 71 74 String s = "Hello from ManifestedJar2"; 72 75 Assert.assertFalse(id + " stdout should NOT contains `" + s + "`, but didn ", q.stdout.contains(s)); 73 76 } 74 77 75 private void assertNotDead(String id, ServerAccess.ProcessResult pr) {78 private void assertNotDead(String id, ProcessResult pr) { 76 79 String cc = "ClassNotFoundException"; 77 80 Assert.assertFalse(id + " stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc)); … … 86 89 public void manifestedJar1nothing2nothingNoAppDesc() throws Exception { 87 90 String id = "ManifestedJar-1nothing2nothingNoAppDesc"; 88 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");91 ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); 89 92 assertManifestedJar1(id, pr); 90 93 assertNotDead(id, pr); … … 98 101 public void manifestedJar1noAppDesc() throws Exception { 99 102 String id = "ManifestedJar-1noAppDesc"; 100 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");103 ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); 101 104 assertManifestedJar1(id, pr); 102 105 assertNotDead(id, pr); … … 110 113 public void manifestedJar1mainNoAppDesc() throws Exception { 111 114 String id = "ManifestedJar-1mainNoAppDesc"; 112 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");115 ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); 113 116 assertManifestedJar1(id, pr); 114 117 assertNotDead(id, pr); … … 122 125 public void ManifestedJar1mainHaveAppDesc() throws Exception { 123 126 String id = "ManifestedJar-1mainHaveAppDesc"; 124 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");127 ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); 125 128 assertManifestedJar2(id, pr); 126 129 assertNotDead(id, pr); … … 134 137 public void ManifestedJar1main2nothingNoAppDesc() throws Exception { 135 138 String id = "ManifestedJar-1main2nothingNoAppDesc"; 136 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");139 ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); 137 140 assertManifestedJar2(id, pr); 138 141 assertNotDead(id, pr); … … 146 149 public void manifestedJar1main2nothingNoAppDesc() throws Exception { 147 150 String id = "ManifestedJar-1main2nothingNoAppDesc"; 148 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");151 ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); 149 152 assertManifestedJar2(id, pr); 150 153 assertNotDead(id, pr); … … 154 157 * 155 158 * Two jars, both with manifest, sboth with main tag, no app desc 156 * 157 * thisis passing, SUSPICIOUS, but to lunch at least something is better then to lunch nothing at all. 158 * althoug it maybe SHOULD throw twoMainException 159 * first jar is taken 160 * 159 161 */ 160 162 @Test 161 163 public void manifestedJar1main2mainNoAppDesc() throws Exception { 162 164 String id = "ManifestedJar-1main2mainNoAppDesc"; 163 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); 164 assertManifestedJar1(id, pr); 165 assertNotDead(id, pr); 165 ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); 166 assertManifestedJar1(id, pr); 167 assertNotManifestedJar2(id, pr); 168 assertNotDead(id, pr); 169 } 170 171 /** 172 * 173 * Two jars, both with manifest, sboth with main tag, no app desc 174 * two main jars reported 175 * 176 */ 177 @Test 178 public void manifestedJar1main2mainNoAppDescStrict() throws Exception { 179 String id = "ManifestedJar-1main2mainNoAppDesc"; 180 ProcessResult pr = server.executeJavawsHeadless(Arrays.asList(new String[]{"-strict"}), "/" + id + ".jnlp"); 181 assertNotManifestedJar1(id, pr); 182 assertNotManifestedJar2(id, pr); 183 assertNotDead(id, pr); 184 Assert.assertTrue(pr.stderr.contains(Translator.R("PTwoMains")) || pr.stdout.contains(Translator.R("PTwoMains"))); 166 185 } 167 186 … … 175 194 public void manifestedJar1main2mainAppDesc() throws Exception { 176 195 String id = "ManifestedJar-1main2mainAppDesc"; 177 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");196 ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); 178 197 assertNotManifestedJar1(id, pr); 179 198 assertNotManifestedJar2(id, pr); … … 190 209 public void manifestedJar1noAppDescAtAll() throws Exception { 191 210 String id = "ManifestedJar-1noAppDescAtAll"; 192 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");211 ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); 193 212 assertNotManifestedJar1(id, pr); 194 213 assertNotManifestedJar2(id, pr); … … 209 228 public void manifestedJar1nothing2nothingAppDesc() throws Exception { 210 229 String id = "ManifestedJar-1nothing2nothingAppDesc"; 211 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");212 assert NotManifestedJar2(id, pr);230 ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); 231 assertManifestedJar2(id, pr); 213 232 assertNotManifestedJar1(id, pr); 214 233 assertNotDead(id, pr); -
trunk/icedtea-web/tests/reproducers/simple/ReadEnvironment/testcases/ReadEnvironmentTest.java
r418 r429 36 36 */ 37 37 38 import net.sourceforge.jnlp.ProcessResult; 38 39 import net.sourceforge.jnlp.ServerAccess; 39 40 import org.junit.Assert; 40 41 41 import org.junit.Test; 42 42 … … 47 47 @Test 48 48 public void ReadEnvironmentLunch1() throws Exception { 49 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/ReadEnvironment.jnlp");49 ProcessResult pr = server.executeJavawsHeadless(null, "/ReadEnvironment.jnlp"); 50 50 String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "getenv.USER" + ".*"; 51 51 Assert.assertTrue("stderr should match"+s+"but didn't",pr.stderr.matches(s)); 52 52 String cc="ClassNotFoundException"; 53 53 Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc)); 54 Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);55 54 Assert.assertFalse("ReadEnvironmentLunch1 should not be terminated, but was",pr.wasTerminated); 56 55 Assert.assertEquals((Integer) 0, pr.returnValue); -
trunk/icedtea-web/tests/reproducers/simple/ReadProperties/testcases/ReadPropertiesTest.java
r418 r429 36 36 */ 37 37 38 38 import net.sourceforge.jnlp.ProcessResult; 39 39 import net.sourceforge.jnlp.ServerAccess; 40 40 import org.junit.Assert; … … 48 48 @Test 49 49 public void ReadPropertiesLunch1() throws Exception { 50 ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/ReadProperties1.jnlp");50 ProcessResult pr=server.executeJavawsHeadless(null,"/ReadProperties1.jnlp"); 51 51 String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.util.PropertyPermission.{0,5}" + "user.name.{0,5}read" + ".*"; 52 52 Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s)); 53 53 String cc="ClassNotFoundException"; 54 54 Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc)); 55 Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);56 55 Assert.assertFalse("ReadPropertiesLunch1 should not be terminated, but was",pr.wasTerminated); 57 56 Assert.assertEquals((Integer)0, pr.returnValue); … … 60 59 @Test 61 60 public void ReadPropertiesLunch2() throws Exception { 62 ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/ReadProperties2.jnlp");61 ProcessResult pr=server.executeJavawsHeadless(null,"/ReadProperties2.jnlp"); 63 62 String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.util.PropertyPermission.{0,5}" + "user.home.{0,5}read" + ".*"; 64 63 Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s)); 65 64 String cc="ClassNotFoundException"; 66 65 Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc)); 67 Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);68 66 Assert.assertFalse("ReadPropertiesLunch2 should not be terminated, but was",pr.wasTerminated); 69 67 Assert.assertEquals((Integer)0, pr.returnValue); -
trunk/icedtea-web/tests/reproducers/simple/RedirectStreams/testcases/RedirectStreamsTest.java
r418 r429 36 36 */ 37 37 38 import net.sourceforge.jnlp.ProcessResult; 38 39 import net.sourceforge.jnlp.ServerAccess; 39 40 import org.junit.Assert; … … 46 47 @Test 47 48 public void RedirectStreamsTest1() throws Exception { 48 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/RedirectStreams.jnlp");49 ProcessResult pr = server.executeJavawsHeadless(null, "/RedirectStreams.jnlp"); 49 50 String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "setIO" + ".*"; 50 51 Assert.assertTrue("Stderr should match "+s+" but didn't",pr.stderr.matches(s)); 51 52 String cc="ClassNotFoundException"; 52 53 Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc)); 53 Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);54 54 Assert.assertFalse("RedirectStreams should not be terminated, but was",pr.wasTerminated); 55 55 Assert.assertEquals((Integer) 0, pr.returnValue); -
trunk/icedtea-web/tests/reproducers/simple/ReplaceSecurityManager/testcases/ReplaceSecurityManagerTest.java
r418 r429 36 36 */ 37 37 38 import net.sourceforge.jnlp.ProcessResult; 38 39 import net.sourceforge.jnlp.ServerAccess; 39 40 import org.junit.Assert; … … 46 47 @Test 47 48 public void ReplaceSecurityManagerLunch1() throws Exception { 48 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/ReplaceSecurityManager.jnlp");49 ProcessResult pr = server.executeJavawsHeadless(null, "/ReplaceSecurityManager.jnlp"); 49 50 String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "setSecurityManager" + ".*"; 50 51 Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s)); 51 52 String cc="ClassNotFoundException"; 52 53 Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc)); 53 Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);54 54 Assert.assertFalse("ReplaceSecurityManagerLunch1 should not be terminated, but was",pr.wasTerminated); 55 55 Assert.assertEquals((Integer) 0, pr.returnValue); -
trunk/icedtea-web/tests/reproducers/simple/SetContextClassLoader/testcases/SetContextClassLoaderTest.java
r418 r429 36 36 */ 37 37 38 import net.sourceforge.jnlp.ProcessResult; 38 39 import net.sourceforge.jnlp.ServerAccess; 39 40 import org.junit.Assert; … … 46 47 @Test 47 48 public void SetContextClassLoader1() throws Exception { 48 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/SetContextClassLoader.jnlp");49 ProcessResult pr = server.executeJavawsHeadless(null, "/SetContextClassLoader.jnlp"); 49 50 String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "setContextClassLoader" + ".*"; 50 51 Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s)); 51 52 String cc="ClassNotFoundException"; 52 53 Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc)); 53 Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);54 54 Assert.assertFalse("SetContextClassLoader1 should not be terminated, but was",pr.wasTerminated); 55 55 Assert.assertEquals((Integer) 0, pr.returnValue); -
trunk/icedtea-web/tests/reproducers/simple/Spaces can be everywhere/testcases/SpacesCanBeEverywhereTests.java
r418 r429 37 37 38 38 import java.util.ArrayList; 39 import java.util.Arrays; 39 40 import java.util.List; 41 import net.sourceforge.jnlp.ContentReaderListener; 42 import net.sourceforge.jnlp.ProcessResult; 40 43 import net.sourceforge.jnlp.ServerAccess; 41 44 import net.sourceforge.jnlp.annotations.Bug; … … 44 47 import net.sourceforge.jnlp.browsertesting.Browsers; 45 48 import net.sourceforge.jnlp.annotations.TestInBrowsers; 49 import net.sourceforge.jnlp.closinglisteners.StringBasedClosingListener; 46 50 import org.junit.Assert; 47 51 import org.junit.Test; … … 50 54 public class SpacesCanBeEverywhereTests extends BrowserTest { 51 55 52 56 public static final String s = "Spaces can be everywhere.jsr was launched correctly"; 53 57 @Bug(id="PR811") 54 58 @Test … … 82 86 * only on ocal files, and probably only from test run - it can be ignored 83 87 */ 84 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands); 85 String s="Spaces can be everywhere.jsr was launched correctly"; 86 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 87 String cc = "xception"; 88 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc)); 88 ProcessResult pr = ServerAccess.executeProcess(commands); 89 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 89 90 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated); 90 91 Assert.assertEquals((Integer) 0, pr.returnValue); … … 95 96 @NeedsDisplay 96 97 public void SpacesCanBeEverywhereRemoteAppletTestsJnlp2() throws Exception { 97 ServerAccess.ProcessResult pr = server.executeJavaws("/NotOnly%20spaces%20can%20kill%20%C4%9B%C5%A1%C4%8D%C5%99%C5%BE%20too.jnlp"); 98 String s="Spaces can be everywhere.jsr was launched correctly"; 99 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 100 String cc = "xception"; 101 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc)); 102 Assert.assertFalse("should NOT be terminated, but was not", pr.wasTerminated); 98 ProcessResult pr = server.executeJavaws("/NotOnly%20spaces%20can%20kill%20%C4%9B%C5%A1%C4%8D%C5%99%C5%BE%20too.jnlp"); 99 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 100 Assert.assertFalse("should NOT be terminated, but was", pr.wasTerminated); 103 101 } 104 102 … … 108 106 @TestInBrowsers(testIn = {Browsers.all}) 109 107 public void SpacesCanBeEverywhereRemoteAppletTestsHtml2() throws Exception { 110 ServerAccess.ProcessResult pr = server.executeBrowser("/spaces+applet+Tests.html"); 111 String s="Spaces can be everywhere.jsr was launched correctly"; 112 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 113 String cc = "xception"; 114 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc)); 108 ProcessResult pr = server.executeBrowser("/spaces+applet+Tests.html", Arrays.asList(new ContentReaderListener[] {new StringBasedClosingListener(s)}), null); 109 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 115 110 Assert.assertTrue("should be terminated, but was not", pr.wasTerminated); 116 111 } … … 120 115 @Test 121 116 public void SpacesCanBeEverywhereRemoteTests1() throws Exception { 122 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere1.jnlp");117 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere1.jnlp"); 123 118 String s = "Good simple javaws exapmle"; 124 119 Assert.assertTrue("stdout should contains `" + s + "`, but did not", pr.stdout.contains(s)); … … 132 127 @Test 133 128 public void SpacesCanBeEverywhereRemoteTests2() throws Exception { 134 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2.jnlp"); 135 String s="Spaces can be everywhere.jsr was launched correctly"; 129 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2.jnlp"); 136 130 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 137 131 String cc = "ClassNotFoundException"; … … 144 138 @Test 145 139 public void SpacesCanBeEverywhereRemoteTests2_withQuery1() throws Exception { 146 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2.jnlp?test=10"); 147 String s="Spaces can be everywhere.jsr was launched correctly"; 140 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2.jnlp?test=10"); 148 141 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 149 142 String cc = "ClassNotFoundException"; … … 157 150 @Test 158 151 public void SpacesCanBeEverywhereRemoteTests2_withQuery2() throws Exception { 159 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2.jnlp?test%3D10"); 160 String s="Spaces can be everywhere.jsr was launched correctly"; 152 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2.jnlp?test%3D10"); 161 153 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 162 154 String cc = "ClassNotFoundException"; … … 169 161 @Test 170 162 public void SpacesCanBeEverywhereRemoteTests3() throws Exception { 171 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/SpacesCanBeEverywhere1.jnlp"); 172 String s="Spaces can be everywhere.jsr was launched correctly"; 163 ProcessResult pr = server.executeJavawsHeadless(null, "/SpacesCanBeEverywhere1.jnlp"); 173 164 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 174 165 String cc = "ClassNotFoundException"; … … 186 177 commands.add(ServerAccess.HEADLES_OPTION); 187 178 commands.add("Spaces can be everywhere1.jnlp"); 188 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());179 ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir()); 189 180 String s = "Good simple javaws exapmle"; 190 181 Assert.assertTrue("stdout should contains `" + s + "`, but did not", pr.stdout.contains(s)); … … 202 193 commands.add(ServerAccess.HEADLES_OPTION); 203 194 commands.add("Spaces can be everywhere2.jnlp"); 204 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir()); 205 String s="Spaces can be everywhere.jsr was launched correctly"; 195 ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir()); 206 196 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 207 197 String cc = "ClassNotFoundException"; … … 218 208 commands.add(ServerAccess.HEADLES_OPTION); 219 209 commands.add(server.getDir()+"/Spaces can be everywhere2.jnlp"); 220 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands); 221 String s="Spaces can be everywhere.jsr was launched correctly"; 210 ProcessResult pr = ServerAccess.executeProcess(commands); 222 211 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 223 212 String cc = "ClassNotFoundException"; … … 234 223 commands.add(ServerAccess.HEADLES_OPTION); 235 224 commands.add("SpacesCanBeEverywhere1.jnlp"); 236 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir()); 237 String s="Spaces can be everywhere.jsr was launched correctly"; 225 ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir()); 238 226 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s)); 239 227 String cc = "ClassNotFoundException"; -
trunk/icedtea-web/tests/reproducers/simple/UnsignedJnlpApplication/testcases/UnsignedJnlpApplicationTest.java
r418 r429 39 39 import java.util.Collections; 40 40 import java.util.List; 41 import net.sourceforge.jnlp.ProcessResult; 41 42 import net.sourceforge.jnlp.ServerAccess; 42 43 import org.junit.Assert; … … 51 52 @Test 52 53 public void jnlpFileIsUnchecked1() throws Exception { 53 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication1.jnlp");54 ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication1.jnlp"); 54 55 Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString)); 55 56 } … … 57 58 @Test 58 59 public void jnlpFileIsUnchecked2() throws Exception { 59 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication2.jnlp");60 ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication2.jnlp"); 60 61 Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString)); 61 62 } … … 63 64 @Test 64 65 public void jnlpFileIsUnchecked3() throws Exception { 65 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication3.jnlp");66 ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication3.jnlp"); 66 67 Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString)); 67 68 } -
trunk/icedtea-web/tests/reproducers/simple/UnsignedJnlpTemplate/testcases/UnsignedJnlpTemplateTest.java
r418 r429 39 39 import java.util.Collections; 40 40 import java.util.List; 41 import net.sourceforge.jnlp.ProcessResult; 41 42 import net.sourceforge.jnlp.ServerAccess; 42 43 import org.junit.Assert; … … 51 52 @Test 52 53 public void jnlpTemplateIsUnchecked1() throws Exception { 53 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate1.jnlp");54 ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate1.jnlp"); 54 55 Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString)); 55 56 } … … 57 58 @Test 58 59 public void jnlpTemplateIsUnchecked2() throws Exception { 59 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate2.jnlp");60 ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate2.jnlp"); 60 61 Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString)); 61 62 } … … 63 64 @Test 64 65 public void jnlpTemplateIsUnchecked3() throws Exception { 65 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate3.jnlp");66 ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate3.jnlp"); 66 67 Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString)); 67 68 } -
trunk/icedtea-web/tests/reproducers/simple/deadlocktest/testcases/DeadLockTestTest.java
r418 r429 37 37 38 38 import java.util.ArrayList; 39 import net.sourceforge.jnlp.ProcessResult; 39 40 import net.sourceforge.jnlp.ServerAccess; 40 import net.sourceforge.jnlp.ServerAccess.ProcessResult;41 41 import org.junit.Assert; 42 42 import java.util.Arrays; … … 81 81 List<String> before = countJavaInstances(); 82 82 ServerAccess.logOutputReprint("java1 " + jnlp + " : " + before.size()); 83 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, jnlp);83 ProcessResult pr = server.executeJavawsHeadless(null, jnlp); 84 84 assertDeadlockTestLaunched(pr); 85 85 List<String> after = countJavaInstances(); … … 168 168 ServerAccess.PROCESS_LOG = false; 169 169 try { 170 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(Arrays.asList(new String[]{"kill", "-9", string}));170 ProcessResult pr = ServerAccess.executeProcess(Arrays.asList(new String[]{"kill", "-9", string})); 171 171 } finally { 172 172 ServerAccess.PROCESS_LOG = true; … … 183 183 ServerAccess.PROCESS_LOG = false; 184 184 try { 185 ServerAccess.ProcessResult pr = ServerAccess.executeProcess(Arrays.asList(new String[]{"ps", "-eo", "pid,ppid,stat,fname"}));185 ProcessResult pr = ServerAccess.executeProcess(Arrays.asList(new String[]{"ps", "-eo", "pid,ppid,stat,fname"})); 186 186 Matcher m = Pattern.compile("\\s*\\d+\\s+\\d+ .+ java\\s*").matcher(pr.stdout); 187 187 int i = 0; … … 206 206 String s = "Deadlock test started"; 207 207 Assert.assertTrue("Deadlock test should print out " + s + ", but did not", pr.stdout.contains(s)); 208 String ss = "xception";209 Assert.assertFalse("Deadlock test should not stderr " + ss + " but did", pr.stderr.contains(ss));210 208 //each 3500 seconds deadlock test stdout something 211 209 //timeout is 20s -
trunk/icedtea-web/tests/reproducers/simple/simpletest1/srcs/SimpleTest1.java
r418 r429 40 40 public static void main(String[] args){ 41 41 System.out.println("Good simple javaws exapmle"); 42 for (int i = 0; i < args.length; i++) { 43 String string = args[i]; 44 System.out.println(string); 45 46 } 42 47 } 43 48 } -
trunk/icedtea-web/tests/reproducers/simple/simpletest1/testcases/SimpleTest1Test.java
r418 r429 36 36 */ 37 37 38 38 import java.io.File; 39 import java.io.FileInputStream; 40 import java.io.IOException; 41 import java.net.MalformedURLException; 42 import java.net.URL; 43 import java.util.Arrays; 44 import java.util.List; 45 import net.sourceforge.jnlp.ProcessResult; 39 46 import net.sourceforge.jnlp.ServerAccess; 40 47 import org.junit.Assert; … … 45 52 46 53 private static ServerAccess server = new ServerAccess(); 54 private static final List<String> strict = Arrays.asList(new String[]{"-strict", ServerAccess.VERBOSE_OPTION}); 47 55 48 56 private void checkLaunched(ProcessResult pr) { 57 checkLaunched(pr, false); 58 } 59 60 private void checkLaunched(ProcessResult pr, boolean negate) { 61 String s = "Good simple javaws exapmle"; 62 if (negate) { 63 Assert.assertFalse("testSimpletest1lunchOk stdout should NOT contains " + s + " bud did", pr.stdout.contains(s)); 64 } else { 65 Assert.assertTrue("testSimpletest1lunchOk stdout should contains " + s + " bud didn't", pr.stdout.contains(s)); 66 } 67 String ss = "xception"; 68 if (negate) { 69 Assert.assertTrue("testSimpletest1lunchOk stderr should contains " + ss + " but didn't", pr.stderr.contains(ss)); 70 } else { 71 //disabled, unnecessary exceptions may occure 72 //Assert.assertFalse("testSimpletest1lunchOk stderr should not contains " + ss + " but did", pr.stderr.contains(ss)); 73 } 74 Assert.assertFalse(pr.wasTerminated); 75 Assert.assertEquals((Integer) 0, pr.returnValue); 76 } 49 77 50 78 @Test 51 79 public void testSimpletest1lunchOk() throws Exception { 52 ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/simpletest1.jnlp"); 53 String s="Good simple javaws exapmle"; 54 Assert.assertTrue("testSimpletest1lunchOk stdout should contains "+s+" bud didn't",pr.stdout.contains(s)); 55 String ss="xception"; 56 Assert.assertFalse("testSimpletest1lunchOk stderr should not contains "+ss+" but did",pr.stderr.contains(ss)); 57 Assert.assertFalse(pr.wasTerminated); 58 Assert.assertEquals((Integer)0, pr.returnValue); 80 ProcessResult pr = server.executeJavawsHeadless(null, "/simpletest1.jnlp"); 81 checkLaunched(pr); 59 82 } 60 83 61 } 84 @Test 85 public void testSimpletest1lunchNotOkJnlpStrict() throws Exception { 86 ProcessResult pr = server.executeJavawsHeadless(strict, "/simpletest1.jnlp"); 87 checkLaunched(pr, true); 88 } 89 90 @Test 91 public void testSimpletest1lunchOkStrictJnlp() throws Exception { 92 String originalResourceName = "simpletest1.jnlp"; 93 String newResourceName = "simpletest1_strict.jnlp"; 94 createStrictFile(originalResourceName, newResourceName, server.getUrl("")); 95 ProcessResult pr = server.executeJavawsHeadless(null, "/" + newResourceName); 96 checkLaunched(pr); 97 } 98 99 @Test 100 public void testSimpletest1lunchOkStrictJnlpStrict() throws Exception { 101 String originalResourceName = "simpletest1.jnlp"; 102 String newResourceName = "simpletest1_strict.jnlp"; 103 createStrictFile(originalResourceName, newResourceName, server.getUrl("")); 104 ProcessResult pr = server.executeJavawsHeadless(strict, "/" + newResourceName); 105 checkLaunched(pr); 106 } 107 108 private void createStrictFile(String originalResourceName, String newResourceName, URL codebase) throws MalformedURLException, IOException { 109 String originalContent = ServerAccess.getContentOfStream(new FileInputStream(new File(server.getDir(), originalResourceName))); 110 String nwContent1 = originalContent.replaceAll("href=\""+originalResourceName+"\"", "href=\""+newResourceName+"\""); 111 String nwContent = nwContent1.replaceAll("codebase=\".\"", "codebase=\"" + codebase + "\""); 112 ServerAccess.saveFile(nwContent, new File(server.getDir(), newResourceName)); 113 } 114 } -
trunk/icedtea-web/tests/reproducers/simple/simpletest2/srcs/SimpleTest2.java
r418 r429 1 2 import java.applet.Applet; 3 1 4 /* SimpleTest2.java 2 5 Copyright (C) 2011 Red Hat, Inc. … … 36 39 */ 37 40 38 public class SimpleTest2 {41 public class SimpleTest2 extends Applet{ 39 42 40 public static void main(String[] args){ 41 throw new RuntimeException("Correct exception"); 43 public static void main(String[] args) { 44 throw new RuntimeException("Correct exception"); 45 } 42 46 47 @Override 48 public void init() { 49 System.out.println("applet was initialised"); 43 50 } 51 52 @Override 53 public void start() { 54 System.out.println("applet was started"); 55 main(null); 56 } 57 58 @Override 59 public void stop() { 60 System.out.println("applet was stopped"); 61 } 62 63 @Override 64 public void destroy() { 65 System.out.println("applet will be destroyed"); 66 } 67 44 68 } -
trunk/icedtea-web/tests/reproducers/simple/simpletest2/testcases/SimpleTest2Test.java
r418 r429 36 36 */ 37 37 38 import net.sourceforge.jnlp.ProcessResult; 38 39 import net.sourceforge.jnlp.ServerAccess; 40 39 41 import org.junit.Assert; 40 41 42 import org.junit.Test; 42 43 … … 48 49 @Test 49 50 public void testSimpletest2lunchException() throws Exception { 50 ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/simpletest2.jnlp"); 51 Assert.assertTrue("stdout should be < 1 , but was "+pr.stdout.trim().length(),pr.stdout.trim().length() < 1); 51 ProcessResult pr=server.executeJavawsHeadless(null,"/simpletest2.jnlp"); 52 52 String s="Correct exception"; 53 53 Assert.assertTrue("stderr should contains "+s+" but didn't",pr.stderr.contains(s)); … … 55 55 Assert.assertTrue("stderr should contains "+ss+" but did not",pr.stderr.contains(ss)); 56 56 Assert.assertFalse("testSimpletest2lunchException should not be terminated, but was",pr.wasTerminated); 57 //Assert.assertFalse(0==pr.returnValue);exception and still returned 0?58 57 } 59 58 -
trunk/icedtea-web/tests/test-extensions-tests/net/sourceforge/jnlp/ResourcesTest.java
r418 r429 65 65 public void testNonExisitngBrowserWillNotDeadlock() throws Exception { 66 66 server.setCurrentBrowser(Browsers.none); 67 ServerAccess.ProcessResult pr = server.executeBrowser("not_existing_url.html");67 ProcessResult pr = server.executeBrowser("not_existing_url.html"); 68 68 Assert.assertNull(pr.process); 69 69 Assert.assertEquals(pr.stderr, ""); … … 71 71 Assert.assertTrue(pr.wasTerminated); 72 72 Assert.assertTrue(pr.returnValue < 0); 73 junit.framework.Assert.assertNotNull(pr.deadlyException);73 Assert.assertNotNull(pr.deadlyException); 74 74 } 75 75 … … 78 78 server.setCurrentBrowser(Browsers.none); 79 79 List<String> al=Arrays.asList(new String[] {"definietly_not_Existing_process"}); 80 ServerAccess.ProcessResult pr = server.executeProcess(al);80 ProcessResult pr = server.executeProcess(al); 81 81 Assert.assertNull(pr.process); 82 82 Assert.assertEquals(pr.stderr, ""); … … 84 84 Assert.assertTrue(pr.wasTerminated); 85 85 Assert.assertTrue(pr.returnValue < 0); 86 junit.framework.Assert.assertNotNull(pr.deadlyException);86 Assert.assertNotNull(pr.deadlyException); 87 87 } 88 88 … … 97 97 @TestInBrowsers(testIn=Browsers.none) 98 98 public void testNonExisitngBrowserWillNotCauseMess() throws Exception { 99 ServerAccess.ProcessResult pr = server.executeBrowser("not_existing_url.html");99 ProcessResult pr = server.executeBrowser("not_existing_url.html"); 100 100 Assert.assertNull(pr.process); 101 101 Assert.assertEquals(pr.stderr, ""); … … 103 103 Assert.assertTrue(pr.wasTerminated); 104 104 Assert.assertTrue(pr.returnValue < 0); 105 junit.framework.Assert.assertNotNull(pr.deadlyException);105 Assert.assertNotNull(pr.deadlyException); 106 106 } 107 107 … … 121 121 public void testBrowser3() throws Exception { 122 122 testBrowser(server.getCurrentBrowser()); 123 124 125 123 } 126 124 … … 216 214 expected = 2; 217 215 Assert.assertTrue("Created from " + s + "there must be " + expected + " browsers in factory. Is" + bf.getAllBrowsers().size(), bf.getAllBrowsers().size() == expected); 218 219 220 221 222 216 } 223 217 … … 275 269 @Override 276 270 public void charReaded(char ch) { 277 //ServerAccess.logOutputReprint("OO recieved char: "+ch);278 271 o1.append(ch); 279 272 } … … 281 274 @Override 282 275 public void lineReaded(String s) { 283 //ServerAccess.logOutputReprint("OO recieved line: "+s);284 276 o2.append(s).append("\n"); 285 277 } … … 289 281 @Override 290 282 public void charReaded(char ch) { 291 //ServerAccess.logOutputReprint("EE recieved char: "+ch);292 283 e1.append(ch); 293 284 } … … 295 286 @Override 296 287 public void lineReaded(String s) { 297 //ServerAccess.logOutputReprint("EE recieved line: "+s);298 288 e2.append(s).append("\n"); 299 289 } 300 290 }; 301 ServerAccess.ProcessResult pr = server.executeBrowser("not_existing_url.html",lo,le); 302 server.setCurrentBrowser(BrowserFactory.getFactory().getFirst().getID()); 303 Assert.assertNotNull(server.getCurrentBrowsers()); 304 Assert.assertNotNull(server.getCurrentBrowser()); 305 // ServerAccess.logOutputReprint("total o"); 306 // ServerAccess.logOutputReprint(pr.stdout); 307 // ServerAccess.logOutputReprint("total e"); 308 // ServerAccess.logOutputReprint(pr.stderr); 291 ProcessResult pr = server.executeBrowser("not_existing_url.html",lo,le); 292 server.setCurrentBrowser(BrowserFactory.getFactory().getFirst().getID()); 293 Assert.assertNotNull(server.getCurrentBrowsers()); 294 Assert.assertNotNull(server.getCurrentBrowser()); 309 295 Assert.assertEquals(pr.stdout, o1.toString()); 310 296 Assert.assertEquals(pr.stderr, e1.toString()); … … 312 298 Assert.assertEquals(pr.stdout.replace("\n", ""), o2.toString().replace("\n", "")); 313 299 Assert.assertEquals(pr.stderr.replace("\n", ""), e2.toString().replace("\n", "")); 314 315 300 } 316 301 … … 325 310 326 311 private void testBrowser(Browser browser) throws IOException { 327 File f1= null;312 File defaultPluginDir = null; 328 313 if (browser.getDefaultPluginExpectedLocation() != null) { 329 f1 = new File(browser.getDefaultPluginExpectedLocation()); 330 } 331 File f2 = null; 314 defaultPluginDir = new File(browser.getDefaultPluginExpectedLocation()); 315 } 316 if (defaultPluginDir != null) { 317 Assert.assertTrue("browser's plugins location should exist " + defaultPluginDir.toString() + " for " + browser.getID().toString(), defaultPluginDir.exists()); 318 } 319 320 File userPluginDir = null; 332 321 if (browser.getUserDefaultPluginExpectedLocation() != null) { 333 f2 = new File(browser.getUserDefaultPluginExpectedLocation()); 334 } 335 if (f1 != null) { 336 Assert.assertTrue("browser's plugins location should exist " + f1.toString() + " for " + browser.getID().toString(), f1.exists()); 337 } 338 if (f2 != null) { 339 Assert.assertTrue("browser's users-plugins location should exist " + f2.toString() + " for " + browser.getID().toString(), f2.exists()); 340 } 341 342 File[] ff1 = new File[0]; 343 if (f1 != null) { 344 ff1 = f1.listFiles(); 345 } 346 347 File[] ff2 = new File[0]; 348 if (f2 != null) { 349 ff2 = f2.listFiles(); 350 } 351 352 Assert.assertTrue("at least one of browser's plugins directory should contains at least one file didn't. For " + browser.getID().toString(), ff1.length + ff2.length > 0); 353 354 ff1 = new File[0]; 355 if (f1 != null) { 356 ff1 = f1.listFiles(new FileFilter() { 322 userPluginDir = new File(browser.getUserDefaultPluginExpectedLocation()); 323 } 324 // userPluginDir (~/.mozilla/plugins/) may not exist if user has not installed any Firefox plugins. 325 326 File[] defaultPlugins = new File[0]; 327 if (defaultPluginDir != null && defaultPluginDir.isDirectory()) { 328 defaultPlugins = defaultPluginDir.listFiles(); 329 } 330 331 File[] userPlugins = new File[0]; 332 if (userPluginDir != null && userPluginDir.isDirectory()) { 333 userPlugins = userPluginDir.listFiles(); 334 } 335 336 Assert.assertTrue("at least one of browser's plugins directory should contains at least one file didn't. For " + browser.getID().toString(), defaultPlugins.length + userPlugins.length > 0); 337 338 defaultPlugins = new File[0]; 339 if (defaultPluginDir != null && defaultPluginDir.isDirectory()) { 340 defaultPlugins = defaultPluginDir.listFiles(new FileFilter() { 357 341 358 342 @Override … … 363 347 } 364 348 365 ff2= new File[0];366 if ( f2 != null) {367 ff2 = f2.listFiles(new FileFilter() {349 userPlugins = new File[0]; 350 if (userPluginDir != null && userPluginDir.isDirectory()) { 351 userPlugins = userPluginDir.listFiles(new FileFilter() { 368 352 369 353 @Override … … 375 359 376 360 Assert.assertTrue("browser's plugins directories should contains exactly one " + LinuxBrowser.DEFAULT_PLUGIN_NAME + ", but didnt for " + browser.getID().toString(), 377 ff1.length + ff2.length == 1);361 defaultPlugins.length + userPlugins.length == 1); 378 362 String currentPath = server.getJavawsFile().getParentFile().getParentFile().getAbsolutePath(); 379 363 380 File[] ff;381 if ( ff1.length == 1) {382 ff = ff1;364 File[] plugins; 365 if (defaultPlugins.length == 1) { 366 plugins = defaultPlugins; 383 367 } else { 384 ff = ff2;385 } 386 String s = ServerAccess.getContentOfStream(new FileInputStream( ff[0]), "ASCII");368 plugins = userPlugins; 369 } 370 String s = ServerAccess.getContentOfStream(new FileInputStream(plugins[0]), "ASCII"); 387 371 Assert.assertTrue("browser's plugins shoud points to" + currentPath + ", but didnt", 388 372 s.contains(s)); -
trunk/icedtea-web/tests/test-extensions-tests/net/sourceforge/jnlp/ServerAccessTest.java
r418 r429 40 40 import java.io.FileInputStream; 41 41 import java.net.URL; 42 42 43 import org.junit.Assert; 43 44 import org.junit.Test; -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/ContentReader.java
r418 r429 35 35 exception statement from your version. 36 36 */ 37 38 37 package net.sourceforge.jnlp; 39 38 … … 42 41 import java.io.InputStreamReader; 43 42 import java.io.Reader; 43 import java.util.ArrayList; 44 import java.util.List; 44 45 45 46 /** 46 * Class to read content of stdout/stderr of process, and to cooperate with its running/terminated/finished statuses. 47 * Class to read content of stdout/stderr of process, and to cooperate with its 48 * running/terminated/finished statuses. 47 49 */ 48 50 class ContentReader implements Runnable { … … 51 53 private final InputStream is; 52 54 private boolean done; 53 ContentReaderListener listener;55 final List<ContentReaderListener> listeners = new ArrayList<ContentReaderListener>(1); 54 56 55 57 public String getContent() { … … 63 65 public ContentReader(InputStream is, ContentReaderListener l) throws IOException { 64 66 this.is = is; 65 this.listener = l; 67 if (l != null) { 68 this.listeners.add(l); 69 } 66 70 } 67 71 68 public void setListener(ContentReaderListener listener) { 69 this.listener = listener; 72 public ContentReader(InputStream is, List<ContentReaderListener> l) throws IOException { 73 this.is = is; 74 if (l != null) { 75 this.listeners.addAll(l); 76 } 70 77 } 71 78 72 public ContentReaderListener getListener() { 73 return listener; 79 public void addListener(ContentReaderListener listener) { 80 this.listeners.add(listener); 81 } 82 83 public List<ContentReaderListener> getListener() { 84 return listeners; 74 85 } 75 86 … … 97 108 int s = br.read(); 98 109 if (s < 0) { 99 if (line.length() > 0 && listener != null) { 100 listener.lineReaded(line.toString()); 110 if (line.length() > 0 && listeners != null) { 111 for (ContentReaderListener listener : listeners) { 112 if (listener != null) { 113 listener.lineReaded(line.toString()); 114 } 115 } 101 116 } 102 117 break; … … 106 121 line.append(ch); 107 122 if (ch == '\n') { 108 if (listener != null) { 109 listener.lineReaded(line.toString()); 123 if (listeners != null) { 124 for (ContentReaderListener listener : listeners) { 125 if (listener != null) { 126 listener.lineReaded(line.toString()); 127 } 128 } 110 129 } 111 130 line = new StringBuilder(); 112 131 } 113 if (listener != null) { 114 listener.charReaded(ch); 132 if (listeners != null) { 133 for (ContentReaderListener listener : listeners) { 134 if (listener != null) { 135 listener.charReaded(ch); 136 } 137 } 115 138 } 116 139 } 117 //do not want to bother output with terminations 118 //mostly compaling when assassin kill the process about StreamClosed 119 //do not want to bother output with terminations 120 //mostly compaling when assassin kill the process about StreamClosed 121 } catch (Exception ex) { 140 } catch (NullPointerException ex) { 141 ex.printStackTrace(); 142 } 143 //do not want to bother output with terminations 144 //mostly compaling when assassin kill the process about StreamClosed 145 catch (Exception ex) { 122 146 // logException(ex); 147 //ex.printStackTrace(); 123 148 } finally { 124 149 try { -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/LoggingBottleneck.java
r418 r429 46 46 import java.io.Writer; 47 47 import java.lang.reflect.Method; 48 import java.util.Collections; 48 49 import java.util.HashMap; 49 50 import java.util.Map; … … 81 82 * class.testMethod.logs 82 83 */ 83 final Map<String, Map<String, TestsLogs>> processLogs = new HashMap<String, Map<String, TestsLogs>>(100);84 final Map<String, Map<String, TestsLogs>> processLogs = Collections.synchronizedMap(new HashMap<String, Map<String, TestsLogs>>(1000)); 84 85 private boolean added = false; 85 86 86 public static LoggingBottleneck getDefaultLoggingBottleneck() {87 synchronized public static LoggingBottleneck getDefaultLoggingBottleneck() { 87 88 if (loggingBottleneck == null) { 88 89 loggingBottleneck = new LoggingBottleneck(); … … 102 103 } 103 104 104 void writeXmlLog() throws FileNotFoundException, IOException {105 synchronized void writeXmlLog() throws FileNotFoundException, IOException { 105 106 writeXmlLog(DEFAULT_LOG_FILE); 106 107 } 107 108 108 void writeXmlLog(File f) throws FileNotFoundException, IOException { 109 synchronized void writeXmlLog(File f) throws FileNotFoundException, IOException { 110 writeXmlLog(f, Collections.unmodifiableMap(processLogs)); 111 } 112 113 synchronized static void writeXmlLog(File f, Map<String, Map<String, TestsLogs>> processLogs) throws FileNotFoundException, IOException { 109 114 Writer w = new OutputStreamWriter(new FileOutputStream(f)); 110 115 Set<Entry<String, Map<String, TestsLogs>>> classes = processLogs.entrySet(); … … 118 123 String testLogs = testLog.getValue().toString(); 119 124 w.write("<" + TESTLOG_ELEMENT + " " + TESTMETHOD_ATTRIBUTE + "=\"" + testName + "\" " + FULLID_ATTRIBUTE + "=\"" + className + "." + testName + "\" >"); 120 w.write( testLogs);125 w.write(clearChars(testLogs)); 121 126 w.write("</" + TESTLOG_ELEMENT + ">"); 122 127 } … … 128 133 } 129 134 130 void addToXmlLog(String message, boolean printToOut, boolean printToErr, StackTraceElement ste) {135 synchronized void addToXmlLog(String message, boolean printToOut, boolean printToErr, StackTraceElement ste) { 131 136 Map<String, TestsLogs> classLog = processLogs.get(ste.getClassName()); 132 137 if (classLog == null) { … … 158 163 } 159 164 160 public String modifyMethodWithForBrowser(String methodBrowseredName, String className) {165 synchronized public String modifyMethodWithForBrowser(String methodBrowseredName, String className) { 161 166 try { 162 Class clazz = Class.forName(className);167 Class<?> clazz = Class.forName(className); 163 168 /* 164 169 * By using this isAssignable to ensure corect class before invocation, … … 181 186 } 182 187 183 public void setLoggedBrowser(String loggedBrowser) {188 synchronized public void setLoggedBrowser(String loggedBrowser) { 184 189 this.loggedBrowser = loggedBrowser; 185 190 } 186 191 187 public void logIntoPlaintextLog(String message, boolean printToOut, boolean printToErr) {192 synchronized public void logIntoPlaintextLog(String message, boolean printToOut, boolean printToErr) { 188 193 try { 189 194 if (printToOut) { … … 202 207 DEFAULT_STDOUT_WRITER.write(idded); 203 208 DEFAULT_STDOUT_WRITER.newLine(); 209 DEFAULT_STDOUT_WRITER.flush(); 204 210 } 205 211 … … 207 213 DEFAULT_STDERR_WRITER.write(idded); 208 214 DEFAULT_STDERR_WRITER.newLine(); 215 DEFAULT_STDERR_WRITER.flush(); 209 216 } 210 217 … … 212 219 DEFAULT_STDLOGS_WRITER.write(idded); 213 220 DEFAULT_STDLOGS_WRITER.newLine(); 221 DEFAULT_STDLOGS_WRITER.flush(); 222 } 223 224 synchronized public static String clearChars(String ss) { 225 StringBuilder s = new StringBuilder(ss); 226 for (int i = 0; i < s.length(); i++) { 227 char q = s.charAt(i); 228 if (q == '\n') { 229 continue; 230 } 231 if (q == '\t') { 232 continue; 233 } 234 int iq = (int) q; 235 if ((iq <= 31 || iq > 65533)||(iq >= 64976 && iq <= 65007)) { 236 s.setCharAt(i, 'I'); 237 s.insert(i + 1, "NVALID_CHAR_" + iq); 238 i--; 239 } 240 } 241 return s.toString(); 214 242 } 215 243 } -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/ProcessAssasin.java
r418 r429 40 40 import java.util.ArrayList; 41 41 import java.util.List; 42 import net.sourceforge.jnlp.browsertesting.ReactingProcess; 42 43 43 44 /** 44 * class which timeout any ThreadedProcess. This killing of 'thread with process' replaced not working process.destroy(). 45 * class which timeout any ThreadedProcess. This killing of 'thread with 46 * process' replaced not working process.destroy(). 45 47 */ 46 class ProcessAssasin extends Thread {48 public class ProcessAssasin extends Thread { 47 49 48 50 long timeout; … … 51 53 private boolean canRun = true; 52 54 private boolean wasTerminated = false; 55 //signifies that assasin have been summoned 56 private volatile boolean killing = false; 57 //signifies that assasin have done its job 58 private volatile boolean killed = false; 53 59 /** 54 * if this is true, then process is not destroyed after timeout, but just left to its own destiny. 55 * Its stdout/err is no longer recorded, and it is leaking system resources until it dies by itself 56 * The contorl is returned to main thread with all informations recorded untill now. 57 * You will be able to listen to std out from listeners still 60 * if this is true, then process is not destroyed after timeout, but just 61 * left to its own destiny. Its stdout/err is no longer recorded, and it is 62 * leaking system resources until it dies by itself The contorl is returned 63 * to main thread with all informations recorded untill now. You will be 64 * able to listen to std out from listeners still 58 65 */ 59 66 private boolean skipInstedOfDesroy = false; 67 private ReactingProcess reactingProcess; 60 68 61 69 public ProcessAssasin(ThreadedProcess p, long timeout) { … … 98 106 return skipInstedOfDesroy; 99 107 } 108 109 void setTimeout(long timeout) { 110 this.timeout = timeout; 111 } 112 100 113 101 114 @Override … … 119 132 try { 120 133 if (!skipInstedOfDesroy) { 121 destroyProcess( p);134 destroyProcess(); 122 135 } 123 136 } catch (Throwable ex) { … … 161 174 } 162 175 163 public static void destroyProcess(ThreadedProcess pp) { 176 public void destroyProcess() { 177 try { 178 killing = true; 179 destroyProcess(p, reactingProcess); 180 } finally { 181 killed = true; 182 } 183 } 184 185 public boolean haveKilled() { 186 return killed; 187 } 188 189 public boolean isKilling() { 190 return killing; 191 } 192 193 194 195 public static void destroyProcess(ThreadedProcess pp, ReactingProcess reactingProcess) { 164 196 Process p = pp.getP(); 165 197 try { … … 167 199 f.setAccessible(true); 168 200 String pid = (f.get(p)).toString(); 201 if (reactingProcess != null) { 202 reactingProcess.beforeKill(pid); 203 }; 169 204 sigInt(pid); 170 205 //sigTerm(pid); … … 174 209 } finally { 175 210 p.destroy(); 211 if (reactingProcess != null) { 212 reactingProcess.afterKill(""); 213 }; 176 214 } 177 215 } … … 189 227 } 190 228 191 public static void kill(String pid, String signal) throws InterruptedException, Exception {229 public static void kill(String pid, String signal) throws InterruptedException, Exception { 192 230 List<String> ll = new ArrayList<String>(4); 193 231 ll.add("kill"); … … 199 237 Thread.sleep(1000); 200 238 } 239 240 void setReactingProcess(ReactingProcess reactingProcess) { 241 this.reactingProcess = reactingProcess; 242 } 243 244 public static void closeWindow(String pid) throws Exception { 245 List<String> ll = new ArrayList<String>(2); 246 ll.add(ServerAccess.getInstance().getDir().getParent() + "/softkiller"); 247 ll.add(pid); 248 ServerAccess.executeProcess(ll); //sync, but acctually release 249 //before affected application "close" 250 Thread.sleep(100); 251 252 } 253 254 public static void closeWindows(String s) throws Exception { 255 closeWindows(s, 10); 256 } 257 258 public static void closeWindows(String s, int count) throws Exception { 259 //each close closes just one tab... 260 for (int i = 0; i < count; i++) { 261 ProcessAssasin.closeWindow(s); 262 } 263 } 264 265 201 266 } -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java
r418 r429 1 1 /* ServerAccess.java 2 Copyright (C) 2011 Red Hat, Inc.2 Copyright (C) 2011, 2012 Red Hat, Inc. 3 3 4 4 This file is part of IcedTea. … … 56 56 import java.util.ArrayList; 57 57 import java.util.List; 58 import net.sourceforge.jnlp.ProcessResult; 58 59 import net.sourceforge.jnlp.browsertesting.Browser; 59 60 import net.sourceforge.jnlp.browsertesting.BrowserFactory; 60 61 import net.sourceforge.jnlp.browsertesting.Browsers; 62 import net.sourceforge.jnlp.closinglisteners.AutoErrorClosingListener; 63 import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener; 64 import net.sourceforge.jnlp.util.FileUtils; 65 import net.sourceforge.jnlp.util.logging.OutputController; 61 66 import org.junit.Assert; 62 67 … … 78 83 public class ServerAccess { 79 84 85 public static enum AutoClose { 86 87 CLOSE_ON_EXCEPTION, CLOSE_ON_CORRECT_END, CLOSE_ON_BOTH 88 } 89 80 90 public static final long NANO_TIME_DELIMITER=1000000l; 81 91 /** … … 132 142 } else { 133 143 int port = 44321; 134 if (args.length > 0) { 135 port=new Integer(args[0]); 144 if (args.length > 0 && args[0].equalsIgnoreCase("randomport")) { 145 port = findFreePort(); 146 } else if (args.length > 0) { 147 port = new Integer(args[0]); 136 148 } 137 149 getIndependentInstance(port); … … 157 169 } 158 170 public static final String HEADLES_OPTION="-headless"; 159 public static final String VERBOSE_OPTION="-verbose 171 public static final String VERBOSE_OPTION="-verbose"; 160 172 161 173 /** … … 260 272 List<String> l1=this.currentBrowser.getComaptibilitySwitches(); 261 273 List<String> l2=this.currentBrowser.getDefaultSwitches(); 262 List<String> l= new ArrayList ();274 List<String> l= new ArrayList<String>(); 263 275 if (l1!=null)l.addAll(l1); 264 276 if (l2!=null)l.addAll(l2); … … 409 421 * @throws IOException if connection can't be established or resource does not exist 410 422 */ 411 public static String getContentOfStream(InputStream is,String encoding) throws IOException { 412 try { 413 BufferedReader br = new BufferedReader(new InputStreamReader(is, encoding)); 414 StringBuilder sb = new StringBuilder(); 415 while (true) { 416 String s = br.readLine(); 417 if (s == null) { 418 break; 419 } 420 sb.append(s).append("\n"); 421 422 } 423 return sb.toString(); 424 } finally { 425 is.close(); 426 } 427 423 public static String getContentOfStream(InputStream is, String encoding) throws IOException { 424 return FileUtils.getContentOfStream(is, encoding); 428 425 } 429 426 … … 436 433 */ 437 434 public static String getContentOfStream(InputStream is) throws IOException { 438 return getContentOfStream(is, "UTF-8"); 439 435 return FileUtils.getContentOfStream(is); 440 436 } 441 437 … … 483 479 */ 484 480 public static void saveFile(String content, File f) throws IOException { 485 saveFile(content, f, "utf-8");481 FileUtils.saveFile(content, f); 486 482 } 487 483 public static void saveFile(String content, File f,String encoding) throws IOException { 488 Writer output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f),encoding)); 489 output.write(content); 490 output.flush(); 491 output.close(); 484 FileUtils.saveFile(content, f, encoding); 492 485 } 493 486 … … 546 539 return executeJavaws(null, resource,stdoutl,stderrl); 547 540 } 541 542 public net.sourceforge.jnlp.ProcessResult executeBrowser(String string, AutoClose autoClose) throws Exception { 543 ClosingListener errClosing = null; 544 ClosingListener outClosing = null; 545 if (autoClose == AutoClose.CLOSE_ON_BOTH || autoClose == AutoClose.CLOSE_ON_EXCEPTION){ 546 errClosing=new AutoErrorClosingListener(); 547 } 548 if (autoClose == AutoClose.CLOSE_ON_BOTH || autoClose == AutoClose.CLOSE_ON_CORRECT_END){ 549 outClosing=new AutoOkClosingListener(); 550 } 551 return executeBrowser(string, outClosing, errClosing); 552 } 553 554 548 555 public ProcessResult executeBrowser(String resource) throws Exception { 549 556 return executeBrowser(getBrowserParams(), resource); 550 557 } 551 558 public ProcessResult executeBrowser(String resource,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception { 559 return executeBrowser(getBrowserParams(), resource, stdoutl, stderrl); 560 } 561 562 public ProcessResult executeBrowser(String resource, List<ContentReaderListener> stdoutl, List<ContentReaderListener> stderrl) throws Exception { 552 563 return executeBrowser(getBrowserParams(), resource, stdoutl, stderrl); 553 564 } … … 572 583 573 584 public ProcessResult executeBrowser(List<String> otherargs, String resource) throws Exception { 574 return executeProcessUponURL(getBrowserLocation(), otherargs, getUrlUponThisInstance(resource)); 575 } 576 public ProcessResult executeBrowser(List<String> otherargs, String resource,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception { 577 return executeProcessUponURL(getBrowserLocation(), otherargs, getUrlUponThisInstance(resource),stdoutl,stderrl); 578 } 579 580 public ProcessResult executeBrowser(Browser b,List<String> otherargs, String resource) throws Exception { 581 return executeProcessUponURL(b.getBin(), otherargs, getUrlUponThisInstance(resource)); 582 } 583 public ProcessResult executeBrowser(Browser b,List<String> otherargs, String resource,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception { 584 return executeProcessUponURL(b.getBin(), otherargs, getUrlUponThisInstance(resource),stdoutl,stderrl); 585 return executeBrowser(otherargs, getUrlUponThisInstance(resource)); 586 } 587 588 public ProcessResult executeBrowser(List<String> otherargs, URL url) throws Exception { 589 ProcessWrapper rpw = new ProcessWrapper(getBrowserLocation(), otherargs, url); 590 rpw.setReactingProcess(getCurrentBrowser());//current browser may be null, but it does not metter 591 return rpw.execute(); 592 } 593 594 public ProcessResult executeBrowser(List<String> otherargs, String resource, ContentReaderListener stdoutl, ContentReaderListener stderrl) throws Exception { 595 ProcessWrapper rpw = new ProcessWrapper(getBrowserLocation(), otherargs, getUrlUponThisInstance(resource), stdoutl, stderrl, null); 596 rpw.setReactingProcess(getCurrentBrowser());//current browser may be null, but it does not metter 597 return rpw.execute(); 598 } 599 600 public ProcessResult executeBrowser(List<String> otherargs, String resource, List<ContentReaderListener> stdoutl, List<ContentReaderListener> stderrl) throws Exception { 601 ProcessWrapper rpw = new ProcessWrapper(getBrowserLocation(), otherargs, getUrlUponThisInstance(resource), stdoutl, stderrl, null); 602 rpw.setReactingProcess(getCurrentBrowser());// current browser may be null, but it does not matter 603 return rpw.execute(); 604 } 605 606 public ProcessResult executeBrowser(Browser b, List<String> otherargs, String resource) throws Exception { 607 ProcessWrapper rpw = new ProcessWrapper(b.getBin(), otherargs, getUrlUponThisInstance(resource)); 608 rpw.setReactingProcess(b); 609 return rpw.execute(); 610 } 611 612 public ProcessResult executeBrowser(Browser b, List<String> otherargs, String resource, ContentReaderListener stdoutl, ContentReaderListener stderrl) throws Exception { 613 ProcessWrapper rpw = new ProcessWrapper(b.getBin(), otherargs, getUrlUponThisInstance(resource), stdoutl, stderrl, null); 614 rpw.setReactingProcess(b); 615 return rpw.execute(); 616 } 617 618 public ProcessResult executeBrowser(Browser b, List<String> otherargs, String resource, List<ContentReaderListener> stdoutl, List<ContentReaderListener> stderrl) throws Exception { 619 ProcessWrapper rpw = new ProcessWrapper(b.getBin(), otherargs, getUrlUponThisInstance(resource), stdoutl, stderrl, null); 620 rpw.setReactingProcess(b); 621 return rpw.execute(); 622 } 623 624 /** 625 * Create resource on http, on 'localhost' on port on which this cached instance is running 626 * @param resource 627 * @return 628 * @throws MalformedURLException 629 */ 630 public URL getUrlUponThisInstance(String resource) throws MalformedURLException { 631 getInstance(); 632 return getUrlUponInstance(server, resource); 585 633 } 586 634 … … 591 639 * @throws MalformedURLException 592 640 */ 593 public URL getUrlUponThisInstance(String resource) throws MalformedURLException { 594 if (!resource.startsWith("/")) { 595 resource = "/" + resource; 596 } 597 return new URL("http", server.getServerName(), getPort(), resource); 641 public static URL getUrlUponInstance(ServerLauncher instance,String resource) throws MalformedURLException { 642 return instance.getUrl(resource); 598 643 } 599 644 … … 623 668 */ 624 669 public static ProcessResult executeProcessUponURL(String toBeExecuted, List<String> otherargs, URL u) throws Exception { 625 return executeProcessUponURL(toBeExecuted, otherargs, u,null,null); 626 } 627 628 public static ProcessResult executeProcessUponURL(String toBeExecuted, List<String> otherargs, URL u,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception { 629 return executeProcessUponURL(toBeExecuted, otherargs, u, stdoutl, stderrl, null); 630 } 631 public static ProcessResult executeProcessUponURL(String toBeExecuted, List<String> otherargs, URL u,ContentReaderListener stdoutl,ContentReaderListener stderrl,String[] vars) throws Exception { 632 Assert.assertNotNull(u); 633 Assert.assertNotNull(toBeExecuted); 634 Assert.assertTrue(toBeExecuted.trim().length() > 1); 635 if (otherargs == null) { 636 otherargs = new ArrayList<String>(1); 637 } 638 List<String> urledArgs = new ArrayList<String>(otherargs); 639 urledArgs.add(0, toBeExecuted); 640 urledArgs.add(u.toString()); 641 return executeProcess(urledArgs, stdoutl, stderrl,vars); 670 return new ProcessWrapper(toBeExecuted, otherargs, u).execute(); 671 } 672 673 public static ProcessResult executeProcessUponURL(String toBeExecuted, List<String> otherargs, URL u, ContentReaderListener stdoutl, ContentReaderListener stderrl) throws Exception { 674 return new ProcessWrapper(toBeExecuted, otherargs, u, stdoutl, stderrl, null).execute(); 675 } 676 677 public static ProcessResult executeProcessUponURL(String toBeExecuted, List<String> otherargs, URL u, ContentReaderListener stdoutl, ContentReaderListener stderrl, String[] vars) throws Exception { 678 return new ProcessWrapper(toBeExecuted, otherargs, u, stdoutl, stderrl, vars).execute(); 642 679 } 643 680 … … 671 708 } 672 709 673 private static String createConnectionMessage(ThreadedProcess t) {674 return "Connecting " + t.getCommandLine();675 }676 677 710 /** 678 711 * Proceed message s to logging with request to reprint to System.err … … 699 732 } 700 733 701 privatestatic void log(String message, boolean printToOut, boolean printToErr) {734 static void log(String message, boolean printToOut, boolean printToErr) { 702 735 String idded; 703 736 StackTraceElement ste = getTestMethod(); … … 726 759 } 727 760 public static void logException(Throwable t, boolean print){ 728 try{ 729 StringWriter sw = new StringWriter(); 730 PrintWriter pw = new PrintWriter(sw); 731 t.printStackTrace(pw); 732 log(sw.toString(), false, print); 733 pw.close(); 734 sw.close(); 735 }catch(Exception ex){ 736 throw new RuntimeException(ex); 737 } 761 log(OutputController.exceptionToString(t), false, print); 738 762 } 739 763 … … 744 768 private static StackTraceElement getTestMethod(StackTraceElement[] stack) { 745 769 //0 is always thread 746 //1 is net.sourceforge.jnlp.ServerAccess 770 //1 is net.sourceforge.jnlp.* 771 //we need to get out of all of classes from this package or pick last of it 747 772 StackTraceElement result = stack[1]; 748 773 String baseClass = stack[1].getClassName(); … … 750 775 for (; i < stack.length; i++) { 751 776 result = stack[i];//at least moving up 752 if (stack[i].getClassName().contains("$")){777 if (stack[i].getClassName().contains("$")) { 753 778 continue; 754 779 } 755 if (!baseClass.equals(stack[i].getClassName())) { 756 break; 780 //probablky it is necessary to get out of net.sourceforge.jnlp. 781 //package where are right now all test-extensions 782 //for now keeping exactly the three classes helping you access the log 783 try { 784 Class<?> clazz = Class.forName(stack[i].getClassName()); 785 String path = null; 786 try { 787 path = clazz.getProtectionDomain().getCodeSource().getLocation().getPath(); 788 } catch (NullPointerException ex) { 789 //silently ignoring and continuing with null path 790 } 791 if (path != null && path.contains("/tests.build/")) { 792 if (!path.contains("/test-extensions/")) { 793 break; 794 } 795 } else { 796 //running from ide 797 if (!stack[i].getClassName().startsWith("net.sourceforge.jnlp.")) { 798 break; 799 } 800 } 801 } catch (ClassNotFoundException ex) { 802 ///should not happen, searching only for already loaded class 803 ex.printStackTrace(); 757 804 } 758 805 } … … 760 807 //so the target method is the highest form it and better to return it 761 808 //rather then die to ArrayOutOfBounds 762 if (i >= stack.length){809 if (i >= stack.length) { 763 810 return result; 764 811 } 765 //now we are out of net.sourceforge.jnlp.ServerAccess812 //now we are out of test-extensions 766 813 //method we need (the test) is highest from following class 767 814 baseClass = stack[i].getClassName(); … … 783 830 784 831 } 785 public static ProcessResult executeProcess(final List<String> args, File dir, ContentReaderListener stdoutl, ContentReaderListener stderrl,String[] vars) throws Exception { 786 ThreadedProcess t = new ThreadedProcess(args, dir,vars); 787 if (PROCESS_LOG) { 788 String connectionMesaage = createConnectionMessage(t); 789 log(connectionMesaage, true, true); 790 } 791 ProcessAssasin pa = new ProcessAssasin(t, PROCESS_TIMEOUT); 792 pa.start(); 793 t.start(); 794 while (t.getP() == null && t.deadlyException == null) { 795 Thread.sleep(100); 796 } 797 if (t.deadlyException != null) { 798 pa.setCanRun(false); 799 return new ProcessResult("", "", null, true, Integer.MIN_VALUE, t.deadlyException); 800 } 801 ContentReader crs = new ContentReader(t.getP().getInputStream(),stdoutl); 802 ContentReader cre = new ContentReader(t.getP().getErrorStream(),stderrl); 803 804 OutputStream out = t.getP().getOutputStream(); 805 if (out != null) { 806 out.close(); 807 } 808 809 new Thread(crs).start(); 810 new Thread(cre).start(); 811 while (t.isRunning()) { 812 Thread.sleep(100); 813 } 814 815 while (!t.isDestoyed()) { 816 Thread.sleep(100); 817 } 818 pa.setCanRun(false); 819 // ServerAccess.logOutputReprint(t.getP().exitValue()); when process is killed, this throws exception 820 821 ProcessResult pr=new ProcessResult(crs.getContent(), cre.getContent(), t.getP(), pa.wasTerminated(), t.getExitCode(), null); 822 if (PROCESS_LOG) { 823 log(pr.stdout, true, false); 824 log(pr.stderr, false, true); 825 } 826 return pr; 827 } 828 829 /** 830 * this is temprary solution until refactoring is fully done 831 * Use net.sourceforge.jnlp.ProcessResult instead 832 */ 833 @Deprecated 834 public static class ProcessResult extends net.sourceforge.jnlp.ProcessResult { 835 836 public ProcessResult(String stdout, String stderr, Process process, boolean wasTerminated, Integer r, Throwable deadlyException) { 837 super(stdout, stderr, process, wasTerminated, r, deadlyException); 838 } 839 } 840 } 832 public static ProcessResult executeProcess(final List<String> args, File dir, ContentReaderListener stdoutl, ContentReaderListener stderrl, String[] vars) throws Exception { 833 return new ProcessWrapper(args, dir, stdoutl, stderrl, vars).execute(); 834 } 835 836 } -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/ServerLauncher.java
r418 r429 57 57 private final Integer port; 58 58 private final File dir; 59 private ServerSocket serverSocket; 60 private boolean supportingHeadRequest = true; 59 61 62 public void setSupportingHeadRequest(boolean supportsHead) { 63 this.supportingHeadRequest = supportsHead; 64 } 65 66 public boolean isSupportingHeadRequest() { 67 return supportingHeadRequest; 68 } 69 70 71 60 72 public String getServerName() { 61 73 return serverName; … … 100 112 running = true; 101 113 try { 102 ServerSocket s= new ServerSocket(port);114 serverSocket = new ServerSocket(port); 103 115 while (running) { 104 new TinyHttpdImpl(s.accept(), dir, port); 116 TinyHttpdImpl server = new TinyHttpdImpl(serverSocket.accept(), dir, false); 117 server.setSupportingHeadRequest(isSupportingHeadRequest()); 118 server.start(); 105 119 } 106 120 } catch (Exception e) { 107 e.printStackTrace();121 ServerAccess.logException(e); 108 122 } finally { 109 123 running = false; … … 112 126 113 127 public URL getUrl(String resource) throws MalformedURLException { 128 if (resource == null) { 129 resource = ""; 130 } 131 if (resource.trim().length() > 0 && !resource.startsWith("/")) { 132 resource = "/" + resource; 133 } 114 134 return new URL("http", getServerName(), getPort(), resource); 115 135 } … … 118 138 return getUrl(""); 119 139 } 140 141 public void stop() { 142 this.running = false; 143 if (serverSocket != null) { 144 try { 145 serverSocket.close(); 146 } catch (Exception ex) { 147 ServerAccess.logException(ex); 148 } 149 } 150 } 120 151 } -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/ThreadedProcess.java
r418 r429 46 46 * Process builder caused some unexpected and weird behavior :/ 47 47 */ 48 class ThreadedProcess extends Thread {48 public class ThreadedProcess extends Thread { 49 49 50 50 Process p = null; … … 60 60 */ 61 61 private boolean destoyed = false; 62 private ProcessAssasin assasin; 62 63 63 64 public boolean isDestoyed() { … … 118 119 } catch (Exception ex) { 119 120 ex.printStackTrace(); 120 } finally {121 return commandLine;122 121 } 122 return commandLine; 123 123 } 124 124 … … 144 144 exitCode = p.waitFor(); 145 145 Thread.sleep(500); //this is giving to fast done proecesses's e/o readers time to read all. I would like to know better solution :-/ 146 while(assasin.isKilling() && !assasin.haveKilled()){ 147 Thread.sleep(100); 148 }; 146 149 } finally { 147 150 destoyed = true; … … 164 167 } 165 168 } 169 170 void setAssasin(ProcessAssasin pa) { 171 this.assasin=pa; 172 } 166 173 } -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java
r418 r429 43 43 import java.io.FileInputStream; 44 44 import java.io.InputStreamReader; 45 import java.io.UnsupportedEncodingException; 46 import java.net.HttpURLConnection; 45 47 import java.net.Socket; 46 48 import java.net.SocketException; … … 56 58 * is returned, but its delivery is delayed 57 59 */ 58 class TinyHttpdImpl extends Thread { 59 60 Socket c; 61 private final File dir; 62 private final int port; 60 public class TinyHttpdImpl extends Thread { 61 62 private static final String CRLF = "\r\n"; 63 private static final String HTTP_NOT_IMPLEMENTED = "HTTP/1.0 " + HttpURLConnection.HTTP_NOT_IMPLEMENTED + " Not Implemented" + CRLF; 64 private static final String HTTP_NOT_FOUND = "HTTP/1.0 " + HttpURLConnection.HTTP_NOT_FOUND + " Not Found" + CRLF; 65 private static final String HTTP_OK = "HTTP/1.0 " + HttpURLConnection.HTTP_OK + " OK" + CRLF; 66 private static final String XSX = "/XslowX"; 67 68 private Socket socket; 69 private final File testDir; 63 70 private boolean canRun = true; 64 private static final String XSX = "/XslowX"; 65 66 public TinyHttpdImpl(Socket s, File f, int port) { 67 c = s; 68 this.dir = f; 69 this.port = port; 70 start(); 71 private boolean supportingHeadRequest = true; 72 73 public TinyHttpdImpl(Socket socket, File dir) { 74 this(socket, dir, true); 75 } 76 77 public TinyHttpdImpl(Socket socket, File dir, boolean start) { 78 this.socket = socket; 79 this.testDir = dir; 80 if (start) { 81 start(); 82 } 71 83 } 72 84 … … 75 87 } 76 88 89 public void setSupportingHeadRequest(boolean supportsHead) { 90 this.supportingHeadRequest = supportsHead; 91 } 92 93 public boolean isSupportingHeadRequest() { 94 return this.supportingHeadRequest; 95 } 96 77 97 public int getPort() { 78 return port;98 return this.socket.getPort(); 79 99 } 80 100 … … 82 102 public void run() { 83 103 try { 84 BufferedReader i = new BufferedReader(new InputStreamReader(c.getInputStream()));85 DataOutputStream o = new DataOutputStream(c.getOutputStream());104 BufferedReader reader = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); 105 DataOutputStream writer = new DataOutputStream(this.socket.getOutputStream()); 86 106 try { 87 107 while (canRun) { 88 String s = i.readLine();89 if ( s.length() < 1) {108 String line = reader.readLine(); 109 if (line.length() < 1) { 90 110 break; 91 111 } 92 if (s.startsWith("GET")) { 93 StringTokenizer t = new StringTokenizer(s, " "); 94 t.nextToken(); 95 String op = t.nextToken(); 96 String p = op; 97 if (p.startsWith(XSX)) { 98 p = p.replace(XSX, "/"); 99 } 100 ServerAccess.logNoReprint("Getting: " + p); 101 p = URLDecoder.decode(p, "UTF-8"); 102 ServerAccess.logNoReprint("Serving: " + p); 103 p = (".".concat((p.endsWith("/")) ? p.concat("index.html") : p)).replace('/', File.separatorChar); 104 File pp = new File(dir, p); 105 int l = (int) pp.length(); 106 byte[] b = new byte[l]; 107 FileInputStream f = new FileInputStream(pp); 108 f.read(b); 109 String content = ""; 110 String ct = "Content-Type: "; 111 if (p.toLowerCase().endsWith(".jnlp")) { 112 content = ct + "application/x-java-jnlp-file\n"; 113 } else if (p.toLowerCase().endsWith(".html")) { 114 content = ct + "text/html\n"; 115 } else if (p.toLowerCase().endsWith(".jar")) { 116 content = ct + "application/x-jar\n"; 117 } 118 o.writeBytes("HTTP/1.0 200 OK\nConten" + "t-Length:" + l + "\n" + content + "\n"); 119 if (op.startsWith(XSX)) { 120 byte[][] bb = splitArray(b, 10); 112 113 StringTokenizer t = new StringTokenizer(line, " "); 114 String request = t.nextToken(); 115 116 boolean isHeadRequest = request.equals("HEAD"); 117 boolean isGetRequest = request.equals("GET"); 118 119 if (isHeadRequest && !isSupportingHeadRequest()) { 120 ServerAccess.logOutputReprint("Received HEAD request but not supported"); 121 writer.writeBytes(HTTP_NOT_IMPLEMENTED); 122 continue; 123 } 124 125 if (!isHeadRequest && !isGetRequest) { 126 ServerAccess.logOutputReprint("Received unknown request type " + request); 127 continue; 128 } 129 130 String filePath = t.nextToken(); 131 boolean slowSend = filePath.startsWith(XSX); 132 133 if (slowSend) { 134 filePath = filePath.replace(XSX, "/"); 135 } 136 137 ServerAccess.logOutputReprint("Getting- " + request + ": " + filePath); 138 filePath = urlToFilePath(filePath); 139 140 File resource = new File(this.testDir, filePath); 141 142 if (!(resource.isFile() && resource.canRead())) { 143 ServerAccess.logOutputReprint("Could not open file " + filePath); 144 writer.writeBytes(HTTP_NOT_FOUND); 145 continue; 146 } 147 ServerAccess.logOutputReprint("Serving- " + request + ": " + filePath); 148 149 int resourceLength = (int) resource.length(); 150 byte[] buff = new byte[resourceLength]; 151 FileInputStream fis = new FileInputStream(resource); 152 fis.read(buff); 153 fis.close(); 154 155 String contentType = "Content-Type: "; 156 if (filePath.toLowerCase().endsWith(".jnlp")) { 157 contentType += "application/x-java-jnlp-file"; 158 } else if (filePath.toLowerCase().endsWith(".jar")) { 159 contentType += "application/x-jar"; 160 } else { 161 contentType += "text/html"; 162 } 163 writer.writeBytes(HTTP_OK + "Content-Length:" + resourceLength + CRLF + contentType + CRLF + CRLF); 164 165 if (isGetRequest) { 166 if (slowSend) { 167 byte[][] bb = splitArray(buff, 10); 121 168 for (int j = 0; j < bb.length; j++) { 122 169 Thread.sleep(2000); 123 170 byte[] bs = bb[j]; 124 o.write(bs, 0, bs.length);171 writer.write(bs, 0, bs.length); 125 172 } 126 173 } else { 127 o.write(b, 0, l);174 writer.write(buff, 0, resourceLength); 128 175 } 129 176 } … … 132 179 ServerAccess.logException(e, false); 133 180 } catch (Exception e) { 134 o.writeBytes("HTTP/1.0 404 ERROR\n\n\n");181 writer.writeBytes(HTTP_NOT_FOUND); 135 182 ServerAccess.logException(e, false); 183 } finally { 184 reader.close(); 185 writer.close(); 136 186 } 137 o.close();138 187 } catch (Exception e) { 139 188 ServerAccess.logException(e, false); … … 172 221 return array; 173 222 } 223 224 /** 225 * This function transforms a request URL into a path to a file which the server 226 * will return to the requester. 227 * @param url - the request URL 228 * @return a String representation of the local path to the file 229 * @throws UnsupportedEncodingException 230 */ 231 public static String urlToFilePath(String url) throws UnsupportedEncodingException { 232 url = URLDecoder.decode(url, "UTF-8"); // Decode URL encoded charaters, eg "%3B" becomes ';' 233 if (url.startsWith(XSX)) { 234 url = url.replace(XSX, "/"); 235 } 236 url = url.replaceAll("\\?.*", ""); // Remove query string from URL 237 url = ".".concat(url); // Change path into relative path 238 if (url.endsWith("/")) { 239 url += "index.html"; 240 } 241 url = url.replace('/', File.separatorChar); // If running on Windows, replace '/' in path with "\\" 242 url = stripHttpPathParams(url); 243 return url; 244 } 245 246 /** 247 * This function removes the HTTP Path Parameter from a given JAR URL, assuming that the 248 * path param delimiter is a semicolon 249 * @param url - the URL from which to remove the path parameter 250 * @return the URL with the path parameter removed 251 */ 252 public static String stripHttpPathParams(String url) { 253 if (url == null) { 254 return null; 255 } 256 257 // If JNLP specifies JAR URL with .JAR extension (as it should), then look for any semicolons 258 // after this position. If one is found, remove it and any following characters. 259 int fileExtension = url.toUpperCase().lastIndexOf(".JAR"); 260 if (fileExtension != -1) { 261 int firstSemiColon = url.indexOf(';', fileExtension); 262 if (firstSemiColon != -1) { 263 url = url.substring(0, firstSemiColon); 264 } 265 } 266 return url; 267 } 174 268 } -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/annotations/KnownToFail.java
r418 r429 42 42 import java.lang.annotation.RetentionPolicy; 43 43 import java.lang.annotation.Target; 44 import net.sourceforge.jnlp.browsertesting.Browsers; 44 45 45 46 /** … … 53 54 * implemented. 54 55 * </p> 56 * <p> 57 * The meaning of optional parameter failsIn is either a list of 58 * browsers where the test fails, or a default value - an empty array {}, 59 * default value means that the test fails always. 60 * </p> 55 61 */ 56 62 … … 58 64 @Retention(RetentionPolicy.RUNTIME) 59 65 public @interface KnownToFail { 60 66 public Browsers[] failsIn() default {}; 61 67 } -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/browsertesting/Browser.java
r418 r429 43 43 * interface which represents individual browsers 44 44 */ 45 public interface Browser {45 public interface Browser extends ReactingProcess{ 46 46 public String getDefaultBin(); 47 47 public String getDefaultPluginExpectedLocation(); … … 53 53 public List<String> getDefaultSwitches(); 54 54 55 56 55 } -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/Epiphany.java
r418 r429 35 35 exception statement from your version. 36 36 */ 37 38 37 package net.sourceforge.jnlp.browsertesting.browsers; 39 38 39 import java.util.Arrays; 40 import java.util.List; 40 41 import net.sourceforge.jnlp.browsertesting.Browsers; 41 42 42 43 public class Epiphany extends MozillaFamilyLinuxBrowser { 44 45 46 String[] cs = {}; 43 47 44 48 public Epiphany(String bin) { … … 47 51 48 52 @Override 53 public List<String> getComaptibilitySwitches() { 54 return Arrays.asList(cs); 55 } 56 57 @Override 49 58 public Browsers getID() { 50 59 return Browsers.epiphany; 51 60 } 52 53 54 55 61 } -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/Firefox.java
r418 r429 35 35 exception statement from your version. 36 36 */ 37 38 37 package net.sourceforge.jnlp.browsertesting.browsers; 39 38 40 39 import java.util.Arrays; 41 40 import java.util.List; 41 import net.sourceforge.jnlp.ProcessAssasin; 42 import net.sourceforge.jnlp.ServerAccess; 42 43 import net.sourceforge.jnlp.browsertesting.Browsers; 44 import net.sourceforge.jnlp.browsertesting.browsers.firefox.FirefoxProfilesOperator; 43 45 44 46 public class Firefox extends MozillaFamilyLinuxBrowser { 47 48 private static final FirefoxProfilesOperator firefoxProfilesOperatorSingleton = new FirefoxProfilesOperator(); 45 49 46 50 public Firefox(String bin) { 47 51 super(bin); 48 52 } 49 50 String[] cs={"-new-tab"}; 53 String[] cs = {"-new-tab"}; 51 54 52 55 @Override … … 60 63 } 61 64 65 @Override 66 public void beforeProcess(String s) { 67 try { 68 firefoxProfilesOperatorSingleton.backupProfiles(); //assuming firefox is not in safemode already 69 } catch (Exception ex) { 70 throw new RuntimeException("Firefox profile backup failed", ex); 71 } 72 } 62 73 74 @Override 75 public void afterProcess(String s) { 76 } 63 77 78 @Override 79 public void beforeKill(String s) { 80 try { 81 ProcessAssasin.closeWindows(s); 82 } catch (Exception ex) { 83 throw new RuntimeException(ex); 84 } 85 } 64 86 65 87 @Override 88 public void afterKill(String s) { 89 try { 90 firefoxProfilesOperatorSingleton.restoreProfiles(); 91 } catch (Exception ex) { 92 throw new RuntimeException("Firefox profile restoration failed", ex); 93 } 94 95 } 66 96 } -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/LinuxBrowser.java
r418 r429 93 93 } 94 94 95 @Override 96 public void beforeProcess(String s) { 97 98 } 99 100 @Override 101 public void afterProcess(String s) { 102 103 } 104 105 @Override 106 public void beforeKill(String s) { 107 108 } 109 110 @Override 111 public void afterKill(String s) { 112 113 } 95 114 96 115 -
trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/Midory.java
r418 r429 51 51 } 52 52 53 53 54 54 55 55 }
Note:
See TracChangeset
for help on using the changeset viewer.