Author: mageshbk(a)jboss.com
Date: 2009-05-13 16:59:35 -0400 (Wed, 13 May 2009)
New Revision: 13365
Added:
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/apps/httpHeader-portlet.war
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/src/org/jboss/portal/test/selenium/core/
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/src/org/jboss/portal/test/selenium/core/HttpHeaderTestCase.java
Modified:
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/build.xml
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/testng.xml
Log:
[JBEPP-73] - Added testcase
Added:
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/apps/httpHeader-portlet.war
===================================================================
(Binary files differ)
Property changes on:
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/apps/httpHeader-portlet.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/build.xml
===================================================================
---
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/build.xml 2009-05-13
20:54:47 UTC (rev 13364)
+++
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/build.xml 2009-05-13
20:59:35 UTC (rev 13365)
@@ -2,7 +2,7 @@
<property environment="env" />
- <property name="workspace" location="build.xml" />
+ <property name="workspace" location="${basedir}" />
<property name="java.home" location="${env.JAVA_HOME}" />
<property name="suitename" location="testng-files" />
@@ -92,6 +92,8 @@
<target name="copyApps">
<echo message="Copying userInterceptor portlet into the ${portal.instance}
server" />
<copy file="apps/userDetail-portlet.war"
tofile="${jboss.home}/server/${portal.instance}/deploy/userDetail-portlet.war"
/>
+ <echo message="Copying httpHeader portlet into the ${portal.instance}
server" />
+ <copy file="apps/httpHeader-portlet.war"
tofile="${jboss.home}/server/${portal.instance}/deploy/httpHeader-portlet.war"
/>
</target>
<target name="clean">
@@ -99,6 +101,11 @@
<delete dir="${test.build.dir}" />
</target>
+ <target name="undeployApps">
+ <delete
file="${jboss.home}/server/${portal.instance}/deploy/userDetail-portlet.war"
/>
+ <delete
file="${jboss.home}/server/${portal.instance}/deploy/httpHeader-portlet.war"
/>
+ </target>
+
<server:config javaHome="${java.home}"
jbossHome="${jboss.home}">
<server name="${portal.instance}" host="${node0}">
<!-- jvmarg value="${jpda.cmdline}" / -->
@@ -112,7 +119,7 @@
<target name="cleanup">
<echo message="Cleaning up..." />
<antcall target="stop-src" />
-
+ <antcall target="undeployApps" />
</target>
<target name="run-and-build" depends="init, compile,
run-src">
Added:
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/src/org/jboss/portal/test/selenium/core/HttpHeaderTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/src/org/jboss/portal/test/selenium/core/HttpHeaderTestCase.java
(rev 0)
+++
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/src/org/jboss/portal/test/selenium/core/HttpHeaderTestCase.java 2009-05-13
20:59:35 UTC (rev 13365)
@@ -0,0 +1,78 @@
+package org.jboss.portal.test.selenium.core;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:mageshbk@jboss.com">Magesh Kumar B</a>
+ */
+@Test(groups = { "portlet_http_header" }, enabled = true, description =
"Checking http headers and cookies of portlet responses.")
+public class HttpHeaderTestCase extends JBossPortalSeleniumTestCase
+{
+ @Test(enabled = true, description = "Checking http headers of portlet
responses.")
+ public void testHttpHeaders()
+ {
+ try
+ {
+ HttpURLConnection connection;
+ Map<String,List<String>> headers;
+ connection = (HttpURLConnection)new
URL("http://localhost:8080/portal/portal/HttpHeaderPortal/default/HttpHeaderPortletWindow2?action=1").openConnection();
+ headers = connection.getHeaderFields();
+ //System.out.println(headers);
+ List<String> others1 = headers.get("Foo");
+ List<String> others2 = headers.get("Foo2");
+ List<String> others3 = headers.get("partialRefresh");
+ List<String> others4 = headers.get("Expires");
+ List<String> others5 = headers.get("Pragma");
+ List<String> others6 = headers.get("Cache-Control");
+
+ Assert.assertTrue(others1 == null, "Expected no Foo as it is set in
processAction!");
+ Assert.assertTrue(others2.size() == 2, "Expected 2 Foo2!");
+ Assert.assertTrue(others3.size() == 1, "Expected 1 partialRefresh!");
+ Assert.assertTrue(others4.size() == 1, "Expected 1 Expires!");
+ Assert.assertTrue(others5.size() == 1, "Expected 1 Pragma!");
+ Assert.assertTrue(others6.size() == 1, "Expected 1 Cache-Control!");
+
+ Assert.assertTrue(others2.get(0).equals("BarView2")
+ && others2.get(1).equals("BarView1"), "Foo2 not
found!");
+ Assert.assertTrue(others3.get(0).equals("true"), "partialRefresh
not found!");
+ Assert.assertTrue(others4.get(0).equals("0"), "Expires not
found!");
+ Assert.assertTrue(others5.get(0).equals("no-cache"), "Pragma not
found!");
+ Assert.assertTrue(others6.get(0).equals("private, no-store, no-cache,
must-revalidate, post-check=0, pre-check=0, max-age=0, s-maxage=0"),
+ "Cache-Control not
found!");
+ connection.disconnect();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Test(enabled = true, description = "Checking cookies of portlet
responses.")
+ public void testHttpCookies()
+ {
+ logoutIfPossible();
+ login("admin", "admin");
+ selenium.open("portal/HttpHeaderPortal");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ String cookie = selenium.getCookie();
+ // This is set in doView()
+ Assert.assertTrue(cookie.indexOf("MyIdea=1.1") >= 0,"Custom
Cookie set in doView not found!");
+
+ selenium.click("link=doAction");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ cookie = selenium.getCookie();
+ // Cookie order is unknown, but all cookies are set properly.
+ // Sometimes it is set multiple times too...
+ Assert.assertTrue(cookie.indexOf("MyIdea=1.1") >= 0
+ && cookie.indexOf("MyIdea2=2.0") >= 0,"Custom
Cookies set in processAction not found!");
+ logout();
+ }
+}
Modified:
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/testng.xml
===================================================================
---
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/testng.xml 2009-05-13
20:54:47 UTC (rev 13364)
+++
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-73/testsuite/ui-tests/testng.xml 2009-05-13
20:59:35 UTC (rev 13365)
@@ -52,6 +52,12 @@
<class
name="org.jboss.portal.test.selenium.cms.CMSFileUploadTestCase"></class></classes>
</test>
+ <test name="org.jboss.portal.test.selenium.core.HttpHeaderTestCase"
+ verbose="2" annotations="JDK">
+ <classes>
+ <class
name="org.jboss.portal.test.selenium.core.HttpHeaderTestCase"></class></classes>
+ </test>
+
<test name="org.jboss.portal.test.selenium.DashboardTestCase"
verbose="2" annotations="JDK">
<classes>