portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asfgr...@apache.org
Subject [08/22] portals-pluto git commit: PLUTO-733 Add Path Info Demo test
Date Thu, 25 Oct 2018 20:19:40 GMT
PLUTO-733 Add Path Info Demo test


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/fb03f2f5
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/fb03f2f5
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/fb03f2f5

Branch: refs/heads/master
Commit: fb03f2f59a5070be2a162ae9b3d3bc9e1e277d06
Parents: 3dcd223
Author: Kyle Stiemann <stiemannkj1@gmail.com>
Authored: Thu Oct 11 14:51:53 2018 -0400
Committer: Neil Griffin <neil.griffin.scm@gmail.com>
Committed: Thu Oct 25 15:48:30 2018 -0400

----------------------------------------------------------------------
 .../org/apache/portals/samples/PathDisplay.java |  8 ++-
 .../apache/portals/samples/PathInfoPortlet.java |  5 +-
 .../src/main/webapp/WEB-INF/jsp/pathinfo.jsp    |  2 +-
 .../demo/integration/test/PathInfoDemoIT.java   | 61 ++++++++++++++++++++
 4 files changed, 72 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fb03f2f5/PortletV3AnnotatedDemo/src/main/java/org/apache/portals/samples/PathDisplay.java
----------------------------------------------------------------------
diff --git a/PortletV3AnnotatedDemo/src/main/java/org/apache/portals/samples/PathDisplay.java
b/PortletV3AnnotatedDemo/src/main/java/org/apache/portals/samples/PathDisplay.java
index a59dc35..d41dfa5 100644
--- a/PortletV3AnnotatedDemo/src/main/java/org/apache/portals/samples/PathDisplay.java
+++ b/PortletV3AnnotatedDemo/src/main/java/org/apache/portals/samples/PathDisplay.java
@@ -58,6 +58,7 @@ public class PathDisplay {
    private String method_path_xlated;
    private String method_query_string;
    
+   private String title;
    private String type;
    private String caller;
    private boolean isAsyncSupported = false;
@@ -68,7 +69,7 @@ public class PathDisplay {
 
    public PathDisplay(HttpServletRequest req, String caller) {
       this.caller = caller;
-      
+      title = (String) req.getAttribute("title");
       async_request_uri = (String) req.getAttribute("javax.servlet.async.request_uri");
       async_context_path = (String) req.getAttribute("javax.servlet.async.context_path");
       async_servlet_path = (String) req.getAttribute("javax.servlet.async.servlet_path");
@@ -105,7 +106,7 @@ public class PathDisplay {
 
    public PathDisplay(PortletRequest req, String caller) {
       this.caller = caller;
-      
+      title = (String) req.getAttribute("title");
       async_request_uri = (String) req.getAttribute("javax.servlet.async.request_uri");
       async_context_path = (String) req.getAttribute("javax.servlet.async.context_path");
       async_servlet_path = (String) req.getAttribute("javax.servlet.async.servlet_path");
@@ -155,6 +156,9 @@ public class PathDisplay {
 
    public String toMarkup() {
       StringBuilder txt = new StringBuilder(128);
+      if (title != null) {
+         txt.append("<p id=\"path_info_title\">").append(title).append("</p>");
+      }
       txt.append("<hr>");
       txt.append("<h5>").append(caller).append(" Path Info:</h5>");
       txt.append("<table border='0' cellpadding='0'><tr>");

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fb03f2f5/PortletV3AnnotatedDemo/src/main/java/org/apache/portals/samples/PathInfoPortlet.java
----------------------------------------------------------------------
diff --git a/PortletV3AnnotatedDemo/src/main/java/org/apache/portals/samples/PathInfoPortlet.java
b/PortletV3AnnotatedDemo/src/main/java/org/apache/portals/samples/PathInfoPortlet.java
index e28c371..cca2eee 100644
--- a/PortletV3AnnotatedDemo/src/main/java/org/apache/portals/samples/PathInfoPortlet.java
+++ b/PortletV3AnnotatedDemo/src/main/java/org/apache/portals/samples/PathInfoPortlet.java
@@ -129,13 +129,14 @@ public class PathInfoPortlet {
          if (op.equals("fwd")) {
             RenderLink renlink = new RenderLink("back", cntlurl);
             req.setAttribute("renderLink", renlink);
+            req.setAttribute("title", "Forwarded to Servlet by render method.");
             PortletRequestDispatcher rd = pcfg.getPortletContext().getRequestDispatcher(SERVLET);
             rd.forward(req, resp);
             return;
          } else if (op.equals("fwdjsp")) {
             RenderLink renlink = new RenderLink("back", cntlurl);
             req.setAttribute("renderLink", renlink);
-            req.setAttribute("jsptitle", "Forwarded by render method.");
+            req.setAttribute("jsptitle", "Forwarded to JSP by render method.");
             PortletRequestDispatcher rd = pcfg.getPortletContext().getRequestDispatcher(JSP);
             rd.forward(req, resp);
             return;
@@ -144,6 +145,7 @@ public class PathInfoPortlet {
          writer.append("<div class='infobox'>");
 
          if (op.equals("nested")) {
+            req.setAttribute("title", "Included nested in Portlet -> Servlet -> JSP.");
             PathDisplay pd = new PathDisplay(req, "Render Method (Before)");
             writer.write(pd.toMarkup());
             PortletRequestDispatcher rd = pcfg.getPortletContext().getRequestDispatcher(SERVLET);
@@ -198,6 +200,7 @@ public class PathInfoPortlet {
             writer.append("</script>\n");
          } else if (op.equals("named")) {
             writer.write("Including named servlet:");
+            req.setAttribute("title", "Included named Servlet.");
             PortletRequestDispatcher rd = req.getPortletContext().getNamedDispatcher(NAME);
             rd.include(req, resp);
          } else {

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fb03f2f5/PortletV3AnnotatedDemo/src/main/webapp/WEB-INF/jsp/pathinfo.jsp
----------------------------------------------------------------------
diff --git a/PortletV3AnnotatedDemo/src/main/webapp/WEB-INF/jsp/pathinfo.jsp b/PortletV3AnnotatedDemo/src/main/webapp/WEB-INF/jsp/pathinfo.jsp
index 4d1d4f3..c61fac3 100644
--- a/PortletV3AnnotatedDemo/src/main/webapp/WEB-INF/jsp/pathinfo.jsp
+++ b/PortletV3AnnotatedDemo/src/main/webapp/WEB-INF/jsp/pathinfo.jsp
@@ -25,7 +25,7 @@ limitations under the License.
 <portlet:defineObjects />
 
 <div class='bluebox'>
-<p>${jsptitle}</p>
+<p id="path_info_title">${jsptitle}</p>
 <%
 
 RenderLink rl = (RenderLink) request.getAttribute("renderLink");

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fb03f2f5/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/PathInfoDemoIT.java
----------------------------------------------------------------------
diff --git a/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/PathInfoDemoIT.java
b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/PathInfoDemoIT.java
new file mode 100644
index 0000000..146ecda
--- /dev/null
+++ b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/PathInfoDemoIT.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2000-2018 Liferay, Inc. All rights reserved.
+ *
+ * Licensed 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 org.apache.portals.pluto.demo.integration.test;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import static org.apache.portals.pluto.demo.integration.test.Util.*;
+import static org.openqa.selenium.support.ui.ExpectedConditions.*;
+
+
+/**
+ *
+ * @author Kyle Stiemann
+ */
+public class PathInfoDemoIT extends DemoTestDriver{
+
+   private static final List<String> EXPECTED_TITLES = unmodifiableList(
+         "Included by resource method.",
+         "Forwarded to Servlet by render method.",
+         "Forwarded to JSP by render method.",
+         "Included by render method.",
+         "Included nested in Portlet -> Servlet -> JSP.",
+         "Included named Servlet.");
+
+   @Test
+   public void testPathInfoDemo() {
+      navigateToPage("Async Tests");
+      By linksByXpath = By.xpath("//h3[text()='Path Info Portlet']/parent::div[@class='body']//a");
+      waitingAsserter.waitFor(visibilityOfElementLocated(linksByXpath));
+      List<WebElement> links = driver.findElements(linksByXpath);
+      List<String> urls = new ArrayList<>();
+
+      for (WebElement link : links) {
+         urls.add(link.getAttribute("href"));
+      }
+
+      for (int i = 0; i < urls.size(); i++) {
+         driver.get(urls.get(i));
+         By titleByXpath = By.xpath("//p[contains(@id,'path_info_title')]");
+         waitingAsserter.assertTrue(and(visibilityOfElementLocated(titleByXpath),
+               textToBe(titleByXpath, EXPECTED_TITLES.get(i))));
+      }
+   }
+}


Mime
View raw message