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.

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  
    2727    public static void runMainAndExit(JUnitSystem system, String... args) {
    2828        new CommandLine().runMain(system, args);
    29         system.exit(0);
     29        System.exit(0);
    3030    }
    3131
    32     @Override
    3332    public Result runMain(JUnitSystem system, String... args) {
    3433        List<Class<?>> classes = new ArrayList<Class<?>>();
     
    4746        RunListener listener = new LessVerboseTextListener(system);
    4847        addListener(listener);
    49         Result result = run(classes.toArray(new Class[0]));
     48        Result result = run(classes.toArray(new Class<?>[0]));
    5049        for (Failure each : missingClasses) {
    5150            result.getFailures().add(each);
  • trunk/icedtea-web/tests/junit-runner/JunitLikeXmlOutputListener.java

    r418 r429  
    2121import java.util.Map.Entry;
    2222import java.util.Set;
     23import java.util.Arrays;
    2324import java.util.concurrent.TimeUnit;
    2425import net.sourceforge.jnlp.annotations.Bug;
    2526import net.sourceforge.jnlp.annotations.KnownToFail;
     27import net.sourceforge.jnlp.annotations.Remote;
     28import net.sourceforge.jnlp.browsertesting.Browsers;
    2629
    2730
     
    5053    private static final String BUG = "bug";
    5154    private static final String K2F = "known-to-fail";
     55    private static final String REMOTE = "remote";
    5256    private static final String TEST_NAME_ATTRIBUTE = "name";
    5357    private static final String TEST_TIME_ATTRIBUTE = "time";
     
    7781    private class ClassStat {
    7882
    79         Class c;
     83        Class<?> c;
    8084        int total;
    8185        int failed;
     
    173177        testDone(description, testTime, testTimeSeconds, false);
    174178    }
    175 
     179   
     180
     181    @SuppressWarnings("unchecked")
    176182    private void testDone(Description description, long testTime, double testTimeSeconds, boolean ignored) throws Exception {
    177         Class testClass = null;
     183        Class<?> testClass = null;
    178184        Method testMethod = null;
    179185        try {
     
    198204            testcaseAtts.put(TEST_IGNORED_ATTRIBUTE, Boolean.TRUE.toString());
    199205        }
    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
    210227        }
    211228        openElement(TEST_ELEMENT, testcaseAtts);
    212229        if (testFailed != null) {
    213             if (k2f != null) {
     230            if (thisTestIsK2F) {
    214231                failedK2F++;
    215232            }
     
    226243            writeElement(TEST_ERROR_ELEMENT, testFailed.getTrace(), errorAtts);
    227244        } else {
    228             if (k2f != null) {
     245            if (thisTestIsK2F) {
    229246                if (ignored) {
    230247                    ignoredK2F++;
     
    265282        }
    266283        classStat.total++;
    267         if (k2f != null) {
     284        if (thisTestIsK2F) {
    268285            classStat.totalK2F++;
    269286        }
     
    272289            if (ignored) {
    273290                classStat.ignored++;
    274                 if (k2f != null) {
     291                if (thisTestIsK2F) {
    275292                    classStat.ignoredK2F++;
    276293                }
    277294            } else {
    278295                classStat.passed++;
    279                 if (k2f != null) {
     296                if (thisTestIsK2F) {
    280297                    classStat.passedK2F++;
    281298                }
     
    283300        } else {
    284301            classStat.failed++;
    285             if (k2f != null) {
     302            if (thisTestIsK2F) {
    286303                classStat.failedK2F++;
    287304            }
     
    290307
    291308    @Override
     309    @SuppressWarnings("unchecked")
    292310    public void testRunFinished(Result result) throws Exception {
    293311
     
    320338                Bug b = null;
    321339                if (entry.getValue().c != null) {
    322                     b = (Bug) entry.getValue().c.getAnnotation(Bug.class);
     340                    b = entry.getValue().c.getAnnotation(Bug.class);
    323341                }
    324342                if (b != null) {
  • trunk/icedtea-web/tests/junit-runner/LessVerboseTextListener.java

    r418 r429  
    77 */
    88import java.io.PrintStream;
     9import java.lang.annotation.Annotation;
    910import java.lang.reflect.Method;
    1011import net.sourceforge.jnlp.annotations.KnownToFail;
     12import net.sourceforge.jnlp.annotations.Remote;
     13import net.sourceforge.jnlp.browsertesting.Browsers;
    1114
    1215import org.junit.internal.JUnitSystem;
     
    3841        writer.println("Ignored: " + description.getClassName() + "." + description.getMethodName());
    3942        printK2F(writer, null, description);
     43        printRemote(writer, description);
    4044    }
    4145
     
    4650        writer.println("FAILED: " + failure.getTestHeader() + " " + failure.getMessage());
    4751        printK2F(writer,true,failure.getDescription());
     52        printRemote(writer, failure.getDescription());
    4853    }
    4954
     
    5358            writer.println("Passed: " + description.getClassName() + "." + description.getMethodName());
    5459            printK2F(writer,false,description);
     60            printRemote(writer, description);
    5561        }
    5662    }
     
    7076        try {
    7177            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 ){
    7394                totalK2F++;
    7495                if (failed != null) {
     
    94115    }
    95116
    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) {
    97120        try {
    98             Class q = description.getTestClass();
    99121            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;
    101127                if (qs.contains(" - ")) {
    102128                    qs = qs.replaceAll(" - .*", "");
     
    104130                Method qm = q.getMethod(qs);
    105131                if (qm != null) {
    106                     KnownToFail k2f = qm.getAnnotation(KnownToFail.class);
    107                     return k2f;
     132                    rem = qm.getAnnotation(a);
     133                    return rem;
    108134
    109135                }
     
    115141    }
    116142
     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    }
    117162}
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/DefaultLaunchHandlerTest.java

    r418 r429  
    4343import java.io.ByteArrayOutputStream;
    4444import java.io.PrintStream;
     45import java.lang.reflect.Field;
     46import net.sourceforge.jnlp.util.logging.LogConfig;
     47import net.sourceforge.jnlp.util.logging.OutputController;
    4548
    4649import org.junit.Test;
     
    4851public class DefaultLaunchHandlerTest {
    4952
     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
    5086    @Test
    5187    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);
    5490
    5591        // all no-ops with no output
     
    5894        handler.launchCompleted(null);
    5995
    60         String output = baos.toString();
    61         assertEquals("", output);
     96        assertEquals("", l.getStream1());
     97        assertEquals("", l.getStream2());
    6298    }
    6399
    64100    @Test
    65101    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);
    68104
    69105        LaunchException warning = new LaunchException(null, null,
     
    72108
    73109        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());
    76111    }
    77112
    78113    @Test
    79114    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);
    82117
    83118        LaunchException error = new LaunchException(null, null,
     
    85120        handler.launchError(error);
    86121
    87         String output = baos.toString();
    88         assertEquals("netx: error type: test error\n", output);
     122        assertEquals("netx: error type: test error\n", l.getStream1());
    89123    }
    90124
    91125    @Test
    92126    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);
    95129
    96130        ParseException parse = new ParseException("no information element");
     
    99133        handler.launchError(error);
    100134
    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());
    103136    }
    104137
    105138    @Test
    106139    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);
    109142
    110143        ParseException parse = new ParseException("no information element");
     
    114147        handler.launchError(error);
    115148
    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());
    118150    }
    119 
    120151
    121152    @Test
    122153    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);
    125156
    126157        LaunchException error = new LaunchException(null, null,
     
    128159        handler.validationError(error);
    129160
    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());
    132162    }
    133163}
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java

    r418 r429  
    3838package net.sourceforge.jnlp;
    3939
     40import java.io.ByteArrayInputStream;
     41import java.io.InputStream;
     42import java.net.MalformedURLException;
     43import java.net.URL;
    4044import java.util.Locale;
     45import java.util.Map;
    4146
    4247import net.sourceforge.jnlp.JNLPFile.Match;
     48import net.sourceforge.jnlp.annotations.Bug;
    4349import net.sourceforge.jnlp.mock.MockJNLPFile;
     50import net.sourceforge.jnlp.util.logging.NoStdOutErrTest;
    4451
    4552import org.junit.Assert;
    4653import org.junit.Test;
    4754
    48 public class JNLPFileTest {
     55public class JNLPFileTest extends NoStdOutErrTest{
    4956    Locale jvmLocale = new Locale("en", "CA", "utf8");
    5057    MockJNLPFile file = new MockJNLPFile(jvmLocale);
     
    104111                file.localeMatches(jvmLocale, mismatchAvailable, Match.GENERALIZED));
    105112    }
     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    }
    106363}
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/JNLPMatcherTest.java

    r418 r429  
    7272            "Testing by calling JNLPMatcher.match() multiple times. Checking to see if the returns value is consistent" };
    7373
    74     final ClassLoader cl = JNLPMatcherTest.class.getClassLoader();
     74    final ClassLoader cl = ClassLoader.getSystemClassLoader();
    7575
    7676    private InputStreamReader getLaunchReader() {
     
    467467    }
    468468
    469     @Test (timeout=1000 /*ms*/)
     469    @Test (timeout=5000 /*ms*/)
    470470    public void testIsMatchDoesNotHangOnLargeData() throws JNLPMatcherException {
    471471        /* construct an alphabet containing characters 'a' to 'z' */
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserBasic.java

    r348 r429  
    3838package net.sourceforge.jnlp;
    3939
    40 import java.io.ByteArrayInputStream;
    4140import java.io.InputStream;
    4241import java.util.List;
    43 
    44 import org.junit.After;
     42import net.sourceforge.jnlp.mock.DummyJNLPFile;
     43import net.sourceforge.jnlp.util.logging.NoStdOutErrTest;
     44
    4545import org.junit.Assert;
    46 import org.junit.Before;
    4746import org.junit.BeforeClass;
    4847import org.junit.Test;
    4948
    5049/** Test that the parser works with basic jnlp files */
    51 public class ParserBasic {
     50public class ParserBasic extends NoStdOutErrTest{
    5251
    5352    private static Node root;
     
    6059            cl = ClassLoader.getSystemClassLoader();
    6160        }
     61        ParserSettings defaultParser = new ParserSettings();
    6262        InputStream jnlpStream = cl.getResourceAsStream("net/sourceforge/jnlp/basic.jnlp");
    63         root = Parser.getRootNode(jnlpStream);
    64         parser = new Parser(null, null, root, false, false);
     63        root = Parser.getRootNode(jnlpStream, defaultParser);
     64        parser = new Parser(new DummyJNLPFile(), null, root, defaultParser);
    6565    }
    6666
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserCornerCases.java

    r418 r429  
    5151/** Test various corner cases of the parser */
    5252public class ParserCornerCases {
     53    private static final ParserSettings defaultParser = new ParserSettings(false, true,true);
    5354
    5455    @Test
     
    6465        Assert.assertTrue(target.getContent().contains("<entry key=\"key\">value</entry>"));
    6566
    66         Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()));
     67        Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
    6768        Assert.assertEquals("argument", node.getNodeName());
    6869        String contents = node.getNodeValue();
     
    8485        XMLElement elem = new XMLElement();
    8586        elem.parseFromReader(new StringReader(data));
    86         XMLElement target = (XMLElement) ((XMLElement) elem.enumerateChildren().nextElement()).enumerateChildren().nextElement();
     87        XMLElement target = (elem.enumerateChildren().nextElement()).enumerateChildren().nextElement();
    8788        Assert.assertEquals("argument", target.getName());
    8889        Assert.assertTrue("too small", target.getContent().length() > 20);
     
    9192        Assert.assertTrue(target.getContent().contains("<entry key=\"key\">value</entry>"));
    9293
    93         Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()));
     94        Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
    9495        node = node.getFirstChild().getFirstChild();
    9596        Assert.assertEquals("argument", node.getNodeName());
     
    127128    public void testUnsupportedSpecNumber() throws ParseException {
    128129        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);
    131132        Assert.assertEquals("11.11", parser.getSpecVersion().toString());
    132133    }
     
    135136    public void testApplicationAndComponent() throws ParseException {
    136137        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);
    139140        Assert.assertNotNull(parser.getLauncher(root));
    140141    }
     
    143144    public void testCommentInElements() throws ParseException {
    144145        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);
    147148        Assert.assertEquals("1.0", p.getSpecVersion().toString());
    148     }
    149 
    150     @Test
    151     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     @Test
    159     @KnownToFail
    160     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());
    165149    }
    166150
     
    172156                "<!-- outer <!-- inner --> -->" +
    173157                "</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);
    176160        Assert.assertEquals(" -->", p.getInfo(root).get(0).getDescription());
    177161    }
     
    187171                "  <information/>" +
    188172                "</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    }
    193211}
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserMalformedXml.java

    r418 r429  
    5252
    5353    private static String originalJnlp = null;
     54    private static ParserSettings lenientParserSettings = new ParserSettings(false, true, true);
    5455
    5556    @BeforeClass
     
    7273    public void testMissingXmlDecleration() throws ParseException {
    7374        String malformedJnlp = originalJnlp.replaceFirst("<\\?xml.*\\?>", "");
    74         Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()));
     75        Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), lenientParserSettings);
    7576    }
    7677
     
    7980    public void testMalformedArguments() throws ParseException {
    8081        String malformedJnlp = originalJnlp.replace("arg2</argument", "arg2<argument");
    81         Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()));
     82        Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), lenientParserSettings);
    8283    }
    8384
    8485    @Test
    85     @KnownToFail
    8686    public void testTagNotClosed() throws ParseException {
    8787        String malformedJnlp = originalJnlp.replace("</jnlp>", "<jnlp>");
    88         Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()));
     88        Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes()), lenientParserSettings);
    8989    }
    9090
    9191    @Test
    92     @KnownToFail
    9392    public void testUnquotedAttributes() throws ParseException {
    9493        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));
    96107    }
    97108
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserTest.java

    r418 r429  
    3939
    4040import java.io.ByteArrayInputStream;
     41import java.net.URL;
    4142import java.util.ArrayList;
    4243import java.util.List;
     
    5859    private static final Locale ALL_LOCALE = new Locale(LANG, COUNTRY, VARIANT);
    5960
     61    ParserSettings defaultParser=new ParserSettings();
    6062    @Test(expected = MissingInformationException.class)
    6163    public void testMissingInfoFullLocale() throws ParseException {
    6264        String data = "<jnlp></jnlp>\n";
    6365
    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);
    6971        parser.getInfo(root);
    7072    }
     
    7779                + "</jnlp>\n";
    7880
    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);
    8486        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    8587        infoDescs.addAll(parser.getInfo(root));
     
    100102                + "</jnlp>\n";
    101103
    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);
    107109        List<InformationDesc> infoDescs = parser.getInfo(root);
    108110
     
    130132                + "</jnlp>\n";
    131133
    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);
    136138        List<InformationDesc> infoDescs = parser.getInfo(root);
    137139        Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2);
     
    157159                + "</jnlp>\n";
    158160
    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);
    163165        List<InformationDesc> infoDescs = parser.getInfo(root);
    164166        Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2);
     
    180182                + "</jnlp>\n";
    181183
    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);
    186188        List<InformationDesc> infoDescs = parser.getInfo(root);
    187189        Assert.assertTrue("Exactly one info desc should be found", infoDescs.size() == 1);
     
    211213                + "</jnlp>\n";
    212214
    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);
    217219        List<InformationDesc> infoDescs = parser.getInfo(root);
    218220        Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3);
     
    242244                + "</jnlp>\n";
    243245
    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);
    248250        List<InformationDesc> infoDescs = parser.getInfo(root);
    249251        Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3);
     
    272274                + "</jnlp>\n";
    273275
    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);
    278280        List<InformationDesc> infoDescs = parser.getInfo(root);
    279281        Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3);
     
    301303                + "</jnlp>\n";
    302304
    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);
    307309        List<InformationDesc> infoDescs = parser.getInfo(root);
    308310        Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3);
     
    329331                + "</jnlp>\n";
    330332
    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);
    335337        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    336338        infoDescs.addAll(parser.getInfo(root));
     
    356358                + "</jnlp>\n";
    357359
    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);
    362364        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    363365        infoDescs.addAll(parser.getInfo(root));
     
    380382                + "</jnlp>\n";
    381383
    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);
    386388        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    387389        infoDescs.addAll(parser.getInfo(root));
     
    404406                + "</jnlp>\n";
    405407
    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);
    410412        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    411413        infoDescs.addAll(parser.getInfo(root));
     
    426428                + "</jnlp>\n";
    427429
    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);
    433435        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    434436        infoDescs.addAll(parser.getInfo(root));
     
    449451                + "</jnlp>\n";
    450452
    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);
    456458        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    457459        infoDescs.addAll(parser.getInfo(root));
     
    488490                + "</jnlp>\n";
    489491
    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);
    495497        List<InformationDesc> infoDescs = parser.getInfo(root);
    496498
     
    511513        String data = "<jnlp></jnlp>\n";
    512514
    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);
    518520        parser.getInfo(root);
    519521    }
     
    526528                + "</jnlp>\n";
    527529
    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);
    533535        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    534536        infoDescs.addAll(parser.getInfo(root));
     
    549551                + "</jnlp>\n";
    550552
    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);
    556558        List<InformationDesc> infoDescs = parser.getInfo(root);
    557559
     
    575577                + "</jnlp>\n";
    576578
    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);
    581583        List<InformationDesc> infoDescs = parser.getInfo(root);
    582584        Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2);
     
    602604                + "</jnlp>\n";
    603605
    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);
    608610        List<InformationDesc> infoDescs = parser.getInfo(root);
    609611        Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2);
     
    625627                + "</jnlp>\n";
    626628
    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);
    631633        List<InformationDesc> infoDescs = parser.getInfo(root);
    632634        Assert.assertTrue("Exactly one info desc should be found", infoDescs.size() == 1);
     
    656658                + "</jnlp>\n";
    657659
    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);
    662664        List<InformationDesc> infoDescs = parser.getInfo(root);
    663665        Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3);
     
    687689                + "</jnlp>\n";
    688690
    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);
    693695        List<InformationDesc> infoDescs = parser.getInfo(root);
    694696        Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3);
     
    717719                + "</jnlp>\n";
    718720
    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);
    723725        List<InformationDesc> infoDescs = parser.getInfo(root);
    724726        Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3);
     
    746748                + "</jnlp>\n";
    747749
    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);
    752754        List<InformationDesc> infoDescs = parser.getInfo(root);
    753755        Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3);
     
    774776                + "</jnlp>\n";
    775777
    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);
    780782        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    781783        infoDescs.addAll(parser.getInfo(root));
     
    801803                + "</jnlp>\n";
    802804
    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);
    807809        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    808810        infoDescs.addAll(parser.getInfo(root));
     
    825827                + "</jnlp>\n";
    826828
    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);
    831833        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    832834        infoDescs.addAll(parser.getInfo(root));
     
    849851                + "</jnlp>\n";
    850852
    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);
    855857        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    856858        infoDescs.addAll(parser.getInfo(root));
     
    871873                + "</jnlp>\n";
    872874
    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);
    878880        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    879881        infoDescs.addAll(parser.getInfo(root));
     
    894896                + "</jnlp>\n";
    895897
    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);
    901903        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    902904        infoDescs.addAll(parser.getInfo(root));
     
    933935                + "</jnlp>\n";
    934936
    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);
    940942        List<InformationDesc> infoDescs = parser.getInfo(root);
    941943
     
    956958        String data = "<jnlp></jnlp>\n";
    957959
    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);
    963965        parser.getInfo(root);
    964966    }
     
    971973                + "</jnlp>\n";
    972974
    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);
    978980        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    979981        infoDescs.addAll(parser.getInfo(root));
     
    994996                + "</jnlp>\n";
    995997
    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);
    10011003        List<InformationDesc> infoDescs = parser.getInfo(root);
    10021004
     
    10161018                + "</jnlp>\n";
    10171019
    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);
    10221024        List<InformationDesc> infoDescs = parser.getInfo(root);
    10231025        Assert.assertTrue("Exactly one info desc should be found", infoDescs.size() == 1);
     
    10401042                + "</jnlp>\n";
    10411043
    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);
    10461048        List<InformationDesc> infoDescs = parser.getInfo(root);
    10471049        Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2);
     
    10631065                + "</jnlp>\n";
    10641066
    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);
    10691071        List<InformationDesc> infoDescs = parser.getInfo(root);
    10701072        Assert.assertTrue("Exactly one info desc should be found", infoDescs.size() == 1);
     
    10941096                + "</jnlp>\n";
    10951097
    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);
    11001102        List<InformationDesc> infoDescs = parser.getInfo(root);
    11011103        Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3);
     
    11251127                + "</jnlp>\n";
    11261128
    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);
    11311133        List<InformationDesc> infoDescs = parser.getInfo(root);
    11321134        Assert.assertTrue("Exactly three info descs should be found", infoDescs.size() == 3);
     
    11511153                + "</jnlp>\n";
    11521154
    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);
    11571159        List<InformationDesc> infoDescs = parser.getInfo(root);
    11581160        Assert.assertTrue("Exactly two info descs should be found", infoDescs.size() == 2);
     
    11791181                + "</jnlp>\n";
    11801182
    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);
    11851187        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    11861188        infoDescs.addAll(parser.getInfo(root));
     
    12061208                + "</jnlp>\n";
    12071209
    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);
    12121214        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    12131215        infoDescs.addAll(parser.getInfo(root));
     
    12301232                + "</jnlp>\n";
    12311233
    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);
    12361238        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    12371239        infoDescs.addAll(parser.getInfo(root));
     
    12541256                + "</jnlp>\n";
    12551257
    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);
    12601262        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    12611263        infoDescs.addAll(parser.getInfo(root));
     
    12761278                + "</jnlp>\n";
    12771279
    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);
    12831285        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    12841286        infoDescs.addAll(parser.getInfo(root));
     
    12991301                + "</jnlp>\n";
    13001302
    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);
    13061308        List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
    13071309        infoDescs.addAll(parser.getInfo(root));
     
    13381340                + "</jnlp>\n";
    13391341
    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);
    13451347        List<InformationDesc> infoDescs = parser.getInfo(root);
    13461348
     
    13561358        parser.checkForInformation();
    13571359    }
     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    }
    13581416}
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java

    r418 r429  
    2828import java.net.MalformedURLException;
    2929import java.net.URL;
     30import java.util.ArrayList;
    3031import java.util.HashMap;
     32import java.util.Map;
    3133import java.util.Hashtable;
     34import java.util.List;
    3235
    3336import net.sourceforge.jnlp.cache.UpdatePolicy;
     37import net.sourceforge.jnlp.util.replacements.BASE64Encoder;
     38import org.junit.Assert;
    3439
    3540import org.junit.Test;
     
    4449        }
    4550
    46         public JNLPFile create(URL location, Version version, boolean strict,
     51        @Override
     52        public JNLPFile create(URL location, Version version, ParserSettings settings,
    4753                UpdatePolicy policy, URL forceCodebase) throws IOException, ParseException {
    4854            JNLPHref = location;
     
    6167    }
    6268
     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
    6375    @Test
    6476    public void testAbsoluteJNLPHref() throws MalformedURLException, Exception {
    6577        URL codeBase = new URL("http://undesired.absolute.codebase.com");
    6678        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);
    7183        assertEquals(absoluteLocation, mockCreator.getJNLPHref().toExternalForm());
    7284    }
     
    7688        URL codeBase = new URL("http://desired.absolute.codebase.com/");
    7789        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);
    8294        assertEquals(codeBase.toExternalForm() + relativeLocation,
    83                      mockCreator.getJNLPHref().toExternalForm());
     95                mockCreator.getJNLPHref().toExternalForm());
    8496    }
    8597
     
    89101        URL codeBase = new URL(desiredDomain + "/undesired/sub/dir");
    90102        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);
    95107        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    }
    99321}
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/cache/CacheLRUWrapperTest.java

    r418 r429  
    4343import net.sourceforge.jnlp.ServerAccess;
    4444
    45 import net.sourceforge.jnlp.config.DeploymentConfiguration;
    46 import net.sourceforge.jnlp.runtime.JNLPRuntime;
     45import net.sourceforge.jnlp.util.PropertiesFile;
     46import org.junit.AfterClass;
    4747
    4848import org.junit.BeforeClass;
     
    5151public class CacheLRUWrapperTest {
    5252
    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;
    5756    // 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";
    5958
    6059    private final int noEntriesCacheFile = 1000;
     
    6261    @BeforeClass
    6362    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;
    6574    }
    6675   
     
    6877    public void testLoadStoreTiming() throws InterruptedException {
    6978
     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       
    7085        int noLoops = 1000;
    7186
     
    96111        // wait more than 100 microseconds for noLoops = 1000 and noEntries=1000 is bad
    97112        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        }
    100117    }
    101118
     
    104121        // fill cache index file
    105122        for(int i = 0; i < noEntries; i++) {
    106             String path = cacheDir + File.separatorChar + i + File.separatorChar + "test" + i + ".jar";
     123            String path = clw.cacheDir + File.separatorChar + i + File.separatorChar + "test" + i + ".jar";
    107124            String key = clw.generateKey(path);
    108125            clw.addEntry(key, path);
     
    113130    public void testModTimestampAfterStore() throws InterruptedException {
    114131
    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{
    117137        clw.lock();
    118138       
    119139        // 1. clear cache entries + store
     140        clw.addEntry("aa", "bb");
     141        clw.store();
    120142        long lmBefore = cacheIndexFile.lastModified();
     143        Thread.sleep(1010);
    121144        clearCacheIndexFile();
    122145        long lmAfter = cacheIndexFile.lastModified();
     
    124147
    125148        // FIXME: wait a second, because of file modification timestamp only provides accuracy on seconds.
    126         Thread.sleep(1000);
     149        Thread.sleep(1010);
    127150
    128151        // 2. load cache file
     
    139162        assertTrue("modification timestamp hasn't changed! Before = " + lmBefore + " After = " + lmAfter, lmBefore < lmAfter);
    140163
    141         clw.unlock();
     164        } finally {
     165            cacheIndexFile.delete();
     166            clw.unlock();
     167        }
    142168    }
    143169   
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java

    r418 r429  
    11/* 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/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.
     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.
    3636 */
    3737package net.sourceforge.jnlp.cache;
    3838
     39import java.io.ByteArrayOutputStream;
     40import java.io.File;
     41import java.io.IOException;
     42import java.io.PrintStream;
    3943import java.io.UnsupportedEncodingException;
     44import java.net.HttpURLConnection;
    4045import java.net.MalformedURLException;
     46import java.net.URISyntaxException;
    4147import java.net.URL;
     48import java.util.HashMap;
     49import net.sourceforge.jnlp.ServerAccess;
     50import net.sourceforge.jnlp.ServerLauncher;
     51import net.sourceforge.jnlp.Version;
     52import net.sourceforge.jnlp.runtime.JNLPRuntime;
     53import net.sourceforge.jnlp.util.logging.OutputController;
     54import net.sourceforge.jnlp.util.UrlUtils;
     55import org.junit.AfterClass;
    4256import org.junit.Assert;
     57import org.junit.BeforeClass;
    4358import org.junit.Test;
    4459
    45 /** Test various corner cases of the parser */
    4660public 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";
    4768
    4869    @Test
     
    5576        Assert.assertNull("first normalized url should be null", n[0]);
    5677        for (int i = 1; i < CHANGE_BORDER; i++) {
    57             Assert.assertTrue("url " + i + " must be equals too normlaized url " + i, u[i].equals(n[i]));
     78            Assert.assertTrue("url " + i + " must be equals too normalized url " + i, u[i].equals(n[i]));
    5879        }
    5980        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;
    6885
    6986    public static URL[] getUrls() throws MalformedURLException {
     
    7188            /*constant*/
    7289            null,
    73             new URL("http://localhost:44321/Spaces%20Can%20Be%20Everyw%2Fhere1.jnlp"),
    7490            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"),
    7691            new URL("http://localhost:44321/SpacesCanBeEverywhere1.jnlp"),
    7792            new URL("http:///SpacesCanBeEverywhere1.jnlp"),
    7893            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"),
    7997            /*changing*/
    8098            new URL("http://localhost/SpacesC anBeEverywhere1.jnlp?a=5&b=10#df"),
     
    86104    }
    87105
    88     public static URL[] getNormalizedUrls() throws MalformedURLException, UnsupportedEncodingException {
     106    public static URL[] getNormalizedUrls() throws MalformedURLException, UnsupportedEncodingException, URISyntaxException {
    89107        URL[] u = getUrls();
    90108
    91109        URL[] n = new URL[u.length];
    92110        for (int i = 0; i < n.length; i++) {
    93             n[i] = normalizeUrl(u[i]);
     111            n[i] = UrlUtils.normalizeUrl(u[i]);
    94112        }
    95113        return n;
    96114
    97115    }
     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    }
    98371}
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/runtime/CodeBaseClassLoaderTest.java

    r418 r429  
    11/* 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 */
    3837package net.sourceforge.jnlp.runtime;
    3938
     39import net.sourceforge.jnlp.mock.DummyJNLPFile;
    4040import static org.junit.Assert.assertFalse;
    4141import static org.junit.Assert.assertTrue;
    4242
    43 import java.io.IOException;
    44 import java.net.MalformedURLException;
     43import java.lang.reflect.Field;
    4544import java.net.URL;
    4645import java.util.Locale;
    4746
    4847import net.sourceforge.jnlp.JNLPFile;
    49 import net.sourceforge.jnlp.LaunchException;
    50 import net.sourceforge.jnlp.ParseException;
     48import net.sourceforge.jnlp.NullJnlpFileException;
    5149import net.sourceforge.jnlp.ResourcesDesc;
    5250import net.sourceforge.jnlp.SecurityDesc;
     51import net.sourceforge.jnlp.SecurityDescTest;
    5352import net.sourceforge.jnlp.ServerAccess;
    54 import net.sourceforge.jnlp.runtime.JNLPClassLoader;
    5553import net.sourceforge.jnlp.runtime.JNLPClassLoader.CodeBaseClassLoader;
    5654import net.sourceforge.jnlp.annotations.Bug;
     55import net.sourceforge.jnlp.annotations.Remote;
     56import net.sourceforge.jnlp.config.DeploymentConfiguration;
     57import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel;
     58import net.sourceforge.jnlp.security.appletextendedsecurity.AppletStartupSecuritySettings;
     59import net.sourceforge.jnlp.util.logging.NoStdOutErrTest;
     60import org.junit.AfterClass;
     61import org.junit.Assert;
     62import org.junit.BeforeClass;
    5763
    5864import org.junit.Test;
    5965
    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         };
     66public 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();
    86144
    87145        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        }
    90154        long startTime, stopTime;
    91155
    92156        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        }
    94163        stopTime = System.nanoTime();
    95164        long timeOnFirstTry = stopTime - startTime;
    96         ServerAccess.logErrorReprint(""+timeOnFirstTry);
     165        ServerAccess.logErrorReprint("" + timeOnFirstTry);
    97166
    98167        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        }
    100174        stopTime = System.nanoTime();
    101175        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();
    173213
    174214        final boolean[] parentWasInvoked = new boolean[1];
     
    181221            }
    182222        };
    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);
    184224        try {
    185225            classLoader.findClass("foo");
     
    189229        assertTrue(parentWasInvoked[0]);
    190230    }
     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    }
    191269}
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/tools/JarCertVerifierTest.java

    r418 r429  
    3838package net.sourceforge.jnlp.tools;
    3939
    40 import static org.junit.Assert.*;
    41 
     40import static net.sourceforge.jnlp.runtime.Translator.R;
     41import static org.junit.Assert.assertFalse;
     42import static org.junit.Assert.assertTrue;
     43
     44import java.security.CodeSigner;
     45import java.util.Date;
     46import java.util.List;
     47import java.util.Vector;
     48import java.util.jar.JarEntry;
     49
     50import net.sourceforge.jnlp.JARDesc;
     51import net.sourceforge.jnlp.tools.JarCertVerifier.VerifyResult;
     52
     53import org.junit.Assert;
     54import org.junit.BeforeClass;
    4255import org.junit.Test;
    4356
     
    4659    @Test
    4760    public void testIsMetaInfFile() {
    48         final String METAINF ="META-INF";
     61        final String METAINF = "META-INF";
    4962        assertFalse(JarCertVerifier.isMetaInfFile("some_dir/" + METAINF + "/filename"));
    5063        assertFalse(JarCertVerifier.isMetaInfFile(METAINF + "filename"));
     
    5265    }
    5366
     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
    54520}
  • trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/util/PropertiesFileTest.java

    r418 r429  
    4444import java.nio.channels.FileLock;
    4545import java.nio.channels.OverlappingFileLockException;
     46import net.sourceforge.jnlp.cache.CacheLRUWrapper;
    4647
    4748import net.sourceforge.jnlp.config.DeploymentConfiguration;
     
    6263
    6364    // 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;
    6566
    6667    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  
    4949public class BASE64EncoderTest {
    5050
    51     private static final String sSrc = "abcdefgHIJKLMNOPQrstuvwxyz1234567890\r\n"
     51    static final String sSrc = "abcdefgHIJKLMNOPQrstuvwxyz1234567890\r\n"
    5252            + "-=+_))(**&&&^^%%$$##@@!!~{}][\":'/\\.,><\n"
    5353            + "+ěšěčřşÜáíé=ů/úěřťšďňéíáč";
    54     private static 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,
    5555        48, 104, 74, 83, 107, 116, 77, 84, 85, 53, 80, 85, 70, 70, 121, 99, 51,
    5656        82, 49, 100, 110, 100, 52, 101, 88, 111, 120, 77, 106, 77, 48, 78, 84,
     
    6464        68, 113, 99, 79, 116, 119, 54, 72, 69, 106, 81, 61, 61, 10};
    6565   
    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";
    6867
    6968    @Test
     
    9897        byte[] encoded2 = out2.toByteArray();
    9998        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")));
    101100        Assert.assertArrayEquals(data, decoded);
    102101        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"));
    107115    }
    108116
    109     private static Object createInsatnce(String ofCalss) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
     117    static Object createInsatnce(String ofCalss) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    110118
    111         Class classDefinition = Class.forName(ofCalss);
     119        Class<?> classDefinition = Class.forName(ofCalss);
    112120        return classDefinition.newInstance();
    113121
    114122    }
    115123
    116     private static 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 {
    117125        Class<?>[] cs = new Class<?>[params.length];
    118126        for (int i = 0; i < params.length; i++) {
  • trunk/icedtea-web/tests/report-styles/jreport.xsl

    r418 r429  
    262262             <xsl:choose>
    263263               <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>
    265265               </xsl:when>
    266266               <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>
    268268               </xsl:otherwise>
    269269             </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>
    270275           </xsl:when>
    271276         </xsl:choose>
     
    277282         <xsl:choose>
    278283           <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>
    280290           </xsl:when>
    281291         </xsl:choose>
  • trunk/icedtea-web/tests/reproducers/custom/AppletFolderInArchiveTag/srcs/Makefile

    r418 r429  
    11TESTNAME=AppletFolderInArchiveTag
    22ARCHIVE_TEST_FOLDER=archive_tag_folder_test
    3 JAVAC_CLASSPATH=$(JNLP_TESTS_ENGINE_DIR):$(NETX_DIR)/lib/classes.jar
    4 DEPLOY_SUBDIR=$(JNLP_TESTS_SERVER_DEPLOYDIR)/$(ARCHIVE_TEST_FOLDER)
     3JAVAC_CLASSPATH=$(TEST_EXTENSIONS_DIR):$(NETX_DIR)/lib/classes.jar
     4DEPLOY_SUBDIR=$(REPRODUCERS_TESTS_SERVER_DEPLOYDIR)/$(ARCHIVE_TEST_FOLDER)
    55INDEX_HTML_BODY="<html><body><h1>Required to recognize folder structure</h1></body></html>"
    66
  • trunk/icedtea-web/tests/reproducers/custom/AppletFolderInArchiveTag/testcases/AppletFolderInArchiveTagTests.java

    r418 r429  
    3636 */
    3737
    38 import net.sourceforge.jnlp.ServerAccess.ProcessResult;
     38import net.sourceforge.jnlp.ProcessResult;
    3939import net.sourceforge.jnlp.annotations.Bug;
    4040import net.sourceforge.jnlp.annotations.NeedsDisplay;
  • trunk/icedtea-web/tests/reproducers/custom/UnsignedContentInMETAINF/srcs/Makefile

    r418 r429  
    11TESTNAME=UnsignedContentInMETAINF
    2 JAVAC_CLASSPATH=$(JNLP_TESTS_ENGINE_DIR):$(NETX_DIR)/lib/classes.jar
    3 DEPLOY_DIR=$(JNLP_TESTS_SERVER_DEPLOYDIR)
     2JAVAC_CLASSPATH=$(TEST_EXTENSIONS_DIR):$(NETX_DIR)/lib/classes.jar
     3DEPLOY_DIR=$(REPRODUCERS_TESTS_SERVER_DEPLOYDIR)
    44JAVAC=$(BOOT_DIR)/bin/javac
    55JAR=$(BOOT_DIR)/bin/jar
    6 ABS_SRC_PATH=$(JNLP_TESTS_SRCDIR)/custom/$(TESTNAME)/srcs
     6ABS_SRC_PATH=$(REPRODUCERS_TESTS_SRCDIR)/custom/$(TESTNAME)/srcs
    77
    88prepare-reproducer:
  • trunk/icedtea-web/tests/reproducers/signed/AppletTestSigned/resources/AppletTestSigned.html

    r418 r429  
    3838<html><head></head><body bgcolor="red">
    3939<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">
    4141    <param name="key1" value="value1">
    4242    <param name="key2" value="#value2">
  • trunk/icedtea-web/tests/reproducers/signed/AppletTestSigned/srcs/AppletTestSigned.java

    r418 r429  
    4949                Thread.sleep(n);
    5050                System.out.println("AppletTestSigned killing himself after " + n + " ms of life");
     51                System.out.println("*** APPLET FINISHED ***");
    5152                System.exit(0);
    5253            } catch (Exception ex) {
  • trunk/icedtea-web/tests/reproducers/signed/AppletTestSigned/testcases/AppletTestSignedTests.java

    r418 r429  
    4444import net.sourceforge.jnlp.browsertesting.Browsers;
    4545import net.sourceforge.jnlp.annotations.TestInBrowsers;
     46import net.sourceforge.jnlp.closinglisteners.Rule;
     47import net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener;
     48import static net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener.*;
    4649import org.junit.Assert;
    4750
     
    5154
    5255    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);
    5367
    54     @Test
     68   // @Test
    5569    public void AppletTestSignedTest() throws Exception {
    5670        ProcessResult pr = server.executeJavawsHeadless(l, "/AppletTestSigned.jnlp");
     
    6175
    6276    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));
    7582        if (!javawsApplet) {
    7683            /*this is working correctly in most browser, but not in all. temporarily disabling
     
    8592    @Test
    8693    @TestInBrowsers(testIn = {Browsers.all})
    87     public void AppletTestSignedFirefoxTest() throws Exception {
     94    public void AppletTestSignedFirefoxTestXslowX() throws Exception {
    8895        ServerAccess.PROCESS_TIMEOUT = 30 * 1000;
    8996        try {
    90             ProcessResult pr = server.executeBrowser("/AppletTestSigned.html");
     97            ProcessResult pr = server.executeBrowser("/AppletTestSigned2.html", okListener, null);
    9198            evaluateSignedApplet(pr, false);
    92             Assert.assertTrue(pr.wasTerminated);
     99            //Assert.assertTrue(pr.wasTerminated);
    93100            //Assert.assertEquals((Integer) 0, pr.returnValue); due to destroy is null
    94101        } finally {
     
    96103        }
    97104    }
     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    }
    98114}
  • 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    }
  • trunk/icedtea-web/tests/reproducers/signed/ClasspathManifestTest/testcases/ClasspathManifestTest.java

    r418 r429  
    3939import java.util.List;
    4040
     41import net.sourceforge.jnlp.ProcessResult;
    4142import net.sourceforge.jnlp.ServerAccess;
    42 import net.sourceforge.jnlp.ServerAccess.ProcessResult;
    43 import net.sourceforge.jnlp.annotations.Bug;
    4443import net.sourceforge.jnlp.annotations.KnownToFail;
    4544import net.sourceforge.jnlp.annotations.NeedsDisplay;
     
    5150import org.junit.Test;
    5251
    53 @Bug(id = "PR975")
    5452public class ClasspathManifestTest extends BrowserTest {
    5553
     
    7977        commands.add(ServerAccess.HEADLES_OPTION);
    8078        commands.add("ClasspathManifestApplicationTest.jnlp");
    81         ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir());
     79        ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir());
    8280        checkAppFails(pr, "ApplicationJNLPLocalTest");
    8381    }
     
    8684    @Test
    8785    public void AppletJNLPRemoteTest() throws Exception {
    88         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/ClasspathManifestAppletTest.jnlp");
     86        ProcessResult pr = server.executeJavawsHeadless(null, "/ClasspathManifestAppletTest.jnlp");
    8987        checkAppFails(pr, "AppletJNLPRemoteTest");
    9088    }
     
    9896        commands.add(ServerAccess.HEADLES_OPTION);
    9997        commands.add("ClasspathManifestAppletTest.jnlp");
    100         ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir());
     98        ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir());
    10199        checkAppFails(pr, "AppletJNLPRLocalTest");
    102100    }
     
    106104    @Test
    107105    public void BrowserJNLPHrefRemoteTest() throws Exception {
    108         ServerAccess.ProcessResult pr = server.executeBrowser("/ClasspathManifestJNLPHrefTest.html");
     106        ProcessResult pr = server.executeBrowser("/ClasspathManifestJNLPHrefTest.html");
    109107        checkAppFails(pr, "BrowserJNLPHrefRemoteTest");
    110108    }
     
    118116        commands.add(server.getBrowserLocation());
    119117        commands.add("ClasspathManifestJNLPHrefTest.html");
    120         ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir());
     118        ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir());
    121119        checkAppFails(pr, "BrowserJNLPHrefLocalTest");
    122120    }
     
    126124    @Test
    127125    public void BrowserAppletRemoteTest() throws Exception {
    128         ServerAccess.ProcessResult pr = server.executeBrowser("/ClasspathManifestAppletTest.html");
     126        ProcessResult pr = server.executeBrowser("/ClasspathManifestAppletTest.html");
    129127        Assert.assertTrue("ClasspathManifest.BrowserAppletRemoteTest stdout should contain " + s1 + " but didn't", pr.stdout.contains(s1));
    130128        // Should be the only one to search manifest for classpath.
    131129        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));
    133130    }
    134131}
  • trunk/icedtea-web/tests/reproducers/signed/ExtensionJnlp/testcases/ExtensionJnlpTest.java

    r418 r429  
    3939import java.util.Collections;
    4040import java.util.List;
     41import net.sourceforge.jnlp.ProcessResult;
    4142import net.sourceforge.jnlp.ServerAccess;
    4243import net.sourceforge.jnlp.annotations.Bug;
     
    5657    @Test
    5758    public void checkingForRequiredResources() throws Exception {
    58         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJar.jnlp");
     59        ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJar.jnlp");
    5960        Assert.assertTrue("Could not locate SignedJarResource class within SignedJarResource jar", pr.stdout.contains(jarOutput));
    6061
     
    6768    @Test
    6869    public void usingSignedExtension() throws Exception {
    69         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJarExtension.jnlp");
     70        ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJarExtension.jnlp");
    7071        Assert.assertTrue("Stdout should contain " + jarOutput + " but did not", pr.stdout.contains(jarOutput));
    7172    }
     
    7475    @Test
    7576    public void mainJarInExtension() throws Exception {
    76         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJnlpJarAndSignedJarExtension.jnlp");
     77        ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJnlpJarAndSignedJarExtension.jnlp");
    7778        Assert.assertTrue("Stdout should contain " + jarOutput + " but did not", pr.stdout.contains(jarOutput));
    7879    }
     
    8182    @Test
    8283    public void checkingSignedJnlpInExtension() throws Exception {
    83         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJnlpExtension.jnlp");
     84        ProcessResult pr = server.executeJavawsHeadless(l, "/UsesSignedJnlpExtension.jnlp");
    8485        Assert.assertTrue("Stdout should contain " + signedJnlpException + " but did not", pr.stderr.contains(signedJnlpException));
    8586    }
  • trunk/icedtea-web/tests/reproducers/signed/InternalClassloaderWithDownloadedResource/testcases/InternalClassloaderWithDownloadedResourceTest.java

    r418 r429  
    4040import java.util.Collections;
    4141import java.util.List;
     42import net.sourceforge.jnlp.ProcessResult;
    4243import net.sourceforge.jnlp.ServerAccess;
    43 import net.sourceforge.jnlp.ServerAccess.ProcessResult;
    4444import net.sourceforge.jnlp.annotations.Bug;
    4545import net.sourceforge.jnlp.annotations.NeedsDisplay;
     
    7979    @Bug(id = {"RH816592","PR858"})
    8080    public void launchInternalClassloaderWithDownloadedResourceAsJnlpApplication() throws Exception {
    81         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-new.jnlp");
     81        ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-new.jnlp");
    8282        evaluate(pr);
    8383        Assert.assertFalse("should not be terminated but was", pr.wasTerminated);
     
    8888        String ss = "Good simple javaws exapmle";
    8989        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));
    9290    }
    9391
     
    9593    @Bug(id = {"RH816592","PR858"})
    9694    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");
    9896        evaluate(pr);
    9997        Assert.assertFalse("should not be terminated but was", pr.wasTerminated);
     
    106104    @TestInBrowsers(testIn={Browsers.all})
    107105    public void launchInternalClassloaderWithDownloadedResourceAsHtmlApplet() throws Exception {
    108         ServerAccess.ProcessResult pr = server.executeBrowser("/InternalClassloaderWithDownloadedResource-new.html");
     106        ProcessResult pr = server.executeBrowser("/InternalClassloaderWithDownloadedResource-new.html");
    109107        evaluate(pr);
    110108        Assert.assertTrue("should be terminated but was not", pr.wasTerminated);
     
    114112    @Bug(id = {"http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-May/018737.html"})
    115113    public void launchInternalClassloaderWithDownloadedResourceAsJnlpApplicationHack() throws Exception {
    116         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-hack.jnlp");
     114        ProcessResult pr = server.executeJavawsHeadless(l, "/InternalClassloaderWithDownloadedResource-hack.jnlp");
    117115        evaluate(pr);
    118116        Assert.assertFalse("should not be terminated but was", pr.wasTerminated);
     
    123121    @Bug(id = {"http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-May/018737.html"})
    124122    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");
    126124        evaluate(pr);
    127125        Assert.assertFalse("should not be terminated but was", pr.wasTerminated);
     
    134132    @TestInBrowsers(testIn={Browsers.all})
    135133    public void launchInternalClassloaderWithDownloadedResourceAsHtmlAppletHack() throws Exception {
    136         ServerAccess.ProcessResult pr = server.executeBrowser("/InternalClassloaderWithDownloadedResource-hack.html");
     134        ProcessResult pr = server.executeBrowser("/InternalClassloaderWithDownloadedResource-hack.html");
    137135        evaluate(pr);
    138136        Assert.assertTrue("should be terminated but was not", pr.wasTerminated);
  • trunk/icedtea-web/tests/reproducers/signed/MissingJar/testcases/MissingJarTest.java

    r418 r429  
    1 /* MissingJar.java
     1/* MissingJarTest.java
    22Copyright (C) 2011 Red Hat, Inc.
    33
     
    3939import java.util.Collections;
    4040import java.util.List;
     41import net.sourceforge.jnlp.ProcessResult;
    4142import net.sourceforge.jnlp.ServerAccess;
    42 import net.sourceforge.jnlp.ServerAccess.ProcessResult;
     43
    4344import org.junit.Assert;
    44 
    4545import org.junit.Test;
    4646
     
    6161    @Test
    6262    public void MissingJarTest1() throws Exception {
    63         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar.jnlp");
     63        ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar.jnlp");
    6464        evaluateResult(pr);
    6565    }
     
    6767    @Test
    6868    public void MissingJarTest2() throws Exception {
    69         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar2.jnlp");
     69        ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar2.jnlp");
    7070        evaluateResult(pr);
    7171    }
     
    7373    @Test
    7474    public void MissingJarTest3() throws Exception {
    75         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar3.jnlp");
     75        ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar3.jnlp");
    7676        evaluateResult(pr);
    7777    }
     
    7979    @Test
    8080    public void MissingJarTest4() throws Exception {
    81         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar4.jnlp");
     81        ProcessResult pr = server.executeJavawsHeadless(l, "/MissingJar4.jnlp");
    8282        evaluateResult(pr);
    8383    }
  • trunk/icedtea-web/tests/reproducers/signed/ReadPropertiesBySignedHack/testcases/ReadPropertiesBySignedHackTest.java

    r418 r429  
    1 /* ReadPropertiesSignedTest.java
     1/* ReadPropertiesBySignedHackTest.java
    22Copyright (C) 2011 Red Hat, Inc.
    33
     
    3636 */
    3737
    38 
    3938import java.util.Arrays;
    4039import java.util.Collections;
    4140import java.util.List;
     41import net.sourceforge.jnlp.ProcessResult;
    4242import net.sourceforge.jnlp.ServerAccess;
     43
    4344import org.junit.Assert;
    4445import org.junit.Test;
     
    5354    public void ReadPropertiesBySignedHackWithjoutXtrustAll() throws Exception {
    5455        //no request for permissions
    55         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesBySignedHack.jnlp");
     56        ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesBySignedHack.jnlp");
    5657        String s="java.lang.SecurityException: class \"ReadProperties\"'s signer information does not match signer information of other classes in the same package";
    5758        Assert.assertTrue("Stderr should contains "+s+" but did not",pr.stderr.contains(s));
    5859        String ss="ClassNotFoundException";
    5960        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 :(
    6161        Assert.assertFalse("should not be terminated but was",pr.wasTerminated);
    6262        Assert.assertEquals((Integer)0, pr.returnValue);
  • trunk/icedtea-web/tests/reproducers/signed/ReadPropertiesSigned/testcases/ReadPropertiesSignedTest.java

    r418 r429  
    3636 */
    3737
    38 
    3938import java.util.Arrays;
    4039import java.util.Collections;
    4140import java.util.List;
     41import net.sourceforge.jnlp.ProcessResult;
    4242import net.sourceforge.jnlp.ServerAccess;
     43
    4344import org.junit.Assert;
    4445import org.junit.Test;
     
    5455    public void ReadSignedPropertiesWithoutPermissionsWithXtrustAll() throws Exception {
    5556        //no request for permissions
    56         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesSigned1.jnlp");
     57        ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesSigned1.jnlp");
    5758        Assert.assertTrue("Stderr should match "+accessMatcher+" but did not",pr.stderr.matches(accessMatcher));
    5859        String ss="ClassNotFoundException";
    5960        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 :(
    6161        Assert.assertFalse("should not be terminated but was",pr.wasTerminated);
    6262        Assert.assertEquals((Integer)0, pr.returnValue);
     
    6666    public void ReadSignedPropertiesWithPermissionsWithXtrustAll() throws Exception {
    6767        //request for allpermissions
    68         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesSigned2.jnlp");
     68        ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesSigned2.jnlp");
    6969        Assert.assertFalse("Stderr should NOT match "+accessMatcher+" but did",pr.stderr.matches(accessMatcher));
    7070        String ss="ClassNotFoundException";
    7171        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 :(
    7372        Assert.assertFalse("should not be terminated but was",pr.wasTerminated);
    7473        Assert.assertEquals((Integer)0, pr.returnValue);
     
    7776    @Test
    7877    public void EnsureXtrustallNotAffectingUnsignedBehaviour() throws Exception {
    79         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(l,"/ReadProperties1.jnlp");
     78        ProcessResult pr=server.executeJavawsHeadless(l,"/ReadProperties1.jnlp");
    8079        Assert.assertTrue("Stderr should match "+accessMatcher+" but did not",pr.stderr.matches(accessMatcher));
    8180        String ss="ClassNotFoundException";
    8281        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);
    8482        Assert.assertFalse("should not be terminated but was",pr.wasTerminated);
    8583        Assert.assertEquals((Integer)0, pr.returnValue);
    86         ServerAccess.ProcessResult pr2=server.executeJavawsHeadless(null,"/ReadProperties1.jnlp");
     84        ProcessResult pr2=server.executeJavawsHeadless(null,"/ReadProperties1.jnlp");
    8785        Assert.assertEquals(pr.stderr, pr2.stderr);
    8886        Assert.assertEquals(pr.stdout, pr2.stdout);
    89 
    9087    }
    9188  }
  • trunk/icedtea-web/tests/reproducers/signed/SavingCookies/resources/CheckCookieAndGotoClear.html

    r418 r429  
    3838 
    3939<!-- Uses show-document to go to a page that clears the cookie -->
    40  
     40
    4141<html><head></head><body bgcolor="red">
    4242<p>
    4343  <applet code="CheckingCookies.class" archive="SavingCookies.jar" codebase="." width="100" height="100">
    44  
     44
    4545  <param name="show-document" value="ClearPersistentCookie.html">
    46  
     46
    4747  </applet>
    4848</p>
  • trunk/icedtea-web/tests/reproducers/signed/SavingCookies/resources/ClearPersistentCookie.html

    r418 r429  
    4141
    4242  <param name="persistent" value="no">
    43  
     43
    4444  <param name="cookie" value="TEST=deleted; Expires=Thu, 01 Jan 1970 00:00:01 GMT">
    4545
  • trunk/icedtea-web/tests/reproducers/signed/SavingCookies/resources/SavePersistentCookie.html

    r418 r429  
    4141
    4242  <param name="persistent" value="yes">
    43  
     43
    4444  <param name="cookie" value="TEST=persistent">
    45  
     45
    4646  </applet>
    4747</p>
  • trunk/icedtea-web/tests/reproducers/signed/SavingCookies/resources/SavePersistentCookieAndGotoCheck.html

    r418 r429  
    4242  <param name="show-document" value="CheckCookieAndGotoClear.html">
    4343  <param name="persistent" value="yes">
    44  
     44
    4545  <param name="cookie" value="TEST=persistent">
    4646
  • trunk/icedtea-web/tests/reproducers/signed/SavingCookies/resources/SaveSessionCookie.html

    r418 r429  
    4141
    4242  <param name="persistent" value="no">
    43  
     43
    4444  <param name="cookie" value="TEST=session">
    4545
  • trunk/icedtea-web/tests/reproducers/signed/SavingCookies/srcs/SavingCookies.java

    r418 r429  
    11/* SavingCookies.java
    22 Store cookies in the java cookie store, and go to a page that confirms they are there.
    3  
     3
    44Copyright (C) 2012 Red Hat, Inc.
    55
  • trunk/icedtea-web/tests/reproducers/signed/SavingCookies/testcases/SavingCookiesTests.java

    r418 r429  
    5151
    5252public class SavingCookiesTests extends BrowserTest {
    53    
     53
    5454    static final String ENTERING_CHECK = "Entered CheckingCookies";
    5555    static final String CHECKING_COMPLETION = "Finished CheckingCookies";
     
    8686                };
    8787                if (url.endsWith(".html")) {
    88                     pr = server.executeBrowser(url, stdoutListener, stdoutListener);
     88                    pr = server.executeBrowser(url, stdoutListener, null);
    8989                } else if (url.endsWith(".jnlp")) {
    90                     pr = server.executeJavawsHeadless(TRUSTALL, url, stdoutListener, stdoutListener);
     90                    pr = server.executeJavawsHeadless(TRUSTALL, url, stdoutListener, null, null);
    9191                }
    9292            } catch (Exception ex) {
     
    106106        final String COOKIE_SANITY_CHECK = "Found cookie: TEST=";
    107107        ProcessResult pr = server.executeBrowser("/CheckCookie.html");
    108        
     108
    109109        Assert.assertFalse("stdout should NOT contain '" + COOKIE_SANITY_CHECK + "' but did.", pr.stdout.contains(COOKIE_SANITY_CHECK));
    110110        Assert.assertTrue("stdout should contain '" + CHECKING_COMPLETION + "' but did not.", pr.stdout.contains(CHECKING_COMPLETION));
    111111    }
    112    
     112
    113113    @Test
    114114    @TestInBrowsers(testIn = { Browsers.one })
     
    130130            Thread.sleep(100);
    131131        }
    132        
     132
    133133        ProcessResult check = server.executeBrowser("/CheckCookie.html");
    134134        save.join();
    135        
     135
    136136        Assert.assertTrue("stdout should contain '" + ENTERING_CHECK + "' but did not.", save.pr.stdout.contains(ENTERING_CHECK));
    137137        //XXX: It is necessary to check save.pr's stdout, because it does not show up in 'check.stdout' for some reason
     
    155155    public void AppletPersistentCookieShowDoc() throws Exception {
    156156        ProcessResult pr = server.executeBrowser("/SavePersistentCookieAndGotoCheck.html");
    157        
     157
    158158        Assert.assertTrue("stdout should contain '" + ENTERING_CHECK + "' but did not.", pr.stdout.contains(ENTERING_CHECK));
    159159        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  
    3939import java.util.Collections;
    4040import java.util.List;
     41import net.sourceforge.jnlp.ProcessResult;
    4142import net.sourceforge.jnlp.ServerAccess;
     43
    4244import org.junit.Assert;
    4345import org.junit.Test;
     
    5355    @Test
    5456    public void launchingFileMatchesSignedApplication1() throws Exception {
    55         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication1.jnlp");
     57        ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication1.jnlp");
    5658        String s = "Running signed application in main";
    5759        Assert.assertTrue("Stdout should contains " + s + " but did not", pr.stdout.contains(s));
     
    6365    @Test
    6466    public void launchingFileDoesNotMatchSignedApplication1() throws Exception {
    65         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication2.jnlp");
     67        ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication2.jnlp");
    6668        Assert.assertTrue("Stderr should contains " + signedException + " but did not", pr.stderr.contains(signedException));
    6769    }
     
    7274    @Test
    7375    public void launchingFileDoesNotMatchSignedApplication2() throws Exception {
    74         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication3.jnlp");
     76        ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpApplication3.jnlp");
    7577        Assert.assertTrue("Stderr should contains " + signedException + " but did not", pr.stderr.contains(signedException));
    7678    }
  • trunk/icedtea-web/tests/reproducers/signed/SignedJnlpCaseTestOne/testcases/SignedJnlpCaseOneTest.java

    r418 r429  
    3939import java.util.Collections;
    4040import java.util.List;
     41import net.sourceforge.jnlp.ProcessResult;
    4142import net.sourceforge.jnlp.ServerAccess;
     43
    4244import org.junit.Assert;
    4345import org.junit.Test;
     
    5052    @Test
    5153    public void launchingFileMatchesSigned() throws Exception {
    52         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestOne1.jnlp");
     54        ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestOne1.jnlp");
    5355        String s = "Running signed application in main";
    5456        Assert.assertTrue("Stdout should contains " + s + " but did not", pr.stdout.contains(s));
     
    5759    @Test
    5860    public void launchingFileDoesNotMatchSigned() throws Exception {
    59         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestOne2.jnlp");
     61        ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestOne2.jnlp");
    6062        String s = "net.sourceforge.jnlp.LaunchException: Fatal: Application Error: The signed " +
    6163                "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  
    3939import java.util.Collections;
    4040import java.util.List;
     41import net.sourceforge.jnlp.ProcessResult;
    4142import net.sourceforge.jnlp.ServerAccess;
    4243import org.junit.Assert;
     
    5051    @Test
    5152    public void launchingFileMatchesSigned() throws Exception {
    52         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestTwo1.jnlp");
     53        ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestTwo1.jnlp");
    5354        String s = "Running signed application in main";
    5455        Assert.assertTrue("Stdout should contains " + s + " but did not", pr.stdout.contains(s));
     
    5758    @Test
    5859    public void launchingFileDoesNotMatchSigned() throws Exception {
    59         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestTwo2.jnlp");
     60        ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpCaseTestTwo2.jnlp");
    6061        String s = "net.sourceforge.jnlp.LaunchException: Fatal: Application Error: The signed " +
    6162                "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  
    3939import java.util.Collections;
    4040import java.util.List;
     41import net.sourceforge.jnlp.ProcessResult;
    4142import net.sourceforge.jnlp.ServerAccess;
     43
    4244import org.junit.Assert;
    4345import org.junit.Test;
     
    5355    @Test
    5456    public void launchingFileMatchesSignedTemplate1() throws Exception {
    55         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate1.jnlp");
     57        ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate1.jnlp");
    5658        String s = "Running signed application in main";
    5759        Assert.assertTrue("Stdout should contains " + s + " but did not", pr.stdout.contains(s));
     
    6365    @Test
    6466    public void launchingFileDoesNotMatchSignedTemplate2() throws Exception {
    65         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate2.jnlp");
     67        ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate2.jnlp");
    6668        Assert.assertTrue("Stderr should contains " + signedException + " but did not", pr.stderr.contains(signedException));
    6769    }
     
    7274    @Test
    7375    public void launchingFileDoesNotMatchSignedTemplate3() throws Exception {
    74         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate3.jnlp");
     76        ProcessResult pr = server.executeJavawsHeadless(l, "/SignedJnlpTemplate3.jnlp");
    7577        Assert.assertTrue("Stderr should contains " + signedException + " but did not", pr.stderr.contains(signedException));
    7678    }
  • trunk/icedtea-web/tests/reproducers/signed/Spaces can be everywhere signed/testcases/SpacesCanBeEverywhereTestsSigned.java

    r418 r429  
    3838import java.util.ArrayList;
    3939import java.util.List;
     40import net.sourceforge.jnlp.ProcessResult;
    4041import net.sourceforge.jnlp.ServerAccess;
    4142import net.sourceforge.jnlp.annotations.Bug;
     
    4445import net.sourceforge.jnlp.browsertesting.Browsers;
    4546import net.sourceforge.jnlp.annotations.TestInBrowsers;
     47
    4648import org.junit.Assert;
    47 
    4849import org.junit.Test;
    4950
    5051@Bug(id={"http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2011-October/016127.html","PR804","PR811"})
    5152public class SpacesCanBeEverywhereTestsSigned extends BrowserTest {
    52 
    5353
    5454    @Bug(id="PR811")
     
    8383         * only on ocal files, and probably only from test run - it can be ignored
    8484         */
    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));
    9088        Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
    9189        Assert.assertEquals((Integer) 0, pr.returnValue);
     
    9694    @NeedsDisplay
    9795    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));
    10399        Assert.assertFalse("should NOT be terminated, but was not", pr.wasTerminated);
    104100    }
     
    109105    @TestInBrowsers(testIn = {Browsers.one})
    110106    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));
    116110        Assert.assertTrue("should be terminated, but was not", pr.wasTerminated);
    117111    }
     
    121115    @Test
    122116    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");
    124118        String s = "Good simple javaws exapmle";
    125119        Assert.assertTrue("stdout should contains `" + s + "`, but did not", pr.stdout.contains(s));
     
    133127    @Test
    134128    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");
    136130        String s="Signed spaces can be everywhere.jsr was launched correctly";
    137131        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
     
    145139    @Test
    146140    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");
    148142        String s="Signed spaces can be everywhere.jsr was launched correctly";
    149143        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
     
    157151    @Test
    158152    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");
    160154
    161155        String s="Signed spaces can be everywhere.jsr was launched correctly";
     
    170164    @Test
    171165    public void SpacesCanBeEverywhereRemoteTests3Signed() throws Exception {
    172         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/SpacesCanBeEverywhere1signed.jnlp");
     166        ProcessResult pr = server.executeJavawsHeadless(null, "/SpacesCanBeEverywhere1signed.jnlp");
    173167        String s="Signed spaces can be everywhere.jsr was launched correctly";
    174168        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
     
    187181        commands.add(ServerAccess.HEADLES_OPTION);
    188182        commands.add("Spaces can be everywhere1.jnlp");
    189         ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());
     183        ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());
    190184        String s = "Good simple javaws exapmle";
    191185        Assert.assertTrue("stdout should contains `" + s + "`, but did not", pr.stdout.contains(s));
     
    203197        commands.add(ServerAccess.HEADLES_OPTION);
    204198        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());
    206200        String s="Signed spaces can be everywhere.jsr was launched correctly";
    207201        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
     
    219213        commands.add(ServerAccess.HEADLES_OPTION);
    220214        commands.add(server.getDir()+"/Spaces can be everywhere2 signed.jnlp");
    221         ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands);
     215        ProcessResult pr = ServerAccess.executeProcess(commands);
    222216        String s="Signed spaces can be everywhere.jsr was launched correctly";
    223217        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
     
    235229        commands.add(ServerAccess.HEADLES_OPTION);
    236230        commands.add("SpacesCanBeEverywhere1signed.jnlp");
    237         ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());
     231        ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());
    238232        String s="Signed spaces can be everywhere.jsr was launched correctly";
    239233        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  
    3838import java.util.Arrays;
    3939import java.util.List;
     40import net.sourceforge.jnlp.ProcessResult;
    4041import net.sourceforge.jnlp.ServerAccess;
    41 import net.sourceforge.jnlp.ServerAccess.ProcessResult;
     42
    4243import org.junit.Assert;
    43 
    4444import org.junit.Test;
    4545
     
    7373    private static final List<String> xta = Arrays.asList(new String[]{"-Xtrustall"});
    7474
    75     private void testShouldFail(ServerAccess.ProcessResult pr, String s) {
     75    private void testShouldFail(ProcessResult pr, String s) {
    7676        String c = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + s + ".*";
    7777        Assert.assertTrue("stderr should match `" + c + "`, but didn't ", pr.stderr.matches(c));
    7878    }
    7979
    80     private void testShouldNOTFail(ServerAccess.ProcessResult pr, String s) {
     80    private void testShouldNOTFail(ProcessResult pr, String s) {
    8181        String c = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + s + ".*";
    8282        Assert.assertFalse("stderr should NOT match `" + c + "`, but did ", pr.stderr.matches(c));
     
    9090    }
    9191
    92     private void testShouldPass(ServerAccess.ProcessResult pr, String s) {
     92    private void testShouldPass(ProcessResult pr, String s) {
    9393        String c = "Class was obtained: " + s;
    9494        Assert.assertTrue("stdout should contains `" + c + "`, but didn't ", pr.stdout.contains(c));
    9595    }
    9696
    97     private void testShouldNOTPass(ServerAccess.ProcessResult pr, String s) {
     97    private void testShouldNOTPass(ProcessResult pr, String s) {
    9898        String c = "Class was obtained: " + s;
    9999        Assert.assertFalse("stdout should not contains `" + c + "`, but did ", pr.stdout.contains(c));
     
    102102    @Test
    103103    public void AccessClassInPackageJAVAXJNLP() throws Exception {
    104         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[0]);
     104        ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[0]);
    105105        commonPitfall(pr);
    106106        testShouldPass(pr, pass[0]);
     
    110110    @Test
    111111    public void AccessClassInPackageSELF() throws Exception {
    112         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[1]);
     112        ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[1]);
    113113        commonPitfall(pr);
    114114        testShouldPass(pr, pass[1]);
     
    118118    @Test
    119119    public void AccessClassInPackageNETSF() throws Exception {
    120         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[2]);
     120        ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[2]);
    121121        commonPitfall(pr);
    122122        testShouldFail(pr, badExceptions[2]);
     
    126126    @Test
    127127    public void AccessClassInPackageSUNSEC() throws Exception {
    128         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[3]);
     128        ProcessResult pr = server.executeJavawsHeadless(null, "/" + files[3]);
    129129        commonPitfall(pr);
    130130        commonPitfall(pr);
     
    136136    @Test
    137137    public void AccessClassInPackageSignedJAVAXJNLP() throws Exception {
    138         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[0]);
     138        ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[0]);
    139139        commonPitfall(pr);
    140140        testShouldPass(pr, pass[0]);
     
    144144    @Test
    145145    public void AccessClassInPackageSignedSELF() throws Exception {
    146         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[1]);
     146        ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[1]);
    147147        commonPitfall(pr);
    148148        testShouldPass(pr, pass[1]);
     
    152152    @Test
    153153    public void AccessClassInPackageSignedNETSF() throws Exception {
    154         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[2]);
     154        ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[2]);
    155155        commonPitfall(pr);
    156156        testShouldPass(pr, pass[2]);
     
    160160    @Test
    161161    public void AccessClassInPackageSignedSUNSEC() throws Exception {
    162         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[3]);
     162        ProcessResult pr = server.executeJavawsHeadless(xta, "/" + filesSigned[3]);
    163163        commonPitfall(pr);
    164164        testShouldPass(pr, pass[3]);
  • trunk/icedtea-web/tests/reproducers/simple/AddShutdownHook/srcs/AddShutdownHook.java

    r418 r429  
     1
     2import java.applet.Applet;
     3
    14/* AddShutdownHook.java
    2 Copyright (C) 2011 Red Hat, Inc.
     5 Copyright (C) 2011 Red Hat, Inc.
    36
    4 This file is part of IcedTea.
     7 This file is part of IcedTea.
    58
    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 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.
    912
    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.
     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.
    1417
    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.
     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.
    1922
    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.
     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.
    2427
    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.
     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.
    3639 */
     40public class AddShutdownHook extends Applet {
    3741
    38 public class AddShutdownHook {
    3942    public static void main(String[] args) {
    4043
    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");
    4756    }
    4857}
  • trunk/icedtea-web/tests/reproducers/simple/AddShutdownHook/testcases/AddShutdownHookTest.java

    r418 r429  
    11/* AddShutdownHookTest.java
    2 Copyright (C) 2011 Red Hat, Inc.
     2 Copyright (C) 2011 Red Hat, Inc.
    33
    4 This file is part of IcedTea.
     4 This file is part of IcedTea.
    55
    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.
     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.
    99
    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.
     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.
    1414
    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.
     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.
    1919
    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.
     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.
    2424
    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.
     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.
    3636 */
    3737
    38 import net.sourceforge.jnlp.ServerAccess;
     38import net.sourceforge.jnlp.ClosingListener;
     39import net.sourceforge.jnlp.ProcessResult;
     40import net.sourceforge.jnlp.annotations.TestInBrowsers;
     41import net.sourceforge.jnlp.browsertesting.BrowserTest;
     42import net.sourceforge.jnlp.browsertesting.Browsers;
     43import net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener;
     44import net.sourceforge.jnlp.closinglisteners.StringMatchClosingListener;
    3945import org.junit.Assert;
    4046
    4147import org.junit.Test;
    4248
    43 public class AddShutdownHookTest {
     49public class AddShutdownHookTest extends BrowserTest {
    4450
    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);
    4658
    4759    @Test
    4860    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));
    5666        Assert.assertEquals((Integer) 0, pr.returnValue);
    5767    }
     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    }
    5881}
  • trunk/icedtea-web/tests/reproducers/simple/AllStackTraces/testcases/AllStackTracesTest.java

    r418 r429  
    3636 */
    3737
     38import net.sourceforge.jnlp.ProcessResult;
    3839import net.sourceforge.jnlp.ServerAccess;
    3940import org.junit.Assert;
     
    4950    @Test
    5051    public void AllStackTracesTest1() throws Exception {
    51         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/AllStackTraces.jnlp");
     52        ProcessResult pr=server.executeJavawsHeadless(null,"/AllStackTraces.jnlp");
    5253        String c = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "getStackTrace" + ".*";
    5354        Assert.assertTrue("stderr should match `"+c+"`, but didn't ",pr.stderr.matches(c));
    5455        String cc="ClassNotFoundException";
    5556        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);
    5757        Assert.assertFalse("AllStackTracesTest1 should not be terminated, but was",pr.wasTerminated);
    5858        Assert.assertEquals((Integer)0, pr.returnValue);
  • trunk/icedtea-web/tests/reproducers/simple/AppletBaseURLTest/srcs/AppletBaseURL.java

    r418 r429  
    3838import java.applet.Applet;
    3939public class AppletBaseURL extends Applet {
    40 
    41     private class Killer extends Thread {
    42 
    43         public int n = 1000;
    44 
    45         @Override
    46         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 
    5740    @Override
    5841    public void init() {
    5942        System.out.println("Document base is " + getDocumentBase() + " for this applet");
    6043        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);
    6348    }
    6449}
  • trunk/icedtea-web/tests/reproducers/simple/AppletBaseURLTest/testcases/AppletBaseURLTest.java

    r418 r429  
    3636 */
    3737
    38 import net.sourceforge.jnlp.ServerAccess.ProcessResult;
     38import net.sourceforge.jnlp.ProcessResult;
     39import net.sourceforge.jnlp.ServerAccess.AutoClose;
    3940import net.sourceforge.jnlp.annotations.Bug;
    4041import net.sourceforge.jnlp.annotations.NeedsDisplay;
     
    4950
    5051    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));
    5758    }
    5859
     
    6061    @Test
    6162    public void AppletWebstartBaseURLTest() throws Exception {
    62         ProcessResult pr = server.executeJavaws(null, "/AppletBaseURLTest.jnlp");
     63        ProcessResult pr = server.executeJavaws("/AppletBaseURLTest.jnlp");
    6364        evaluateApplet(pr, "");
    6465        Assert.assertFalse(pr.wasTerminated);
     
    7172    @TestInBrowsers(testIn={Browsers.one})
    7273    public void AppletInFirefoxTest() throws Exception {
    73         ProcessResult pr = server.executeBrowser("/AppletBaseURLTest.html");
     74        ProcessResult pr = server.executeBrowser("/AppletBaseURLTest.html", AutoClose.CLOSE_ON_BOTH);
    7475        pr.process.destroy();
    7576        evaluateApplet(pr, "AppletBaseURLTest.html");
     
    8283    @TestInBrowsers(testIn={Browsers.one})
    8384    public void AppletWithJNLPHrefTest() throws Exception {
    84         ProcessResult pr = server.executeBrowser("/AppletJNLPHrefBaseURLTest.html");
     85        ProcessResult pr = server.executeBrowser("/AppletJNLPHrefBaseURLTest.html", AutoClose.CLOSE_ON_BOTH);
    8586        pr.process.destroy();
    8687        evaluateApplet(pr, "AppletJNLPHrefBaseURLTest.html");
  • trunk/icedtea-web/tests/reproducers/simple/AppletReadsInvalidJar/testcases/AppletReadsInvalidJarTests.java

    r418 r429  
    3636 */
    3737
     38import net.sourceforge.jnlp.ProcessResult;
    3839import net.sourceforge.jnlp.ServerAccess;
    3940import net.sourceforge.jnlp.annotations.TestInBrowsers;
    4041import net.sourceforge.jnlp.browsertesting.BrowserTest;
    4142import net.sourceforge.jnlp.browsertesting.Browsers;
     43
    4244import org.junit.Assert;
    43 
    4445import org.junit.Test;
    4546
     
    5354    @Test
    5455    public void AppletJNLPTest() throws Exception {
    55         ServerAccess.ProcessResult pr = server.executeJavawsHeadless("/AppletReadsInvalidJar.jnlp");
     56        ProcessResult pr = server.executeJavawsHeadless("/AppletReadsInvalidJar.jnlp");
    5657
    5758        Assert.assertFalse("AppletReadsInvalidJar stdout should NOT contain '" + CORRECT_EXECUTION + "', but did (applet should not have ran!).", pr.stdout.contains(CORRECT_EXECUTION));
     
    6364    @TestInBrowsers(testIn={Browsers.one})
    6465    public void AppletInFirefoxTest() throws Exception {
    65         ServerAccess.ProcessResult pr = server.executeBrowser("/AppletReadsInvalidJar.html");
     66        ProcessResult pr = server.executeBrowser("/AppletReadsInvalidJar.html");
    6667
    6768        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  
    3939 */
    4040public class AppletTakesLastParam extends Applet {
    41 
    42     private class Killer extends Thread {
    43 
    44         public int n = 2000;
    45 
    46         @Override
    47         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     @Override
    5941    public void init() {
    6042        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);
    6247    }
    6348}
  • trunk/icedtea-web/tests/reproducers/simple/AppletTakesLastParam/testcases/AppletTakesLastParamTests.java

    r418 r429  
    1 /* AppletTestTests.java
     1/* AppletTakesLastParamTests.java
    22Copyright (C) 2011 Red Hat, Inc.
    33
     
    3636 */
    3737
    38 import net.sourceforge.jnlp.ServerAccess;
    39 import net.sourceforge.jnlp.ServerAccess.ProcessResult;
     38import net.sourceforge.jnlp.ProcessResult;
     39import net.sourceforge.jnlp.ServerAccess.AutoClose;
    4040import net.sourceforge.jnlp.browsertesting.BrowserTest;
    4141import net.sourceforge.jnlp.browsertesting.Browsers;
     
    4646
    4747public class AppletTakesLastParamTests extends BrowserTest {
     48    private void evaluate(ProcessResult pr) {
     49        String firstParam = "value1";
     50        String secondParam = "value2";
    4851
    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));
    6056    }
    6157
    6258    @Test
    6359    @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);
    6768    }
    6869}
  • trunk/icedtea-web/tests/reproducers/simple/AppletTest/testcases/AppletTestTests.java

    r418 r429  
    1 /* AppletTestTests.java
     1/*
    22Copyright (C) 2011 Red Hat, Inc.
    33
     
    3636 */
    3737
     38import net.sourceforge.jnlp.closinglisteners.CountingClosingListener;
    3839import net.sourceforge.jnlp.ProcessResult;
    3940import net.sourceforge.jnlp.ServerAccess;
     
    4849public class AppletTestTests extends BrowserTest {
    4950
     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
    5065    @Test
    5166    @TestInBrowsers(testIn = {Browsers.googleChrome})
     
    5671            //System.out.println("connecting AppletInFirefoxTest request in " + getBrowser().toString());
    5772            //just verify loging is recording browser
    58             ProcessResult pr1 = server.executeBrowser("/appletAutoTests.html");
     73            ProcessResult pr1 = server.executeBrowser("/appletAutoTests2.html", new CountingClosingListenerImpl(), new CountingClosingListenerImpl());
    5974            if (pr1.process == null) {
    6075                Assert.assertTrue("If proces was null here, then google-chrome had to not exist, and so "
     
    6580                return;
    6681            }
    67             evaluateApplet(pr1,false);
     82            evaluateApplet(pr1, false);
    6883            Assert.assertTrue(pr1.wasTerminated);
    6984            //System.out.println("connecting AppletInFirefoxTest request in " + getBrowser().toString());
    7085            // 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);
    7388            Assert.assertTrue(pr.wasTerminated);
    7489        } finally {
     
    8196    public void AppletTest() throws Exception {
    8297        ProcessResult pr = server.executeJavawsHeadless(null, "/AppletTest.jnlp");
    83         evaluateApplet(pr,true);
     98        evaluateApplet(pr, true);
    8499        Assert.assertFalse(pr.wasTerminated);
    85100        Assert.assertEquals((Integer) 0, pr.returnValue);
     
    87102
    88103    private void evaluateApplet(ProcessResult pr, boolean javawsApplet) {
    89         String s3 = "applet was initialised";
    90104        Assert.assertTrue("AppletTest stdout should contains " + s3 + " bud didn't", pr.stdout.contains(s3));
    91         String s0 = "applet was started";
    92105        Assert.assertTrue("AppletTest stdout should contains " + s0 + " bud didn't", pr.stdout.contains(s0));
    93         String s1 = "value1";
    94106        Assert.assertTrue("AppletTest stdout should contains " + s1 + " bud didn't", pr.stdout.contains(s1));
    95         String s2 = "value2";
    96107        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";
    100108        Assert.assertTrue("AppletTest stdout should contains " + s7 + " bud didn't", pr.stdout.contains(s7));
    101109        if (!javawsApplet) {
    102110            /*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));
    107115             */
    108116        }
     
    117125        ServerAccess.PROCESS_TIMEOUT = 30 * 1000;
    118126        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
    122130            //Assert.assertEquals((Integer) 0, pr.returnValue); due to destroy is null
    123131        } finally {
     
    133141        ServerAccess.PROCESS_TIMEOUT = 30 * 1000;
    134142        try {
    135             ProcessResult pr = server.executeBrowser("/appletAutoTests.html");
     143            ProcessResult pr = server.executeBrowser("/appletAutoTests.html", new CountingClosingListenerImpl(), new CountingClosingListenerImpl());
    136144            pr.process.destroy();
    137             evaluateApplet(pr,false);
     145            evaluateApplet(pr, false);
    138146            Assert.assertTrue(pr.wasTerminated);
    139147            //Assert.assertEquals((Integer) 0, pr.returnValue); due to destroy is null
     
    142150        }
    143151    }
     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    }
    144177}
  • trunk/icedtea-web/tests/reproducers/simple/CreateClassLoader/testcases/CreateClassLoaderTest.java

    r418 r429  
    3636 */
    3737
     38import net.sourceforge.jnlp.ProcessResult;
    3839import net.sourceforge.jnlp.ServerAccess;
     40
    3941import org.junit.Assert;
    40 
    4142import org.junit.Test;
    4243
     
    4748    @Test
    4849    public void CreateClassLoaderLunch1() throws Exception {
    49         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/CreateClassLoader.jnlp");
     50        ProcessResult pr = server.executeJavawsHeadless(null, "/CreateClassLoader.jnlp");
    5051        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "createClassLoader" + ".*";
    5152        Assert.assertTrue("Stderr should match "+s+" but didn't",pr.stderr.matches(s));
    5253        String cc="ClassNotFoundException";
    5354        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);
    5555        Assert.assertFalse("CreateClassLoaderLunch1 should not be terminated, but was",pr.wasTerminated);
    5656        Assert.assertEquals((Integer) 0, pr.returnValue);
  • trunk/icedtea-web/tests/reproducers/simple/InformationTitleVendorParser/testcases/InformationTitleVendorParserTest.java

    r418 r429  
    3636 */
    3737
    38 
    3938import java.util.Arrays;
    4039import java.util.List;
    4140
     41import net.sourceforge.jnlp.ProcessResult;
    4242import net.sourceforge.jnlp.ServerAccess;
    4343import org.junit.Assert;
     
    5050    public void runTest(String jnlpName, String exception) throws Exception {
    5151        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");
    5353        String s1 = "Good simple javaws exapmle";
    5454        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  
    6363        Map<String, String> p = System.getenv();
    6464        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);
    6666        Collections.sort(rr, new Comparator<Entry<String, String>>() {
    6767
     
    9494        String s = "LocalisedInformationElement launched";
    9595        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));
    9996        String locMatch = "(?s).*default locale: \\w{2}.*";
    10097        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  
    3636 */
    3737
     38import java.util.Arrays;
     39import net.sourceforge.jnlp.ProcessResult;
    3840import net.sourceforge.jnlp.ServerAccess;
    3941import net.sourceforge.jnlp.annotations.Bug;
     42import net.sourceforge.jnlp.runtime.Translator;
     43
    4044import org.junit.Assert;
    41 
    4245import org.junit.Test;
    4346
     
    5053    private static final String twoMainException = "net.sourceforge.jnlp.ParseException: Invalid XML document syntax";
    5154
    52     private void assertManifestedJar1(String id, ServerAccess.ProcessResult q) {
     55    private void assertManifestedJar1(String id, ProcessResult q) {
    5356        String s = "Hello from ManifestedJar1";
    5457        Assert.assertTrue(id + " stdout should contains `" + s + "`, but didn't ", q.stdout.contains(s));
    5558    }
    5659
    57     private void assertManifestedJar2(String id, ServerAccess.ProcessResult q) {
     60    private void assertManifestedJar2(String id, ProcessResult q) {
    5861        String s = "Hello from ManifestedJar2";
    5962        Assert.assertTrue(id + " stdout should contains `" + s + "`, but didn't ", q.stdout.contains(s));
    6063    }
    6164
    62     private void assertNotManifestedJar1(String id, ServerAccess.ProcessResult q) {
     65    private void assertNotManifestedJar1(String id, ProcessResult q) {
    6366        String s = "Hello from ManifestedJar1";
    6467        Assert.assertFalse(id + " stdout should NOT contains `" + s + "`, but didn ", q.stdout.contains(s));
    6568    }
    66     private void assertAppError(String id, ServerAccess.ProcessResult q) {
     69    private void assertAppError(String id, ProcessResult q) {
    6770        Assert.assertTrue(id + " stderr should contains `" + nonLunchableMessage + "`, but didnn't ", q.stderr.contains(nonLunchableMessage));
    6871    }
    6972
    70     private void assertNotManifestedJar2(String id, ServerAccess.ProcessResult q) {
     73    private void assertNotManifestedJar2(String id, ProcessResult q) {
    7174        String s = "Hello from ManifestedJar2";
    7275        Assert.assertFalse(id + " stdout should NOT contains `" + s + "`, but didn ", q.stdout.contains(s));
    7376    }
    7477
    75     private void assertNotDead(String id, ServerAccess.ProcessResult pr) {
     78    private void assertNotDead(String id, ProcessResult pr) {
    7679        String cc = "ClassNotFoundException";
    7780        Assert.assertFalse(id + " stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc));
     
    8689    public void manifestedJar1nothing2nothingNoAppDesc() throws Exception {
    8790        String id = "ManifestedJar-1nothing2nothingNoAppDesc";
    88         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
     91        ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
    8992        assertManifestedJar1(id, pr);
    9093        assertNotDead(id, pr);
     
    98101    public void manifestedJar1noAppDesc() throws Exception {
    99102        String id = "ManifestedJar-1noAppDesc";
    100         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
     103        ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
    101104        assertManifestedJar1(id, pr);
    102105        assertNotDead(id, pr);
     
    110113    public void manifestedJar1mainNoAppDesc() throws Exception {
    111114        String id = "ManifestedJar-1mainNoAppDesc";
    112         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
     115        ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
    113116        assertManifestedJar1(id, pr);
    114117        assertNotDead(id, pr);
     
    122125    public void ManifestedJar1mainHaveAppDesc() throws Exception {
    123126        String id = "ManifestedJar-1mainHaveAppDesc";
    124         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
     127        ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
    125128        assertManifestedJar2(id, pr);
    126129        assertNotDead(id, pr);
     
    134137    public void ManifestedJar1main2nothingNoAppDesc() throws Exception {
    135138        String id = "ManifestedJar-1main2nothingNoAppDesc";
    136         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
     139        ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
    137140        assertManifestedJar2(id, pr);
    138141        assertNotDead(id, pr);
     
    146149    public void manifestedJar1main2nothingNoAppDesc() throws Exception {
    147150        String id = "ManifestedJar-1main2nothingNoAppDesc";
    148         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
     151        ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
    149152        assertManifestedJar2(id, pr);
    150153        assertNotDead(id, pr);
     
    154157     *
    155158     * 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     *
    159161     */
    160162    @Test
    161163    public void manifestedJar1main2mainNoAppDesc() throws Exception {
    162164        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")));
    166185    }
    167186
     
    175194    public void manifestedJar1main2mainAppDesc() throws Exception {
    176195        String id = "ManifestedJar-1main2mainAppDesc";
    177         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
     196        ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
    178197        assertNotManifestedJar1(id, pr);
    179198        assertNotManifestedJar2(id, pr);
     
    190209    public void manifestedJar1noAppDescAtAll() throws Exception {
    191210        String id = "ManifestedJar-1noAppDescAtAll";
    192         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
     211        ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
    193212        assertNotManifestedJar1(id, pr);
    194213        assertNotManifestedJar2(id, pr);
     
    209228    public void manifestedJar1nothing2nothingAppDesc() throws Exception {
    210229        String id = "ManifestedJar-1nothing2nothingAppDesc";
    211         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
    212         assertNotManifestedJar2(id, pr);
     230        ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp");
     231        assertManifestedJar2(id, pr);
    213232        assertNotManifestedJar1(id, pr);
    214233        assertNotDead(id, pr);
  • trunk/icedtea-web/tests/reproducers/simple/ReadEnvironment/testcases/ReadEnvironmentTest.java

    r418 r429  
    3636 */
    3737
     38import net.sourceforge.jnlp.ProcessResult;
    3839import net.sourceforge.jnlp.ServerAccess;
    3940import org.junit.Assert;
    40 
    4141import org.junit.Test;
    4242
     
    4747    @Test
    4848    public void ReadEnvironmentLunch1() throws Exception {
    49         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/ReadEnvironment.jnlp");
     49        ProcessResult pr = server.executeJavawsHeadless(null, "/ReadEnvironment.jnlp");
    5050        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "getenv.USER" + ".*";
    5151        Assert.assertTrue("stderr should match"+s+"but didn't",pr.stderr.matches(s));
    5252        String cc="ClassNotFoundException";
    5353        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);
    5554        Assert.assertFalse("ReadEnvironmentLunch1 should not be terminated, but was",pr.wasTerminated);
    5655        Assert.assertEquals((Integer) 0, pr.returnValue);
  • trunk/icedtea-web/tests/reproducers/simple/ReadProperties/testcases/ReadPropertiesTest.java

    r418 r429  
    3636 */
    3737
    38 
     38import net.sourceforge.jnlp.ProcessResult;
    3939import net.sourceforge.jnlp.ServerAccess;
    4040import org.junit.Assert;
     
    4848    @Test
    4949    public void ReadPropertiesLunch1() throws Exception {
    50         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/ReadProperties1.jnlp");
     50        ProcessResult pr=server.executeJavawsHeadless(null,"/ReadProperties1.jnlp");
    5151        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.util.PropertyPermission.{0,5}" + "user.name.{0,5}read" + ".*";
    5252        Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s));
    5353        String cc="ClassNotFoundException";
    5454        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);
    5655        Assert.assertFalse("ReadPropertiesLunch1 should not be terminated, but was",pr.wasTerminated);
    5756        Assert.assertEquals((Integer)0, pr.returnValue);
     
    6059    @Test
    6160    public void ReadPropertiesLunch2() throws Exception {
    62         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/ReadProperties2.jnlp");
     61        ProcessResult pr=server.executeJavawsHeadless(null,"/ReadProperties2.jnlp");
    6362        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.util.PropertyPermission.{0,5}" + "user.home.{0,5}read" + ".*";
    6463        Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s));
    6564        String cc="ClassNotFoundException";
    6665        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);
    6866        Assert.assertFalse("ReadPropertiesLunch2 should not be terminated, but was",pr.wasTerminated);
    6967        Assert.assertEquals((Integer)0, pr.returnValue);
  • trunk/icedtea-web/tests/reproducers/simple/RedirectStreams/testcases/RedirectStreamsTest.java

    r418 r429  
    3636 */
    3737
     38import net.sourceforge.jnlp.ProcessResult;
    3839import net.sourceforge.jnlp.ServerAccess;
    3940import org.junit.Assert;
     
    4647    @Test
    4748    public void RedirectStreamsTest1() throws Exception {
    48         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/RedirectStreams.jnlp");
     49        ProcessResult pr = server.executeJavawsHeadless(null, "/RedirectStreams.jnlp");
    4950        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "setIO" + ".*";
    5051        Assert.assertTrue("Stderr should match "+s+" but didn't",pr.stderr.matches(s));
    5152        String cc="ClassNotFoundException";
    5253        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);
    5454        Assert.assertFalse("RedirectStreams should not be terminated, but was",pr.wasTerminated);
    5555        Assert.assertEquals((Integer) 0, pr.returnValue);
  • trunk/icedtea-web/tests/reproducers/simple/ReplaceSecurityManager/testcases/ReplaceSecurityManagerTest.java

    r418 r429  
    3636 */
    3737
     38import net.sourceforge.jnlp.ProcessResult;
    3839import net.sourceforge.jnlp.ServerAccess;
    3940import org.junit.Assert;
     
    4647    @Test
    4748    public void ReplaceSecurityManagerLunch1() throws Exception {
    48         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/ReplaceSecurityManager.jnlp");
     49        ProcessResult pr = server.executeJavawsHeadless(null, "/ReplaceSecurityManager.jnlp");
    4950        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "setSecurityManager" + ".*";
    5051        Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s));
    5152        String cc="ClassNotFoundException";
    5253        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);
    5454        Assert.assertFalse("ReplaceSecurityManagerLunch1 should not be terminated, but was",pr.wasTerminated);
    5555        Assert.assertEquals((Integer) 0, pr.returnValue);
  • trunk/icedtea-web/tests/reproducers/simple/SetContextClassLoader/testcases/SetContextClassLoaderTest.java

    r418 r429  
    3636 */
    3737
     38import net.sourceforge.jnlp.ProcessResult;
    3839import net.sourceforge.jnlp.ServerAccess;
    3940import org.junit.Assert;
     
    4647    @Test
    4748    public void SetContextClassLoader1() throws Exception {
    48         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/SetContextClassLoader.jnlp");
     49        ProcessResult pr = server.executeJavawsHeadless(null, "/SetContextClassLoader.jnlp");
    4950        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "setContextClassLoader" + ".*";
    5051        Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s));
    5152        String cc="ClassNotFoundException";
    5253        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);
    5454        Assert.assertFalse("SetContextClassLoader1 should not be terminated, but was",pr.wasTerminated);
    5555        Assert.assertEquals((Integer) 0, pr.returnValue);
  • trunk/icedtea-web/tests/reproducers/simple/Spaces can be everywhere/testcases/SpacesCanBeEverywhereTests.java

    r418 r429  
    3737
    3838import java.util.ArrayList;
     39import java.util.Arrays;
    3940import java.util.List;
     41import net.sourceforge.jnlp.ContentReaderListener;
     42import net.sourceforge.jnlp.ProcessResult;
    4043import net.sourceforge.jnlp.ServerAccess;
    4144import net.sourceforge.jnlp.annotations.Bug;
     
    4447import net.sourceforge.jnlp.browsertesting.Browsers;
    4548import net.sourceforge.jnlp.annotations.TestInBrowsers;
     49import net.sourceforge.jnlp.closinglisteners.StringBasedClosingListener;
    4650import org.junit.Assert;
    4751import org.junit.Test;
     
    5054public class SpacesCanBeEverywhereTests extends BrowserTest {
    5155
    52 
     56public static final String s = "Spaces can be everywhere.jsr was launched correctly";
    5357    @Bug(id="PR811")
    5458    @Test
     
    8286         * only on ocal files, and probably only from test run - it can be ignored
    8387         */
    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));
    8990        Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
    9091        Assert.assertEquals((Integer) 0, pr.returnValue);
     
    9596    @NeedsDisplay
    9697    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);
    103101    }
    104102
     
    108106    @TestInBrowsers(testIn = {Browsers.all})
    109107    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));
    115110        Assert.assertTrue("should be terminated, but was not", pr.wasTerminated);
    116111    }
     
    120115    @Test
    121116    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");
    123118        String s = "Good simple javaws exapmle";
    124119        Assert.assertTrue("stdout should contains `" + s + "`, but did not", pr.stdout.contains(s));
     
    132127    @Test
    133128    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");
    136130        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
    137131        String cc = "ClassNotFoundException";
     
    144138    @Test
    145139    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");
    148141        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
    149142        String cc = "ClassNotFoundException";
     
    157150    @Test
    158151    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");
    161153        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
    162154        String cc = "ClassNotFoundException";
     
    169161    @Test
    170162    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");
    173164        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
    174165        String cc = "ClassNotFoundException";
     
    186177        commands.add(ServerAccess.HEADLES_OPTION);
    187178        commands.add("Spaces can be everywhere1.jnlp");
    188         ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());
     179        ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());
    189180        String s = "Good simple javaws exapmle";
    190181        Assert.assertTrue("stdout should contains `" + s + "`, but did not", pr.stdout.contains(s));
     
    202193        commands.add(ServerAccess.HEADLES_OPTION);
    203194        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());
    206196        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
    207197        String cc = "ClassNotFoundException";
     
    218208        commands.add(ServerAccess.HEADLES_OPTION);
    219209        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);
    222211        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
    223212        String cc = "ClassNotFoundException";
     
    234223        commands.add(ServerAccess.HEADLES_OPTION);
    235224        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());
    238226        Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
    239227        String cc = "ClassNotFoundException";
  • trunk/icedtea-web/tests/reproducers/simple/UnsignedJnlpApplication/testcases/UnsignedJnlpApplicationTest.java

    r418 r429  
    3939import java.util.Collections;
    4040import java.util.List;
     41import net.sourceforge.jnlp.ProcessResult;
    4142import net.sourceforge.jnlp.ServerAccess;
    4243import org.junit.Assert;
     
    5152    @Test
    5253    public void jnlpFileIsUnchecked1() throws Exception {
    53         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication1.jnlp");
     54        ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication1.jnlp");
    5455        Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString));
    5556    }
     
    5758    @Test
    5859    public void jnlpFileIsUnchecked2() throws Exception {
    59         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication2.jnlp");
     60        ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication2.jnlp");
    6061        Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString));
    6162    }
     
    6364    @Test
    6465    public void jnlpFileIsUnchecked3() throws Exception {
    65         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication3.jnlp");
     66        ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpApplication3.jnlp");
    6667        Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString));
    6768    }
  • trunk/icedtea-web/tests/reproducers/simple/UnsignedJnlpTemplate/testcases/UnsignedJnlpTemplateTest.java

    r418 r429  
    3939import java.util.Collections;
    4040import java.util.List;
     41import net.sourceforge.jnlp.ProcessResult;
    4142import net.sourceforge.jnlp.ServerAccess;
    4243import org.junit.Assert;
     
    5152    @Test
    5253    public void jnlpTemplateIsUnchecked1() throws Exception {
    53         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate1.jnlp");
     54        ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate1.jnlp");
    5455        Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString));
    5556    }
     
    5758    @Test
    5859    public void jnlpTemplateIsUnchecked2() throws Exception {
    59         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate2.jnlp");
     60        ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate2.jnlp");
    6061        Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString));
    6162    }
     
    6364    @Test
    6465    public void jnlpTemplateIsUnchecked3() throws Exception {
    65         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate3.jnlp");
     66        ProcessResult pr = server.executeJavawsHeadless(l, "/UnsignedJnlpTemplate3.jnlp");
    6667        Assert.assertTrue("Stdout should contains " + outputString + " but did not", pr.stdout.contains(outputString));
    6768    }
  • trunk/icedtea-web/tests/reproducers/simple/deadlocktest/testcases/DeadLockTestTest.java

    r418 r429  
    3737
    3838import java.util.ArrayList;
     39import net.sourceforge.jnlp.ProcessResult;
    3940import net.sourceforge.jnlp.ServerAccess;
    40 import net.sourceforge.jnlp.ServerAccess.ProcessResult;
    4141import org.junit.Assert;
    4242import java.util.Arrays;
     
    8181        List<String> before = countJavaInstances();
    8282        ServerAccess.logOutputReprint("java1 " + jnlp + " : " + before.size());
    83         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, jnlp);
     83        ProcessResult pr = server.executeJavawsHeadless(null, jnlp);
    8484        assertDeadlockTestLaunched(pr);
    8585        List<String> after = countJavaInstances();
     
    168168            ServerAccess.PROCESS_LOG = false;
    169169            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}));
    171171            } finally {
    172172                ServerAccess.PROCESS_LOG = true;
     
    183183        ServerAccess.PROCESS_LOG = false;
    184184        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"}));
    186186            Matcher m = Pattern.compile("\\s*\\d+\\s+\\d+ .+ java\\s*").matcher(pr.stdout);
    187187            int i = 0;
     
    206206        String s = "Deadlock test started";
    207207        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));
    210208        //each 3500 seconds deadlock test stdout something
    211209        //timeout is 20s
  • trunk/icedtea-web/tests/reproducers/simple/simpletest1/srcs/SimpleTest1.java

    r418 r429  
    4040    public static void main(String[] args){
    4141        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        }
    4247    }
    4348}
  • trunk/icedtea-web/tests/reproducers/simple/simpletest1/testcases/SimpleTest1Test.java

    r418 r429  
    3636 */
    3737
    38 
     38import java.io.File;
     39import java.io.FileInputStream;
     40import java.io.IOException;
     41import java.net.MalformedURLException;
     42import java.net.URL;
     43import java.util.Arrays;
     44import java.util.List;
     45import net.sourceforge.jnlp.ProcessResult;
    3946import net.sourceforge.jnlp.ServerAccess;
    4047import org.junit.Assert;
     
    4552
    4653    private static ServerAccess server = new ServerAccess();
     54    private static final List<String> strict = Arrays.asList(new String[]{"-strict", ServerAccess.VERBOSE_OPTION});
    4755
    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    }
    4977
    5078    @Test
    5179    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);
    5982    }
    6083
    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
     2import java.applet.Applet;
     3
    14/* SimpleTest2.java
    25Copyright (C) 2011 Red Hat, Inc.
     
    3639 */
    3740
    38 public class SimpleTest2{
     41public class SimpleTest2 extends Applet{
    3942
    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    }
    4246
     47    @Override
     48    public void init() {
     49        System.out.println("applet was initialised");
    4350    }
     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
    4468}
  • trunk/icedtea-web/tests/reproducers/simple/simpletest2/testcases/SimpleTest2Test.java

    r418 r429  
    3636 */
    3737
     38import net.sourceforge.jnlp.ProcessResult;
    3839import net.sourceforge.jnlp.ServerAccess;
     40
    3941import org.junit.Assert;
    40 
    4142import org.junit.Test;
    4243
     
    4849    @Test
    4950    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");
    5252        String s="Correct exception";
    5353        Assert.assertTrue("stderr should contains "+s+" but didn't",pr.stderr.contains(s));
     
    5555        Assert.assertTrue("stderr should contains "+ss+" but did not",pr.stderr.contains(ss));
    5656        Assert.assertFalse("testSimpletest2lunchException should not be terminated, but was",pr.wasTerminated);
    57         //Assert.assertFalse(0==pr.returnValue);exception and still returned 0?
    5857    }
    5958
  • trunk/icedtea-web/tests/test-extensions-tests/net/sourceforge/jnlp/ResourcesTest.java

    r418 r429  
    6565    public void testNonExisitngBrowserWillNotDeadlock() throws Exception {
    6666        server.setCurrentBrowser(Browsers.none);
    67         ServerAccess.ProcessResult pr = server.executeBrowser("not_existing_url.html");
     67        ProcessResult pr = server.executeBrowser("not_existing_url.html");
    6868        Assert.assertNull(pr.process);
    6969        Assert.assertEquals(pr.stderr, "");
     
    7171        Assert.assertTrue(pr.wasTerminated);
    7272        Assert.assertTrue(pr.returnValue < 0);
    73         junit.framework.Assert.assertNotNull(pr.deadlyException);
     73        Assert.assertNotNull(pr.deadlyException);
    7474    }
    7575
     
    7878        server.setCurrentBrowser(Browsers.none);
    7979        List<String> al=Arrays.asList(new String[] {"definietly_not_Existing_process"});
    80         ServerAccess.ProcessResult pr = server.executeProcess(al);
     80        ProcessResult pr = server.executeProcess(al);
    8181        Assert.assertNull(pr.process);
    8282        Assert.assertEquals(pr.stderr, "");
     
    8484        Assert.assertTrue(pr.wasTerminated);
    8585        Assert.assertTrue(pr.returnValue < 0);
    86         junit.framework.Assert.assertNotNull(pr.deadlyException);
     86        Assert.assertNotNull(pr.deadlyException);
    8787    }
    8888
     
    9797    @TestInBrowsers(testIn=Browsers.none)
    9898    public void testNonExisitngBrowserWillNotCauseMess() throws Exception {
    99         ServerAccess.ProcessResult pr = server.executeBrowser("not_existing_url.html");
     99        ProcessResult pr = server.executeBrowser("not_existing_url.html");
    100100        Assert.assertNull(pr.process);
    101101        Assert.assertEquals(pr.stderr, "");
     
    103103        Assert.assertTrue(pr.wasTerminated);
    104104        Assert.assertTrue(pr.returnValue < 0);
    105         junit.framework.Assert.assertNotNull(pr.deadlyException);
     105        Assert.assertNotNull(pr.deadlyException);
    106106    }
    107107
     
    121121    public void testBrowser3() throws Exception {
    122122        testBrowser(server.getCurrentBrowser());
    123 
    124 
    125123    }
    126124
     
    216214        expected = 2;
    217215        Assert.assertTrue("Created from  " + s + "there must be " + expected + " browsers in factory. Is" + bf.getAllBrowsers().size(), bf.getAllBrowsers().size() == expected);
    218 
    219 
    220 
    221 
    222216    }
    223217
     
    275269            @Override
    276270            public void charReaded(char ch) {
    277                 //ServerAccess.logOutputReprint("OO recieved char: "+ch);
    278271                o1.append(ch);
    279272            }
     
    281274            @Override
    282275            public void lineReaded(String s) {
    283                 //ServerAccess.logOutputReprint("OO recieved line: "+s);
    284276                o2.append(s).append("\n");
    285277            }
     
    289281            @Override
    290282            public void charReaded(char ch) {
    291                 //ServerAccess.logOutputReprint("EE recieved char: "+ch);
    292283                e1.append(ch);
    293284            }
     
    295286            @Override
    296287            public void lineReaded(String s) {
    297                 //ServerAccess.logOutputReprint("EE recieved line: "+s);
    298288                e2.append(s).append("\n");
    299289            }
    300290        };
    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());
    309295       Assert.assertEquals(pr.stdout, o1.toString());
    310296       Assert.assertEquals(pr.stderr, e1.toString());
     
    312298       Assert.assertEquals(pr.stdout.replace("\n", ""), o2.toString().replace("\n", ""));
    313299       Assert.assertEquals(pr.stderr.replace("\n", ""), e2.toString().replace("\n", ""));
    314 
    315300    }
    316301
     
    325310
    326311    private void testBrowser(Browser browser) throws IOException {
    327         File f1 = null;
     312        File defaultPluginDir = null;
    328313        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;
    332321        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() {
    357341
    358342                @Override
     
    363347        }
    364348
    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() {
    368352
    369353                @Override
     
    375359
    376360        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);
    378362        String currentPath = server.getJavawsFile().getParentFile().getParentFile().getAbsolutePath();
    379363
    380         File[] ff;
    381         if (ff1.length == 1) {
    382             ff = ff1;
     364        File[] plugins;
     365        if (defaultPlugins.length == 1) {
     366            plugins = defaultPlugins;
    383367        } 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");
    387371        Assert.assertTrue("browser's plugins  shoud points to" + currentPath + ", but  didnt",
    388372                s.contains(s));
  • trunk/icedtea-web/tests/test-extensions-tests/net/sourceforge/jnlp/ServerAccessTest.java

    r418 r429  
    4040import java.io.FileInputStream;
    4141import java.net.URL;
     42
    4243import org.junit.Assert;
    4344import org.junit.Test;
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/ContentReader.java

    r418 r429  
    3535exception statement from your version.
    3636 */
    37 
    3837package net.sourceforge.jnlp;
    3938
     
    4241import java.io.InputStreamReader;
    4342import java.io.Reader;
     43import java.util.ArrayList;
     44import java.util.List;
    4445
    4546/**
    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.
    4749 */
    4850class ContentReader implements Runnable {
     
    5153    private final InputStream is;
    5254    private boolean done;
    53     ContentReaderListener listener;
     55    final List<ContentReaderListener> listeners = new ArrayList<ContentReaderListener>(1);
    5456
    5557    public String getContent() {
     
    6365    public ContentReader(InputStream is, ContentReaderListener l) throws IOException {
    6466        this.is = is;
    65         this.listener = l;
     67        if (l != null) {
     68            this.listeners.add(l);
     69        }
    6670    }
    6771
    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        }
    7077    }
    7178
    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;
    7485    }
    7586
     
    97108                int s = br.read();
    98109                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                        }
    101116                    }
    102117                    break;
     
    106121                line.append(ch);
    107122                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                        }
    110129                    }
    111130                    line = new StringBuilder();
    112131                }
    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                    }
    115138                }
    116139            }
    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) {
    122146            // logException(ex);
     147            //ex.printStackTrace();
    123148        } finally {
    124149            try {
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/LoggingBottleneck.java

    r418 r429  
    4646import java.io.Writer;
    4747import java.lang.reflect.Method;
     48import java.util.Collections;
    4849import java.util.HashMap;
    4950import java.util.Map;
     
    8182     * class.testMethod.logs
    8283     */
    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));
    8485    private boolean added = false;
    8586
    86     public static LoggingBottleneck getDefaultLoggingBottleneck() {
     87    synchronized public static LoggingBottleneck getDefaultLoggingBottleneck() {
    8788        if (loggingBottleneck == null) {
    8889            loggingBottleneck = new LoggingBottleneck();
     
    102103    }
    103104
    104     void writeXmlLog() throws FileNotFoundException, IOException {
     105   synchronized void writeXmlLog() throws FileNotFoundException, IOException {
    105106        writeXmlLog(DEFAULT_LOG_FILE);
    106107    }
    107108
    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 {
    109114        Writer w = new OutputStreamWriter(new FileOutputStream(f));
    110115        Set<Entry<String, Map<String, TestsLogs>>> classes = processLogs.entrySet();
     
    118123                String testLogs = testLog.getValue().toString();
    119124                w.write("<" + TESTLOG_ELEMENT + " " + TESTMETHOD_ATTRIBUTE + "=\"" + testName + "\" " + FULLID_ATTRIBUTE + "=\"" + className + "." + testName + "\"  >");
    120                 w.write(testLogs);
     125                w.write(clearChars(testLogs));
    121126                w.write("</" + TESTLOG_ELEMENT + ">");
    122127            }
     
    128133    }
    129134
    130     void addToXmlLog(String message, boolean printToOut, boolean printToErr, StackTraceElement ste) {
     135    synchronized  void addToXmlLog(String message, boolean printToOut, boolean printToErr, StackTraceElement ste) {
    131136        Map<String, TestsLogs> classLog = processLogs.get(ste.getClassName());
    132137        if (classLog == null) {
     
    158163    }
    159164
    160     public String modifyMethodWithForBrowser(String methodBrowseredName, String className) {
     165   synchronized public String modifyMethodWithForBrowser(String methodBrowseredName, String className) {
    161166        try {
    162             Class clazz = Class.forName(className);
     167            Class<?> clazz = Class.forName(className);
    163168            /*
    164169             * By using this isAssignable to ensure corect class before invocation,
     
    181186    }
    182187
    183     public void setLoggedBrowser(String loggedBrowser) {
     188   synchronized public void setLoggedBrowser(String loggedBrowser) {
    184189        this.loggedBrowser = loggedBrowser;
    185190    }
    186191
    187     public void logIntoPlaintextLog(String message, boolean printToOut, boolean printToErr) {
     192  synchronized  public void logIntoPlaintextLog(String message, boolean printToOut, boolean printToErr) {
    188193        try {
    189194            if (printToOut) {
     
    202207        DEFAULT_STDOUT_WRITER.write(idded);
    203208        DEFAULT_STDOUT_WRITER.newLine();
     209        DEFAULT_STDOUT_WRITER.flush();
    204210    }
    205211
     
    207213        DEFAULT_STDERR_WRITER.write(idded);
    208214        DEFAULT_STDERR_WRITER.newLine();
     215        DEFAULT_STDERR_WRITER.flush();
    209216    }
    210217
     
    212219        DEFAULT_STDLOGS_WRITER.write(idded);
    213220        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();
    214242    }
    215243}
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/ProcessAssasin.java

    r418 r429  
    4040import java.util.ArrayList;
    4141import java.util.List;
     42import net.sourceforge.jnlp.browsertesting.ReactingProcess;
    4243
    4344/**
    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().
    4547 */
    46 class ProcessAssasin extends Thread {
     48public class ProcessAssasin extends Thread {
    4749
    4850    long timeout;
     
    5153    private boolean canRun = true;
    5254    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;
    5359    /**
    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
    5865     */
    5966    private boolean skipInstedOfDesroy = false;
     67    private ReactingProcess reactingProcess;
    6068
    6169    public ProcessAssasin(ThreadedProcess p, long timeout) {
     
    98106        return skipInstedOfDesroy;
    99107    }
     108
     109    void setTimeout(long timeout) {
     110        this.timeout = timeout;
     111    }
     112
    100113
    101114    @Override
     
    119132                                try {
    120133                                    if (!skipInstedOfDesroy) {
    121                                         destroyProcess(p);
     134                                        destroyProcess();
    122135                                    }
    123136                                } catch (Throwable ex) {
     
    161174    }
    162175
    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) {
    164196        Process p = pp.getP();
    165197        try {
     
    167199            f.setAccessible(true);
    168200            String pid = (f.get(p)).toString();
     201            if (reactingProcess != null) {
     202                reactingProcess.beforeKill(pid);
     203            };
    169204            sigInt(pid);
    170205            //sigTerm(pid);
     
    174209        } finally {
    175210            p.destroy();
     211            if (reactingProcess != null) {
     212                reactingProcess.afterKill("");
     213            };
    176214        }
    177215    }
     
    189227    }
    190228
    191     public static void kill(String pid,String signal) throws InterruptedException, Exception {
     229    public static void kill(String pid, String signal) throws InterruptedException, Exception {
    192230        List<String> ll = new ArrayList<String>(4);
    193231        ll.add("kill");
     
    199237        Thread.sleep(1000);
    200238    }
     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
    201266}
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java

    r418 r429  
    11/* ServerAccess.java
    2 Copyright (C) 2011 Red Hat, Inc.
     2Copyright (C) 2011, 2012 Red Hat, Inc.
    33
    44This file is part of IcedTea.
     
    5656import java.util.ArrayList;
    5757import java.util.List;
     58import net.sourceforge.jnlp.ProcessResult;
    5859import net.sourceforge.jnlp.browsertesting.Browser;
    5960import net.sourceforge.jnlp.browsertesting.BrowserFactory;
    6061import net.sourceforge.jnlp.browsertesting.Browsers;
     62import net.sourceforge.jnlp.closinglisteners.AutoErrorClosingListener;
     63import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener;
     64import net.sourceforge.jnlp.util.FileUtils;
     65import net.sourceforge.jnlp.util.logging.OutputController;
    6166import org.junit.Assert;
    6267
     
    7883public class ServerAccess {
    7984
     85    public static enum AutoClose {
     86
     87        CLOSE_ON_EXCEPTION, CLOSE_ON_CORRECT_END, CLOSE_ON_BOTH
     88    }
     89
    8090    public static final long NANO_TIME_DELIMITER=1000000l;
    8191    /**
     
    132142        } else {
    133143            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]);
    136148            }
    137149            getIndependentInstance(port);
     
    157169    }
    158170    public static final  String HEADLES_OPTION="-headless";
    159     public static final  String VERBOSE_OPTION="-verbose ";
     171    public static final  String VERBOSE_OPTION="-verbose";
    160172
    161173    /**
     
    260272       List<String> l1=this.currentBrowser.getComaptibilitySwitches();
    261273       List<String> l2=this.currentBrowser.getDefaultSwitches();
    262        List<String> l= new ArrayList();
     274       List<String> l= new ArrayList<String>();
    263275       if (l1!=null)l.addAll(l1);
    264276       if (l2!=null)l.addAll(l2);
     
    409421     * @throws IOException if connection can't be established or resource does not exist
    410422     */
    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);
    428425    }
    429426
     
    436433     */
    437434    public static String getContentOfStream(InputStream is) throws IOException {
    438         return getContentOfStream(is, "UTF-8");
    439 
     435        return FileUtils.getContentOfStream(is);
    440436    }
    441437
     
    483479     */
    484480    public static void saveFile(String content, File f) throws IOException {
    485         saveFile(content, f, "utf-8");
     481        FileUtils.saveFile(content, f);
    486482    }
    487483    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);
    492485    }
    493486
     
    546539        return executeJavaws(null, resource,stdoutl,stderrl);
    547540    }
     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
    548555    public ProcessResult executeBrowser(String resource) throws Exception {
    549556        return executeBrowser(getBrowserParams(), resource);
    550557    }
    551558    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 {
    552563        return executeBrowser(getBrowserParams(), resource, stdoutl, stderrl);
    553564    }
     
    572583
    573584    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);
    585633    }
    586634
     
    591639     * @throws MalformedURLException
    592640     */
    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);
    598643    }
    599644
     
    623668     */
    624669    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();
    642679    }
    643680
     
    671708    }
    672709
    673     private static String createConnectionMessage(ThreadedProcess t) {
    674         return "Connecting " + t.getCommandLine();
    675     }
    676 
    677710    /**
    678711     * Proceed message s to logging with request to reprint to System.err
     
    699732    }
    700733
    701     private static void log(String message, boolean printToOut, boolean printToErr) {
     734    static void log(String message, boolean printToOut, boolean printToErr) {
    702735        String idded;
    703736        StackTraceElement ste = getTestMethod();
     
    726759    }
    727760    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);
    738762    }
    739763
     
    744768    private static StackTraceElement getTestMethod(StackTraceElement[] stack) {
    745769        //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
    747772        StackTraceElement result = stack[1];
    748773        String baseClass = stack[1].getClassName();
     
    750775        for (; i < stack.length; i++) {
    751776            result = stack[i];//at least moving up
    752             if(stack[i].getClassName().contains("$")){
     777            if (stack[i].getClassName().contains("$")) {
    753778                continue;
    754779            }
    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();
    757804            }
    758805        }
     
    760807        //so the target method is the highest form it and better to return it
    761808        //rather then die to ArrayOutOfBounds
    762         if(i >= stack.length){
     809        if (i >= stack.length) {
    763810            return result;
    764811        }
    765         //now we are out of net.sourceforge.jnlp.ServerAccess
     812        //now we are out of test-extensions
    766813        //method we need (the test)  is highest from following class
    767814        baseClass = stack[i].getClassName();
     
    783830
    784831    }
    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  
    5757    private final Integer port;
    5858    private final File dir;
     59    private ServerSocket serverSocket;
     60    private boolean supportingHeadRequest = true;
    5961
     62    public void setSupportingHeadRequest(boolean supportsHead) {
     63        this.supportingHeadRequest = supportsHead;
     64    }
     65
     66    public boolean isSupportingHeadRequest() {
     67        return supportingHeadRequest;
     68    }
     69
     70   
     71   
    6072    public String getServerName() {
    6173        return serverName;
     
    100112        running = true;
    101113        try {
    102             ServerSocket s = new ServerSocket(port);
     114            serverSocket = new ServerSocket(port);
    103115            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();
    105119            }
    106120        } catch (Exception e) {
    107             e.printStackTrace();
     121            ServerAccess.logException(e);
    108122        } finally {
    109123            running = false;
     
    112126
    113127    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        }
    114134        return new URL("http", getServerName(), getPort(), resource);
    115135    }
     
    118138        return getUrl("");
    119139    }
     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    }
    120151}
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/ThreadedProcess.java

    r418 r429  
    4646 * Process builder caused some unexpected and weird behavior :/
    4747 */
    48 class ThreadedProcess extends Thread {
     48public class ThreadedProcess extends Thread {
    4949
    5050    Process p = null;
     
    6060     */
    6161    private boolean destoyed = false;
     62    private ProcessAssasin assasin;
    6263
    6364    public boolean isDestoyed() {
     
    118119        } catch (Exception ex) {
    119120            ex.printStackTrace();
    120         } finally {
    121             return commandLine;
    122121        }
     122        return commandLine;
    123123    }
    124124
     
    144144                exitCode = p.waitFor();
    145145                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                };
    146149            } finally {
    147150                destoyed = true;
     
    164167        }
    165168    }
     169
     170    void setAssasin(ProcessAssasin pa) {
     171        this.assasin=pa;
     172    }
    166173}
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java

    r418 r429  
    4343import java.io.FileInputStream;
    4444import java.io.InputStreamReader;
     45import java.io.UnsupportedEncodingException;
     46import java.net.HttpURLConnection;
    4547import java.net.Socket;
    4648import java.net.SocketException;
     
    5658 * is returned, but its delivery is delayed
    5759 */
    58 class TinyHttpdImpl extends Thread {
    59 
    60     Socket c;
    61     private final File dir;
    62     private final int port;
     60public 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;
    6370    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        }
    7183    }
    7284
     
    7587    }
    7688
     89    public void setSupportingHeadRequest(boolean supportsHead) {
     90        this.supportingHeadRequest = supportsHead;
     91    }
     92
     93    public boolean isSupportingHeadRequest() {
     94        return this.supportingHeadRequest;
     95    }
     96
    7797    public int getPort() {
    78         return port;
     98        return this.socket.getPort();
    7999    }
    80100
     
    82102    public void run() {
    83103        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());
    86106            try {
    87107                while (canRun) {
    88                     String s = i.readLine();
    89                     if (s.length() < 1) {
     108                    String line = reader.readLine();
     109                    if (line.length() < 1) {
    90110                        break;
    91111                    }
    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);
    121168                            for (int j = 0; j < bb.length; j++) {
    122169                                Thread.sleep(2000);
    123170                                byte[] bs = bb[j];
    124                                 o.write(bs, 0, bs.length);
     171                                writer.write(bs, 0, bs.length);
    125172                            }
    126173                        } else {
    127                             o.write(b, 0, l);
     174                            writer.write(buff, 0, resourceLength);
    128175                        }
    129176                    }
     
    132179                ServerAccess.logException(e, false);
    133180            } catch (Exception e) {
    134                 o.writeBytes("HTTP/1.0 404 ERROR\n\n\n");
     181                writer.writeBytes(HTTP_NOT_FOUND);
    135182                ServerAccess.logException(e, false);
     183            } finally {
     184                reader.close();
     185                writer.close();
    136186            }
    137             o.close();
    138187        } catch (Exception e) {
    139188            ServerAccess.logException(e, false);
     
    172221        return array;
    173222    }
     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    }
    174268}
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/annotations/KnownToFail.java

    r418 r429  
    4242import java.lang.annotation.RetentionPolicy;
    4343import java.lang.annotation.Target;
     44import net.sourceforge.jnlp.browsertesting.Browsers;
    4445
    4546/**
     
    5354 * implemented.
    5455 * </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>
    5561 */
    5662
     
    5864@Retention(RetentionPolicy.RUNTIME)
    5965public @interface KnownToFail {
    60    
     66    public Browsers[] failsIn() default {};
    6167}
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/browsertesting/Browser.java

    r418 r429  
    4343 * interface which represents individual browsers
    4444 */
    45 public interface Browser {
     45public interface Browser extends ReactingProcess{
    4646    public String getDefaultBin();
    4747    public String getDefaultPluginExpectedLocation();
     
    5353    public List<String> getDefaultSwitches();
    5454
    55 
    5655}
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/Epiphany.java

    r418 r429  
    3535exception statement from your version.
    3636 */
    37 
    3837package net.sourceforge.jnlp.browsertesting.browsers;
    3938
     39import java.util.Arrays;
     40import java.util.List;
    4041import net.sourceforge.jnlp.browsertesting.Browsers;
    4142
    4243public class Epiphany extends MozillaFamilyLinuxBrowser {
     44
     45   
     46    String[] cs = {};
    4347
    4448    public Epiphany(String bin) {
     
    4751
    4852    @Override
     53    public List<String> getComaptibilitySwitches() {
     54        return Arrays.asList(cs);
     55    }
     56
     57    @Override
    4958    public Browsers getID() {
    5059        return Browsers.epiphany;
    5160    }
    52 
    53 
    54    
    5561}
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/Firefox.java

    r418 r429  
    3535exception statement from your version.
    3636 */
    37 
    3837package net.sourceforge.jnlp.browsertesting.browsers;
    3938
    4039import java.util.Arrays;
    4140import java.util.List;
     41import net.sourceforge.jnlp.ProcessAssasin;
     42import net.sourceforge.jnlp.ServerAccess;
    4243import net.sourceforge.jnlp.browsertesting.Browsers;
     44import net.sourceforge.jnlp.browsertesting.browsers.firefox.FirefoxProfilesOperator;
    4345
    4446public class Firefox extends MozillaFamilyLinuxBrowser {
     47
     48    private static final FirefoxProfilesOperator firefoxProfilesOperatorSingleton = new FirefoxProfilesOperator();
    4549
    4650    public Firefox(String bin) {
    4751        super(bin);
    4852    }
    49 
    50     String[] cs={"-new-tab"};
     53    String[] cs = {"-new-tab"};
    5154
    5255    @Override
     
    6063    }
    6164
     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    }
    6273
     74    @Override
     75    public void afterProcess(String s) {
     76    }
    6377
     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    }
    6486
    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    }
    6696}
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/LinuxBrowser.java

    r418 r429  
    9393    }
    9494
     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    }
    95114
    96115   
  • trunk/icedtea-web/tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/Midory.java

    r418 r429  
    5151    }
    5252
    53 
     53     
    5454   
    5555}
Note: See TracChangeset for help on using the changeset viewer.