portals-pluto-scm mailing list archives

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

Branch: refs/heads/master
Commit: 60284928355e0a8d4e41981a8097b897b9c6aea9
Parents: 9341939
Author: Kyle Stiemann <stiemannkj1@gmail.com>
Authored: Fri Oct 12 16:58:02 2018 -0400
Committer: Neil Griffin <neil.griffin.scm@gmail.com>
Committed: Thu Oct 25 15:48:31 2018 -0400

----------------------------------------------------------------------
 .../src/main/webapp/WEB-INF/jsp/view-rdp.jsp    |  2 +-
 .../demo/integration/test/ChatRoomDemoIT.java   | 10 ++--
 .../demo/integration/test/PortletHubDemoIT.java | 23 ---------
 .../demo/integration/test/RedirectDemoIT.java   | 52 ++++++++++++++++++++
 .../pluto/demo/integration/test/Util.java       | 27 ++++++++++
 5 files changed, 87 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60284928/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-rdp.jsp
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-rdp.jsp b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-rdp.jsp
index 7e8d59b..4391f91 100644
--- a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-rdp.jsp
+++ b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-rdp.jsp
@@ -56,7 +56,7 @@ redirect.
    </td></tr><tr><td>
    Enter URL:
    </td><td colspan=3>
-   <input id='<portlet:namespace/>-msg' name='<%=PARAM_URL_INPUT%>' type='text'
value='' size='50' maxlength='50'>
+   <input id='<portlet:namespace/>-msg' name='<%=PARAM_URL_INPUT%>' type='text'
value=''>
    </td></tr><tr><td>
    <INPUT id ='<portlet:namespace/>-send' VALUE='redirect' TYPE='submit'>
    </td></tr></table>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60284928/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/ChatRoomDemoIT.java
