myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfreed...@apache.org
Subject svn commit: r1139022 - in /myfaces/portlet-bridge/tck/trunk: pom.xml src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java
Date Thu, 23 Jun 2011 18:01:47 GMT
Author: mfreedman
Date: Thu Jun 23 18:01:47 2011
New Revision: 1139022

URL: http://svn.apache.org/viewvc?rev=1139022&view=rev
Log:
Updated test (that were) using /tests/zzz.yyy pathing to use full context path form when refering
to internal (within app) entity -- as fix for PORTLETBRIDGE-215 forced the change.

Modified:
    myfaces/portlet-bridge/tck/trunk/pom.xml
    myfaces/portlet-bridge/tck/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java

Modified: myfaces/portlet-bridge/tck/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/tck/trunk/pom.xml?rev=1139022&r1=1139021&r2=1139022&view=diff
==============================================================================
--- myfaces/portlet-bridge/tck/trunk/pom.xml (original)
+++ myfaces/portlet-bridge/tck/trunk/pom.xml Thu Jun 23 18:01:47 2011
@@ -30,7 +30,7 @@
     <jsp.version>2.1</jsp.version>
     
     <!-- Bridge Configurations -->
-    <portlet-bridge.version>1.0.0</portlet-bridge.version>
+    <portlet-bridge.version>1.0.1-SNAPSHOT</portlet-bridge.version>
     <portlet-bridge.groupId>${project.groupId}</portlet-bridge.groupId>
 
     <portlet-bridge.api.groupId>${portlet-bridge.groupId}</portlet-bridge.api.groupId>

Modified: myfaces/portlet-bridge/tck/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/tck/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java?rev=1139022&r1=1139021&r2=1139022&view=diff
==============================================================================
--- myfaces/portlet-bridge/tck/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java
(original)
+++ myfaces/portlet-bridge/tck/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java
Thu Jun 23 18:01:47 2011
@@ -176,20 +176,33 @@ public class Tests
       "/test.jsp?firstParam=value&javax.portlet.faces.DirectLink=true&anotherParam=value";
     FacesContext ctx = FacesContext.getCurrentInstance();
     ExternalContext extCtx = ctx.getExternalContext();
+    ViewHandler vh = ctx.getApplication().getViewHandler();
+    PortletRequest r = (PortletRequest) extCtx.getRequest();
     
-    if (extCtx.encodeActionURL(DIRECTLINK_TRUE_TEST_STRING).equals(DIRECTLINK_TRUE_TEST_STRING))
+    String testString = new StringBuffer(extCtx.getRequestContextPath()).append(DIRECTLINK_TRUE_TEST_STRING).toString();
+    
+    String s = new StringBuffer(testString.length() + 20)
+                 .append(r.getScheme())
+                 .append("://")
+                 .append(r.getServerName())
+                 .append(":")
+                 .append(r.getServerPort())
+                 .append(testString)
+                 .toString();
+    
+    if (extCtx.encodeActionURL(testString).equalsIgnoreCase(s))
     {
       testRunner.setTestResult(true,
-                               "encodeActionURL correctly returned an unchanged string when
passed an URL containing the javax.portlet.faces.DirectLink parameter with a value of true.");
+                               "encodeActionURL correctly returned an absolute URL representing
the DirectLink url and it correctly contains the javax.portlet.faces.DirectLink parameter
with a value of true.");
       return Constants.TEST_SUCCESS;
     }
     else
     {
       testRunner.setTestResult(false,
-                               "encodeActionURL didn't return an unchanged string when passed
an URL containing the javax.portlet.faces.DirectLink parameter with a value of true.  Test
parameter: " +
-                               DIRECTLINK_TRUE_TEST_STRING +
+                               "encodeActionURL didn't return an absolute URL representing
the DirectLink url or it didn't contain the javax.portlet.faces.DirectLink parameter with
a value of true.  Expected: " +
+                               s +
                                " and encodeActionURL returned: " +
-                               extCtx.encodeActionURL(DIRECTLINK_TRUE_TEST_STRING));
+                               extCtx.encodeActionURL(testString));
       return Constants.TEST_FAILED;
     }
   }
@@ -205,8 +218,11 @@ public class Tests
       "/test.jsp?firstParam=value&javax.portlet.faces.DirectLink=false&anotherParam=value";
     FacesContext ctx = FacesContext.getCurrentInstance();
     ExternalContext extCtx = ctx.getExternalContext();
+    ViewHandler vh = ctx.getApplication().getViewHandler();
+    
+    String testString = new StringBuffer(extCtx.getRequestContextPath()).append(DIRECTLINK_FALSE_TEST_STRING).toString();
     
