Author: sdzmitrovich
Date: 2008-02-28 06:58:05 -0500 (Thu, 28 Feb 2008)
New Revision: 6633
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-dir.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-disabled.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-escape.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-format.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide1718Test.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1718
created tests
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-dir.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-dir.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-dir.jsp 2008-02-28
11:58:05 UTC (rev 6633)
@@ -0,0 +1,13 @@
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+<html>
+<head>
+</head>
+<body>
+<f:view>
+ <b><h:outputFormat escape="true" value="outputFormat"
+ dir="rtl"/><h:outputLink dir="rtl" /><h:outputText
escape="false" value="outputText"
+ dir="rtl" /><h:outputLabel value="outputLabel"
dir="rtl" /></b>
+</f:view>
+</body>
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-disabled.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-disabled.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-disabled.jsp 2008-02-28
11:58:05 UTC (rev 6633)
@@ -0,0 +1,16 @@
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+<html>
+<head>
+</head>
+<body>
+<f:view>
+ <h:outputLink>
+ enabled link
+ </h:outputLink>
+ <h:outputLink disabled="true">
+ disabled link
+ </h:outputLink>
+</f:view>
+</body>
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-escape.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-escape.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-escape.jsp 2008-02-28
11:58:05 UTC (rev 6633)
@@ -0,0 +1,20 @@
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<html>
+<head>
+</head>
+<body>
+
+<f:view>
+ <h:outputFormat escape="false"
+ value='<input type="button" value="outputFormat">'
/>
+ <h:outputText escape="false"
+ value="<input type='button'
+ value='outputText' />" />
+ <h:outputLabel escape="false"
+ value="<input type='button'
+ value='outputLabel' />" />
+</f:view>
+</body>
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-format.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-format.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1718/JBIDE-1718-format.jsp 2008-02-28
11:58:05 UTC (rev 6633)
@@ -0,0 +1,13 @@
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+<html>
+<head>
+</head>
+<body>
+<f:view>
+ <b><h:outputFormat value="{0}"
+ ><f:param value="paramValue"
+ /></h:outputFormat></b>
+</f:view>
+</body>
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide1718Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide1718Test.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide1718Test.java 2008-02-28
11:58:05 UTC (rev 6633)
@@ -0,0 +1,311 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNamedNodeMap;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
+
+/**
+ *
+ * @author sdzmitrovich
+ *
+ * test for
http://jira.jboss.com/jira/browse/JBIDE-1718
+ *
+ *
+ */
+public class JsfJbide1718Test extends VpeTest {
+
+ public static final String IMPORT_PROJECT_NAME = "jsfTest";
+
+ private static final String DIR_TEST_PAGE_NAME =
"JBIDE/1718/JBIDE-1718-dir.jsp";
+
+ private static final String ESCAPE_TEST_PAGE_NAME =
"JBIDE/1718/JBIDE-1718-escape.jsp";
+
+ private static final String DISABLED_TEST_PAGE_NAME =
"JBIDE/1718/JBIDE-1718-disabled.jsp";
+
+ private static final String FORMAT_TEST_PAGE_NAME =
"JBIDE/1718/JBIDE-1718-format.jsp";
+
+ public JsfJbide1718Test(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ * @throws Throwable
+ */
+ public void testDirAttribute() throws Throwable {
+
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(DIR_TEST_PAGE_NAME,
+ IMPORT_PROJECT_NAME);
+
+ IEditorInput input = new FileEditorInput(file);
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ // get dom document
+ nsIDOMDocument document = getVpeVisualDocument(part);
+ assertNotNull(document);
+
+ // get dom element
+ nsIDOMElement element = document.getDocumentElement();
+ assertNotNull(element);
+
+ // get root node
+ nsIDOMNode node = (nsIDOMNode) element
+ .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+
+ // find "b" elements
+ List<nsIDOMNode> bElements = new ArrayList<nsIDOMNode>();
+ TestUtil.findElementsByName(node, bElements, HTML.TAG_B);
+
+ // number of "b" elements must be 1
+ assertEquals(1, bElements.size());
+ nsIDOMNode b = bElements.get(0);
+
+ List<nsIDOMNode> spanElements = new ArrayList<nsIDOMNode>();
+ List<nsIDOMNode> labelElements = new ArrayList<nsIDOMNode>();
+ List<nsIDOMNode> aElements = new ArrayList<nsIDOMNode>();
+
+ // find "span" elements in "b" tag
+ TestUtil.findElementsByName(b, spanElements, HTML.TAG_SPAN);
+ // find "label" elements in "b"
+ TestUtil.findElementsByName(b, labelElements, HTML.TAG_LABEL);
+ // find "a" elements in "b"
+ TestUtil.findElementsByName(b, aElements, HTML.TAG_A);
+
+ // number of "span" elements must be 2
+ assertEquals(2, spanElements.size());
+
+ // number of "label" elements must be 1
+ assertEquals(1, labelElements.size());
+
+ // number of "a" elements must be 1
+ assertEquals(1, aElements.size());
+
+ // join all elements
+ List<nsIDOMNode> elements = new ArrayList<nsIDOMNode>();
+
+ elements.addAll(spanElements);
+ elements.addAll(labelElements);
+ elements.addAll(aElements);
+
+ for (nsIDOMNode child : elements) {
+
+ // get attributes
+ nsIDOMNamedNodeMap attributes = child.getAttributes();
+
+ // all elements must have attributes
+ assertNotNull(attributes);
+
+ // all elements must have "dir" attribute
+ assertNotNull(attributes.getNamedItem(HTML.ATTR_DIR));
+
+ }
+
+ // check exception
+ if (getException() != null) {
+ throw getException();
+ }
+
+ }
+
+ /**
+ *
+ * @throws Throwable
+ */
+ public void testEscapeAttribute() throws Throwable {
+
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(ESCAPE_TEST_PAGE_NAME,
+ IMPORT_PROJECT_NAME);
+
+ IEditorInput input = new FileEditorInput(file);
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ // get dom document
+ nsIDOMDocument document = getVpeVisualDocument(part);
+ assertNotNull(document);
+
+ // get dom element
+ nsIDOMElement element = document.getDocumentElement();
+ assertNotNull(element);
+
+ // get root node
+ nsIDOMNode node = (nsIDOMNode) element
+ .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+
+ List<nsIDOMNode> spanElements = new ArrayList<nsIDOMNode>();
+
+ // find "input" elements
+ TestUtil.findElementsByName(node, spanElements, HTML.TAG_INPUT);
+
+ // number of "input" elements must be 3
+ assertEquals(3, spanElements.size());
+
+ // check exception
+ if (getException() != null) {
+ throw getException();
+ }
+
+ }
+
+ /**
+ *
+ * @throws Throwable
+ */
+ public void testDisabledAttribute() throws Throwable {
+
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(DISABLED_TEST_PAGE_NAME,
+ IMPORT_PROJECT_NAME);
+
+ IEditorInput input = new FileEditorInput(file);
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ // get dom document
+ nsIDOMDocument document = getVpeVisualDocument(part);
+ assertNotNull(document);
+
+ // get dom element
+ nsIDOMElement element = document.getDocumentElement();
+ assertNotNull(element);
+
+ // get root node
+ nsIDOMNode node = (nsIDOMNode) element
+ .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+
+ List<nsIDOMNode> aElements = new ArrayList<nsIDOMNode>();
+
+ // find "input" elements
+ TestUtil.findElementsByName(node, aElements, HTML.TAG_A);
+
+ // page has 2 <h:outputLink ...> tags but one from them have attribute
+ // disabled="true", so number of "a" tags must be one
+ assertEquals(1, aElements.size());
+
+ // check exception
+ if (getException() != null) {
+ throw getException();
+ }
+
+ }
+
+ /**
+ *
+ * @throws Throwable
+ */
+ public void testFormatMessageElements() throws Throwable {
+
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(FORMAT_TEST_PAGE_NAME,
+ IMPORT_PROJECT_NAME);
+
+ IEditorInput input = new FileEditorInput(file);
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ // get dom document
+ nsIDOMDocument document = getVpeVisualDocument(part);
+ assertNotNull(document);
+
+ // get dom element
+ nsIDOMElement element = document.getDocumentElement();
+ assertNotNull(element);
+
+ // get root node
+ nsIDOMNode node = (nsIDOMNode) element
+ .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+
+ // find "b" elements
+ List<nsIDOMNode> bElements = new ArrayList<nsIDOMNode>();
+ TestUtil.findElementsByName(node, bElements, HTML.TAG_B);
+
+ // number of "b" elements must be 1
+ assertEquals(1, bElements.size());
+ nsIDOMNode b = bElements.get(0);
+
+ List<nsIDOMNode> spanElements = new ArrayList<nsIDOMNode>();
+
+ // find "input" elements in b elements
+ TestUtil.findElementsByName(b, spanElements, HTML.TAG_SPAN);
+
+ // page has 2 <h:outputLink ...> tags but one from them have attribute
+ // disabled="true", so number of "a" tags must be one
+ assertEquals(1, spanElements.size());
+
+ nsIDOMNode span = spanElements.get(0);
+
+ nsIDOMNodeList children = span.getChildNodes();
+ assertNotNull(children);
+
+ boolean isFind = false;
+ for (int i = 0; i < children.getLength(); i++) {
+
+ nsIDOMNode text = children.item(i);
+
+ if ("paramValue".equals(text.getNodeValue())) {
+ isFind = true;
+ break;
+ }
+
+ assertEquals(true, isFind);
+
+ }
+
+ // check exception
+ if (getException() != null) {
+ throw getException();
+ }
+
+ }
+
+}