----------------------------------------------------------------------
diff --git a/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/ChatRoomDemoIT.java
b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/ChatRoomDemoIT.java
index a2c1d51..fa963df 100644
--- a/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/ChatRoomDemoIT.java
+++ b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/ChatRoomDemoIT.java
@@ -30,12 +30,16 @@ import static org.openqa.selenium.support.ui.ExpectedConditions.*;
  * @author Kyle Stiemann
  */
 public class ChatRoomDemoIT extends DemoTestDriver {
+
+   // Public Constants
+   public static final String CHAT_ROOM_DEMO_URL = baseUrl + Util.encodeURL("Chat Room Demo");
+
+   // Private Constants
    private static final String CHAT_ROOM_PORTLET_NAMESPACE = "Pluto_chatRoomDemo_BeanPortletDemo";
 
    @Test
    public void testChatRoomDemos() throws UnsupportedEncodingException {
-      String chatDemoURL = baseUrl + Util.encodeURL("Chat Room Demo");
-      driver.get(chatDemoURL);
+      driver.get(CHAT_ROOM_DEMO_URL);
 
       // 1. Clear any previous chat history.
       clickElement(driver, waitingAsserter, "input", CHAT_ROOM_PORTLET_NAMESPACE, "clear");
@@ -45,7 +49,7 @@ public class ChatRoomDemoIT extends DemoTestDriver {
 
       // 2. Open a new window/tab to the same page.
       String originalWindowHandle = driver.getWindowHandle();
-      executeScript(driver, "window.open('" + chatDemoURL + "');");
+      executeScript(driver, "window.open('" + CHAT_ROOM_DEMO_URL + "');");
 
       // 3. In the current window/tab, add a user named "me".
       // 4. Verify that an image appears for the user.

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60284928/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/PortletHubDemoIT.java
----------------------------------------------------------------------
diff --git a/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/PortletHubDemoIT.java
b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/PortletHubDemoIT.java
index 45155bc..070f2d9 100644
--- a/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/PortletHubDemoIT.java
+++ b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/PortletHubDemoIT.java
@@ -37,8 +37,6 @@ import static org.openqa.selenium.support.ui.ExpectedConditions.*;
  * @author Kyle Stiemann
  */
 public class PortletHubDemoIT extends DemoTestDriver {
-
-   private static final int COLOR_HEX_STRING_LENGTH = 2;
    private static final String COLOR_SELECTION_PORTLET_NAMESPACE = "Pluto_PortletHubDemo_PH_ColorSelPortlet";
    private static final String IMAGE_SELECTION_PORTLET_NAMESPACE = "Pluto_PortletHubDemo_ImageSelPortlet";
    private static final List<String> IMAGE_OPTIONS = Util.unmodifiableList("golfball",
"baseball", "fussball");
@@ -176,27 +174,6 @@ public class PortletHubDemoIT extends DemoTestDriver {
                   attributeContains(messageOutputByXpath, "style", "color: " + colorCombo.getCSS_RGBString()
+ ";"))));
    }
 
-   private static ExpectedCondition<Boolean> backgroundColor(By locator, int red, int
green, int blue) {
-
-      String colorCode = "#" +
-            getHexString(red, COLOR_HEX_STRING_LENGTH) +
-            getHexString(green, COLOR_HEX_STRING_LENGTH) +
-            getHexString(blue, COLOR_HEX_STRING_LENGTH);
-
-      return and(visibilityOfElementLocated(locator),
-            or(attributeContains(locator, "style", "background-color:" + colorCode + ";"),
-                  attributeContains(locator, "style",
-                        "background-color: rgb(" + red + ", " + green + ", " + blue + ");")));
-   }
-
-   private static String getHexString(int toHexValue, int stringLength) {
-      return getZeroPaddedString(Integer.toHexString(toHexValue), stringLength);
-   }
-
-   private static String getZeroPaddedString(String string, int stringLength) {
-      return String.format("%" + stringLength + "s", string).replace(" ", "0");
-   }
-
    private void handleColorCheckbox(String colorName, boolean colorSelected) {
 
       WebElement colorCheckbox =

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60284928/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/RedirectDemoIT.java
----------------------------------------------------------------------
diff --git a/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/RedirectDemoIT.java
b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/RedirectDemoIT.java
new file mode 100644
index 0000000..95b4b54
--- /dev/null
+++ b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/RedirectDemoIT.java
@@ -0,0 +1,52 @@
+/*  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 org.apache.portals.pluto.demo.integration.test;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+import static org.apache.portals.pluto.demo.integration.test.Util.*;
+import static org.openqa.selenium.support.ui.ExpectedConditions.*;
+
+
+/**
+ *
+ * @author Kyle Stiemann
+ */
+public class RedirectDemoIT extends DemoTestDriver {
+
+   @Test
+   public void testRedirectDemo() {
+      navigateToPage("V3.0 Misc Tests - redirect");
+      int red = 0xFF;
+      int green = 0x00;
+      int blue = 0x00;
+
+      String color = getColorCode(red, green, blue);
+      sendKeysToElement(driver, waitingAsserter, "//input[@name='color'][@type='text']",
color);
+      clickElement(driver, waitingAsserter, "//input[@value='redirect'][@type='submit']");
+      waitingAsserter.assertTrue(backgroundColor(By.xpath("//h3[text()='V3 Redirect Portlet']/.."),
red, green, blue));
+      sendKeysToElement(driver, waitingAsserter, "//input[@name='url'][@type='text']",
+            ChatRoomDemoIT.CHAT_ROOM_DEMO_URL);
+      clickElement(driver, waitingAsserter, "//input[@value='redirect'][@type='submit']");
+      waitingAsserter.assertTrue(visibilityOfElementLocated(By.xpath(
+            "//h3[contains(text(),'Hello')][contains(text(),'World')][contains(text(),'!!')]")));
+   }
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/60284928/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/Util.java
----------------------------------------------------------------------
diff --git a/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/Util.java
b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/Util.java
index 5199e09..57d809b 100644
--- a/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/Util.java
+++ b/demo-integration-tests/src/test/java/org/apache/portals/pluto/demo/integration/test/Util.java
@@ -35,6 +35,7 @@ import static org.openqa.selenium.support.ui.ExpectedConditions.*;
  * @author Kyle Stiemann
  */
 public final class Util {
+   private static final int COLOR_HEX_STRING_LENGTH = 2;
 
    private Util() {
       throw new AssertionError();
@@ -54,6 +55,18 @@ public final class Util {
       return ((JavascriptExecutor)webDriver).executeScript(script, arguments);
    }
 
+   public static String getColorCode(int red, int green, int blue) {
+
+      return "#" +
+            getHexString(red, COLOR_HEX_STRING_LENGTH) +
+            getHexString(green, COLOR_HEX_STRING_LENGTH) +
+            getHexString(blue, COLOR_HEX_STRING_LENGTH);
+   }
+
+   public static String getZeroPaddedString(String string, int stringLength) {
+      return String.format("%" + stringLength + "s", string).replace(" ", "0");
+   }
+
    public static <T> List<T> unmodifiableList(T... items) {
       return Collections.unmodifiableList(Arrays.asList(items));
    }
@@ -63,6 +76,16 @@ public final class Util {
       return or(attributeToBe(locator, attributeName, null), attributeToBe(locator, attributeName,
""));
    }
 
+   public static ExpectedCondition<Boolean> backgroundColor(By locator, int red, int
green, int blue) {
+
+      String colorCode = getColorCode(red, green, blue);
+
+      return and(visibilityOfElementLocated(locator),
+            or(attributeContains(locator, "style", "background-color:" + colorCode + ";"),
+                  attributeContains(locator, "style",
+                        "background-color: rgb(" + red + ", " + green + ", " + blue + ");")));
+   }
+
    public static ExpectedCondition<Boolean> elementNotPresentOrNotVisible(By locator)
{
       return or(not(presenceOfAllElementsLocatedBy(locator)), invisibilityOfElementLocated(locator));
    }
@@ -148,4 +171,8 @@ public final class Util {
          boolean clearBeforeSendingKeys, String elementXpath, CharSequence... keys) {
       sendKeysToElement(webDriver, waitingAsserter, clearBeforeSendingKeys, By.xpath(elementXpath),
keys);
    }
+
+   private static String getHexString(int toHexValue, int stringLength) {
+      return getZeroPaddedString(Integer.toHexString(toHexValue), stringLength);
+   }
 }


Mime
View raw message