Author: sdzmitrovich
Date: 2008-10-14 09:34:51 -0400 (Tue, 14 Oct 2008)
New Revision: 10828
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/column.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/column.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columnGroup.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columnGroup.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataGrid.xhtml.xml
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/ComparisonException.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataGrid.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.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-2810
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/column.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/column.xhtml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/column.xhtml 2008-10-14
13:34:51 UTC (rev 10828)
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich">
+
+<head>
+</head>
+<body>
+<h1>column</h1>
+<h:form>
+ <rich:dataTable cellpadding="0" cellspacing="0"
width="700" border="0"
+ var="row" value="#{bean.dtList}" rowKeyVar="rowKey"
id="dataTable">
+
+ <f:facet name="header">
+ <rich:columnGroup>
+ <rich:column rowspan="2">
+ <rich:spacer />
+ </rich:column>
+ <rich:column colspan="3" id="column1">
+ <h:outputText value="FIELDS" />
+ </rich:column>
+ <rich:column breakBefore="true" id="column2">
+ <h:outputText value="field1" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="field2" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="field3" />
+ </rich:column>
+ </rich:columnGroup>
+ </f:facet>
+
+
+ <rich:columnGroup>
+ <rich:column>
+ <h:outputText value="#{rowKey}" />
+ </rich:column>
+ <rich:column id="column3">
+ <h:outputText value="#{row.field1}">
+ </h:outputText>
+ </rich:column>
+ <rich:column>
+ <h:outputText value="#{row.field2}">
+ </h:outputText>
+ </rich:column>
+ <rich:column>
+ <h:outputText value="#{row.field3}">
+ </h:outputText>
+ </rich:column>
+
+ </rich:columnGroup>
+
+
+
+ <f:facet name="footer">
+
+ <rich:columnGroup>
+ <rich:column></rich:column>
+ <rich:column id="column4">
+ <h:outputText value="footer1" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="footer2" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="footer3" />
+ </rich:column>
+
+ </rich:columnGroup>
+ </f:facet>
+
+ </rich:dataTable>
+</h:form>
+</body>
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/column.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/column.xhtml.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/column.xhtml.xml 2008-10-14
13:34:51 UTC (rev 10828)
@@ -0,0 +1,24 @@
+<tests>
+ <test id="column1">
+ <TD CLASS="dr-table-headercell rich-table-headercell"
COLSPAN="3"
+ ID="column1">
+ <SPAN> FIELDS</SPAN>
+ </TD>
+ </test>
+ <test id="column2">
+ <TD CLASS="dr-table-headercell rich-table-headercell"
BREAKBEFORE="true"
+ ID="column2">
+ <SPAN > field1</SPAN>
+ </TD>
+ </test>
+ <test id="column3">
+ <TD CLASS="dr-table-cell rich-table-cell" ID="column3">
+ <SPAN> #{row.field1}</SPAN>
+ </TD>
+ </test>
+ <test id="column4">
+ <TD CLASS="dr-table-footercell rich-table-footercell"
ID="column4">
+ <SPAN> footer1</SPAN>
+ </TD>
+ </test>
+</tests>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columnGroup.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columnGroup.xhtml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columnGroup.xhtml 2008-10-14
13:34:51 UTC (rev 10828)
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich">
+
+<head>
+</head>
+<body>
+<h1>columnGroup</h1>
+<h:form>
+ <rich:dataTable cellpadding="0" cellspacing="0"
width="700" border="0"
+ var="row" value="#{bean.dtList}" rowKeyVar="rowKey"
id="dataTable">
+
+ <f:facet name="header">
+ <rich:columnGroup id="columnGroup1">
+ <rich:column rowspan="2">
+ <rich:spacer />
+ </rich:column>
+ <rich:column colspan="3">
+ <h:outputText value="FIELDS" />
+ </rich:column>
+ <rich:column breakBefore="true">
+ <h:outputText value="field1" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="field2" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="field3" />
+ </rich:column>
+ </rich:columnGroup>
+ </f:facet>
+
+
+ <rich:columnGroup id="columnGroup2">
+ <rich:column>
+ <h:outputText value="#{rowKey}" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="#{row.field1}">
+ </h:outputText>
+ </rich:column>
+ <rich:column>
+ <h:outputText value="#{row.field2}">
+ </h:outputText>
+ </rich:column>
+ <rich:column>
+ <h:outputText value="#{row.field3}">
+ </h:outputText>
+ </rich:column>
+
+ </rich:columnGroup>
+
+
+
+ <f:facet name="footer">
+
+ <rich:columnGroup id="columnGroup3">
+ <rich:column></rich:column>
+ <rich:column>
+ <h:outputText value="footer1" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="footer2" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="footer3" />
+ </rich:column>
+
+ </rich:columnGroup>
+ </f:facet>
+
+ </rich:dataTable>
+</h:form>
+</body>
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columnGroup.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columnGroup.xhtml.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columnGroup.xhtml.xml 2008-10-14
13:34:51 UTC (rev 10828)
@@ -0,0 +1,25 @@
+<tests>
+ <test id="columnGroup1">
+ <TR ID="columnGroup1" CLASS="dr-table-header
rich-table-header">
+ <TD CLASS="dr-table-headercell rich-table-headercell"
ROWSPAN="2">
+ <IMG WIDTH="1" HEIGHT="1" />
+ </TD>
+ <TD CLASS="dr-table-headercell rich-table-headercell"
COLSPAN="3">
+ <SPAN> FIELDS</SPAN>
+ </TD>
+ </TR>
+ <TR CLASS="dr-table-header-continue rich-table-header-continue"
ID="columnGroup1">
+ <TD
+ CLASS="__drag__available_style dr-table-headercell rich-table-headercell"
+ BREAKBEFORE="true">
+ <SPAN> field1</SPAN>
+ </TD>
+ <TD CLASS="dr-table-headercell rich-table-headercell">
+ <SPAN> field2</SPAN>
+ </TD>
+ <TD CLASS="dr-table-headercell rich-table-headercell">
+ <SPAN> field3</SPAN>
+ </TD>
+ </TR>
+ </test>
+</tests>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml 2008-10-14
13:34:51 UTC (rev 10828)
@@ -0,0 +1,23 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich">
+
+<head>
+</head>
+<body>
+<h1>columns</h1>
+
+<h:form>
+ <rich:dataTable value="#{bookList.books}" var="book"
border="4"
+ style="background-color:grey; width : 117px;">
+ <rich:columns value="#{bookList.books}" var="label"
id="columns">
+ <h:outputText value="#{book.price}" />
+ </rich:columns>
+ </rich:dataTable>
+</h:form>
+</body>
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/columns.xhtml.xml 2008-10-14
13:34:51 UTC (rev 10828)
@@ -0,0 +1,7 @@
+<tests>
+ <test id="columns">
+ <TD CLASS="dr-table-cell rich-table-cell">
+ <SPAN> #{book.price}</SPAN>
+ </TD>
+ </test>
+</tests>
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataGrid.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataGrid.xhtml 2008-10-14
12:52:11 UTC (rev 10827)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataGrid.xhtml 2008-10-14
13:34:51 UTC (rev 10828)
@@ -9,30 +9,17 @@
<head>
</head>
<body>
- <!-- Data Grid -->
- <rich:panel>
- <f:facet name="header">
- <h:outputText value="Car Store"></h:outputText>
- </f:facet>
- <h:form>
- <rich:dataGrid columns="2" elements="12">
- <rich:panel>
- <f:facet name="header">
- <h:outputText value="Car"></h:outputText>
- </f:facet>
- <h:panelGrid columns="2">
- <h:outputText value="Price:"></h:outputText>
- <h:outputText value="30000" />
- <h:outputText value="Mileage:"></h:outputText>
- <h:outputText value="345345345" />
- <h:outputText value="VIN:"></h:outputText>
- <h:outputText value="HKFFGHGKHJKLJ" />
- <h:outputText value="Stock:"></h:outputText>
- <h:outputText value="GHKFGH" />
- </h:panelGrid>
- </rich:panel>
- </rich:dataGrid>
- </h:form>
- </rich:panel>
+<h1>dataGrid</h1>
+<h:form>
+ <rich:dataGrid value="#{bean.dtList}" var="data"
columns="2"
+ elements="4" id="dataGrid">
+ <rich:panel>
+ <f:facet name="header">
+ <h:outputText value="#{data.number}"></h:outputText>
+ </f:facet>
+ <h:outputText value="#{data.field1}" />
+ </rich:panel>
+ </rich:dataGrid>
+</h:form>
</body>
</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataGrid.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataGrid.xhtml.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/dataGrid.xhtml.xml 2008-10-14
13:34:51 UTC (rev 10828)
@@ -0,0 +1,59 @@
+<tests>
+ <test id="dataGrid">
+ <TABLE VALUE="#{bean.dtList}" VAR="data" COLUMNS="2"
ELEMENTS="4"
+ ID="dataGrid" CLASS="dr-table rich-table">
+ <COLGROUP SPAN="2">
+ </COLGROUP>
+ <TBODY>
+ <TR CLASS="dr-table-row rich-table-row">
+ <TD CLASS="dr-table-cell rich-table-cell">
+ <DIV CLASS="dr-pnl rich-panel" TITLE="rich:panel">
+ <DIV CLASS="dr-pnl-h rich-panel-header"
+ STYLE="background-image:
{url(.*org.jboss.tools.jsf.vpe.richfaces/resources/common/background.gif)};">
+ <SPAN> #{data.number}</SPAN>
+ </DIV>
+ <DIV CLASS="dr-pnl-b rich-panel-body">
+ <SPAN> #{data.field1}</SPAN>
+ </DIV>
+ </DIV>
+ </TD>
+ <TD CLASS="dr-table-cell rich-table-cell">
+ <DIV CLASS="dr-pnl rich-panel" TITLE="rich:panel">
+ <DIV CLASS="dr-pnl-h rich-panel-header"
+ STYLE="background-image:
url(file:////home/transfer/work/RHDS/repository/trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/common/background.gif);">
+ <SPAN> #{data.number}</SPAN>
+ </DIV>
+ <DIV CLASS="dr-pnl-b rich-panel-body">
+ <SPAN> #{data.field1}</SPAN>
+ </DIV>
+ </DIV>
+ </TD>
+ </TR>
+ <TR CLASS="dr-table-row rich-table-row">
+ <TD CLASS="dr-table-cell rich-table-cell">
+ <DIV CLASS="dr-pnl rich-panel" TITLE="rich:panel">
+ <DIV CLASS="dr-pnl-h rich-panel-header"
+ STYLE="background-image:
url(file:////home/transfer/work/RHDS/repository/trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/common/background.gif);">
+ <SPAN> #{data.number}</SPAN>
+ </DIV>
+ <DIV CLASS="dr-pnl-b rich-panel-body"
TITLE="rich:panel">
+ <SPAN> #{data.field1}</SPAN>
+ </DIV>
+ </DIV>
+ </TD>
+ <TD CLASS="dr-table-cell rich-table-cell">
+ <DIV CLASS="dr-pnl rich-panel" TITLE="rich:panel">
+ <DIV CLASS="dr-pnl-h rich-panel-header"
+ STYLE="background-image:
url(file:////home/transfer/work/RHDS/repository/trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/common/background.gif);">
+ <SPAN> #{data.number}</SPAN>
+ </DIV>
+ <DIV CLASS="dr-pnl-b rich-panel-body"
TITLE="rich:panel">
+ <SPAN> #{data.field1}</SPAN>
+ </DIV>
+ </DIV>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </test>
+</tests>
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java 2008-10-14
12:52:11 UTC (rev 10827)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java 2008-10-14
13:34:51 UTC (rev 10828)
@@ -25,6 +25,10 @@
setCheckWarning(false);
}
+ /**
+ *
+ * @throws Throwable
+ */
public void testAjaxValidator() throws Throwable {
performInvisibleTagTest(
"components/ajaxValidator.xhtml", "ajaxValidator");//$NON-NLS-1$
//$NON-NLS-2$
@@ -62,12 +66,12 @@
}
public void testDatascroller() throws Throwable {
-
+
performContentTest("components/datascroller.xhtml");//$NON-NLS-1$
}
public void testColumns() throws Throwable {
- assertTrue("it is necessary to add a body of the test ",
false);//$NON-NLS-1$
+ performContentTest("components/columns.xhtml");//$NON-NLS-1$
}
public void testColumnGroup() throws Throwable {
@@ -75,11 +79,11 @@
}
public void testColumn() throws Throwable {
- assertTrue("it is necessary to add a body of the test ",
false);//$NON-NLS-1$
+ performContentTest("components/column.xhtml");//$NON-NLS-1$
}
public void testDataGrid() throws Throwable {
- assertTrue("it is necessary to add a body of the test ",
false);//$NON-NLS-1$
+ performContentTest("components/dataGrid.xhtml");//$NON-NLS-1$
}
public void testDataList() throws Throwable {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-10-14
12:52:11 UTC (rev 10827)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-10-14
13:34:51 UTC (rev 10828)
@@ -87,8 +87,8 @@
public static final String ATTR_ALIGN = "align"; //$NON-NLS-1$
public static final String ATTR_SRC = "src"; //$NON-NLS-1$
public static final String ATTR_ALT = "alt"; //$NON-NLS-1$
- public static final String ATTR_JSFC = "jsfc"; //$NON-NLS-1$
- public static final String ATTR_DISPLAY = "display"; //$NON-NLS-1$
+ public static final String ATTR_JSFC = "jsfc"; //$NON-NLS-1$
+ public static final String ATTR_DISPLAY = "display"; //$NON-NLS-1$
public static final String ATTR_READONLY = "readonly"; //$NON-NLS-1$
public static final String ATTR_SCOPE = "scope"; //$NON-NLS-1$
@@ -102,9 +102,10 @@
public static final String VALUE_CHECKBOX_TYPE = "checkbox"; //$NON-NLS-1$
public static final String VALUE_HIDDEN_TYPE = "hidden"; //$NON-NLS-1$
public static final String VALUE_BUTTON_TYPE = "button"; //$NON-NLS-1$
- public static final String VALUE_ALIGN_CENTER= "center"; //$NON-NLS-1$
+ public static final String VALUE_ALIGN_CENTER = "center"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_WIDTH = "width"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_HEIGHT = "height"; //$NON-NLS-1$
+ public static final String STYLE_PARAMETER_BACKGROUND_IMAGE =
"background-image"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_MAX_HEIGHT = "max-height";
//$NON-NLS-1$
}
\ No newline at end of file
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/ComparisonException.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/ComparisonException.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/ComparisonException.java 2008-10-14
13:34:51 UTC (rev 10828)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.vpe.ui.test;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class ComparisonException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7127064462771778364L;
+
+ public ComparisonException() {
+ super();
+ }
+
+ public ComparisonException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ComparisonException(String message) {
+ super(message);
+ }
+
+ public ComparisonException(Throwable cause) {
+ super(cause);
+ }
+
+}
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-10-14
12:52:11 UTC (rev 10827)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/ComponentContentTest.java 2008-10-14
13:34:51 UTC (rev 10828)
@@ -92,8 +92,7 @@
for (String id : ids) {
- assertEquals(true, compareElements(controller, xmlTestDocument, id,
- id));
+ compareElements(controller, xmlTestDocument, id, id);
}
if (getException() != null) {
@@ -109,14 +108,20 @@
* @param elementId
* @param xmlTestId
* @return
+ * @throws ComparisonException
*/
- protected boolean compareElements(VpeController controller,
- Document xmlTestDocument, String elementId, String xmlTestId) {
+ protected void compareElements(VpeController controller,
+ Document xmlTestDocument, String elementId, String xmlTestId)
+ throws ComparisonException {
// get element by id
nsIDOMElement vpeElement = findElementById(controller, elementId);
assertNotNull(vpeElement);
+ // DOMTreeDumper dumper = new DOMTreeDumper(
+ // VpeDebug.VISUAL_DUMP_PRINT_HASH);
+ // dumper.dumpToStream(System.out, vpeElement);
+
// get test element by id - get <test id="..." > element and get his
// first child
Element xmlModelElement = TestDomUtil.getFirstChildElement(TestDomUtil
@@ -125,7 +130,7 @@
assertNotNull(xmlModelElement);
// compare DOMs
- return TestDomUtil.compareNodes(vpeElement, xmlModelElement);
+ TestDomUtil.compareNodes(vpeElement, xmlModelElement);
}
@@ -186,9 +191,7 @@
.getDocumentElement();
assertNotNull(modelElement);
- // compare elements
- assertEquals(true, TestDomUtil
- .compareNodes(visualElement, modelElement));
+ TestDomUtil.compareNodes(visualElement, modelElement);
if (getException() != null) {
throw getException();
@@ -234,7 +237,7 @@
nsIDOMElement visualElement = findElementById(controller, elementId);
assertNull(visualElement);
- // check children of non-visual
+ // check children of non-visual
NodeList children = sourceELement.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
@@ -261,8 +264,7 @@
assertNotNull(modelElement);
// compare elements
- assertEquals(true, TestDomUtil
- .compareNodes(visualElement, modelElement));
+ TestDomUtil.compareNodes(visualElement, modelElement);
if (getException() != null) {
throw getException();
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-10-14
12:52:11 UTC (rev 10827)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestDomUtil.java 2008-10-14
13:34:51 UTC (rev 10828)
@@ -16,9 +16,14 @@
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.jboss.tools.common.model.util.XMLUtil;
-import org.mozilla.interfaces.nsIDOMElement;
+import org.jboss.tools.vpe.editor.util.Constants;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMAttr;
+import org.mozilla.interfaces.nsIDOMNamedNodeMap;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
import org.w3c.dom.Attr;
@@ -34,8 +39,16 @@
*/
public class TestDomUtil {
- public static String ID_ATTRIBUTE = "id";
+ final public static String ID_ATTRIBUTE = "id"; //$NON-NLS-1$
+ final public static String ILLEGAL_ATTRIBUTES = "illegalAttributes";
//$NON-NLS-1$
+
+ final public static String ILLEGAL_ATTRIBUTES_SEPARATOR = Constants.COMMA;
+
+ final public static String START_REGEX = "{"; //$NON-NLS-1$
+
+ final public static String END_REGEX = "}"; //$NON-NLS-1$
+
public static Document getDocument(File file) throws FileNotFoundException {
// create reader
FileReader reader = new FileReader(file);
@@ -103,40 +116,34 @@
* @param vpeNode
* @param schemeNode
* @return
+ * @throws ComparisonException
*/
- public static boolean compareNodes(nsIDOMNode vpeNode, Node schemeNode) {
+ public static void compareNodes(nsIDOMNode vpeNode, Node modelNode)
+ throws ComparisonException {
- // compare node's features
- if ((schemeNode.getNodeType() != vpeNode.getNodeType())
- || (!schemeNode.getNodeName().equalsIgnoreCase(
- vpeNode.getNodeName()))
- || ((schemeNode.getNodeValue() != null) && (!schemeNode
- .getNodeValue().trim().equalsIgnoreCase(
- vpeNode.getNodeValue().trim()))))
- return false;
-
+ if (!modelNode.getNodeName().equalsIgnoreCase(vpeNode.getNodeName())) {
+ throw new ComparisonException("name of tag is \""
+ + vpeNode.getNodeName() + "\"but must be \""
+ + modelNode.getNodeName() + "\"");
+ }
+ if ((modelNode.getNodeValue() != null)
+ && (!modelNode.getNodeValue().trim().equalsIgnoreCase(
+ vpeNode.getNodeValue().trim()))) {
+ throw new ComparisonException("value of " + vpeNode.getNodeName()
+ + " is \"" + vpeNode.getNodeValue().trim()
+ + "\" but must be \"" + modelNode.getNodeValue().trim()
+ + "\"");
+ }
// compare node's attributes
- if (schemeNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (modelNode.getNodeType() == Node.ELEMENT_NODE) {
- NamedNodeMap attributes = schemeNode.getAttributes();
- nsIDOMElement vpeElement = (nsIDOMElement) vpeNode
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
- Attr attr = (Attr) attributes.item(i);
-
- if ((!vpeElement.hasAttribute(attr.getName()))
- || (!attr.getNodeValue().trim().equals(
- vpeElement.getAttributeNode(attr.getName())
- .getNodeValue().trim())))
- return false;
- }
- }
+ compareAttributes(modelNode.getAttributes(), vpeNode
+ .getAttributes());
}
// compare children
nsIDOMNodeList vpeChildren = vpeNode.getChildNodes();
- NodeList schemeChildren = schemeNode.getChildNodes();
+ NodeList schemeChildren = modelNode.getChildNodes();
int realCount = 0;
for (int i = 0; i < schemeChildren.getLength(); i++) {
@@ -158,13 +165,10 @@
}
- if (!compareNodes(vpeChild, schemeChild))
- return false;
+ compareNodes(vpeChild, schemeChild);
}
- return true;
-
}
/**
@@ -185,4 +189,118 @@
}
return ids;
}
+
+ private static void compareAttributes(NamedNodeMap modelAttributes,
+ nsIDOMNamedNodeMap vpeAttributes) throws ComparisonException {
+
+ for (int i = 0; i < modelAttributes.getLength(); i++) {
+ Attr modelAttr = (Attr) modelAttributes.item(i);
+ String name = modelAttr.getName();
+
+ // if there are limitation of attributes
+ if (ILLEGAL_ATTRIBUTES.equals(name)) {
+
+ String[] illegalAttributes = modelAttr.getNodeValue().split(
+ ILLEGAL_ATTRIBUTES_SEPARATOR);
+
+ for (String illegalAttributeName : illegalAttributes) {
+ if (vpeAttributes.getNamedItem(illegalAttributeName.trim()) != null)
+ throw new ComparisonException("illegal attribute :"
+ + illegalAttributeName);
+ }
+
+ } else {
+
+ nsIDOMAttr vpeAttr = (nsIDOMAttr) vpeAttributes.getNamedItem(
+ name).queryInterface(nsIDOMAttr.NS_IDOMATTR_IID);
+
+ if (vpeAttr == null)
+ throw new ComparisonException("there is not : \"" + name
+ + "\" attribute");
+
+ if (HTML.ATTR_STYLE.equalsIgnoreCase(name)) {
+
+ String[] modelParameters = modelAttr.getNodeValue().split(
+ Constants.SEMICOLON);
+ String[] vpeParameters = vpeAttr.getNodeValue().split(
+ Constants.SEMICOLON);
+
+ for (int j = 0; j < modelParameters.length; j++) {
+ String modelParam = modelParameters[j];
+ String vpeParam = vpeParameters[j];
+
+ String[] splittedModelParam = modelParam.split(
+ Constants.COLON, 2);
+
+ String[] splittedVpeParam = vpeParam.split(
+ Constants.COLON, 2);
+
+ if (!splittedModelParam[0].trim().equals(
+ splittedVpeParam[0].trim())) {
+ throw new ComparisonException(
+ "param of style attribute is\""
+ + splittedVpeParam[0].trim()
+ + "\" but must be \""
+ + splittedModelParam[0].trim()
+ + "\"");
+ }
+
+ compareComplexStrings(splittedModelParam[1].trim(),
+ splittedVpeParam[1].trim());
+
+ }
+
+ } else {
+
+ compareComplexStrings(modelAttr.getNodeValue().trim(),
+ vpeAttr.getNodeValue().trim());
+
+ }
+ }
+ }
+ }
+
+ static private void compareComplexStrings(String modelString,
+ String vpeString) throws ComparisonException {
+
+ if (modelString.startsWith(START_REGEX)
+ && modelString.endsWith(END_REGEX)) {
+
+ String regex = modelString.substring(START_REGEX.length(),
+ modelString.length() - END_REGEX.length());
+
+ Matcher matcher = Pattern.compile(regex).matcher(vpeString);
+ if (!matcher.find()) {
+ throw new ComparisonException("string is\"" + vpeString
+ + "\" but pattern is \"" + regex + "\"");
+ }
+
+ } else if (!modelString.equals(vpeString)) {
+ throw new ComparisonException("string is\"" + vpeString
+ + "\" but must be \"" + modelString + "\"");
+ }
+
+ }
+
+ /**
+ * is created to be sure that attributes/parameters will be correctly
+ * compared ( ignore case )
+ *
+ * @param list
+ * @param string
+ * @return
+ */
+ static private boolean findIgnoreCase(String[] strings,
+ String requiredString) {
+
+ for (String string : strings) {
+
+ if (string.equalsIgnoreCase(requiredString))
+ return true;
+
+ }
+
+ return false;
+ }
+
}