Author: jpapouse
Date: 2011-09-15 07:59:57 -0400 (Thu, 15 Sep 2011)
New Revision: 22721
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementA.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementLink.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementScript.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/AbstractMediaOutputTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestImagePng.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestTextHtml.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestTextPlain.java
Log:
RFPL-1444 (media output): tests for other elements
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/AbstractMediaOutputTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/AbstractMediaOutputTest.java 2011-09-15
11:54:05 UTC (rev 22720)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/AbstractMediaOutputTest.java 2011-09-15
11:59:57 UTC (rev 22721)
@@ -21,6 +21,14 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.a4jMediaOutput;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
@@ -31,4 +39,22 @@
protected static final JQueryLocator MEDIA_OUTPUT =
pjq("*[id$=mediaOutput]");
+ protected String getTextContentByUrlAttribute(AttributeLocator urlAttribute) throws
IOException {
+ URL url = buildUrl(contextRoot, selenium.getAttribute(urlAttribute));
+ BufferedReader input = null;
+ StringBuilder foundContent = new StringBuilder();
+ try {
+ input = new BufferedReader(new InputStreamReader(url.openStream()));
+ String line;
+ while((line = input.readLine()) != null) {
+ foundContent.append(line);
+ }
+ } finally {
+ if (input != null) {
+ input.close();
+ }
+ }
+ return foundContent.toString();
+ }
+
}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementA.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementA.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementA.java 2011-09-15
11:59:57 UTC (rev 22721)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.a4jMediaOutput;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.test.selenium.locator.Attribute;
+import org.richfaces.tests.metamer.bean.a4j.A4JMediaOutputBean;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jMediaOutput/elementA.xhtml
+ *
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class TestElementA extends AbstractMediaOutputTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jMediaOutput/elementA.xhtml");
+ }
+
+ @Test
+ public void init() throws IOException {
+ assertEquals(selenium.getText(MEDIA_OUTPUT), "This is a link",
"The link text doesn't match.");
+ assertTrue(
+
getTextContentByUrlAttribute(MEDIA_OUTPUT.getAttribute(Attribute.HREF)).contains(A4JMediaOutputBean.HTML_TEXT),
+ "Target HTML page doesn't match."
+ );
+ }
+
+
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementLink.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementLink.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementLink.java 2011-09-15
11:59:57 UTC (rev 22721)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.a4jMediaOutput;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.css.CssProperty;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jMediaOutput/elementLink.xhtml
+ *
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class TestElementLink extends AbstractMediaOutputTest {
+
+ private static final JQueryLocator MARKED_TEXT =
pjq("*#mediaOutputMarked");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jMediaOutput/elementLink.xhtml");
+ }
+
+ @Test
+ public void init() {
+ assertEquals(selenium.getStyle(MARKED_TEXT, CssProperty.COLOR), "rgb(255, 0,
0)", "The marked text should be red.");
+ }
+
+
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementScript.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementScript.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestElementScript.java 2011-09-15
11:59:57 UTC (rev 22721)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.a4jMediaOutput;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URL;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jMediaOutput/elementScript.xhtml
+ *
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class TestElementScript extends AbstractMediaOutputTest {
+
+ private static final JQueryLocator JAVASCRIPT_TEXT =
pjq("*#mediaOutputJavascriptText");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jMediaOutput/elementScript.xhtml");
+ }
+
+ @Test
+ public void init() {
+ assertTrue(selenium.isElementPresent(JAVASCRIPT_TEXT), "The javascript text
is not present.");
+ assertEquals(selenium.getText(JAVASCRIPT_TEXT), "JAVASCRIPT TEXT",
"The javascript text doesn't match.");
+ }
+
+
+}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestImagePng.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestImagePng.java 2011-09-15
11:54:05 UTC (rev 22720)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestImagePng.java 2011-09-15
11:59:57 UTC (rev 22721)
@@ -50,7 +50,7 @@
}
@Test
- public void testImage() {
+ public void init() {
AttributeLocator imageURLAttr = MEDIA_OUTPUT.getAttribute(Attribute.SRC);
URL imageURL = buildUrl(contextRoot, selenium.getAttribute(imageURLAttr));
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestTextHtml.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestTextHtml.java 2011-09-15
11:54:05 UTC (rev 22720)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestTextHtml.java 2011-09-15
11:59:57 UTC (rev 22721)
@@ -46,22 +46,10 @@
@Test
public void testInit() throws IOException {
- AttributeLocator urlAttr = MEDIA_OUTPUT.getAttribute(Attribute.DATA);
- URL url = buildUrl(contextRoot, selenium.getAttribute(urlAttr));
- BufferedReader input = null;
- StringBuilder foundContent = new StringBuilder();
- try {
- input = new BufferedReader(new InputStreamReader(url.openStream()));
- String line;
- while((line = input.readLine()) != null) {
- foundContent.append(line);
- }
- } finally {
- if (input != null) {
- input.close();
- }
- }
- assertTrue(foundContent.toString().contains(A4JMediaOutputBean.HTML_TEXT));
+ assertTrue(
+
getTextContentByUrlAttribute(MEDIA_OUTPUT.getAttribute(Attribute.DATA)).toString().contains(A4JMediaOutputBean.HTML_TEXT),
+ "The HTML content doesn't match."
+ );
}
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestTextPlain.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestTextPlain.java 2011-09-15
11:54:05 UTC (rev 22720)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestTextPlain.java 2011-09-15
11:59:57 UTC (rev 22721)
@@ -23,13 +23,10 @@
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.net.URL;
import org.jboss.test.selenium.locator.Attribute;
-import org.jboss.test.selenium.locator.AttributeLocator;
import org.richfaces.tests.metamer.bean.a4j.A4JMediaOutputBean;
import org.testng.annotations.Test;
import static org.testng.Assert.assertTrue;
@@ -46,22 +43,10 @@
@Test
public void testInit() throws IOException {
- AttributeLocator urlAttr = MEDIA_OUTPUT.getAttribute(Attribute.DATA);
- URL url = buildUrl(contextRoot, selenium.getAttribute(urlAttr));
- BufferedReader input = null;
- StringBuilder foundContent = new StringBuilder();
- try {
- input = new BufferedReader(new InputStreamReader(url.openStream()));
- String line;
- while((line = input.readLine()) != null) {
- foundContent.append(line);
- }
- } finally {
- if (input != null) {
- input.close();
- }
- }
- assertTrue(foundContent.toString().contains(A4JMediaOutputBean.PLAIN_TEXT));
+ assertTrue(
+
getTextContentByUrlAttribute(MEDIA_OUTPUT.getAttribute(Attribute.DATA)).toString().contains(A4JMediaOutputBean.PLAIN_TEXT),
+ "The plain text content doesn't match."
+ );
}
}