Author: pkawiak
Date: 2008-08-12 02:46:35 -0400 (Tue, 12 Aug 2008)
New Revision: 10037
Added:
trunk/ui/extendedDataTable/src/test/java/org/richfaces/component/DefaultExtendedDataTable.java
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/AbstractExtendedRowsRendererTest.java
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/AbstractExtendedTableRendererTest.java
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ExtendedRowsRenderer.java
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ExtendedTableRenderer.java
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ResponseWriterMock.java
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/html/
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/html/TableDragDropRendererTest.java
Log:
JUnit tests
Added:
trunk/ui/extendedDataTable/src/test/java/org/richfaces/component/DefaultExtendedDataTable.java
===================================================================
---
trunk/ui/extendedDataTable/src/test/java/org/richfaces/component/DefaultExtendedDataTable.java
(rev 0)
+++
trunk/ui/extendedDataTable/src/test/java/org/richfaces/component/DefaultExtendedDataTable.java 2008-08-12
06:46:35 UTC (rev 10037)
@@ -0,0 +1,58 @@
+package org.richfaces.component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.richfaces.component.UIExtendedDataTable;
+import org.richfaces.model.FilterField;
+import org.richfaces.model.SortField2;
+import org.richfaces.model.selection.Selection;
+
+/**
+ * @author mpopiolek
+ *
+ */
+public class DefaultExtendedDataTable extends UIExtendedDataTable {
+
+ @Override
+ public Object getActiveRowKey() {
+ return "activeRowKey";
+ }
+
+ @Override
+ public void setActiveRowKey(Object activeRowKey) {
+ }
+
+ @Override
+ public String getSortMode() {
+ return null;
+ }
+
+ @Override
+ public void setSortMode(String sortMode) {
+ }
+
+ public Selection getSelection() {
+ return null;
+ }
+
+ public void setSelection(Selection selection) {
+ }
+
+ public List<SortField2> getSortFields() {
+ List<SortField2> list = new ArrayList<SortField2>();
+ return list;
+ }
+
+ public void setSortFields(List<SortField2> sortFields) {
+ }
+
+ public List<FilterField> getFilterFields() {
+ List<FilterField> list = new ArrayList<FilterField>();
+ return list;
+ }
+
+ public void setFilterFields(List<FilterField> filterFields) {
+ }
+
+}
Added:
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/AbstractExtendedRowsRendererTest.java
===================================================================
---
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/AbstractExtendedRowsRendererTest.java
(rev 0)
+++
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/AbstractExtendedRowsRendererTest.java 2008-08-12
06:46:35 UTC (rev 10037)
@@ -0,0 +1,171 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.faces.component.UIOutput;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIExtendedDataTable;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author mpopiolek
+ *
+ */
+public class AbstractExtendedRowsRendererTest extends AbstractAjax4JsfTestCase {
+
+ private ExtendedRowsRenderer rr;
+ private UIExtendedDataTable table;
+
+ public AbstractExtendedRowsRendererTest(String name) {
+ super(name);
+ rr = new ExtendedRowsRenderer();
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ application.addComponent(UIExtendedDataTable.COMPONENT_TYPE,
+ "org.richfaces.component.DefaultExtendedDataTable");
+ table = (UIExtendedDataTable) application
+ .createComponent(UIExtendedDataTable.COMPONENT_TYPE);
+ facesContext.getViewRoot().getChildren().add(table);
+ table.setId("extDT");
+ }
+
+ public void tearDown() throws Exception {
+ table = null;
+ super.tearDown();
+ }
+
+ public void testGetRendersChildren() {
+ assertTrue(rr.getRendersChildren());
+ }
+
+ public void testProcess() {
+ Object rowKey = 100;
+ ExtendedTableHolder eth = new ExtendedTableHolder(table);
+ int count = eth.getRowCounter();
+ Object argument = (Object) eth;
+ try {
+ rr.process(facesContext, rowKey, argument);
+ eth = (ExtendedTableHolder) argument;
+ assertEquals(count + 1, eth.getRowCounter());
+ assertEquals(100, eth.getLastKey());
+ assertEquals(100, eth.getTable().getRowKey());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ eth = (ExtendedTableHolder) argument;
+ assertEquals(count + 1, ((ExtendedTableHolder) argument)
+ .getRowCounter());
+
+ }
+
+ public void testEncodeRowsFacesContextUIComponentExtendedTableHolder() {
+ ExtendedTableHolder eth = new ExtendedTableHolder(table);
+ try {
+ rr.encodeRows(facesContext, table, eth);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeCaption() {
+ UIOutput caption = new UIOutput();
+ caption.setValue("test");
+ table.getFacets().put("caption", caption);
+ try {
+ setupResponseWriter();
+ rr.encodeCaption(facesContext, table);
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement capt = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+ if (node.getNodeName().equalsIgnoreCase("caption")) {
+ capt = node;
+ }
+ }
+
+ assertNotNull(capt);
+
+ String className = capt.getAttributeValue("class");
+ assertNotNull(className);
+ assertEquals("extdt-caption rich-extdt-caption", className);
+
+ className = capt.getAttributeValue("id");
+ assertNotNull(className);
+ assertEquals("extDT:caption", className);
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeStyleClass() {
+ ResponseWriterMock writer = new ResponseWriterMock();
+ try {
+ rr.encodeStyleClass(writer, null, "predefined", "parent",
"custom");
+ ArrayList<String> attr = writer.attr;
+ assertTrue(attr.contains("class predefined parent custom"));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeStyle() {
+ ResponseWriterMock writer = new ResponseWriterMock();
+ try {
+ rr.encodeStyle(writer, null, "predefined", "parent",
"custom");
+ ArrayList<String> attr = writer.attr;
+ assertTrue(attr.contains("style predefined parent custom"));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeTableHeaderFacet() {
+ UIOutput footer = new UIOutput();
+ footer.setValue("test");
+ table.getFacets().put("footer", footer);
+ try {
+ setupResponseWriter();
+ rr.encodeTableHeaderFacet(facesContext, 10, writer, footer,
+ "skinFirstRowClass", "skinRowClass",
"skinCellClass",
+ "footerClass", "element",
"facetName");
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement n = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+ if (node.getNodeName().equalsIgnoreCase("element")) {
+ n = node;
+ }
+ }
+
+ assertNotNull(n);
+
+ String className = n.getAttributeValue("colspan");
+ assertNotNull(className);
+ assertEquals("10", className);
+
+ className = n.getAttributeValue("scope");
+ assertNotNull(className);
+ assertEquals("colgroup", className);
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+}
Added:
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/AbstractExtendedTableRendererTest.java
===================================================================
---
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/AbstractExtendedTableRendererTest.java
(rev 0)
+++
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/AbstractExtendedTableRendererTest.java 2008-08-12
06:46:35 UTC (rev 10037)
@@ -0,0 +1,477 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.faces.component.UIInput;
+import javax.faces.component.UIOutput;
+import javax.faces.component.html.HtmlOutputText;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIColumn;
+import org.richfaces.component.UIExtendedDataTable;
+import org.richfaces.model.Ordering;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author mpopiolek
+ *
+ */
+public class AbstractExtendedTableRendererTest extends AbstractAjax4JsfTestCase {
+
+ private ExtendedTableRenderer renderer;
+ private UIExtendedDataTable table;
+
+ public AbstractExtendedTableRendererTest(String name) {
+ super(name);
+ renderer = new ExtendedTableRenderer();
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ application.addComponent(UIExtendedDataTable.COMPONENT_TYPE,
+ "org.richfaces.component.DefaultExtendedDataTable");
+ table = (UIExtendedDataTable) application
+ .createComponent(UIExtendedDataTable.COMPONENT_TYPE);
+
+ table.setFirst(0);
+ table.setRows(40);
+
+ facesContext.getViewRoot().getChildren().add(table);
+ table.setId("extDT");
+
+ for (int i = 0; i < 4; i++) {
+ UIColumn column = (UIColumn) application
+ .createComponent(UIColumn.COMPONENT_TYPE);
+ column.setId("columnId" + i);
+ column.setRendered(true);
+ column.setSortable(true);
+ if (i == 0) {
+ column.setSortOrder(Ordering.ASCENDING);
+ }
+
+ table.getChildren().add(column);
+ }
+
+ }
+
+ public void tearDown() throws Exception {
+ table = null;
+ super.tearDown();
+ }
+
+ public void testEncodeOneRow() {
+ try {
+ setupResponseWriter();
+ ExtendedTableHolder holder = new ExtendedTableHolder(table);
+
+ table.setRowKey(10);
+ renderer.encodeOneRow(facesContext, holder);
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement capt = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+ if (node.getNodeName().equalsIgnoreCase("div")) {
+ capt = node;
+
+ assertNotNull(capt);
+
+ String className = capt.getAttributeValue("class");
+ assertNotNull(className);
+ assertEquals("extdt-cell-div", className);
+ }
+ }
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeColumns() {
+ try {
+ setupResponseWriter();
+ renderer.encodeColumns(facesContext, table);
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement element = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+ if (node.getNodeName().equalsIgnoreCase("col")) {
+ element = node;
+ assertNotNull(element);
+ String className = element.getAttributeValue("width");
+ if (!className.isEmpty()) {
+ assertEquals("100", className);
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeHeader() {
+ try {
+ UIOutput text = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class
+ .getName(), null, null, null);
+ table.getFacets().put("header", text);
+ setupResponseWriter();
+ renderer.encodeHeader(facesContext, table);
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement element = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+ if (node.getNodeName().equalsIgnoreCase("thead")) {
+ element = node;
+ assertNotNull(element);
+
+ String className = element.getAttributeValue("id");
+ assertNotNull(className);
+ assertEquals("extDT:header", className);
+ } else if (node.getNodeName().equalsIgnoreCase("tr")) {
+ element = node;
+ assertNotNull(element);
+
+ String className = element.getAttributeValue("id");
+ assertNotNull(className);
+ if (!className.isEmpty())
+ assertEquals("extDT:fakeIeRow", className);
+ } else if (node.getNodeName().equalsIgnoreCase("thead")) {
+ element = node;
+ assertNotNull(element);
+
+ String className = element.getAttributeValue("th");
+ assertNotNull(className);
+
+ assertEquals(
+ "extdt-headercell extdt-fakeierow rich-extdt-headercell
",
+ className);
+ }
+ }
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testIsColumnFacetPresent() {
+ assertFalse(renderer.isColumnFacetPresent(table, "header"));
+ UIOutput text = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ table.getSortedColumns().next().getFacets().put("header", text);
+ assertTrue(renderer.isColumnFacetPresent(table, "header"));
+ }
+
+ public void testIsColumnRendered() {
+ table.setRendered(false);
+ assertFalse(renderer.isColumnRendered(table));
+ table.setRendered(true);
+ assertTrue(renderer.isColumnRendered(table));
+ }
+
+ public void testEncodeHeaderFacets() {
+ try {
+ UIOutput text = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class
+ .getName(), null, null, null);
+ // header
+ table.getFacets().put("header", text);
+ setupResponseWriter();
+ renderer
+ .encodeHeaderFacets(
+ facesContext,
+ writer,
+ table,
+ table.getSortedColumns(),
+ "extdt-dr-menucell extdt-subheadercell
rich-extdt-subheadercell",
+ (String) table.getAttributes().get("headerClass"),
+ "header", "th", 4);
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement element = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+
+ if (node.getNodeName().equalsIgnoreCase("th")) {
+ element = node;
+ assertNotNull(element);
+
+ String className = element.getAttributeValue("scope");
+ assertNotNull(className);
+ assertEquals("col", className);
+ }
+ }
+ // footer
+ table.getFacets().put("footer", text);
+ setupResponseWriter();
+ renderer
+ .encodeHeaderFacets(
+ facesContext,
+ writer,
+ table,
+ table.getSortedColumns(),
+ "extdt-dr-menucell extdt-subheadercell
rich-extdt-subheadercell",
+ (String) table.getAttributes().get("headerClass"),
+ "header", "td", 4);
+ page = processResponseWriter();
+
+ elementIterator = page.getAllHtmlChildElements();
+
+ element = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+
+ if (node.getNodeName().equalsIgnoreCase("td")) {
+ element = node;
+ assertNotNull(element);
+
+ String className = element.getAttributeValue("scope");
+ assertNotNull(className);
+ assertEquals("col", className);
+ }
+ }
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeFooter() {
+ try {
+ UIOutput text = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class
+ .getName(), null, null, null);
+
+ table.getFacets().put("footer", text);
+ setupResponseWriter();
+ renderer.encodeFooter(facesContext, table);
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement element = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+
+ if (node.getNodeName().equalsIgnoreCase("tfoot")) {
+ element = node;
+ assertNotNull(element);
+
+ String className = element.getAttributeValue("id");
+ assertNotNull(className);
+ assertEquals("extDT:footer", className);
+ }
+ }
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testRowGroupChanged() {
+
+ }
+
+ public void
testEncodeRowStartFacesContextStringUIDataTableTableHolderResponseWriter() {
+ try {
+ setupResponseWriter();
+ table.setRowKey(10);
+
+ ExtendedTableHolder holder = new ExtendedTableHolder(table);
+ renderer.encodeRowStart(facesContext, "extdt-row rich-extdt-row",
+ "rowClass", table, holder, writer);
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement element = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+
+ if (node.getNodeName().equalsIgnoreCase("test")) {
+ element = node;
+ assertNotNull(element);
+
+ String className = element.getAttributeValue("id");
+ assertNotNull(className);
+ assertEquals("j_id0:10:n:0", className);
+ }
+ }
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testEncodeRowId() {
+ try {
+ setupResponseWriter();
+ table.setRowKey(10);
+
+ writer.startElement("test", table);
+ renderer.encodeRowId(facesContext, writer, table, 0);
+ writer.endElement("test");
+
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement element = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+
+ if (node.getNodeName().equalsIgnoreCase("test")) {
+ element = node;
+ assertNotNull(element);
+
+ String className = element.getAttributeValue("id");
+ assertNotNull(className);
+ assertEquals("extDT:10:n:0", className);
+ }
+ }
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testGetColumnsCount() {
+ assertEquals(4, renderer.getColumnsCount(table));
+ }
+
+ public void testCalculateRowColumns() {
+ assertEquals(4, renderer.calculateRowColumns(table.columns()));
+ }
+
+ public void testEncodeScriptIfNecessary() {
+ try {
+ setupResponseWriter();
+ renderer.encodeScriptIfNecessary(facesContext, table);
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement element = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+
+ if (node.getNodeName().equalsIgnoreCase("script")) {
+ element = node;
+ assertNotNull(element);
+
+ String className = element.getAttributeValue("type");
+ assertNotNull(className);
+ assertEquals("text/javascript", className);
+ }
+ }
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ // JSFunction or JSFunctionDefinition return:
+
+ // public void testGetSortFunctionDefFacesContextUIDataTable() {
+ // }
+ //
+ // public void testGetSortFunctionDefFacesContextUIDataTableBoolean() {
+ // }
+ //
+ // public void testGetSortFunction() {
+ // }
+ //
+ // public void testGetOnGroupToggleFunctionDef() {
+ // }
+ //
+ // public void testGetGroupFunction() {
+ // }
+ //
+ // public void testGetOnResizeFunctionDef() {
+ // }
+ //
+ // public void testGetChangeColumnVisibilityFunction() {
+ // }
+ //
+ // public void testGetPreSendAjaxRequestFunction() {
+ // }
+ //
+ // public void testBuildAjaxFunction() {
+ // }
+
+ public void testDoDecodeFacesContextUIComponent() {
+ // facesContext.getExternalContext().getRequestParameterMap().put(
+ // table.getClientId(facesContext), "fsp");
+ // facesContext.getExternalContext().getRequestParameterMap().put(
+ // "fsp", "extDT:columnId0");
+ // renderer.doDecode(facesContext, table);
+ }
+
+ // public void testEncodeEndFacesContextUIComponent() {
+ //
+ // }
+
+ public void testAddInplaceInput() {
+ UIColumn column = (UIColumn) application
+ .createComponent(UIColumn.COMPONENT_TYPE);
+ column.setId("columnId");
+ column.setFilterValue("test");
+ // filter event == null
+ try {
+ setupResponseWriter();
+ renderer.addInplaceInput(facesContext, column, "buffer");
+ UIInput input = (UIInput) column.getFacets()
+ .get("filterValueInput");
+ assertEquals("buffer",
input.getAttributes().get("onchange"));
+ assertEquals("test", input.getValue());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ // with set filter event
+ column.getAttributes().put("filterEvent", "testEvent");
+ try {
+ setupResponseWriter();
+ renderer.addInplaceInput(facesContext, column, "buffer");
+ UIInput input = (UIInput) column.getFacets()
+ .get("filterValueInput");
+ assertEquals("buffer",
input.getAttributes().get("testEvent"));
+ assertEquals("test", input.getValue());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testGetJavaScriptVarName() {
+ assertEquals("window.ExtendedDataTable.DataTable_extDT", renderer
+ .getJavaScriptVarName(facesContext, table));
+ }
+
+ public void testGetOnAjaxCompleteFunction() {
+ assertNull(renderer.getOnAjaxCompleteFunction(facesContext, table));
+ }
+
+}
Added:
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ExtendedRowsRenderer.java
===================================================================
---
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ExtendedRowsRenderer.java
(rev 0)
+++
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ExtendedRowsRenderer.java 2008-08-12
06:46:35 UTC (rev 10037)
@@ -0,0 +1,27 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author mpopiolek
+ *
+ */
+public class ExtendedRowsRenderer extends AbstractExtendedRowsRenderer {
+
+ public ExtendedRowsRenderer() {
+ }
+
+ @Override
+ public void encodeOneRow(FacesContext context, ExtendedTableHolder holder)
+ throws IOException {
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return null;
+ }
+
+}
Added:
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ExtendedTableRenderer.java
===================================================================
---
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ExtendedTableRenderer.java
(rev 0)
+++
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ExtendedTableRenderer.java 2008-08-12
06:46:35 UTC (rev 10037)
@@ -0,0 +1,18 @@
+package org.richfaces.renderkit;
+
+import javax.faces.component.UIComponent;
+
+import org.richfaces.component.UIExtendedDataTable;
+
+/**
+ * @author mpopiolek
+ *
+ */
+public class ExtendedTableRenderer extends AbstractExtendedTableRenderer {
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIExtendedDataTable.class;
+ }
+
+}
Added:
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ResponseWriterMock.java
===================================================================
---
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ResponseWriterMock.java
(rev 0)
+++
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/ResponseWriterMock.java 2008-08-12
06:46:35 UTC (rev 10037)
@@ -0,0 +1,90 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.ResponseWriter;
+
+/**
+ * @author mpopiolek
+ *
+ */
+public class ResponseWriterMock extends ResponseWriter {
+
+ public ArrayList<String> attr;
+
+ public ResponseWriterMock() {
+ attr = new ArrayList<String>();
+ }
+
+ @Override
+ public void startElement(String name, UIComponent component)
+ throws IOException {
+ }
+
+ @Override
+ public void writeAttribute(String name, Object value, String property)
+ throws IOException {
+ attr.add(name + " " + value);
+ }
+
+ @Override
+ public void endElement(String name) throws IOException {
+ }
+
+ @Override
+ public ResponseWriter cloneWithWriter(Writer writer) {
+ return null;
+ }
+
+ @Override
+ public void endDocument() throws IOException {
+ }
+
+ @Override
+ public void flush() throws IOException {
+ }
+
+ @Override
+ public String getCharacterEncoding() {
+ return null;
+ }
+
+ @Override
+ public String getContentType() {
+ return null;
+ }
+
+ @Override
+ public void startDocument() throws IOException {
+ }
+
+ @Override
+ public void writeComment(Object comment) throws IOException {
+ }
+
+ @Override
+ public void writeText(Object text, String property) throws IOException {
+ }
+
+ @Override
+ public void writeText(char[] text, int off, int len) throws IOException {
+ }
+
+ @Override
+ public void writeURIAttribute(String name, Object value, String property)
+ throws IOException {
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ attr.add(String.valueOf(cbuf));
+ }
+
+}
Added:
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/html/TableDragDropRendererTest.java
===================================================================
---
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/html/TableDragDropRendererTest.java
(rev 0)
+++
trunk/ui/extendedDataTable/src/test/java/org/richfaces/renderkit/html/TableDragDropRendererTest.java 2008-08-12
06:46:35 UTC (rev 10037)
@@ -0,0 +1,117 @@
+package org.richfaces.renderkit.html;
+
+import java.util.Iterator;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIColumn;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author mpopiolek
+ *
+ */
+public class TableDragDropRendererTest extends AbstractAjax4JsfTestCase {
+
+ private TableDragDropRenderer renderer;
+
+ private UIColumn column1;
+
+ public TableDragDropRendererTest(String name) {
+ super(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ column1 = (UIColumn) application
+ .createComponent(UIColumn.COMPONENT_TYPE);
+ column1.setId("columnId1");
+ facesContext.getViewRoot().getChildren().add(column1);
+
+ renderer = TableDragDropRenderer.getInstance(facesContext);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ renderer = null;
+ column1 = null;
+ }
+
+ public void testEncodeChildScripts() {
+
+ }
+
+ public void testRenderDragSupport() {
+ try {
+ setupResponseWriter();
+ renderer.renderDragSupport(column1, "dragSourceId",
"indicatorId",
+ "dragLabel");
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement script = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+ if (node.getNodeName().equalsIgnoreCase("script")) {
+ script = node;
+ }
+ }
+
+ assertNotNull(script);
+
+ String className = script.getAttributeValue("id");
+
+ assertNotNull(className);
+
+ assertEquals("columnId1:dnd_drag_script", className);
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testRenderDropSupport() {
+
+ try {
+ setupResponseWriter();
+ renderer.renderDropSupport(column1, "dropTargetId", true);
+ HtmlPage page = processResponseWriter();
+
+ Iterator elementIterator = page.getAllHtmlChildElements();
+
+ HtmlElement script = null;
+
+ while (elementIterator.hasNext()) {
+ HtmlElement node = (HtmlElement) elementIterator.next();
+ if (node.getNodeName().equalsIgnoreCase("script")) {
+ script = node;
+ }
+ }
+
+ assertNotNull(script);
+
+ String className = script.getAttributeValue("id");
+
+ assertNotNull(className);
+
+ assertEquals("columnId1:dnd_drop_script_left", className);
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+}