[jboss-cvs] jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/test ...

Shane Bryzak sbryzak at redhat.com
Sun Aug 26 21:32:49 EDT 2007


  User: sbryzak2
  Date: 07/08/26 21:32:49

  Modified:    examples/seamspace/src/org/jboss/seam/example/seamspace/test  
                        testng.xml
  Added:       examples/seamspace/src/org/jboss/seam/example/seamspace/test  
                        BlogTest.java
  Log:
  blog test
  
  Revision  Changes    Path
  1.2       +6 -0      jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/test/testng.xml
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: testng.xml
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/test/testng.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- testng.xml	27 Aug 2007 00:36:54 -0000	1.1
  +++ testng.xml	27 Aug 2007 01:32:49 -0000	1.2
  @@ -8,4 +8,10 @@
        </classes>
      </test>
   	
  +   <test name="SeamSpace: Blog">
  +     <classes>
  +       <class name="org.jboss.seam.example.seamspace.test.BlogTest"/>
  +     </classes>
  +   </test>   
  +	
   </suite>
  \ No newline at end of file
  
  
  
  1.1      date: 2007/08/27 01:32:49;  author: sbryzak2;  state: Exp;jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/test/BlogTest.java
  
  Index: BlogTest.java
  ===================================================================
  package org.jboss.seam.example.seamspace.test;
  
  import org.jboss.seam.mock.SeamTest;
  import org.testng.annotations.Test;
  
  public class BlogTest extends SeamTest
  {
     @Test
     public void testCreateBlog() throws Exception
     {
        // Log in first
        new FacesRequest()
        {
           @Override
           protected void invokeApplication() throws Exception
           {
              setValue("#{identity.username}", "demo");
              setValue("#{identity.password}", "demo");
              invokeAction("#{identity.login}");
              assert getValue("#{identity.loggedIn}").equals(true);
           }
        }.run();
        
        String cid = new FacesRequest()
        {
           @Override
           protected void invokeApplication() throws Exception
           {         
              assert invokeAction("#{blog.createEntry}") == null;
           }         
        }.run();
        
        new FacesRequest("/createBlog.xhtml", cid)
        {
           @Override 
           protected void updateModelValues() throws Exception
           {
              setValue("#{selectedBlog.title}", "A new blog entry");
              setValue("#{selectedBlog.text}", "A very very very long section of text. " + 
                    "This text should be long enough to simulate a typical blog entry. " +
                    "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed interdum " +
                    "felis non arcu. Phasellus sodales pharetra dui. Suspendisse felis turpis, " +
                    "ultricies a, ullamcorper sed, nonummy id, nulla. Ut quis orci. Mauris diam " +
                    "pede, condimentum et, tempor vitae, facilisis non, sem. Mauris quam ipsum, " +
                    "laoreet non, ultricies in, aliquet nec, metus. Morbi dui. Vestibulum " +
                    "ullamcorper, tellus non hendrerit consequat, libero erat laoreet metus, " +
                    "quis facilisis arcu diam vel orci. Fusce tempor erat eget odio. Aliquam urna " +
                    "dui, dignissim id, pretium in, congue quis, est. Phasellus nec erat ac arcu " +
                    "porttitor rhoncus. Pellentesque habitant morbi tristique senectus et netus et " +
                    "malesuada fames ac turpis egestas. Nulla sed massa ut est sodales ultrices. " +
                    "Sed vitae nulla eu tellus fringilla sagittis. Nunc convallis, mi at lobortis " +
                    "rhoncus, neque turpis ullamcorper odio, quis scelerisque est dolor non velit. Integer vulputate.");
           }
           
           @Override
           protected void invokeApplication() throws Exception
           {
              assert invokeAction("#{blog.saveEntry}") == null;
           }
           
        }.run();
      
        new FacesRequest()
        {
           @Override
           protected void invokeApplication() throws Exception
           {
              invokeAction("#{identity.logout}");
              assert getValue("#{identity.loggedIn}").equals(false);
           }
        }.run();      
     }
     
     @Test
     public void testCreateComment() throws Exception
     {
        new FacesRequest()
        {
           @Override
           protected void invokeApplication() throws Exception
           {
              setValue("#{identity.username}", "demo");
              setValue("#{identity.password}", "demo");
              invokeAction("#{identity.login}");
              assert getValue("#{identity.loggedIn}").equals(true);
           }
        }.run();   
        
        String cid = new FacesRequest()
        {
           @Override
           protected void invokeApplication() throws Exception
           {
              setParameter("name", "Mr_Smiley");
              setParameter("blogId", "1");
              assert invokeAction("#{blog.createComment}") == null;
              
              assert getValue("#{comment}") != null;
              assert getValue("#{comment.blog}") != null;
           }
        }.run();
        
        new FacesRequest("/comment.xhtml", cid)
        {
           @Override
           protected void updateModelValues() throws Exception
           {
              setValue("#{comment.comment}", "I totally disagree with your blog entry!");
           }
           
           @Override
           protected void invokeApplication() throws Exception
           {
              assert invokeAction("#{blog.saveComment}") == null;
           }
        }.run();
        
        new FacesRequest()
        {
           @Override
           protected void invokeApplication() throws Exception
           {
              invokeAction("#{identity.logout}");
              assert getValue("#{identity.loggedIn}").equals(false);
           }
        }.run();        
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list