portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asfgr...@apache.org
Subject [11/22] portals-pluto git commit: PLUTO-733 Add Dependency Portlet Demo test
Date Thu, 25 Oct 2018 20:19:43 GMT
PLUTO-733 Add Dependency Portlet 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/429e011b
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/429e011b
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/429e011b

Branch: refs/heads/master
Commit: 429e011b1dd946e55835f334e7d54005e8a3b33b
Parents: de7db48
Author: Kyle Stiemann <stiemannkj1@gmail.com>
Authored: Thu Oct 11 11:37:31 2018 -0400
Committer: Neil Griffin <neil.griffin.scm@gmail.com>
Committed: Thu Oct 25 15:48:30 2018 -0400

----------------------------------------------------------------------
 .../java/basic/portlet/DependencyPortlet.java   |  4 +-
 .../webapp/WEB-INF/jsp/dependencyDialog.jsp     |  2 +-
 demo-integration-tests/pom.xml                  |  5 ++
 .../demo/integration/test/DependencyDemoIT.java | 72 ++++++++++++++++++++
 4 files changed, 80 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/429e011b/PortletV3Demo/src/main/java/basic/portlet/DependencyPortlet.java
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/java/basic/portlet/DependencyPortlet.java b/PortletV3Demo/src/main/java/basic/portlet/DependencyPortlet.java
index eee8ae3..f30ce4d 100644
--- a/PortletV3Demo/src/main/java/basic/portlet/DependencyPortlet.java
+++ b/PortletV3Demo/src/main/java/basic/portlet/DependencyPortlet.java
@@ -81,7 +81,7 @@ public class DependencyPortlet {
 
       String vers = req.getRenderParameters().getValue(PARAM_VER);
       if (vers == null) {
-         resp.addDependency("jQuery", "com.jquery", "1.23.3");
+         resp.addDependency("jQuery", "com.jquery", PARAM_VER_1);
       } else {
          switch (vers) {
          case PARAM_VER_2:
@@ -91,7 +91,7 @@ public class DependencyPortlet {
             resp.addDependency("jQuery", "com.jquery", PARAM_VER_3, DEP_VER_3);
             break;
          default:
-            resp.addDependency("jQuery", "com.jquery", "1.23.3");
+            resp.addDependency("jQuery", "com.jquery", PARAM_VER_1);
          }
       }
       

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/429e011b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/dependencyDialog.jsp
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/dependencyDialog.jsp b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/dependencyDialog.jsp
index 495ed8d..fc3d780 100644
--- a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/dependencyDialog.jsp
+++ b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/dependencyDialog.jsp
@@ -30,7 +30,7 @@ limitations under the License.
 
    jQuery version:
    </td><td>
-   <input type='radio' name='<%=PARAM_VER%>' value='<%=PARAM_VER_1%>' ${version
== "1.12.3" ? "checked" : "" } > <%=PARAM_VER_1%>
+   <input type='radio' name='<%=PARAM_VER%>' value='<%=PARAM_VER_1%>' ${version
== "1.12.3" ? "checked" : "" } > default
    </td><td>
    <input type='radio' name='<%=PARAM_VER%>' value='<%=PARAM_VER_2%>' ${version
== "2.2.3" ? "checked" : "" } > <%=PARAM_VER_2%>
    </td><td>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/429e011b/demo-integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/demo-integration-tests/pom.xml b/demo-integration-tests/pom.xml
index 9cee29a..49f942c 100644
--- a/demo-integration-tests/pom.xml
+++ b/demo-integration-tests/pom.xml
@@ -49,6 +49,7 @@
 
       <!-- test.context.base context string used when addressing test pages. Used by module
stylesheet -->
       <test.context.base>pluto/portal/</test.context.base>
+      <test.dependency.portlet.default.jquery.version>1.12.3</test.dependency.portlet.default.jquery.version>
 
       <!-- This variable is used by the test driver to determine how test
       page links are to be found. Values: generateURLs the driver generates URLs
@@ -330,6 +331,10 @@
                                  <name>test.timeout</name>
                                  <value>${test.timeout}</value>
                               </property>
+                              <property>
+                                 <name>test.dependency.portlet.default.jquery.version</name>
+                                 <value>${test.dependency.portlet.default.jquery.version}</value>
+                              </property>
                            </systemProperties>
                         </configuration>
                      </execution>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/429e011b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/DependencyDemoIT.java
----------------------------------------------------------------------
diff --git a/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/DependencyDemoIT.java
b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/DependencyDemoIT.java
new file mode 100644
index 0000000..ac749f5
--- /dev/null
+++ b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/DependencyDemoIT.java
@@ -0,0 +1,72 @@
+/**
+ * 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.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 DependencyDemoIT extends DemoTestDriver{
+
+   @Test
+   public void testDependencyDemo() {
+      driver.get(baseUrl + "Dependencies");
+      assertBadDependencyStringThrewException("String: Hi there!",
+            "Exception: java.lang.IllegalArgumentException:");
+      assertBadDependencyStringThrewException("String: <script dffsfssf",
+            "Exception: java.lang.IllegalArgumentException:");
+      assertBadDependencyStringThrewException("String: <link href='hi'>bad string<link
href='bye'>",
+            "Exception: java.lang.IllegalArgumentException:");
+      assertBadDependencyStringThrewException("String: <p>bad head tag</p>",
+            "Exception: java.lang.IllegalArgumentException:");
+      List<WebElement> versionRadioButtons = driver.findElements(By.xpath("//input[@name='version']"));
+
+      for (int i = 0; i < versionRadioButtons.size(); i++) {
+
+         String expectedVersion = versionRadioButtons.get(i).getAttribute("value");
+
+         if (i == 0) {
+            expectedVersion = System.getProperty("test.dependency.portlet.default.jquery.version");
+         }
+
+         versionRadioButtons.get(i).click();
+         clickElement(driver, waitingAsserter,
+               By.xpath("//button[contains(text(),'render with selected version')]"));
+         clickElement(driver, waitingAsserter, "button", "Pluto_PortletV3Demo_DependencyPortlet",
"button");
+         By versionTextByXpath = By.xpath(getXpath("p", "Pluto_PortletV3Demo_DependencyPortlet",
"fadeText") +
+               "[text()]");
+         waitingAsserter.assertTrue(and(visibilityOfElementLocated(versionTextByXpath),
+               textToBe(versionTextByXpath, "jQuery version: " + expectedVersion)));
+
+         versionRadioButtons = driver.findElements(By.xpath("//input[@name='version']"));
+      }
+   }
+
+   private void assertBadDependencyStringThrewException(String badDependencyString, String
expectedExceptionString) {
+      By badDepencencyStringByXpath = By.xpath("//p[contains(text(),\"" + badDependencyString
+ "\")]");
+      waitingAsserter.assertTrue(and(visibilityOfElementLocated(badDepencencyStringByXpath),
+            textToBePresentInElementLocated(badDepencencyStringByXpath, expectedExceptionString)));
+   }
+}


Mime
View raw message