Author: sdzmitrovich
Date: 2008-09-18 10:51:55 -0400 (Thu, 18 Sep 2008)
New Revision: 10359
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentContentTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/ComponentContentTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestDomUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2781
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentContentTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentContentTest.java 2008-09-18
14:48:16 UTC (rev 10358)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentContentTest.java 2008-09-18
14:51:55 UTC (rev 10359)
@@ -10,10 +10,6 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.jsf.test;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
import org.jboss.tools.vpe.ui.test.ComponentContentTest;
/**
@@ -24,134 +20,106 @@
*/
public class JsfComponentContentTest extends ComponentContentTest {
- // import project name
- public static final String IMPORT_PROJECT_NAME = "jsfTest"; //$NON-NLS-1$
-
- public static final String TESTS_ROOT_NAME = "tests"; //$NON-NLS-1$
-
public JsfComponentContentTest(String name) {
super(name);
setCheckWarning(false);
}
public void testCommandButton() throws Throwable {
-
- Map<String, String> mapIds = new HashMap<String, String>();
- mapIds.put("commandButton1", "commandButton1");
- mapIds.put("commandButton2", "commandButton2");
- mapIds.put("commandButton3", "commandButton3");
- mapIds.put("commandButton4", "commandButton4");
- mapIds.put("commandButton5", "commandButton5");
- performContentTest("components/commandButton.jsp", //$NON-NLS-1$
- "commandButton.xml", mapIds); //$NON-NLS-1$
+ performContentTest("components/commandButton.jsp"); //$NON-NLS-1$
}
public void testCommandLink() throws Throwable {
- Map<String, String> mapIds = new HashMap<String, String>();
- mapIds.put("commandLink1", "commandLink1");
- mapIds.put("commandLink2", "commandLink2");
- performContentTest("components/commandLink.jsp", //$NON-NLS-1$
- "commandLink.xml", mapIds); //$NON-NLS-1$
+ performContentTest("components/commandLink.jsp"); //$NON-NLS-1$
}
public void testDataTable() throws Throwable {
- performContentTest("components/dataTable.jsp", "dataTable",
- "dataTable.xml");
+ performContentTest("components/dataTable.jsp"); //$NON-NLS-1$
}
public void testForm() throws Throwable {
- performContentTest("components/form.jsp", "form",
"form.xml");
+ performContentTest("components/form.jsp"); //$NON-NLS-1$
}
public void testGraphicImage() throws Throwable {
- Map<String, String> mapIds = new HashMap<String, String>();
- mapIds.put("graphicImage1", "graphicImage1");
- mapIds.put("graphicImage2", "graphicImage2");
- performContentTest("components/graphicImage.jsp", //$NON-NLS-1$
- "graphicImage.xml", mapIds); //$NON-NLS-1$
+ performContentTest("components/graphicImage.jsp"); //$NON-NLS-1$
}
public void testInputHidden() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testInputSecret() throws Throwable {
- performContentTest("components/inputSecret.jsp", "inputSecret",
- "inputSecret.xml");
+ performContentTest("components/inputSecret.jsp"); //$NON-NLS-1$
}
public void testInputText() throws Throwable {
+ performContentTest("components/inputText.jsp"); //$NON-NLS-1$
- performContentTest("components/inputText.jsp", "inputText",
//$NON-NLS-1$ //$NON-NLS-2$
- "inputText.xml"); //$NON-NLS-1$
-
}
public void testInputTextArea() throws Throwable {
- performContentTest("components/inputTextArea.jsp", "inputTextArea",
//$NON-NLS-1$ //$NON-NLS-2$
- "inputTextArea.xml"); //$NON-NLS-1$
+ performContentTest("components/inputTextArea.jsp"); //$NON-NLS-1$
}
public void testMessage() throws Throwable {
- performContentTest("components/message.jsp", "message",
//$NON-NLS-1$ //$NON-NLS-2$
- "message.xml"); //$NON-NLS-1$
+ performContentTest("components/message.jsp"); //$NON-NLS-1$
}
public void testMessages() throws Throwable {
- performContentTest("components/messages.jsp", "messages",
//$NON-NLS-1$ //$NON-NLS-2$
- "messages.xml"); //$NON-NLS-1$
+ performContentTest("components/messages.jsp"); //$NON-NLS-1$
}
public void testOutputFormat() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testOutputLabel() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testOutputLink() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testOutputText() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testPanelGrid() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testPanelGroup() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testSelectBooleanCheckbox() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testSelectManyCheckbox() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testSelectManyListbox() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testSelectManyMenu() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testSelectOneListbox() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testSelectOneMenu() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void _testSelectOneRadio() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
/*
@@ -159,92 +127,87 @@
*/
public void testActionListener() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testAttribute() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testConvertDateTime() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testConvertNumber() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testConverter() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testFacet() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testLoadBundle() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testParam() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testPhaseListener() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testSelectItem() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testSelectItems() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testSetPropertyActionListener() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testSubview() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testValidateDoubleRange() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testValidateLength() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testValidateLongRange() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testValidator() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testValueChangeListener() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testVerbatim() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
public void testView() throws Throwable {
- assertTrue("it is necessery to add body of the test", false);
+ assertTrue("it is necessery to add body of the test", false); //$NON-NLS-1$
}
protected String getTestProjectName() {
- return IMPORT_PROJECT_NAME;
+ return JsfAllTests.IMPORT_PROJECT_NAME;
}
- @Override
- protected String getTestsRoot() {
- return JsfTestPlugin.getPluginResourcePath() + File.separator
- + TESTS_ROOT_NAME;
- }
}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/ComponentContentTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/ComponentContentTest.java 2008-09-18
14:48:16 UTC (rev 10358)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/ComponentContentTest.java 2008-09-18
14:51:55 UTC (rev 10359)
@@ -11,7 +11,7 @@
package org.jboss.tools.vpe.ui.test;
import java.io.File;
-import java.util.Map;
+import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.ui.IEditorInput;
@@ -31,176 +31,32 @@
*/
public abstract class ComponentContentTest extends VpeTest {
+ public static final String XML_FILE_EXTENSION = ".xml"; //$NON-NLS-1$
+
public ComponentContentTest(String name) {
super(name);
}
/**
*
- * @param elementPagePath
- * - path to test page
- * @param elementId
- * - id of element which will be tested
- * @param XmlSchemeContent
- * - probable content of test element
+ * there are several conditions:
*
- * @throws Throwable
- */
- protected void performContentTestByContent(String elementPagePath,
- String elementId, String xmlTestContent) throws Throwable {
- setException(null);
-
- IFile elementPageFile = (IFile) TestUtil.getComponentPath(
- elementPagePath, getTestProjectName());
-
- IEditorInput input = new FileEditorInput(elementPageFile);
-
- TestUtil.waitForJobs();
-
- IEditorPart editor = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().openEditor(input,
- EDITOR_ID, true);
-
- assertNotNull(editor);
-
- TestUtil.waitForJobs();
-
- // get element by id
- nsIDOMElement vpeElement = findElementById(
- getVpeController((JSPMultiPageEditor) editor), elementId);
- assertNotNull(vpeElement);
-
- // get document
- Document modelDocument = TestDomUtil.getDocument(xmlTestContent);
- assertNotNull(modelDocument);
-
- // get element
- Element modelElement = modelDocument.getDocumentElement();
- assertNotNull(modelElement);
-
- assertEquals(true, TestDomUtil.compareNodes(vpeElement, modelElement));
-
- if (getException() != null) {
- throw getException();
- }
-
- }
-
- /**
- * use if xml file contain only one test
+ * 1) xml file which contain tests must be named 'name of test page' +
+ * '.xml'
*
- * @param elementPagePath
- * - path to test page
- * @param elementId
- * - id of element which will be tested
- * @param xmlTestPath
- * - path to xml file which contains tests of content
- * @param xmlTestId
- * - current id of test in xml file
- * @throws Throwable
- */
- protected void performContentTest(String elementPagePath, String elementId,
- String xmlTestPath) throws Throwable {
- setException(null);
-
- IFile elementPageFile = (IFile) TestUtil.getComponentPath(
- elementPagePath, getTestProjectName());
-
- IEditorInput input = new FileEditorInput(elementPageFile);
-
- TestUtil.waitForJobs();
-
- IEditorPart editor = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().openEditor(input,
- EDITOR_ID, true);
-
- assertNotNull(editor);
-
- TestUtil.waitForJobs();
-
- // get xml test file
- File xmlTestFile = TestUtil.getXmlTestFile(xmlTestPath, getTestsRoot());
-
- // get document
- Document xmlTestDocument = TestDomUtil.getDocument(xmlTestFile);
- assertNotNull(xmlTestDocument);
-
- // compare DOMs
- assertEquals(true, compareElements(
- getVpeController((JSPMultiPageEditor) editor), xmlTestDocument,
- elementId));
-
- if (getException() != null) {
- throw getException();
- }
-
- }
-
- /**
+ * Example: test.jsp and test.jsp.xml
*
- * use if xml file contain several tests
+ * 2) a tag <test> in xml file and required element in test page must have
+ * the same attribute "id"
*
- * @param elementPagePath
- * - path to test page
- * @param elementId
- * - id of element which will be tested
- * @param xmlTestPath
- * - path to xml file which contains tests of content
- * @param xmlTestId
- * - current id of test in xml file
- * @throws Throwable
- */
- protected void performContentTest(String elementPagePath, String elementId,
- String xmlTestPath, String xmlTestId) throws Throwable {
- setException(null);
-
- IFile elementPageFile = (IFile) TestUtil.getComponentPath(
- elementPagePath, getTestProjectName());
-
- IEditorInput input = new FileEditorInput(elementPageFile);
-
- TestUtil.waitForJobs();
-
- IEditorPart editor = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().openEditor(input,
- EDITOR_ID, true);
-
- assertNotNull(editor);
-
- TestUtil.waitForJobs();
-
- VpeController controller = getVpeController((JSPMultiPageEditor) editor);
-
- // get xml test file
- File xmlTestFile = TestUtil.getXmlTestFile(xmlTestPath, getTestsRoot());
-
- // get document
- Document xmlTestDocument = TestDomUtil.getDocument(xmlTestFile);
- assertNotNull(xmlTestDocument);
-
- assertEquals(true, compareElements(controller, xmlTestDocument,
- elementId, xmlTestId));
-
- if (getException() != null) {
- throw getException();
- }
-
- }
-
- /**
- * use if it is necessary to check several elements at the same time
+ * Example: <tests>... <test id="testId" > ...<tests> - in
xml file and
+ * <html>... <x:testElement id="testId" > ... </html> - in
test page
*
* @param elementPagePath
* - path to test page
- * @param xmlTestPath
- * - path to xml file which contains tests of content
- * @param mapId
- * - key is id of element which will be tested, value is
- * corresponding id of test in xml file
* @throws Throwable
*/
- protected void performContentTest(String elementPagePath,
- String xmlTestPath, Map<String, String> mapId) throws Throwable {
+ protected void performContentTest(String elementPagePath) throws Throwable {
setException(null);
IFile elementPageFile = (IFile) TestUtil.getComponentPath(
@@ -221,16 +77,20 @@
VpeController controller = getVpeController((JSPMultiPageEditor) editor);
// get xml test file
- File xmlTestFile = TestUtil.getXmlTestFile(xmlTestPath, getTestsRoot());
+ File xmlTestFile = TestUtil.getComponentPath(
+ elementPagePath + XML_FILE_EXTENSION, getTestProjectName())
+ .getLocation().toFile();
// get document
Document xmlTestDocument = TestDomUtil.getDocument(xmlTestFile);
assertNotNull(xmlTestDocument);
- for (String elementId : mapId.keySet()) {
+ List<String> ids = TestDomUtil.getTestIds(xmlTestDocument);
- assertEquals(true, compareElements(controller, xmlTestDocument,
- elementId, mapId.get(elementId)));
+ for (String id : ids) {
+
+ assertEquals(true, compareElements(controller, xmlTestDocument, id,
+ id));
}
if (getException() != null) {
@@ -258,29 +118,6 @@
}
- protected boolean compareElements(VpeController controller,
- Document xmlTestDocument, String elementId) {
-
- // get element by id
- nsIDOMElement vpeElement = findElementById(controller, elementId);
- assertNotNull(vpeElement);
-
- // get test element, get the first <test> tag in file
- Element xmlTestElement = TestDomUtil
- .getFirstChildElement(xmlTestDocument.getDocumentElement());
- assertNotNull(xmlTestElement);
-
- // model element is the first child of <test> tag
- Element xmlModelElement = TestDomUtil
- .getFirstChildElement(xmlTestElement);
-
- assertNotNull(xmlModelElement);
-
- // compare DOMs
- return TestDomUtil.compareNodes(vpeElement, xmlModelElement);
-
- }
-
/**
* find visual element by "id" entered in source part of vpe
*
@@ -306,10 +143,4 @@
*/
abstract protected String getTestProjectName();
- /**
- *
- * @return
- */
- abstract protected String getTestsRoot();
-
}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestDomUtil.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestDomUtil.java 2008-09-18
14:48:16 UTC (rev 10358)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestDomUtil.java 2008-09-18
14:51:55 UTC (rev 10359)
@@ -14,6 +14,8 @@
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
import org.jboss.tools.common.model.util.XMLUtil;
import org.mozilla.interfaces.nsIDOMElement;
@@ -109,8 +111,8 @@
|| (!schemeNode.getNodeName().equalsIgnoreCase(
vpeNode.getNodeName()))
|| ((schemeNode.getNodeValue() != null) && (!schemeNode
- .getNodeValue().trim()
- .equalsIgnoreCase(vpeNode.getNodeValue().trim()))))
+ .getNodeValue().trim().equalsIgnoreCase(
+ vpeNode.getNodeValue().trim()))))
return false;
// compare node's attributes
@@ -163,4 +165,22 @@
return true;
}
+
+ /**
+ * get ids of tests
+ * @param testDocument
+ * @return
+ */
+ public static List<String> getTestIds(Document testDocument) {
+ Element rootElement = testDocument.getDocumentElement();
+ List<String> ids = new ArrayList<String>();
+ NodeList children = rootElement.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE)
+ ids.add(((Element) child).getAttribute(ID_ATTRIBUTE));
+
+ }
+ return ids;
+ }
}