-    if (!extCtx.encodeActionURL(DIRECTLINK_FALSE_TEST_STRING).contains("javax.portlet.faces.DirectLink"))
+    if (!extCtx.encodeActionURL(testString).contains("javax.portlet.faces.DirectLink"))
     {
       testRunner.setTestResult(true,
                                "encodeActionURL correctly returned an url string without
the javax.portlet.faces.DirectLink parameter when its value was false.");
@@ -216,9 +232,9 @@ public class Tests
     {
       testRunner.setTestResult(false,
                                "encodeActionURL didn't return an url string without the javax.portlet.faces.DirectLink
parameter when its value was false.  Test parameter: " +
-                               DIRECTLINK_FALSE_TEST_STRING +
+                               testString +
                                " and encodeActionURL returned: " +
-                               extCtx.encodeActionURL(DIRECTLINK_FALSE_TEST_STRING));
+                               extCtx.encodeActionURL(testString));
       return Constants.TEST_FAILED;
     }
   }
@@ -311,7 +327,6 @@ public class Tests
         extCtx.encodeActionURL(PORTLET_ACTION_TEST_STRING);
     }
     
-    
     if (bridgeEncoded.equals(portletEncoded))
     {
       testRunner.setTestResult(true,
@@ -1308,25 +1323,20 @@ public class Tests
   {
     testRunner.setTestComplete(true);
 
-    final String URL_TEST_STRING = "/resources/myImage.jpg";
+    final String URL_TEST_STRING = "/myportal/resources/myImage.jpg";
     FacesContext ctx = FacesContext.getCurrentInstance();
     ExternalContext extCtx = ctx.getExternalContext();
 
-    if (extCtx.encodeResourceURL(URL_TEST_STRING).equals(((PortletResponse) extCtx.getResponse()).encodeURL(extCtx.getRequestContextPath()
+
-                                                                                        
                   URL_TEST_STRING).replace("&amp;", "&")))
+    if (extCtx.encodeResourceURL(URL_TEST_STRING).equals(((PortletResponse) extCtx.getResponse()).encodeURL(URL_TEST_STRING).replace("&amp;",
"&")))
     {
       testRunner.setTestResult(true,
-                               "encodeResourceURL correctly encoded a resource referenced
by a context path relative path.");
+                               "encodeResourceURL correctly encoded the resource as an external
(App) resource.");
       return Constants.TEST_SUCCESS;
     }
     else
     {
       testRunner.setTestResult(false,
-                               "encodeResourceURL incorrectly encoded a resource referenced
by a context path relative path.  Expected: " +
-                               ((PortletResponse) extCtx.getResponse()).encodeURL(extCtx.getRequestContextPath()
+
-                                                                                  URL_TEST_STRING)
+
-                               " and encodeResourceURL returned: " +
-                               extCtx.encodeResourceURL(URL_TEST_STRING));
+                               "encodeResourceURL incorrectly encoded a resource as if it
were a reference to a resource within this application.");
       return Constants.TEST_FAILED;
     }
   }
@@ -1344,15 +1354,17 @@ public class Tests
       "/resources/myImage.jpg?myBackLinkParam=";
     FacesContext ctx = FacesContext.getCurrentInstance();
     ExternalContext extCtx = ctx.getExternalContext();
+	ViewHandler vh = ctx.getApplication().getViewHandler();
+
     // compute what the backLink should be
     String actionURL =
-      extCtx.encodeActionURL(ctx.getApplication().getViewHandler().getActionURL(ctx,
-                                                                                ctx.getViewRoot().getViewId()));
+      extCtx.encodeActionURL(vh.getActionURL(ctx, ctx.getViewRoot().getViewId()));
+	String testString = vh.getResourceURL(ctx, URL_BACKLINK_TEST_STRING);
     String verifyString = null;
     try
     {
       verifyString =
-          extCtx.getRequestContextPath() + URL_BACKLINK_VERIFY_STRING +
+          vh.getResourceURL(ctx, URL_BACKLINK_VERIFY_STRING) +
           HTTPUtils.encode(actionURL, "UTF-8");
     }
     catch (UnsupportedEncodingException e)
@@ -1363,7 +1375,7 @@ public class Tests
     }
     // According to bridge rules since string passed in isn't xml strict encoded the result
won't be as well
     // So ensure compares match by stripping from the one generated by the portlet container
(if it exists)
-    if (extCtx.encodeResourceURL(URL_BACKLINK_TEST_STRING).equals(((PortletResponse) extCtx.getResponse()).encodeURL(verifyString).replace("&amp;",
"&")))
+    if (extCtx.encodeResourceURL(testString).equals(((PortletResponse) extCtx.getResponse()).encodeURL(verifyString).replace("&amp;",
"&")))
     {
       testRunner.setTestResult(true,
                                "encodeResourceURL correctly encoded an URL with a backLink.");
@@ -1375,7 +1387,7 @@ public class Tests
                                "encodeResourceURL didn't correctly encoded an URL with a
backLink.  Expected: " +
                                ((PortletResponse) extCtx.getResponse()).encodeURL(verifyString)
+
                                " but encodeResourceURL returned: " +
-                               extCtx.encodeResourceURL(URL_BACKLINK_TEST_STRING));
+                               extCtx.encodeResourceURL(testString));
       return Constants.TEST_FAILED;
     }
   }
