You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2006/08/01 19:44:01 UTC
svn commit: r427657 [26/42] - in /myfaces:
core/trunk/api/src/main/java/javax/faces/component/
core/trunk/api/src/test/java/javax/faces/
core/trunk/api/src/test/java/javax/faces/application/
core/trunk/api/src/test/java/javax/faces/component/ core/trun...
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/schedule/resource/javascript/schedule.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/schedule/resource/javascript/schedule.js?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/schedule/resource/javascript/schedule.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/schedule/resource/javascript/schedule.js Tue Aug 1 10:43:28 2006
@@ -1,36 +1,36 @@
-function fireScheduleTimeClicked(obj, e, formId, scheduleId) {
- //make sure it works on IE too
- if (!e) var e = window.event;
- //capture the mouse coordinates relative to the foreground layer
- var y = e.layerY;
- var el = e.target;
- //make sure it works in IE too
- if (!y) y = e.offsetY;
- if (!el) el = e.srcElement;
- if (el != obj) return false;
- var dateInputId = scheduleId + "_last_clicked_date";
- var yInputId = scheduleId + "_last_clicked_y";
- document.forms[formId][dateInputId].value = el.id;
- document.forms[formId][yInputId].value = y;
- document.forms[formId].submit();
- return true;
-}
-
-function fireScheduleDateClicked(obj, e, formId, scheduleId) {
- //make sure it works on IE too
- if (!e) var e = window.event;
- var el = e.target;
- //make sure it works in IE too
- if (!el) el = e.srcElement;
- if (el != obj) return false;
- var dateInputId = scheduleId + "_last_clicked_date";
- document.forms[formId][dateInputId].value = el.id;
- document.forms[formId].submit();
- return true;
-}
-
-function fireEntrySelected(formId, scheduleId, entryId) {
- document.forms[formId][scheduleId].value = entryId;
- document.forms[formId].submit();
- return true;
-}
+function fireScheduleTimeClicked(obj, e, formId, scheduleId) {
+ //make sure it works on IE too
+ if (!e) var e = window.event;
+ //capture the mouse coordinates relative to the foreground layer
+ var y = e.layerY;
+ var el = e.target;
+ //make sure it works in IE too
+ if (!y) y = e.offsetY;
+ if (!el) el = e.srcElement;
+ if (el != obj) return false;
+ var dateInputId = scheduleId + "_last_clicked_date";
+ var yInputId = scheduleId + "_last_clicked_y";
+ document.forms[formId][dateInputId].value = el.id;
+ document.forms[formId][yInputId].value = y;
+ document.forms[formId].submit();
+ return true;
+}
+
+function fireScheduleDateClicked(obj, e, formId, scheduleId) {
+ //make sure it works on IE too
+ if (!e) var e = window.event;
+ var el = e.target;
+ //make sure it works in IE too
+ if (!el) el = e.srcElement;
+ if (el != obj) return false;
+ var dateInputId = scheduleId + "_last_clicked_date";
+ document.forms[formId][dateInputId].value = el.id;
+ document.forms[formId].submit();
+ return true;
+}
+
+function fireEntrySelected(formId, scheduleId, entryId) {
+ document.forms[formId][scheduleId].value = entryId;
+ document.forms[formId].submit();
+ return true;
+}
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/schedule/resource/javascript/schedule.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/component/html/ext/HtmlSelectManyCheckboxRendererCactus.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/date/HtmlDateRenderCactus.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/date/HtmlDateRendererTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/date/MockHtmlDateRendererTestRenderKit.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/date/MockHtmlDateRendererTestRenderKitFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/date/TestBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/date/UserDataTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/date/UserDataTest.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/date/UserDataTest.java (original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/date/UserDataTest.java Tue Aug 1 10:43:28 2006
@@ -1,211 +1,211 @@
-package org.apache.myfaces.custom.date;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.util.Date;
-import java.util.Locale;
-
-import org.apache.myfaces.custom.date.HtmlInputDate.UserData;
-
-import junit.framework.TestCase;
-
-public class UserDataTest extends TestCase {
-
- private UserData userData;
-
- public void testConstructorDoesNotSetDateVariablesWhenTheDateIsNull() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "date");
- assertNull(userData.getYear());
- assertNull(userData.getDay());
- assertNull(userData.getHours());
- }
-
- public void testParseReturnsNullWhenTypeIfDateAndComponentNotUsed() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "date");
- userData.setDay("");
- userData.setMonth("-1");
- userData.setYear("");
- try {
- Date date = userData.parse();
- assertNull(date);
- } catch (ParseException e) {
- fail();
- }
- }
-
- public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeDate() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "date");
- userData.setDay("40");
- userData.setMonth("-1");
- userData.setYear("2005");
- try {
- userData.parse();
- fail();
- } catch (ParseException e) {
- }
- }
-
- public void testParseGivesCorrectDateWhenValidDataIsEnteredForTypeDate() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "date");
- userData.setDay("20");
- userData.setMonth("7");
- userData.setYear("2006");
-
- Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+2:00"), Locale.ENGLISH);
- calendar.set(Calendar.DAY_OF_MONTH, 20);
- calendar.set(Calendar.MONTH, 6);
- calendar.set(Calendar.YEAR, 2006);
-
- //only day, month and year is considered for equality
- SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
- try {
- Date date1 = userData.parse();
- Date date2 = calendar.getTime();
- assertEquals(formatter.format(date1), formatter.format(date2));
- } catch (ParseException e) {
- e.printStackTrace();
- }
- }
-
- public void testParseReturnsNullWhenTypeIsTimeAndComponentNotUsed() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "time");
- userData.setHours("");
- userData.setMinutes("");
- userData.setSeconds("");
-
- try {
- assertNull(userData.parse());
- } catch (ParseException e) {
- fail();
- }
- }
-
- public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeTime() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "time");
- userData.setHours("25");
- userData.setMinutes("");
- userData.setSeconds("10");
-
- try {
- userData.parse();
- fail();
- } catch (ParseException e) {
- }
- }
-
- public void testParseGivesCorrectDateWhenValidDataIsEnteredForTypeTime() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "time");
- userData.setHours("10");
- userData.setMinutes("50");
- userData.setSeconds("30");
-
- Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+2:00"), Locale.ENGLISH);
- calendar.set(Calendar.HOUR_OF_DAY, 10);
- calendar.set(Calendar.MINUTE, 50);
- calendar.set(Calendar.SECOND, 30);
-
- //hour, minute, seconds is considered for equality
- SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss");
- try {
- Date date1 = userData.parse();
- Date date2 = calendar.getTime();
- assertEquals(formatter.format(date1), formatter.format(date2));
- } catch (ParseException e) {
- e.printStackTrace();
- }
- }
-
- public void testParseReturnsNullWhenTypeIsFullAndComponentNotUsed() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", true, "full");
- userData.setDay("");
- userData.setMonth("-1");
- userData.setYear("");
- userData.setHours("");
- userData.setMinutes("");
- userData.setSeconds("");
- userData.setAmpm("-1");
-
- try {
- assertNull(userData.parse());
- } catch (ParseException e) {
- fail();
- }
- }
-
- public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase1() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", true, "full");
- //date is used, time is not
- userData.setDay("40");
- userData.setMonth("-1");
- userData.setYear("");
- userData.setHours("");
- userData.setMinutes("");
- userData.setSeconds("");
- userData.setAmpm("-1");
-
- try {
- userData.parse();
- fail();
- } catch (ParseException e) {
- }
- }
-
- public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase2() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", true, "full");
- //date is used time is not
- userData.setDay("");
- userData.setMonth("0");
- userData.setYear("2005");
- userData.setHours("");
- userData.setMinutes("");
- userData.setSeconds("");
- userData.setAmpm("-1");
-
- try {
- userData.parse();
- fail();
- } catch (ParseException e) {
- }
- }
-
- public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase3() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", true, "full");
- //date is used time is not
- userData.setDay("5");
- userData.setMonth("10");
- userData.setYear("2005");
- userData.setHours("");
- userData.setMinutes("");
- userData.setSeconds("");
- userData.setAmpm("-1");
-
- try {
- userData.parse();
- fail();
- } catch (ParseException e) {
- }
- }
-
- public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase4() {
- userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", true, "full");
- //date is not used but time is
- userData.setDay("");
- userData.setMonth("-1");
- userData.setYear("");
- userData.setHours("");
- userData.setMinutes("30");
- userData.setSeconds("");
- userData.setAmpm("-1");
-
- try {
- userData.parse();
- fail();
- } catch (ParseException e) {
- }
- }
-
-
-
-}
+package org.apache.myfaces.custom.date;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.TimeZone;
+import java.util.Date;
+import java.util.Locale;
+
+import org.apache.myfaces.custom.date.HtmlInputDate.UserData;
+
+import junit.framework.TestCase;
+
+public class UserDataTest extends TestCase {
+
+ private UserData userData;
+
+ public void testConstructorDoesNotSetDateVariablesWhenTheDateIsNull() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "date");
+ assertNull(userData.getYear());
+ assertNull(userData.getDay());
+ assertNull(userData.getHours());
+ }
+
+ public void testParseReturnsNullWhenTypeIfDateAndComponentNotUsed() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "date");
+ userData.setDay("");
+ userData.setMonth("-1");
+ userData.setYear("");
+ try {
+ Date date = userData.parse();
+ assertNull(date);
+ } catch (ParseException e) {
+ fail();
+ }
+ }
+
+ public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeDate() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "date");
+ userData.setDay("40");
+ userData.setMonth("-1");
+ userData.setYear("2005");
+ try {
+ userData.parse();
+ fail();
+ } catch (ParseException e) {
+ }
+ }
+
+ public void testParseGivesCorrectDateWhenValidDataIsEnteredForTypeDate() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "date");
+ userData.setDay("20");
+ userData.setMonth("7");
+ userData.setYear("2006");
+
+ Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+2:00"), Locale.ENGLISH);
+ calendar.set(Calendar.DAY_OF_MONTH, 20);
+ calendar.set(Calendar.MONTH, 6);
+ calendar.set(Calendar.YEAR, 2006);
+
+ //only day, month and year is considered for equality
+ SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
+ try {
+ Date date1 = userData.parse();
+ Date date2 = calendar.getTime();
+ assertEquals(formatter.format(date1), formatter.format(date2));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void testParseReturnsNullWhenTypeIsTimeAndComponentNotUsed() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "time");
+ userData.setHours("");
+ userData.setMinutes("");
+ userData.setSeconds("");
+
+ try {
+ assertNull(userData.parse());
+ } catch (ParseException e) {
+ fail();
+ }
+ }
+
+ public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeTime() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "time");
+ userData.setHours("25");
+ userData.setMinutes("");
+ userData.setSeconds("10");
+
+ try {
+ userData.parse();
+ fail();
+ } catch (ParseException e) {
+ }
+ }
+
+ public void testParseGivesCorrectDateWhenValidDataIsEnteredForTypeTime() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", false, "time");
+ userData.setHours("10");
+ userData.setMinutes("50");
+ userData.setSeconds("30");
+
+ Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+2:00"), Locale.ENGLISH);
+ calendar.set(Calendar.HOUR_OF_DAY, 10);
+ calendar.set(Calendar.MINUTE, 50);
+ calendar.set(Calendar.SECOND, 30);
+
+ //hour, minute, seconds is considered for equality
+ SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss");
+ try {
+ Date date1 = userData.parse();
+ Date date2 = calendar.getTime();
+ assertEquals(formatter.format(date1), formatter.format(date2));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void testParseReturnsNullWhenTypeIsFullAndComponentNotUsed() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", true, "full");
+ userData.setDay("");
+ userData.setMonth("-1");
+ userData.setYear("");
+ userData.setHours("");
+ userData.setMinutes("");
+ userData.setSeconds("");
+ userData.setAmpm("-1");
+
+ try {
+ assertNull(userData.parse());
+ } catch (ParseException e) {
+ fail();
+ }
+ }
+
+ public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase1() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", true, "full");
+ //date is used, time is not
+ userData.setDay("40");
+ userData.setMonth("-1");
+ userData.setYear("");
+ userData.setHours("");
+ userData.setMinutes("");
+ userData.setSeconds("");
+ userData.setAmpm("-1");
+
+ try {
+ userData.parse();
+ fail();
+ } catch (ParseException e) {
+ }
+ }
+
+ public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase2() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", true, "full");
+ //date is used time is not
+ userData.setDay("");
+ userData.setMonth("0");
+ userData.setYear("2005");
+ userData.setHours("");
+ userData.setMinutes("");
+ userData.setSeconds("");
+ userData.setAmpm("-1");
+
+ try {
+ userData.parse();
+ fail();
+ } catch (ParseException e) {
+ }
+ }
+
+ public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase3() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", true, "full");
+ //date is used time is not
+ userData.setDay("5");
+ userData.setMonth("10");
+ userData.setYear("2005");
+ userData.setHours("");
+ userData.setMinutes("");
+ userData.setSeconds("");
+ userData.setAmpm("-1");
+
+ try {
+ userData.parse();
+ fail();
+ } catch (ParseException e) {
+ }
+ }
+
+ public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase4() {
+ userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", true, "full");
+ //date is not used but time is
+ userData.setDay("");
+ userData.setMonth("-1");
+ userData.setYear("");
+ userData.setHours("");
+ userData.setMinutes("30");
+ userData.setSeconds("");
+ userData.setAmpm("-1");
+
+ try {
+ userData.parse();
+ fail();
+ } catch (ParseException e) {
+ }
+ }
+
+
+
+}
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/date/UserDataTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/stylesheet/StylesheetRendererTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/AbstractTreeTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/AbstractTreeTestCase.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/AbstractTreeTestCase.java (original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/AbstractTreeTestCase.java Tue Aug 1 10:43:28 2006
@@ -1,150 +1,150 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.myfaces.custom.tree2;
-
-import org.apache.shale.test.base.AbstractJsfTestCase;
-import org.apache.shale.test.mock.MockRenderKitFactory;
-import org.apache.shale.test.mock.MockResponseWriter;
-import org.apache.myfaces.shared_tomahawk.config.MyfacesConfig;
-
-import java.io.BufferedWriter;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.util.Stack;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import junit.framework.TestSuite;
-import junit.framework.Test;
-
-/**
- * An abstract test case that sets up a Tree2 for testing using the structure below.
- *
- * - .. Root (0)
- * |
- * - .. A (0:0)
- * | |
- * | + .. AA (0:0:0)
- * | |
- * | + .. AB (0:0:1)
- * | |
- * | + .. AC (0:0:2)
- * | | .. aca (0:0:2:0)
- * | | .. acb (0:0:2:1)
- * |
- * + .. B (0:1)
- * | |
- * | + .. BA (0:1:0)
- * | |
- * | + .. BB (0:1:1)
- * |
- * | .. C (0:2)
- * |
- * | .. d (0:3)
- */
-
-public class AbstractTreeTestCase extends AbstractJsfTestCase
-{
- static final String DEFAULT_NODE_TYPE = "default";
- static final String TREE_ID = "some_foo_tree";
-
- HtmlTree tree;
- TreeNodeBase rootNode;
-
- /**
- * Constructor
- * @param name String
- */
- public AbstractTreeTestCase(String name)
- {
- super(name);
- }
-
- /**
- * See abstract class
- */
- public void setUp()
- {
- super.setUp();
-
- tree = new HtmlTree();
- tree.setId(TREE_ID);
-
- // additional setup not provided automatically by the shale mock stuff
- facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), new MyfacesConfig());
- facesContext.setResponseWriter(new MockResponseWriter(new BufferedWriter(new CharArrayWriter()), null, null));
-
- // TODO remove these two lines once shale-test goes alpha, see MYFACES-1155
- facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
-
- // set up the test tree with the standard data
- rootNode = new TreeNodeBase(DEFAULT_NODE_TYPE, "Root", "Root", false);
-
- TreeNodeBase A_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "A", "A", false);
- A_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "AA", "AA", false));
- A_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "AB", "AB", false));
- TreeNodeBase AC_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "AC", "AC", false);
- AC_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "aca", "aca", true));
- AC_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "acb", "acb", true));
- A_node.getChildren().add(AC_node);
- rootNode.getChildren().add(A_node);
-
- TreeNodeBase B_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "B", "B", false);
- B_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "BA", "BA", false));
- B_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "BB", "BB", false));
- rootNode.getChildren().add(B_node);
-
- TreeNodeBase C_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "C", "C", false);
- rootNode.getChildren().add(C_node);
-
- TreeNodeBase d_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "d", "d", true);
- rootNode.getChildren().add(d_node);
-
- tree.setValue(rootNode);
- }
-
- /**
- * Instead of using UIText or whatever inside the tree we use this special "simulator."
- * This way we can keep track of when the renderer is asking the node to render itself.
- */
- static final class NodeSimulator extends UIComponentBase
- {
- private static final String COMPONENT_FAMILY = "Foo";
- private Stack nodeStack = new Stack();
-
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
-
- public void encodeBegin(FacesContext context) throws IOException
- {
- HtmlTree tree = (HtmlTree)super.getParent();
- nodeStack.push(tree.getNode());
- }
-
- public Stack getNodeStack()
- {
- return nodeStack;
- }
- }
-
- // Return the tests included in this test case.
- public static Test suite()
- {
- return (new TestSuite());
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.custom.tree2;
+
+import org.apache.shale.test.base.AbstractJsfTestCase;
+import org.apache.shale.test.mock.MockRenderKitFactory;
+import org.apache.shale.test.mock.MockResponseWriter;
+import org.apache.myfaces.shared_tomahawk.config.MyfacesConfig;
+
+import java.io.BufferedWriter;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.util.Stack;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import junit.framework.TestSuite;
+import junit.framework.Test;
+
+/**
+ * An abstract test case that sets up a Tree2 for testing using the structure below.
+ *
+ * - .. Root (0)
+ * |
+ * - .. A (0:0)
+ * | |
+ * | + .. AA (0:0:0)
+ * | |
+ * | + .. AB (0:0:1)
+ * | |
+ * | + .. AC (0:0:2)
+ * | | .. aca (0:0:2:0)
+ * | | .. acb (0:0:2:1)
+ * |
+ * + .. B (0:1)
+ * | |
+ * | + .. BA (0:1:0)
+ * | |
+ * | + .. BB (0:1:1)
+ * |
+ * | .. C (0:2)
+ * |
+ * | .. d (0:3)
+ */
+
+public class AbstractTreeTestCase extends AbstractJsfTestCase
+{
+ static final String DEFAULT_NODE_TYPE = "default";
+ static final String TREE_ID = "some_foo_tree";
+
+ HtmlTree tree;
+ TreeNodeBase rootNode;
+
+ /**
+ * Constructor
+ * @param name String
+ */
+ public AbstractTreeTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * See abstract class
+ */
+ public void setUp()
+ {
+ super.setUp();
+
+ tree = new HtmlTree();
+ tree.setId(TREE_ID);
+
+ // additional setup not provided automatically by the shale mock stuff
+ facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), new MyfacesConfig());
+ facesContext.setResponseWriter(new MockResponseWriter(new BufferedWriter(new CharArrayWriter()), null, null));
+
+ // TODO remove these two lines once shale-test goes alpha, see MYFACES-1155
+ facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
+
+ // set up the test tree with the standard data
+ rootNode = new TreeNodeBase(DEFAULT_NODE_TYPE, "Root", "Root", false);
+
+ TreeNodeBase A_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "A", "A", false);
+ A_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "AA", "AA", false));
+ A_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "AB", "AB", false));
+ TreeNodeBase AC_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "AC", "AC", false);
+ AC_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "aca", "aca", true));
+ AC_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "acb", "acb", true));
+ A_node.getChildren().add(AC_node);
+ rootNode.getChildren().add(A_node);
+
+ TreeNodeBase B_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "B", "B", false);
+ B_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "BA", "BA", false));
+ B_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "BB", "BB", false));
+ rootNode.getChildren().add(B_node);
+
+ TreeNodeBase C_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "C", "C", false);
+ rootNode.getChildren().add(C_node);
+
+ TreeNodeBase d_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "d", "d", true);
+ rootNode.getChildren().add(d_node);
+
+ tree.setValue(rootNode);
+ }
+
+ /**
+ * Instead of using UIText or whatever inside the tree we use this special "simulator."
+ * This way we can keep track of when the renderer is asking the node to render itself.
+ */
+ static final class NodeSimulator extends UIComponentBase
+ {
+ private static final String COMPONENT_FAMILY = "Foo";
+ private Stack nodeStack = new Stack();
+
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ HtmlTree tree = (HtmlTree)super.getParent();
+ nodeStack.push(tree.getNode());
+ }
+
+ public Stack getNodeStack()
+ {
+ return nodeStack;
+ }
+ }
+
+ // Return the tests included in this test case.
+ public static Test suite()
+ {
+ return (new TestSuite());
+ }
+}
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/AbstractTreeTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/HtmlTreeRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/HtmlTreeRendererTest.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/HtmlTreeRendererTest.java (original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/HtmlTreeRendererTest.java Tue Aug 1 10:43:28 2006
@@ -1,169 +1,169 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.myfaces.custom.tree2;
-
-import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
-import org.apache.shale.test.mock.MockResponseWriter;
-
-import com.meterware.httpunit.WebResponse;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import java.util.Stack;
-import java.io.BufferedWriter;
-import java.io.CharArrayWriter;
-
-/**
- * - .. Root (0)
- * |
- * - .. A (0:0)
- * | |
- * | + .. AA (0:0:0)
- * | |
- * | + .. AB (0:0:1)
- * | |
- * | + .. AC (0:0:2)
- * | | .. aca (0:0:2:0)
- * | | .. acb (0:0:2:1)
- * |
- * + .. B (0:1)
- * | |
- * | + .. BA (0:1:0)
- * | |
- * | + .. BB (0:1:1)
- * |
- * | .. C (0:2)
- * |
- * | .. d (0:3)
- */
-
-public class HtmlTreeRendererTest extends AbstractTreeTestCase
-{
- private NodeSimulator nodeSim;
-
- /**
- * Constructor
- * @param name String
- */
- public HtmlTreeRendererTest(String name)
- {
- super(name);
- }
-
- /**
- * See abstract class
- */
- public void setUp()
- {
- super.setUp();
-
- nodeSim = new NodeSimulator();
-
- // the tree needs a default facet - use a node simulator instead of the usual components
- // so we can detect when a node is rendered
- tree.getFacets().put(DEFAULT_NODE_TYPE, nodeSim);
-
- // set up the renderer for the component. with mock stuff we don't have faces config doing this for us
- renderKit.addRenderer(HtmlTree.COMPONENT_FAMILY, HtmlTree.COMPONENT_TYPE, new HtmlTreeRenderer());
- }
-
- /**
- * Tests the option of hiding the root node (with server side toggling option)
- * @throws Exception
- */
- public void testHideRootNodeServer() throws Exception
- {
- tree.setClientSideToggle(false);
- tree.setShowRootNode(false);
-
- HtmlTreeRenderer treeRenderer = new HtmlTreeRenderer();
- treeRenderer.encodeChildren(facesContext, tree);
-
- // we expect the nodes to come off the stack in the reverse order in which they were added
- Stack nodeStack = nodeSim.getNodeStack();
- int numRendered = nodeStack.size();
- assertEquals("Unexpected number of nodes rendered", 4, numRendered);
-
- TreeNode node = (TreeNode)nodeStack.pop();
- assertEquals("d", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("C", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("B", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("A", node.getIdentifier());
- }
-
- /**
- * Tests the option of hiding the root node (with client side toggling option)
- * @throws Exception
- */
- public void testHideRootNodeClient() throws Exception
- {
- tree.setClientSideToggle(true);
- tree.setShowRootNode(false);
-
- HtmlTreeRenderer treeRenderer = new HtmlTreeRenderer();
- treeRenderer.encodeChildren(facesContext, tree);
-
- // we expect the nodes to come off the stack in the reverse order in which they were added
- Stack nodeStack = nodeSim.getNodeStack();
- int numRendered = nodeStack.size();
- assertEquals("Unexpected number of nodes rendered", 11, numRendered);
-
- TreeNode node = (TreeNode)nodeStack.pop();
- assertEquals("d", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("C", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("BB", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("BA", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("B", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("acb", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("aca", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("AC", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("AB", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("AA", node.getIdentifier());
-
- node = (TreeNode)nodeStack.pop();
- assertEquals("A", node.getIdentifier());
- }
-
- public static Test suite()
- {
- return new TestSuite(HtmlTreeRendererTest.class);
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.custom.tree2;
+
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+import org.apache.shale.test.mock.MockResponseWriter;
+
+import com.meterware.httpunit.WebResponse;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import java.util.Stack;
+import java.io.BufferedWriter;
+import java.io.CharArrayWriter;
+
+/**
+ * - .. Root (0)
+ * |
+ * - .. A (0:0)
+ * | |
+ * | + .. AA (0:0:0)
+ * | |
+ * | + .. AB (0:0:1)
+ * | |
+ * | + .. AC (0:0:2)
+ * | | .. aca (0:0:2:0)
+ * | | .. acb (0:0:2:1)
+ * |
+ * + .. B (0:1)
+ * | |
+ * | + .. BA (0:1:0)
+ * | |
+ * | + .. BB (0:1:1)
+ * |
+ * | .. C (0:2)
+ * |
+ * | .. d (0:3)
+ */
+
+public class HtmlTreeRendererTest extends AbstractTreeTestCase
+{
+ private NodeSimulator nodeSim;
+
+ /**
+ * Constructor
+ * @param name String
+ */
+ public HtmlTreeRendererTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * See abstract class
+ */
+ public void setUp()
+ {
+ super.setUp();
+
+ nodeSim = new NodeSimulator();
+
+ // the tree needs a default facet - use a node simulator instead of the usual components
+ // so we can detect when a node is rendered
+ tree.getFacets().put(DEFAULT_NODE_TYPE, nodeSim);
+
+ // set up the renderer for the component. with mock stuff we don't have faces config doing this for us
+ renderKit.addRenderer(HtmlTree.COMPONENT_FAMILY, HtmlTree.COMPONENT_TYPE, new HtmlTreeRenderer());
+ }
+
+ /**
+ * Tests the option of hiding the root node (with server side toggling option)
+ * @throws Exception
+ */
+ public void testHideRootNodeServer() throws Exception
+ {
+ tree.setClientSideToggle(false);
+ tree.setShowRootNode(false);
+
+ HtmlTreeRenderer treeRenderer = new HtmlTreeRenderer();
+ treeRenderer.encodeChildren(facesContext, tree);
+
+ // we expect the nodes to come off the stack in the reverse order in which they were added
+ Stack nodeStack = nodeSim.getNodeStack();
+ int numRendered = nodeStack.size();
+ assertEquals("Unexpected number of nodes rendered", 4, numRendered);
+
+ TreeNode node = (TreeNode)nodeStack.pop();
+ assertEquals("d", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("C", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("B", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("A", node.getIdentifier());
+ }
+
+ /**
+ * Tests the option of hiding the root node (with client side toggling option)
+ * @throws Exception
+ */
+ public void testHideRootNodeClient() throws Exception
+ {
+ tree.setClientSideToggle(true);
+ tree.setShowRootNode(false);
+
+ HtmlTreeRenderer treeRenderer = new HtmlTreeRenderer();
+ treeRenderer.encodeChildren(facesContext, tree);
+
+ // we expect the nodes to come off the stack in the reverse order in which they were added
+ Stack nodeStack = nodeSim.getNodeStack();
+ int numRendered = nodeStack.size();
+ assertEquals("Unexpected number of nodes rendered", 11, numRendered);
+
+ TreeNode node = (TreeNode)nodeStack.pop();
+ assertEquals("d", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("C", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("BB", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("BA", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("B", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("acb", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("aca", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("AC", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("AB", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("AA", node.getIdentifier());
+
+ node = (TreeNode)nodeStack.pop();
+ assertEquals("A", node.getIdentifier());
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(HtmlTreeRendererTest.class);
+ }
+}
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/HtmlTreeRendererTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/HtmlTreeTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/HtmlTreeTest.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/HtmlTreeTest.java (original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/HtmlTreeTest.java Tue Aug 1 10:43:28 2006
@@ -1,77 +1,77 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.myfaces.custom.tree2;
-
-import org.apache.shale.test.base.AbstractJsfTestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * TestCase for HtmlTree
- *
- * @author Sean Schofield
- */
-public class HtmlTreeTest extends AbstractTreeTestCase
-{
- //private HtmlTree tree;
-
- /**
- * Constructor
- * @param name Test name
- */
- public HtmlTreeTest(String name)
- {
- super(name);
- }
-
-// public void setUp()
-// {
-// super.setUp();
-// tree = new HtmlTree();
-// }
-//
-// public void tearDown()
-// {
-// super.tearDown();
-// }
-
- // Return the tests included in this test case.
- public static Test suite()
- {
- return new TestSuite(HtmlTreeTest.class);
- }
-
- /**
- * Test default values of the tree
- */
- public void testDefaults()
- {
- assertTrue("clientSideToggle default should be true", tree.isClientSideToggle());
- assertTrue("showNav default should be true", tree.isShowNav());
- assertTrue("showLines default should be true", tree.isShowLines());
- assertTrue("showRootNode default should be true", tree.isShowRootNode());
- assertTrue("preserveToggle default should be true", tree.isPreserveToggle());
- }
-
- /**
- *
- */
- public void testSaveAndRestore()
- {
-
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.custom.tree2;
+
+import org.apache.shale.test.base.AbstractJsfTestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * TestCase for HtmlTree
+ *
+ * @author Sean Schofield
+ */
+public class HtmlTreeTest extends AbstractTreeTestCase
+{
+ //private HtmlTree tree;
+
+ /**
+ * Constructor
+ * @param name Test name
+ */
+ public HtmlTreeTest(String name)
+ {
+ super(name);
+ }
+
+// public void setUp()
+// {
+// super.setUp();
+// tree = new HtmlTree();
+// }
+//
+// public void tearDown()
+// {
+// super.tearDown();
+// }
+
+ // Return the tests included in this test case.
+ public static Test suite()
+ {
+ return new TestSuite(HtmlTreeTest.class);
+ }
+
+ /**
+ * Test default values of the tree
+ */
+ public void testDefaults()
+ {
+ assertTrue("clientSideToggle default should be true", tree.isClientSideToggle());
+ assertTrue("showNav default should be true", tree.isShowNav());
+ assertTrue("showLines default should be true", tree.isShowLines());
+ assertTrue("showRootNode default should be true", tree.isShowRootNode());
+ assertTrue("preserveToggle default should be true", tree.isPreserveToggle());
+ }
+
+ /**
+ *
+ */
+ public void testSaveAndRestore()
+ {
+
+ }
+}
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/HtmlTreeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/TreeWalkerBaseTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/TreeWalkerBaseTest.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/TreeWalkerBaseTest.java (original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/TreeWalkerBaseTest.java Tue Aug 1 10:43:28 2006
@@ -1,228 +1,228 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.myfaces.custom.tree2;
-
-import junit.framework.TestCase;
-
-
-/**
- * - .. Root (0)
- * |
- * - .. A (0:0)
- * | |
- * | + .. AA (0:0:0)
- * | |
- * | + .. AB (0:0:1)
- * | |
- * | + .. AC (0:0:2)
- * | | .. aca (0:0:2:0)
- * | | .. acb (0:0:2:1)
- * |
- * + .. B (0:1)
- * | |
- * | + .. BA (0:1:0)
- * | |
- * | + .. BB (0:1:1)
- * |
- * | .. C (0:2)
- * |
- * | .. d (0:3)
- */
-
-public class TreeWalkerBaseTest extends TestCase
-{
- private static final String DEFAULT_NODE_TYPE = "default";
-
- UITreeData treeData = new UITreeData();
- TreeWalker treeWalker;
-
- protected void setUp() throws Exception
- {
- // set up the test tree with the standard data
- TreeNodeBase Root_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "Root", "Root", false);
-
- TreeNodeBase A_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "A", "A", false);
- A_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "AA", "AA", false));
- A_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "AB", "AB", false));
- TreeNodeBase AC_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "AC", "AC", false);
- AC_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "aca", "aca", true));
- AC_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "acb", "acb", true));
- A_node.getChildren().add(AC_node);
- Root_node.getChildren().add(A_node);
-
- TreeNodeBase B_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "B", "B", false);
- B_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "BA", "BA", false));
- B_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "BB", "BB", false));
- Root_node.getChildren().add(B_node);
-
- TreeNodeBase C_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "C", "C", false);
- Root_node.getChildren().add(C_node);
-
- TreeNodeBase d_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "d", "d", true);
- Root_node.getChildren().add(d_node);
-
- treeData.setValue(Root_node);
-
- // setup the tree state
- TreeState treeState = treeData.getDataModel().getTreeState();
- treeState.toggleExpanded("0");
- treeState.toggleExpanded("0:0");
-
- // setup the tree walker
- treeWalker = treeData.getDataModel().getTreeWalker();
- treeWalker.setTree(treeData);
- }
-
- public void testGetRootNodeId() throws Exception
- {
- String nodeId = treeWalker.getRootNodeId();
- assertEquals("Unexpected rootId", "0", nodeId);
- }
-
- /**
- * Walk through all of the nodes and make sure the return value is correct as well as the current node of
- * the tree. Continue until the walker runs out of nodes. Since the checkState property is true only the
- * expanded nodes will be walked.
- *
- * @throws Exception
- */
- public void testNextCheckState() throws Exception
- {
- treeWalker.setCheckState(true);
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0", treeData.getNodeId());
- assertEquals("unexpected node", "Root", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:0", treeData.getNodeId());
- assertEquals("unexpected node", "A", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:0:0", treeData.getNodeId());
- assertEquals("unexpected node", "AA", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:0:1", treeData.getNodeId());
- assertEquals("unexpected node", "AB", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:0:2", treeData.getNodeId());
- assertEquals("unexpected node", "AC", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:1", treeData.getNodeId());
- assertEquals("unexpected node", "B", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:2", treeData.getNodeId());
- assertEquals("unexpected node", "C", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:3", treeData.getNodeId());
- assertEquals("unexpected node", "d", treeData.getNode().getIdentifier());
-
- // not expecting anymore nodes
- assertFalse("unxpected return value", treeWalker.next());
- }
-
-
- /**
- * Walk through all of the nodes and make sure the return value is correct as well as the current node of
- * the tree. Continue until the walker runs out of nodes. Sets the checkState property to false so all of
- * the nodes will be walked.
- *
- * @throws Exception
- */
- public void testNextNoCheckState() throws Exception
- {
- // walk through all of the nodes and make sure the return value is correct until we run out of
- // nodes
- treeWalker.setCheckState(false);
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0", treeData.getNodeId());
- assertEquals("unexpected node", "Root", treeData.getNode().getIdentifier());
-
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:0", treeData.getNodeId());
- assertEquals("unexpected node", "A", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:0:0", treeData.getNodeId());
- assertEquals("unexpected node", "AA", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:0:1", treeData.getNodeId());
- assertEquals("unexpected node", "AB", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:0:2", treeData.getNodeId());
- assertEquals("unexpected node", "AC", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:0:2:0", treeData.getNodeId());
- assertEquals("unexpected node", "aca", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:0:2:1", treeData.getNodeId());
- assertEquals("unexpected node", "acb", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:1", treeData.getNodeId());
- assertEquals("unexpected node", "B", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:1:0", treeData.getNodeId());
- assertEquals("unexpected node", "BA", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:1:1", treeData.getNodeId());
- assertEquals("unexpected node", "BB", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:2", treeData.getNodeId());
- assertEquals("unexpected node", "C", treeData.getNode().getIdentifier());
-
- assertTrue("unxpected return value", treeWalker.next());
- assertEquals("unexpected nodeId", "0:3", treeData.getNodeId());
- assertEquals("unexpected node", "d", treeData.getNode().getIdentifier());
-
- // not expecting anymore nodes
- assertFalse("unxpected return value", treeWalker.next());
- }
-
- /**
- * Walk through the tree. Then call reset. Make sure the tree is walked through again
- * from the beginning. This can be tested by running some of the other tests twice with
- * a call to reset in between.
- */
- public void testReset()
- {
- try
- {
- testNextCheckState();
- treeWalker.reset();
- testNextCheckState();
- }
- catch (Exception e)
- {
- fail("Unable to successfuly check the next method twice with a reset");
- }
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.custom.tree2;
+
+import junit.framework.TestCase;
+
+
+/**
+ * - .. Root (0)
+ * |
+ * - .. A (0:0)
+ * | |
+ * | + .. AA (0:0:0)
+ * | |
+ * | + .. AB (0:0:1)
+ * | |
+ * | + .. AC (0:0:2)
+ * | | .. aca (0:0:2:0)
+ * | | .. acb (0:0:2:1)
+ * |
+ * + .. B (0:1)
+ * | |
+ * | + .. BA (0:1:0)
+ * | |
+ * | + .. BB (0:1:1)
+ * |
+ * | .. C (0:2)
+ * |
+ * | .. d (0:3)
+ */
+
+public class TreeWalkerBaseTest extends TestCase
+{
+ private static final String DEFAULT_NODE_TYPE = "default";
+
+ UITreeData treeData = new UITreeData();
+ TreeWalker treeWalker;
+
+ protected void setUp() throws Exception
+ {
+ // set up the test tree with the standard data
+ TreeNodeBase Root_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "Root", "Root", false);
+
+ TreeNodeBase A_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "A", "A", false);
+ A_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "AA", "AA", false));
+ A_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "AB", "AB", false));
+ TreeNodeBase AC_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "AC", "AC", false);
+ AC_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "aca", "aca", true));
+ AC_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "acb", "acb", true));
+ A_node.getChildren().add(AC_node);
+ Root_node.getChildren().add(A_node);
+
+ TreeNodeBase B_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "B", "B", false);
+ B_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "BA", "BA", false));
+ B_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "BB", "BB", false));
+ Root_node.getChildren().add(B_node);
+
+ TreeNodeBase C_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "C", "C", false);
+ Root_node.getChildren().add(C_node);
+
+ TreeNodeBase d_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "d", "d", true);
+ Root_node.getChildren().add(d_node);
+
+ treeData.setValue(Root_node);
+
+ // setup the tree state
+ TreeState treeState = treeData.getDataModel().getTreeState();
+ treeState.toggleExpanded("0");
+ treeState.toggleExpanded("0:0");
+
+ // setup the tree walker
+ treeWalker = treeData.getDataModel().getTreeWalker();
+ treeWalker.setTree(treeData);
+ }
+
+ public void testGetRootNodeId() throws Exception
+ {
+ String nodeId = treeWalker.getRootNodeId();
+ assertEquals("Unexpected rootId", "0", nodeId);
+ }
+
+ /**
+ * Walk through all of the nodes and make sure the return value is correct as well as the current node of
+ * the tree. Continue until the walker runs out of nodes. Since the checkState property is true only the
+ * expanded nodes will be walked.
+ *
+ * @throws Exception
+ */
+ public void testNextCheckState() throws Exception
+ {
+ treeWalker.setCheckState(true);
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0", treeData.getNodeId());
+ assertEquals("unexpected node", "Root", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:0", treeData.getNodeId());
+ assertEquals("unexpected node", "A", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:0:0", treeData.getNodeId());
+ assertEquals("unexpected node", "AA", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:0:1", treeData.getNodeId());
+ assertEquals("unexpected node", "AB", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:0:2", treeData.getNodeId());
+ assertEquals("unexpected node", "AC", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:1", treeData.getNodeId());
+ assertEquals("unexpected node", "B", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:2", treeData.getNodeId());
+ assertEquals("unexpected node", "C", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:3", treeData.getNodeId());
+ assertEquals("unexpected node", "d", treeData.getNode().getIdentifier());
+
+ // not expecting anymore nodes
+ assertFalse("unxpected return value", treeWalker.next());
+ }
+
+
+ /**
+ * Walk through all of the nodes and make sure the return value is correct as well as the current node of
+ * the tree. Continue until the walker runs out of nodes. Sets the checkState property to false so all of
+ * the nodes will be walked.
+ *
+ * @throws Exception
+ */
+ public void testNextNoCheckState() throws Exception
+ {
+ // walk through all of the nodes and make sure the return value is correct until we run out of
+ // nodes
+ treeWalker.setCheckState(false);
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0", treeData.getNodeId());
+ assertEquals("unexpected node", "Root", treeData.getNode().getIdentifier());
+
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:0", treeData.getNodeId());
+ assertEquals("unexpected node", "A", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:0:0", treeData.getNodeId());
+ assertEquals("unexpected node", "AA", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:0:1", treeData.getNodeId());
+ assertEquals("unexpected node", "AB", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:0:2", treeData.getNodeId());
+ assertEquals("unexpected node", "AC", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:0:2:0", treeData.getNodeId());
+ assertEquals("unexpected node", "aca", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:0:2:1", treeData.getNodeId());
+ assertEquals("unexpected node", "acb", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:1", treeData.getNodeId());
+ assertEquals("unexpected node", "B", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:1:0", treeData.getNodeId());
+ assertEquals("unexpected node", "BA", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:1:1", treeData.getNodeId());
+ assertEquals("unexpected node", "BB", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:2", treeData.getNodeId());
+ assertEquals("unexpected node", "C", treeData.getNode().getIdentifier());
+
+ assertTrue("unxpected return value", treeWalker.next());
+ assertEquals("unexpected nodeId", "0:3", treeData.getNodeId());
+ assertEquals("unexpected node", "d", treeData.getNode().getIdentifier());
+
+ // not expecting anymore nodes
+ assertFalse("unxpected return value", treeWalker.next());
+ }
+
+ /**
+ * Walk through the tree. Then call reset. Make sure the tree is walked through again
+ * from the beginning. This can be tested by running some of the other tests twice with
+ * a call to reset in between.
+ */
+ public void testReset()
+ {
+ try
+ {
+ testNextCheckState();
+ treeWalker.reset();
+ testNextCheckState();
+ }
+ catch (Exception e)
+ {
+ fail("Unable to successfuly check the next method twice with a reset");
+ }
+ }
+}
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/TreeWalkerBaseTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/UITreeDataTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/UITreeDataTest.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/UITreeDataTest.java (original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/UITreeDataTest.java Tue Aug 1 10:43:28 2006
@@ -1,185 +1,185 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.myfaces.custom.tree2;
-
-
-import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import javax.faces.event.ActionEvent;
-import javax.faces.component.html.HtmlCommandLink;
-
-/**
- * Test case for {@link UITreeData}.
- */
-public class UITreeDataTest extends AbstractTreeTestCase
-{
- /**
- * Constructor
- * @param name String
- */
- public UITreeDataTest(String name)
- {
- super(name);
- }
-
- /**
- * See abstract class
- */
- public void setUp()
- {
- super.setUp();
- }
-
- /**
- * Tests the selection of a specific node using both server side and client side
- * toggle options.
- *
- * @throws Exception
- */
- public void testNodeSelected() throws Exception
- {
- tree.setClientSideToggle(false);
- // tree.getAttributes().put(JSFAttr.CLIENT_SIDE_TOGGLE, Boolean.FALSE);
-
- ActionEvent event = new ActionEvent(new HtmlCommandLink());
-
- // set the node to be selected
- tree.setNodeId("0:1:0");
- tree.setNodeSelected(event);
-
- assertTrue("Node 0:1:0 should be selected", tree.isNodeSelected());
-
- tree.setClientSideToggle(true);
- // tree.getAttributes().put(JSFAttr.CLIENT_SIDE_TOGGLE, Boolean.TRUE);
-
- // set the node to be selected
- tree.setNodeId("0:1:0");
- tree.setNodeSelected(event);
-
- assertTrue("Node 0:1:0 should be selected", tree.isNodeSelected());
- }
-
- /**
- * Tests programatic selection of a node. (See MYFACES-717)
- * @throws Exception
- */
- public void testProgramaticSelection() throws Exception
- {
- TreeModel treeModel = tree.getDataModel();
- TreeState treeState = treeModel.getTreeState();
- treeState.setSelected("0:3");
-
- treeModel.setTreeState(treeState);
-
- tree.setValue(treeModel);
- tree.setNodeId("0:3");
- assertTrue("Node 0:3 should be selected", tree.isNodeSelected());
- }
-
- /**
- * Tests the ability to expand all nodes at once. (See TOMAHAWK-436)
- * @throws Exception
- */
- public void testExpandAll() throws Exception
- {
- tree.expandAll();
-
- tree.setNodeId("0");
- assertTrue("Node O should be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:0");
- assertTrue("Node O:0 should be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:0:0");
- assertTrue("Node O:0:0 should be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:0:1");
- assertTrue("Node O:0:1 should be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:0:2");
- assertTrue("Node O:0:2 should be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:0:2:0");
- assertTrue("Node O:0:2:0 should be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:0:2:1");
- assertTrue("Node O:0:2:1 should be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:1");
- assertTrue("Node O:1 should be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:1:0");
- assertTrue("Node O:1:0 should be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:1:1");
- assertTrue("Node O:1:1 should be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:2");
- assertTrue("Node O:2 should be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:3");
- assertTrue("Node O:3 should be expanded", tree.isNodeExpanded());
- }
-
- /**
- * Tests the ability to collapse all nodes at once. (See TOMAHAWK-27)
- * @throws Exception
- */
- public void testCollapseAll() throws Exception
- {
- // expand a few nodes to start off with
- tree.expandPath(new String[] {"0", "0:0", "0:0:1"});
- tree.expandPath(new String[] {"0", "0:1", "0:1:0"});
-
- tree.collapseAll();
-
- tree.setNodeId("0");
- assertFalse("Node O should not be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:0");
- assertFalse("Node O:0 should not be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:0:1");
- assertFalse("Node O:0:1 should not be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:1");
- assertFalse("Node O:1 should not be expanded", tree.isNodeExpanded());
-
- tree.setNodeId("0:1:0");
- assertFalse("Node O:1:0 should not be expanded", tree.isNodeExpanded());
- }
-
- /**
- * Its possible that a facet will be empty on the decode if it contained only EL text.
- * So its wrong to throw an exception when this is the case. (See TOMAHAWK-510)
- *
- * @throws Exception
- */
- public void testEmptyFacet() throws Exception
- {
- tree.processDecodes(facesContext);
-
- }
-
- public static Test suite()
- {
- return new TestSuite(UITreeDataTest.class);
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.custom.tree2;
+
+
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import javax.faces.event.ActionEvent;
+import javax.faces.component.html.HtmlCommandLink;
+
+/**
+ * Test case for {@link UITreeData}.
+ */
+public class UITreeDataTest extends AbstractTreeTestCase
+{
+ /**
+ * Constructor
+ * @param name String
+ */
+ public UITreeDataTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * See abstract class
+ */
+ public void setUp()
+ {
+ super.setUp();
+ }
+
+ /**
+ * Tests the selection of a specific node using both server side and client side
+ * toggle options.
+ *
+ * @throws Exception
+ */
+ public void testNodeSelected() throws Exception
+ {
+ tree.setClientSideToggle(false);
+ // tree.getAttributes().put(JSFAttr.CLIENT_SIDE_TOGGLE, Boolean.FALSE);
+
+ ActionEvent event = new ActionEvent(new HtmlCommandLink());
+
+ // set the node to be selected
+ tree.setNodeId("0:1:0");
+ tree.setNodeSelected(event);
+
+ assertTrue("Node 0:1:0 should be selected", tree.isNodeSelected());
+
+ tree.setClientSideToggle(true);
+ // tree.getAttributes().put(JSFAttr.CLIENT_SIDE_TOGGLE, Boolean.TRUE);
+
+ // set the node to be selected
+ tree.setNodeId("0:1:0");
+ tree.setNodeSelected(event);
+
+ assertTrue("Node 0:1:0 should be selected", tree.isNodeSelected());
+ }
+
+ /**
+ * Tests programatic selection of a node. (See MYFACES-717)
+ * @throws Exception
+ */
+ public void testProgramaticSelection() throws Exception
+ {
+ TreeModel treeModel = tree.getDataModel();
+ TreeState treeState = treeModel.getTreeState();
+ treeState.setSelected("0:3");
+
+ treeModel.setTreeState(treeState);
+
+ tree.setValue(treeModel);
+ tree.setNodeId("0:3");
+ assertTrue("Node 0:3 should be selected", tree.isNodeSelected());
+ }
+
+ /**
+ * Tests the ability to expand all nodes at once. (See TOMAHAWK-436)
+ * @throws Exception
+ */
+ public void testExpandAll() throws Exception
+ {
+ tree.expandAll();
+
+ tree.setNodeId("0");
+ assertTrue("Node O should be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:0");
+ assertTrue("Node O:0 should be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:0:0");
+ assertTrue("Node O:0:0 should be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:0:1");
+ assertTrue("Node O:0:1 should be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:0:2");
+ assertTrue("Node O:0:2 should be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:0:2:0");
+ assertTrue("Node O:0:2:0 should be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:0:2:1");
+ assertTrue("Node O:0:2:1 should be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:1");
+ assertTrue("Node O:1 should be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:1:0");
+ assertTrue("Node O:1:0 should be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:1:1");
+ assertTrue("Node O:1:1 should be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:2");
+ assertTrue("Node O:2 should be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:3");
+ assertTrue("Node O:3 should be expanded", tree.isNodeExpanded());
+ }
+
+ /**
+ * Tests the ability to collapse all nodes at once. (See TOMAHAWK-27)
+ * @throws Exception
+ */
+ public void testCollapseAll() throws Exception
+ {
+ // expand a few nodes to start off with
+ tree.expandPath(new String[] {"0", "0:0", "0:0:1"});
+ tree.expandPath(new String[] {"0", "0:1", "0:1:0"});
+
+ tree.collapseAll();
+
+ tree.setNodeId("0");
+ assertFalse("Node O should not be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:0");
+ assertFalse("Node O:0 should not be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:0:1");
+ assertFalse("Node O:0:1 should not be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:1");
+ assertFalse("Node O:1 should not be expanded", tree.isNodeExpanded());
+
+ tree.setNodeId("0:1:0");
+ assertFalse("Node O:1:0 should not be expanded", tree.isNodeExpanded());
+ }
+
+ /**
+ * Its possible that a facet will be empty on the decode if it contained only EL text.
+ * So its wrong to throw an exception when this is the case. (See TOMAHAWK-510)
+ *
+ * @throws Exception
+ */
+ public void testEmptyFacet() throws Exception
+ {
+ tree.processDecodes(facesContext);
+
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(UITreeDataTest.class);
+ }
+}
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/custom/tree2/UITreeDataTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/renderkit/html/util/AddResourceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/renderkit/html/util/ReducedHTMLParserTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java (original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java Tue Aug 1 10:43:28 2006
@@ -1,118 +1,118 @@
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.apache.myfaces.test;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import org.apache.myfaces.shared_tomahawk.test.ClassElementHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import junit.framework.TestCase;
-
-/**
- * This test makes sure all of our components, tags, renderers,
- * validators, converters, action listeners, phase listeners and
- * core implementation classes are in the build.
- *
- * This class has been copy and pasted into both tomahawk and core
- * in order to avoid a compile scoped dependency on junit in shared.
- *
- * @see ClassElementHandler
- * @author Dennis Byrne
- */
-
-public abstract class AbstractClassElementTestCase extends TestCase
-{
-
- private Log log = LogFactory.getLog(AbstractClassElementTestCase.class);
-
- protected List resource = new ArrayList();
- private List className = new ArrayList();
-
- protected void setUp() throws Exception
- {
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setValidating(false);
- factory.setNamespaceAware(false);
-
- SAXParser parser = factory.newSAXParser();
- ClassElementHandler handler = new ClassElementHandler();
-
- Iterator iterator = resource.iterator();
-
- while(iterator.hasNext()){
-
- String resourceName = (String) iterator.next();
-
- InputStream is = getClass().getClassLoader()
- .getResourceAsStream(resourceName);
-
- if(is == null)
- is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
-
- if(is == null)
- throw new Exception("Could not locate resource :" + resourceName);
-
- parser.parse(is, handler);
-
- }
-
- className.addAll(handler.getClassName());
-
- }
-
- public void testClassPath(){
-
- int i = 0;
- for( ; i < className.size() ; i++){
-
- String clazz = (String) className.get(i);
-
- try
- {
- Class c1 = getClass().getClassLoader().loadClass(clazz);
-
- }
- catch (ClassNotFoundException e)
- {
-
- try{
-
- Class c2 = Thread.currentThread().getContextClassLoader().loadClass(clazz);
-
- }catch(ClassNotFoundException e2){
-
- assertFalse("Could not load " + clazz, true);
-
- }
-
- }
-
- }
-
- log.debug(( i + 1 ) + " class found ");
-
- }
-
-}
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.myfaces.test;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import org.apache.myfaces.shared_tomahawk.test.ClassElementHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import junit.framework.TestCase;
+
+/**
+ * This test makes sure all of our components, tags, renderers,
+ * validators, converters, action listeners, phase listeners and
+ * core implementation classes are in the build.
+ *
+ * This class has been copy and pasted into both tomahawk and core
+ * in order to avoid a compile scoped dependency on junit in shared.
+ *
+ * @see ClassElementHandler
+ * @author Dennis Byrne
+ */
+
+public abstract class AbstractClassElementTestCase extends TestCase
+{
+
+ private Log log = LogFactory.getLog(AbstractClassElementTestCase.class);
+
+ protected List resource = new ArrayList();
+ private List className = new ArrayList();
+
+ protected void setUp() throws Exception
+ {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(false);
+ factory.setNamespaceAware(false);
+
+ SAXParser parser = factory.newSAXParser();
+ ClassElementHandler handler = new ClassElementHandler();
+
+ Iterator iterator = resource.iterator();
+
+ while(iterator.hasNext()){
+
+ String resourceName = (String) iterator.next();
+
+ InputStream is = getClass().getClassLoader()
+ .getResourceAsStream(resourceName);
+
+ if(is == null)
+ is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
+
+ if(is == null)
+ throw new Exception("Could not locate resource :" + resourceName);
+
+ parser.parse(is, handler);
+
+ }
+
+ className.addAll(handler.getClassName());
+
+ }
+
+ public void testClassPath(){
+
+ int i = 0;
+ for( ; i < className.size() ; i++){
+
+ String clazz = (String) className.get(i);
+
+ try
+ {
+ Class c1 = getClass().getClassLoader().loadClass(clazz);
+
+ }
+ catch (ClassNotFoundException e)
+ {
+
+ try{
+
+ Class c2 = Thread.currentThread().getContextClassLoader().loadClass(clazz);
+
+ }catch(ClassNotFoundException e2){
+
+ assertFalse("Could not load " + clazz, true);
+
+ }
+
+ }
+
+ }
+
+ log.debug(( i + 1 ) + " class found ");
+
+ }
+
+}
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/TomahawkClassElementTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/TomahawkClassElementTestCase.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/TomahawkClassElementTestCase.java (original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/TomahawkClassElementTestCase.java Tue Aug 1 10:43:28 2006
@@ -1,34 +1,34 @@
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.apache.myfaces.test;
-
-/**
- * @author Dennis Byrne
- */
-
-public class TomahawkClassElementTestCase extends AbstractClassElementTestCase
-{
-
- public TomahawkClassElementTestCase(){
-
- resource.add("META-INF/tomahawk.tld");
- resource.add("META-INF/faces-config.xml");
-
- }
-
-}
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.myfaces.test;
+
+/**
+ * @author Dennis Byrne
+ */
+
+public class TomahawkClassElementTestCase extends AbstractClassElementTestCase
+{
+
+ public TomahawkClassElementTestCase(){
+
+ resource.add("META-INF/tomahawk.tld");
+ resource.add("META-INF/faces-config.xml");
+
+ }
+
+}
Propchange: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/TomahawkClassElementTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native