[jboss-cvs] jboss-seam/examples/wiki/src/test/org/jboss/seam/wiki/test/browse ...
Christian Bauer
christian at hibernate.org
Sat Aug 25 13:59:26 EDT 2007
User: cbauer
Date: 07/08/25 13:59:26
Modified: examples/wiki/src/test/org/jboss/seam/wiki/test/browse
TestAreaAndDocument.xml DisplayNodes.java
Log:
Major refactoring of navigation
Revision Changes Path
1.2 +6 -1 jboss-seam/examples/wiki/src/test/org/jboss/seam/wiki/test/browse/TestAreaAndDocument.xml
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TestAreaAndDocument.xml
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/test/org/jboss/seam/wiki/test/browse/TestAreaAndDocument.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- TestAreaAndDocument.xml 17 Aug 2007 13:00:30 -0000 1.1
+++ TestAreaAndDocument.xml 25 Aug 2007 17:59:26 -0000 1.2
@@ -2,7 +2,7 @@
<dataset>
- <NODE NODE_ID="100" NODE_TYPE="DIRECTORY" NODE_REVISION="1" OBJ_VERSION="0" NAME="Test Area" WIKINAME="TestArea"
+ <NODE NODE_ID="100" NODE_TYPE="DIRECTORY" NODE_REVISION="1" OBJ_VERSION="0" NAME="Test Area1" WIKINAME="TestArea1"
READ_ACCESS_LEVEL="0" WRITE_ACCESS_LEVEL="0" MENU_ITEM="true" CREATED_ON="2006-09-23 13:45:00" CREATED_BY_USER_ID="1" LAST_MODIFIED_ON="2006-09-23 13:45:00" LAST_MODIFIED_BY_USER_ID="1"
AREA_NR="100" PARENT_NODE_ID="1" NS_THREAD="1" NS_LEFT="8" NS_RIGHT="23" DISPLAY_POSITION="2"/>
<NODE_DIRECTORY DIRECTORY_ID="100" DEFAULT_DOCUMENT_ID="101"/>
@@ -13,4 +13,9 @@
AREA_NR="100" PARENT_NODE_ID="100" NS_THREAD="1" NS_LEFT="9" NS_RIGHT="10" DISPLAY_POSITION="0"/>
<NODE_DOCUMENT DOCUMENT_ID="101" NAME_AS_TITLE="true" ENABLE_COMMENT_FORM="true" ENABLE_COMMENTS="true" CONTENT="This is a *test* document."/>
+ <NODE NODE_ID="102" NODE_TYPE="DIRECTORY" NODE_REVISION="1" OBJ_VERSION="0" NAME="Test Area2" WIKINAME="TestArea2"
+ READ_ACCESS_LEVEL="0" WRITE_ACCESS_LEVEL="0" MENU_ITEM="false" CREATED_ON="2006-09-23 13:45:00" CREATED_BY_USER_ID="1" LAST_MODIFIED_ON="2006-09-23 13:45:00" LAST_MODIFIED_BY_USER_ID="1"
+ AREA_NR="100" PARENT_NODE_ID="1" NS_THREAD="1" NS_LEFT="11" NS_RIGHT="12" DISPLAY_POSITION="3"/>
+ <NODE_DIRECTORY DIRECTORY_ID="102" DEFAULT_DOCUMENT_ID="[NULL]"/>
+
</dataset>
1.2 +80 -24 jboss-seam/examples/wiki/src/test/org/jboss/seam/wiki/test/browse/DisplayNodes.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DisplayNodes.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/test/org/jboss/seam/wiki/test/browse/DisplayNodes.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- DisplayNodes.java 17 Aug 2007 13:00:30 -0000 1.1
+++ DisplayNodes.java 25 Aug 2007 17:59:26 -0000 1.2
@@ -9,6 +9,7 @@
import org.jboss.seam.wiki.core.model.Document;
import org.jboss.seam.wiki.core.model.Directory;
import org.jboss.seam.wiki.core.model.Node;
+import org.jboss.seam.wiki.core.action.DirectoryHome;
import org.jboss.seam.wiki.test.util.DBUnitSeamTest;
import org.jboss.seam.log.Logging;
import org.jboss.seam.log.Log;
@@ -21,8 +22,9 @@
private Log log = Logging.getLog(DisplayNodes.class);
- private static final Long TEST_DIRECTORY_ID = new Long(100);
- private static final Long TEST_DOCUMENT_ID = new Long(101);
+ private static final Long TEST_DIRECTORY1_ID = 100l;
+ private static final Long TEST_DOCUMENT1_ID = 101l;
+ private static final Long TEST_DIRECTORY2_ID = 102l;
protected void prepareDBUnitOperations() {
beforeTestOperations.add(
@@ -34,70 +36,124 @@
}
@Test
- public void displayDocument() throws Exception {
+ public void documentFromNodeId() throws Exception {
- log.info("############################################# TEST: displayDocument()");
-
- new NonFacesRequest("/display.xhtml") {
+ new NonFacesRequest("/wiki.xhtml") {
protected void beforeRequest() {
- setParameter("nodeId", TEST_DOCUMENT_ID.toString());
+ setParameter("nodeId", TEST_DOCUMENT1_ID.toString());
}
protected void renderResponse() throws Exception {
Document doc = (Document)getValue("#{currentDocument}");
assert doc != null;
- assert doc.getId().equals(TEST_DOCUMENT_ID);
+ assert doc.getId().equals(TEST_DOCUMENT1_ID);
Directory dir = (Directory)getValue("#{currentDirectory}");
assert dir != null;
- assert dir.getId().equals(TEST_DIRECTORY_ID);
+ assert dir.getId().equals(TEST_DIRECTORY1_ID);
- List<Node> currentDirectoryPath = (List<Node>)getValue("#{currentDirectoryPath}");
+ List<Node> currentDirectoryPath = (List<Node>)getValue("#{breadcrumb}");
assert currentDirectoryPath.size() == 2;
- assert currentDirectoryPath.get(0).getId().equals( ((Node)getValue("#{wikiRoot}")).getId() );
- assert currentDirectoryPath.get(1).getId().equals( ((Directory)getValue("#{currentDirectory}")).getId() );
+ assert currentDirectoryPath.get(0).getId().equals( ((Directory)getValue("#{currentDirectory}")).getId() );
+ assert currentDirectoryPath.get(1).getId().equals( ((Document)getValue("#{currentDocument}")).getId() );
+
+ assert getRenderedViewId().equals("/docDisplay.xhtml");
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void directoryFromNodeId() throws Exception {
+
+ new NonFacesRequest("/wiki.xhtml") {
+
+ protected void beforeRequest() {
+ setParameter("nodeId", TEST_DIRECTORY2_ID.toString());
}
+ protected void renderResponse() throws Exception {
+ Document doc = (Document)getValue("#{currentDocument}");
+ assert doc == null;
+
+ DirectoryHome dirHome = (DirectoryHome)getInstance("directoryHome");
+ Directory dir = dirHome.getInstance();
+ assert dir != null;
+ assert dir.getId().equals(TEST_DIRECTORY2_ID);
+ assert getRenderedViewId().equals("/dirDisplay.xhtml");
+ }
}.run();
+ }
- /* TODO: Seam filter does not run for unit tests
- new NonFacesRequest("/TestArea/TestDocument") {
+ @Test
+ public void documentFromWikiName() throws Exception {
+ new NonFacesRequest("/wiki.xhtml") {
+ protected void beforeRequest() {
+ setParameter("areaName", "TestArea1");
+ setParameter("nodeName", "TestDocument1");
+ }
protected void renderResponse() throws Exception {
Document doc = (Document)getValue("#{currentDocument}");
assert doc != null;
- assert doc.getId().equals(TEST_DOCUMENT_ID);
+ assert doc.getId().equals(TEST_DOCUMENT1_ID);
Directory dir = (Directory)getValue("#{currentDirectory}");
assert dir != null;
- assert dir.getId().equals(TEST_DIRECTORY_ID);
+ assert dir.getId().equals(TEST_DIRECTORY1_ID);
+
+ assert getRenderedViewId().equals("/docDisplay.xhtml");
}
}.run();
- */
}
@Test
- public void displayDirectory() throws Exception {
-
- log.info("############################################# TEST: displayDirectory()");
+ public void defaultDocumentFromAreaWikiName() throws Exception {
- new NonFacesRequest("/display.xhtml") {
+ new NonFacesRequest("/wiki.xhtml") {
protected void beforeRequest() {
- setParameter("nodeId", TEST_DIRECTORY_ID.toString());
+ setParameter("areaName", "TestArea1");
}
protected void renderResponse() throws Exception {
+ Document doc = (Document)getValue("#{currentDocument}");
+ assert doc != null;
+ assert doc.getId().equals(TEST_DOCUMENT1_ID);
+
Directory dir = (Directory)getValue("#{currentDirectory}");
assert dir != null;
- assert dir.getId().equals(TEST_DIRECTORY_ID);
+ assert dir.getId().equals(TEST_DIRECTORY1_ID);
+
+ assert getRenderedViewId().equals("/docDisplay.xhtml");
}
}.run();
}
+ @Test
+ public void directoryFromAreaWikiName() throws Exception {
+
+ new NonFacesRequest("/wiki.xhtml") {
+ protected void beforeRequest() {
+ setParameter("areaName", "TestArea2");
+ }
+
+ protected void renderResponse() throws Exception {
+ Document doc = (Document)getValue("#{currentDocument}");
+ assert doc == null;
+
+ DirectoryHome dirHome = (DirectoryHome)getInstance("directoryHome");
+ Directory dir = dirHome.getInstance();
+ assert dir != null;
+ assert dir.getId().equals(TEST_DIRECTORY2_ID);
+
+ assert getRenderedViewId().equals("/dirDisplay.xhtml");
+ }
+ }.run();
+ }
}
More information about the jboss-cvs-commits
mailing list