Author: jbq
Date: Fri Feb 23 03:57:41 2007
New Revision: 510916

URL: http://svn.apache.org/viewvc?view=rev&rev=510916
Log:
WICKET-280 Allow to access html resources if they are not associated with a 
java class

NOTE: WicketTesterTest.testClickResourceLink() is still disabled until the
relative path refactoring is ported to trunk

Added:
    
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/BlockedResourceLinkPage.html
    
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/BlockedResourceLinkPage.java
    incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/test.html
Modified:
    
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/PackageResourceGuard.java
    
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/MockResourceLinkPage.java
    
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/WicketTesterTest.java

Modified: 
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/PackageResourceGuard.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/PackageResourceGuard.java?view=diff&rev=510916&r1=510915&r2=510916
==============================================================================
--- 
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/PackageResourceGuard.java
 (original)
+++ 
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/PackageResourceGuard.java
 Fri Feb 23 03:57:41 2007
@@ -40,7 +40,6 @@
                blockedExtensions.add("properties");
                blockedExtensions.add("class");
                blockedExtensions.add("java");
-               blockedExtensions.add("html");
        }
 
        /**
@@ -73,6 +72,10 @@
                else
                {
                        ext = path.substring(ixExtension + 1).toLowerCase();
+               }
+               if ("html".equals(ext) && 
getClass().getClassLoader().getResource(path.replaceAll(".html", ".class")) != 
null)
+               {
+                       return false;
                }
                return acceptExtension(ext);
        }

Added: 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/BlockedResourceLinkPage.html
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/BlockedResourceLinkPage.html?view=auto&rev=510916
==============================================================================
--- 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/BlockedResourceLinkPage.html
 (added)
+++ 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/BlockedResourceLinkPage.html
 Fri Feb 23 03:57:41 2007
@@ -0,0 +1 @@
+<a wicket:id="link">Link</a>

Added: 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/BlockedResourceLinkPage.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/BlockedResourceLinkPage.java?view=auto&rev=510916
==============================================================================
--- 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/BlockedResourceLinkPage.java
 (added)
+++ 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/BlockedResourceLinkPage.java
 Fri Feb 23 03:57:41 2007
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package wicket.util.tester;
+
+import wicket.ResourceReference;
+import wicket.markup.html.WebPage;
+import wicket.markup.html.link.ResourceLink;
+
+/**
+ * Mock page for testing WicketTesters ability to test ResourceLinks
+ * 
+ * @author frankbille
+ */
+public class BlockedResourceLinkPage extends WebPage
+{
+       private static final long serialVersionUID = 1L;
+
+       /**
+        * Construct.
+        */
+       public BlockedResourceLinkPage()
+       {
+               new ResourceLink(this, "link", new 
ResourceReference(BlockedResourceLinkPage.class, 
"BlockedResourceLinkPage.html"));
+       }
+}

Modified: 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/MockResourceLinkPage.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/MockResourceLinkPage.java?view=diff&rev=510916&r1=510915&r2=510916
==============================================================================
--- 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/MockResourceLinkPage.java
 (original)
+++ 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/MockResourceLinkPage.java
 Fri Feb 23 03:57:41 2007
@@ -34,6 +34,6 @@
         */
        public MockResourceLinkPage()
        {
-               new ResourceLink(this, "link", new 
ResourceReference(MockResourceLinkPage.class, "MockResourceLinkPage.html"));
+               new ResourceLink(this, "link", new 
ResourceReference(MockResourceLinkPage.class, "test.html"));
        }
 }

Modified: 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/WicketTesterTest.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/WicketTesterTest.java?view=diff&rev=510916&r1=510915&r2=510916
==============================================================================
--- 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/WicketTesterTest.java
 (original)
+++ 
incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/WicketTesterTest.java
 Fri Feb 23 03:57:41 2007
@@ -28,9 +28,11 @@
 import wicket.ajax.AjaxRequestTarget;
 import wicket.ajax.ClientEvent;
 import wicket.ajax.markup.html.AjaxLink;
+import wicket.markup.html.PackageResource.PackageResourceBlockedException;
 import wicket.markup.html.basic.Label;
 import wicket.markup.html.form.TextField;
 import wicket.markup.html.link.Link;
+import wicket.request.target.coding.IRequestTargetUrlCodingStrategy;
 import wicket.util.tester.MockPageWithFormAndAjaxFormSubmitBehavior.Pojo;
 import wicket.util.tester.apps_1.Book;
 import wicket.util.tester.apps_1.CreateBook;
@@ -335,17 +337,29 @@
         * Test that clickLink on a ResourceLink with a ResourceReference on it
         * works.
         * 
-        * FIXME this test should be activated again once a proper solution to
-        * <b>WICKET-280 Allow to access html resources</b> is found
+        * <p>See also WICKET-280 Allow to access html resources</p>
+        *
+        * FIXME enable this test again when relative path refactoring is 
ported to
+        * trunk
         */
-       public void bugTestClickResourceLink()
+       /*public void testClickResourceLink()
        {
-               WicketTester tester = new WicketTester();
+               try
+               {
+                       tester.startPage(BlockedResourceLinkPage.class);
+                       fail("Accessing " + BlockedResourceLinkPage.class + " 
should have raised a " + PackageResourceBlockedException.class);
+               }
+               catch(PackageResourceBlockedException e)
+               {
+                       
+               }
                
                tester.startPage(MockResourceLinkPage.class);
-               
                tester.clickLink("link");
-               
-               tester.destroy();
+               assertNull(getRequestCodingStrategy());
        }
+       IRequestTargetUrlCodingStrategy getRequestCodingStrategy() {
+               String relativePath = 
tester.getApplication().getWicketFilter().getRelativePath(tester.getServletRequest());
+               return 
tester.getApplication().getRequestCycleProcessor().getRequestCodingStrategy().urlCodingStrategyForPath(relativePath);
+       }*/
 }

Added: incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/test.html
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/test.html?view=auto&rev=510916
==============================================================================
--- incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/test.html 
(added)
+++ incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/test.html 
Fri Feb 23 03:57:41 2007
@@ -0,0 +1 @@
+This is a test!


Reply via email to