<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 12/17/2012 10:14 AM, Jiri Vanek
      wrote:<br>
    </div>
    <blockquote cite="mid:50CF36E6.3060606@redhat.com" type="cite">This
      tests were wrongly adapted for lates ITW. And so they were
      incorrectly failing. This should fix them.
      <br>
      <br>
      J.
      <br>
    </blockquote>
    <br>
    Thanks for looking into it!<br>
    <br>
    <blockquote type="cite"><br>
      <div class="moz-text-plain" wrap="true" graphical-quote="true"
        style="font-family: -moz-fixed; font-size: 12px;"
        lang="x-western">
        <pre wrap="">diff -r 1fe2a4f7981f tests/netx/unit/net/sourceforge/jnlp/runtime/CodeBaseClassLoaderTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/runtime/CodeBaseClassLoaderTest.java        Tue Dec 11 20:32:26 2012 +0100
+++ b/tests/netx/unit/net/sourceforge/jnlp/runtime/CodeBaseClassLoaderTest.java        Mon Dec 17 16:09:22 2012 +0100
@@ -68,6 +68,24 @@
             throw new RuntimeException(ex);
         }
     }
+    
+      private class DummyJNLPFile extends JNLPFile{
+
+            @Override
+            public ResourcesDesc getResources() {
+                return new ResourcesDesc(null, new Locale[0], new String[0], new String[0]);
+            }
+
+            @Override
+            public URL getCodeBase() {
+                return CODEBASE_URL;
+            }
+
+            @Override
+            public SecurityDesc getSecurity() {
+                return new SecurityDesc(this, SecurityDesc.SANDBOX_PERMISSIONS, null);
+            }
+        };</pre>
      </div>
    </blockquote>
    <br>
    +1<br>
    <br>
    <blockquote type="cite">
      <div class="moz-text-plain" wrap="true" graphical-quote="true"
        style="font-family: -moz-fixed; font-size: 12px;"
        lang="x-western">
        <pre wrap="">
     private static final String isWSA = "isWebstartApplication";
 
     static void setStaticField(Field field, Object newValue) throws Exception {
@@ -97,47 +115,73 @@
     public void testResourceLoadSuccessCachingApplication() throws Exception {
         setWSA();
         //we are testing new resource not in cache
-        testResourceLoadSuccessCaching("Main.class");
+        testResourceLoadSuccessCaching2("Main.class");</pre>
      </div>
    </blockquote>
    <br>
    Just a nitpick, <br>
    <pre wrap="">testResourceLoadSuccessCachingApplication calls testResourceLoadSuccessCaching2
but testResourceLoadSuccessCachingApplication2 calls testResourceLoadSuccessCaching1, the mismatch is a little confusing

</pre>
    <blockquote type="cite">
      <div class="moz-text-plain" wrap="true" graphical-quote="true"
        style="font-family: -moz-fixed; font-size: 12px;"
        lang="x-western">
        <pre wrap="">
     }
 
     @Test
     public void testResourceLoadSuccessCachingApplet() throws Exception {
         setApplet();
         //so new resource again not in cache
-        testResourceLoadSuccessCaching("HTMLPanel.java");
+        testResourceLoadSuccessCaching2("Main.class");
+    }
+    
+     @Test
+    public void testResourceLoadSuccessCachingApplication2() throws Exception {
+        setWSA();
+        //we are testing new resource not in cache
+        testResourceLoadSuccessCaching1("HTMLPanel.java");
     }
 
-    public void testResourceLoadSuccessCaching(String r) throws Exception {
-        JNLPFile dummyJnlpFile = new JNLPFile() {
+    @Test
+    public void testResourceLoadSuccessCachingApplet2() throws Exception {
+        setApplet();
+        //so new resource again not in cache
+        testResourceLoadSuccessCaching1("HTMLPanel.java");
+    }
 
-            @Override
-            public ResourcesDesc getResources() {
-                return new ResourcesDesc(null, new Locale[0], new String[0], new String[0]);
-            }
+    public void testResourceLoadSuccessCaching1(String r) throws Exception {
+        JNLPFile dummyJnlpFile = new DummyJNLPFile();
 
-            @Override
-            public URL getCodeBase() {
-                return CODEBASE_URL;
-            }
-
-            @Override
-            public SecurityDesc getSecurity() {
-                return new SecurityDesc(this, SecurityDesc.SANDBOX_PERMISSIONS, null);
-            }
-        };
         JNLPClassLoader parent = new JNLPClassLoader(dummyJnlpFile, null);
         CodeBaseClassLoader classLoader = new CodeBaseClassLoader(new URL[] { JAR_URL, CODEBASE_URL }, parent);
 
         long startTime, stopTime;
 
         startTime = System.nanoTime();
-        classLoader.findResource("net/sourceforge/jnlp/about/"+r);
+        URL u1 = classLoader.findResource("net/sourceforge/jnlp/about/"+r);
+        Assert.assertNull(u1);
         stopTime = System.nanoTime();
         long timeOnFirstTry = stopTime - startTime;
         ServerAccess.logErrorReprint("" + timeOnFirstTry);
 
         startTime = System.nanoTime();
-        classLoader.findResource("net/sourceforge/jnlp/about/"+r);
+        URL u2 = classLoader.findResource("net/sourceforge/jnlp/about/"+r);
+        Assert.assertNull(u2);
+        stopTime = System.nanoTime();
+        long timeOnSecondTry = stopTime - startTime;
+        ServerAccess.logErrorReprint("" + timeOnSecondTry);
+
+        assertTrue(timeOnSecondTry &lt; (timeOnFirstTry / 10));
+    }
+    
+     public void testResourceLoadSuccessCaching2(String r) throws Exception {</pre>
      </div>
    </blockquote>
    <br>
    I dislike numerically distinguished names strongly :-) <br>
    I had to do a diff to be sure of the difference here. It seems there
    should just be one function (equivalent to
    testResourceLoadSuccessCaching2), and the
    "net/sourceforge/jnlp/about/" be added to the parameter upon usage.<br>
    <br>
    <blockquote type="cite">
      <div class="moz-text-plain" wrap="true" graphical-quote="true"
        style="font-family: -moz-fixed; font-size: 12px;"
        lang="x-western">
        <pre wrap="">
+        JNLPFile dummyJnlpFile = new DummyJNLPFile();
+
+        JNLPClassLoader parent = new JNLPClassLoader(dummyJnlpFile, null);
+        CodeBaseClassLoader classLoader = new CodeBaseClassLoader(new URL[] { JAR_URL, CODEBASE_URL }, parent);
+
+        long startTime, stopTime;
+
+        startTime = System.nanoTime();
+        URL u1 = classLoader.findResource(r);
+        Assert.assertNull(u1);
+        stopTime = System.nanoTime();
+        long timeOnFirstTry = stopTime - startTime;
+        ServerAccess.logErrorReprint("" + timeOnFirstTry);
+
+        startTime = System.nanoTime();
+        URL u2 = classLoader.findResource(r);
+        Assert.assertNull(u2);
         stopTime = System.nanoTime();
         long timeOnSecondTry = stopTime - startTime;
         ServerAccess.logErrorReprint("" + timeOnSecondTry);
@@ -161,23 +205,7 @@
     }
 
     public void testResourceLoadFailureCaching() throws Exception {
-        JNLPFile dummyJnlpFile = new JNLPFile() {
-
-            @Override
-            public ResourcesDesc getResources() {
-                return new ResourcesDesc(null, new Locale[0], new String[0], new String[0]);
-            }
-
-            @Override
-            public URL getCodeBase() {
-                return CODEBASE_URL;
-            }
-
-            @Override
-            public SecurityDesc getSecurity() {
-                return new SecurityDesc(this, SecurityDesc.SANDBOX_PERMISSIONS, null);
-            }
-        };
+        JNLPFile dummyJnlpFile = new DummyJNLPFile();
 
         JNLPClassLoader parent = new JNLPClassLoader(dummyJnlpFile, null);
         CodeBaseClassLoader classLoader = new CodeBaseClassLoader(new URL[] { JAR_URL, CODEBASE_URL }, parent);
@@ -212,24 +240,8 @@
     }
 
     public void testParentClassLoaderIsAskedForClasses() throws Exception {
-        JNLPFile dummyJnlpFile = new JNLPFile() {
-
-            @Override
-            public ResourcesDesc getResources() {
-                return new ResourcesDesc(null, new Locale[0], new String[0], new String[0]);
-            }
-
-            @Override
-            public URL getCodeBase() {
-                return CODEBASE_URL;
-            }
-
-            @Override
-            public SecurityDesc getSecurity() {
-                return new SecurityDesc(this, SecurityDesc.SANDBOX_PERMISSIONS, null);
-            }
-        };
-
+        JNLPFile dummyJnlpFile = new DummyJNLPFile();
+        
         final boolean[] parentWasInvoked = new boolean[1];
 
         JNLPClassLoader parent = new JNLPClassLoader(dummyJnlpFile, null) {
</pre>
      </div>
    </blockquote>
    <br>
    Please also rid of the duplicated dummy in testNullFileSecurityDesc.<br>
    <br>
    -Adam<br>
  </body>
</html>