[jboss-cvs] jboss-seam/examples/wiki/src/test/org/jboss/seam/wiki/test/browse ...

Christian Bauer christian at hibernate.org
Fri Aug 17 09:00:30 EDT 2007


  User: cbauer  
  Date: 07/08/17 09:00:30

  Added:       examples/wiki/src/test/org/jboss/seam/wiki/test/browse  
                        TestAreaAndDocument.xml DisplayNodes.java
  Log:
  Major refactoring of core data schema and some new features
  
  Revision  Changes    Path
  1.1      date: 2007/08/17 13:00:30;  author: cbauer;  state: Exp;jboss-seam/examples/wiki/src/test/org/jboss/seam/wiki/test/browse/TestAreaAndDocument.xml
  
  Index: TestAreaAndDocument.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <dataset>
  
      <NODE NODE_ID="100" NODE_TYPE="DIRECTORY" NODE_REVISION="1" OBJ_VERSION="0" NAME="Test Area" WIKINAME="TestArea"
            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"/>
  
  
      <NODE NODE_ID="101" NODE_TYPE="DOCUMENT" NODE_REVISION="1" OBJ_VERSION="0" NAME="Test Document1" WIKINAME="TestDocument1"
            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="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."/>
  
  </dataset>
  
  
  
  1.1      date: 2007/08/17 13:00:30;  author: cbauer;  state: Exp;jboss-seam/examples/wiki/src/test/org/jboss/seam/wiki/test/browse/DisplayNodes.java
  
  Index: DisplayNodes.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.seam.wiki.test.browse;
  
  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.test.util.DBUnitSeamTest;
  import org.jboss.seam.log.Logging;
  import org.jboss.seam.log.Log;
  import org.testng.annotations.Test;
  import org.dbunit.operation.DatabaseOperation;
  
  import java.util.List;
  
  public class DisplayNodes extends DBUnitSeamTest {
  
      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);
  
      protected void prepareDBUnitOperations() {
          beforeTestOperations.add(
              new DataSetOperation("org/jboss/seam/wiki/test/WikiBaseData.xml")
          );
          beforeTestOperations.add(
              new DataSetOperation("org/jboss/seam/wiki/test/browse/TestAreaAndDocument.xml", DatabaseOperation.INSERT)
          );
      }
  
      @Test
      public void displayDocument() throws Exception {
  
          log.info("############################################# TEST: displayDocument()");
  
          new NonFacesRequest("/display.xhtml") {
  
              protected void beforeRequest() {
                  setParameter("nodeId", TEST_DOCUMENT_ID.toString());
              }
  
              protected void renderResponse() throws Exception {
                  Document doc = (Document)getValue("#{currentDocument}");
                  assert doc != null;
                  assert doc.getId().equals(TEST_DOCUMENT_ID);
  
                  Directory dir = (Directory)getValue("#{currentDirectory}");
                  assert dir != null;
                  assert dir.getId().equals(TEST_DIRECTORY_ID);
  
                  List<Node> currentDirectoryPath = (List<Node>)getValue("#{currentDirectoryPath}");
                  assert currentDirectoryPath.size() == 2;
                  assert currentDirectoryPath.get(0).getId().equals( ((Node)getValue("#{wikiRoot}")).getId()  );
                  assert currentDirectoryPath.get(1).getId().equals( ((Directory)getValue("#{currentDirectory}")).getId() );
              }
              
          }.run();
  
          /* TODO: Seam filter does not run for unit tests
          new NonFacesRequest("/TestArea/TestDocument") {
  
  
              
              protected void renderResponse() throws Exception {
                  Document doc = (Document)getValue("#{currentDocument}");
                  assert doc != null;
                  assert doc.getId().equals(TEST_DOCUMENT_ID);
  
                  Directory dir = (Directory)getValue("#{currentDirectory}");
                  assert dir != null;
                  assert dir.getId().equals(TEST_DIRECTORY_ID);
              }
          }.run();
          */
      }
  
      @Test
      public void displayDirectory() throws Exception {
  
          log.info("############################################# TEST: displayDirectory()");
  
          new NonFacesRequest("/display.xhtml") {
  
              protected void beforeRequest() {
                  setParameter("nodeId", TEST_DIRECTORY_ID.toString());
              }
  
              protected void renderResponse() throws Exception {
                  Directory dir = (Directory)getValue("#{currentDirectory}");
                  assert dir != null;
                  assert dir.getId().equals(TEST_DIRECTORY_ID);
              }
          }.run();
      }
  
  
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list