@@ -1395,8 +1407,12 @@ public class Tests
 
     FacesContext ctx = FacesContext.getCurrentInstance();
     ExternalContext extCtx = ctx.getExternalContext();
+    ViewHandler vh = ctx.getApplication().getViewHandler();
+    
+    String testString = vh.getResourceURL(ctx, URL_VIEWLINK_TEST_STRING);
+    String verifyString = vh.getResourceURL(ctx, URL_VIEWLINK_VERIFY_STRING);
 
-    if (extCtx.encodeResourceURL(URL_VIEWLINK_TEST_STRING).equals(extCtx.encodeActionURL(URL_VIEWLINK_VERIFY_STRING)))
+    if (extCtx.encodeResourceURL(testString).equals(extCtx.encodeActionURL(verifyString)))
     {
       testRunner.setTestResult(true,
                                "encodeResourceURL correctly encoded a viewLink.");
@@ -1406,9 +1422,9 @@ public class Tests
     {
       testRunner.setTestResult(false,
                                "encodeResourceURL incorrectly encoded a viewLink.  Expected:
" +
-                               extCtx.encodeActionURL(URL_VIEWLINK_VERIFY_STRING) +
+                               extCtx.encodeActionURL(verifyString) +
                                " but encodeResourceURL with the viewLink returned: " +
-                               extCtx.encodeResourceURL(URL_VIEWLINK_TEST_STRING));
+                               extCtx.encodeResourceURL(testString));
       return Constants.TEST_FAILED;
     }
   }
@@ -1426,17 +1442,18 @@ public class Tests
       "/tests/viewLink.jsf?param1=testValue&myBackLinkParam=";
     FacesContext ctx = FacesContext.getCurrentInstance();
     ExternalContext extCtx = ctx.getExternalContext();
+    ViewHandler vh = ctx.getApplication().getViewHandler();
 
     // compute what the backLink should be
     String actionURL =
-      extCtx.encodeActionURL(ctx.getApplication().getViewHandler().getActionURL(ctx,
-                                                                                ctx.getViewRoot().getViewId()));
+      extCtx.encodeActionURL(vh.getActionURL(ctx, ctx.getViewRoot().getViewId()));
+    String testString = vh.getResourceURL(ctx, URL_VIEWLINK_BACKLINK_TEST_STRING);      

     String verifyString = null;
     try
     {
       verifyString =
-          URL_VIEWLINK_BACKLINK_VERIFY_STRING + HTTPUtils.encode(actionURL,
-                                                                  "UTF-8");
+          vh.getResourceURL(ctx, URL_VIEWLINK_BACKLINK_VERIFY_STRING + HTTPUtils.encode(actionURL,
+                                                                  "UTF-8"));
     }
     catch (UnsupportedEncodingException e)
     {
@@ -1445,7 +1462,7 @@ public class Tests
       return Constants.TEST_FAILED;
     }
     // Note:  as we are adding a URL as a parameter make sure its properly URLEncoded --
this causes it to be doubly encoded
-    if (extCtx.encodeResourceURL(URL_VIEWLINK_BACKLINK_TEST_STRING).equals(extCtx.encodeActionURL(verifyString)))
+    if (extCtx.encodeResourceURL(testString).equals(extCtx.encodeActionURL(verifyString)))
     {
       testRunner.setTestResult(true,
                                "encodeResourceURL correctly encoded a viewLink with a BackLink.");
@@ -1457,7 +1474,7 @@ public class Tests
                                "encodeResourceURL incorrectly encoded a viewLink.  Expected:
" +
                                extCtx.encodeActionURL(verifyString) +
                                " but encodeResourceURL with the viewLink returned: " +
-                               extCtx.encodeResourceURL(URL_VIEWLINK_BACKLINK_TEST_STRING));
+                               extCtx.encodeResourceURL(testString));
       return Constants.TEST_FAILED;
     }
   }
