Ignore:
Timestamp:
Sep 24, 2014, 9:34:21 PM (11 years ago)
Author:
dmik
Message:

icedtea-web: Merge version 1.5.1 from vendor to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/icedtea-web/tests/reproducers/signed/CacheReproducer/testcases/CacheReproducerTest.java

    r418 r429  
    4545import java.util.Arrays;
    4646import java.util.List;
     47import java.util.PropertyResourceBundle;
    4748import java.util.regex.Matcher;
    4849import java.util.regex.Pattern;
    4950import net.sourceforge.jnlp.ServerAccess;
    50 import net.sourceforge.jnlp.ServerAccess.ProcessResult;
     51import net.sourceforge.jnlp.ProcessResult;
    5152import net.sourceforge.jnlp.annotations.KnownToFail;
     53import net.sourceforge.jnlp.config.Defaults;
     54import net.sourceforge.jnlp.tools.MessageProperties;
    5255import org.junit.AfterClass;
    5356import org.junit.Assert;
     
    6164    private static final List<String> trustedVerboses = Arrays.asList(new String[]{"-Xtrustall", ServerAccess.HEADLES_OPTION,"-verbose"});
    6265    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
    7067    private static final String lre = "LruCacheException";
    7168    private static final String ioobe = "IndexOutOfBoundsException";
     
    7471    private static final String corruptString = "156dsf1562kd5";
    7572
    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";
    8186
    8287    @Test
     
    9499    }
    95100
    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    }
    110114
    111115    @Test
     
    261265            public void run() {
    262266                try {
    263                     ServerAccess.ProcessResult pr = server.executeJavawsHeadless(verbosed, "/deadlocktest.jnlp");
     267                    ProcessResult pr = server.executeJavawsHeadless(verbosed, "/deadlocktest.jnlp");
    264268                } catch (Exception ex) {
    265269                    throw new RuntimeException(ex);
     
    270274        Thread.sleep(1000);
    271275        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
    278282    //next four tests are designed to ensure, that corrupted cache will not break already loaded cached files
    279283    public static final String CR1 = "CacheReproducer1";
     
    338342            if (netxLock.isFile()) {
    339343                boolean b = netxLock.delete();
    340                 junit.framework.Assert.assertTrue(b);
     344                Assert.assertTrue(b);
    341345            }
    342346
     
    378382        }
    379383        String sb = breakOne(s, 0);
    380         junit.framework.Assert.assertEquals(s, sb);
     384        Assert.assertEquals(s, sb);
    381385        for (int x = 1; x <= 3; x++) {
    382386            String[] sx = breakOne(s, x).split("\n");
     
    427431
    428432    private static String breakPaths(String s) {
    429        return s.replaceAll(home+".*", "/ho");
     433       return s.replaceAll(System.getProperty("user.home") + ".*", "/ho");
    430434    }
    431435
     
    448452    }
    449453
    450     private static ServerAccess.ProcessResult runSimpleTest1() throws Exception {
     454    private static ProcessResult runSimpleTest1() throws Exception {
    451455        return runSimpleTest1(verbosed, "simpletest1");
    452456    }
    453457
    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");
    456460        return pr2;
    457461    }
    458462
    459     private static ServerAccess.ProcessResult runSimpleTest1Signed() throws Exception {
     463    private static ProcessResult runSimpleTest1Signed() throws Exception {
    460464        return runSimpleTestSigned("SimpletestSigned1");
    461465    }
    462466
    463     private static ServerAccess.ProcessResult runSimpleTestSigned(String id) throws Exception {
     467    private static ProcessResult runSimpleTestSigned(String id) throws Exception {
    464468        return runSimpleTest1(trustedVerboses, id);
    465469    }
    466470
    467     private static void evaluateSimpleTest1OkCache(ServerAccess.ProcessResult pr2) throws Exception {
     471    private static void evaluateSimpleTest1OkCache(ProcessResult pr2) throws Exception {
    468472        String s = "Good simple javaws exapmle";
    469473        Assert.assertTrue("test stdout should contain " + s + " but didn't", pr2.stdout.contains(s));
     
    473477
    474478    private static ProcessResult tryToClearcache() throws Exception {
    475         ServerAccess.ProcessResult pr1 = ServerAccess.executeProcess(clear);
     479        ProcessResult pr1 = ServerAccess.executeProcess(clear);
    476480        return pr1;
    477481    }
Note: See TracChangeset for help on using the changeset viewer.