- Timestamp:
- Sep 24, 2014, 9:34:21 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.