@@ -3883,7 +3900,7 @@ public class Tests
     {
       try
       {
-        extCtx.redirect("/tests/NonJSFView.portlet");
+        extCtx.redirect(ctx.getApplication().getViewHandler().getResourceURL(ctx, "/tests/NonJSFView.portlet"));
       }
       catch (IllegalStateException i)
       {
@@ -3916,48 +3933,51 @@ public class Tests
   @BridgeTest(test = "encodeURLEscapingTest")
   public String encodeURLEscapingTest(TestRunnerBean testRunner)
   {
+    // test encodeActionURL preserves the xml escape encoding in the url it returns
     testRunner.setTestComplete(true);
 
     FacesContext ctx = FacesContext.getCurrentInstance();
     ExternalContext extCtx = ctx.getExternalContext();
 
     // test encodeActionURL preserves the xml escape encoding in the url it returns
-    if (isStrictXhtmlEncoded(extCtx.encodeActionURL("/tests/SingleRequestTest.jsp?parm1=a&param2=b")))
+    if (isStrictXhtmlEncoded(extCtx.encodeActionURL(extCtx.getRequestContextPath() + "/tests/SingleRequestTest.jsf?parm1=a&param2=b")))
     {
       testRunner.setTestResult(false,
                                "EncodeActionURL incorrectly returned an url including xml
escaping when the input url wasn't escaped.");
       return Constants.TEST_FAILED;
     }
     
-    if (!isStrictXhtmlEncoded(extCtx.encodeActionURL("/tests/SingleRequestTest.jsp?parm1=a&amp;param2=b")))
+    if (!isStrictXhtmlEncoded(extCtx.encodeActionURL(extCtx.getRequestContextPath() + "/tests/SingleRequestTest.jsf?parm1=a&amp;param2=b")))
     {
       testRunner.setTestResult(false,
                                "EncodeActionURL incorrectly returned an url without xml escaping
when the input url was escaped.");
       return Constants.TEST_FAILED;
     }
     
-    if (isStrictXhtmlEncoded(extCtx.encodeActionURL("/tests/SingleRequestTest.jsp")))
+    if (isStrictXhtmlEncoded(extCtx.encodeActionURL(extCtx.getRequestContextPath() + "/tests/SingleRequestTest.jsf")))
     {
       testRunner.setTestResult(false,
                                "EncodeActionURL incorrectly returned an url including xml
escaping when the input url contained no indication (no query string).");
       return Constants.TEST_FAILED;
     }
     
-    if (isStrictXhtmlEncoded(extCtx.encodeResourceURL("/tests/SingleRequestTest.jsp?parm1=a&param2=b")))
+    ViewHandler vh = ctx.getApplication().getViewHandler();
+    
+    if (isStrictXhtmlEncoded(extCtx.encodeResourceURL(vh.getResourceURL(ctx, "/tests/SingleRequestTest.jsf?parm1=a&param2=b"))))
     {
       testRunner.setTestResult(false,
                                "EncodeResourceURL incorrectly returned an url including xml
escaping when the input url wasn't escaped.");
       return Constants.TEST_FAILED;
     }
     
-    if (!isStrictXhtmlEncoded(extCtx.encodeResourceURL("/tests/SingleRequestTest.jsp?parm1=a&amp;param2=b")))
+    if (!isStrictXhtmlEncoded(extCtx.encodeResourceURL(vh.getResourceURL(ctx, "/tests/SingleRequestTest.jsf?parm1=a&amp;param2=b"))))
     {
       testRunner.setTestResult(false,
                                "EncodeResourceURL incorrectly returned an url without xml
escaping when the input url was escaped.");
       return Constants.TEST_FAILED;
     }
-    
-    if (isStrictXhtmlEncoded(extCtx.encodeResourceURL("/tests/SingleRequestTest.jsp")))
+  
+    if (isStrictXhtmlEncoded(extCtx.encodeResourceURL(vh.getResourceURL(ctx, "/tests/SingleRequestTest.jsf"))))
 
     {
       testRunner.setTestResult(false,
                                "EncodeResourceURL incorrectly returned an url including xml
escaping when the input url contained no indication (no query string).");
@@ -3970,6 +3990,7 @@ public class Tests
                               "encodeActionURL and encodeResourceURL both correctly xml escaped
urls it should and didn't xml escape urls it shouldn't");
     return Constants.TEST_SUCCESS;
 
+
   }
   
   private boolean isStrictXhtmlEncoded(String url)



Mime
View raw message