[seam-commits] Seam SVN: r9980 - in trunk: src/test/ftest and 10 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Jan 26 05:22:44 EST 2009


Author: jharting
Date: 2009-01-26 05:22:43 -0500 (Mon, 26 Jan 2009)
New Revision: 9980

Added:
   trunk/src/test/ftest/examples/seamspace/
   trunk/src/test/ftest/examples/seamspace/build.xml
   trunk/src/test/ftest/examples/seamspace/jboss.xml
   trunk/src/test/ftest/examples/seamspace/src/
   trunk/src/test/ftest/examples/seamspace/src/org/
   trunk/src/test/ftest/examples/seamspace/src/org/jboss/
   trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/
   trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/
   trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/
   trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/
   trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/
   trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/BlogTest.java
   trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/LoginTest.java
   trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/RoleTest.java
   trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/SeleniumSeamSpaceTest.java
   trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/UserTest.java
Modified:
   trunk/examples/seamspace/view/createBlog.xhtml
   trunk/examples/seamspace/view/home.xhtml
   trunk/examples/seamspace/view/profile.xhtml
   trunk/examples/seamspace/view/roledetail.xhtml
   trunk/examples/seamspace/view/rolemanager.xhtml
   trunk/examples/seamspace/view/security.xhtml
   trunk/examples/seamspace/view/template.xhtml
   trunk/examples/seamspace/view/userdetail.xhtml
   trunk/examples/seamspace/view/usermanager.xhtml
   trunk/src/test/ftest/build.xml
Log:
JBSEAM-3690 Added tests for seamspace example

Modified: trunk/examples/seamspace/view/createBlog.xhtml
===================================================================
--- trunk/examples/seamspace/view/createBlog.xhtml	2009-01-25 18:33:30 UTC (rev 9979)
+++ trunk/examples/seamspace/view/createBlog.xhtml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -32,7 +32,7 @@
           </s:div>				
 				
           <div class="blogEntry">
-            <h:form>
+            <h:form id="newBlog">
               
               <div class="formRow">
                 <h:outputLabel for="title">Please type a title for your blog entry</h:outputLabel><br/>
@@ -45,8 +45,8 @@
               </div>
 
               <div class="buttons">
-                <h:commandButton action="#{blog.saveEntry}" value="Add entry" styleClass="action"/>            
-                <h:commandButton value="Preview" styleClass="action"/>                            
+                <h:commandButton id="submit" action="#{blog.saveEntry}" value="Add entry" styleClass="action"/>            
+                <h:commandButton id="preview" value="Preview" styleClass="action"/>                            
               </div>
               
               <br class="clear"/>

Modified: trunk/examples/seamspace/view/home.xhtml
===================================================================
--- trunk/examples/seamspace/view/home.xhtml	2009-01-25 18:33:30 UTC (rev 9979)
+++ trunk/examples/seamspace/view/home.xhtml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -23,11 +23,11 @@
       <div id="contentSide">
         <div class="advertising"></div>
                
-        <h:form rendered="#{not identity.loggedIn}">
+        <h:form id="loginForm" rendered="#{not identity.loggedIn}">
           <div class="memberLogin">
             <div class="loginHeader">Member Login</div>
             
-            <h:messages globalOnly="true"/>
+            <h:messages id="messages" globalOnly="true"/>
             
             <div class="loginRow">
               <h:outputLabel for="name" value="Member name" styleClass="loginLabel"/>
@@ -53,8 +53,8 @@
             </div>
 
             <div class="buttons">
-              <h:commandButton value="LOGIN" action="#{identity.login}" styleClass="loginButton"/>
-              <h:commandButton value="SIGN UP!" action="#{register.start}" styleClass="registerButton"/>
+              <h:commandButton id="login" value="LOGIN" action="#{identity.login}" styleClass="loginButton"/>
+              <h:commandButton id="register" value="SIGN UP!" action="#{register.start}" styleClass="registerButton"/>
             </div>
 
             <br class="clear"/>

Modified: trunk/examples/seamspace/view/profile.xhtml
===================================================================
--- trunk/examples/seamspace/view/profile.xhtml	2009-01-25 18:33:30 UTC (rev 9979)
+++ trunk/examples/seamspace/view/profile.xhtml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -51,12 +51,12 @@
             </div>
           </ui:repeat>            
           
-          [<s:link view="/blog.seam" value="View all blog entries" propagation="none">
+          [<s:link id="viewBlog" view="/blog.seam" value="View all blog entries" propagation="none">
              <f:param name="name" value="#{selectedMember.memberName}"/>
            </s:link>]
           
           <s:span rendered="#{s:hasPermission(selectedMember, 'createBlog')}">
-            [<s:link action="#{blog.createEntry}" value="Create new blog entry" propagation="none"/>]
+            [<s:link id="createBlog" action="#{blog.createEntry}" value="Create new blog entry" propagation="none"/>]
           </s:span>
         </s:div>
         

Modified: trunk/examples/seamspace/view/roledetail.xhtml
===================================================================
--- trunk/examples/seamspace/view/roledetail.xhtml	2009-01-25 18:33:30 UTC (rev 9979)
+++ trunk/examples/seamspace/view/roledetail.xhtml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -20,18 +20,18 @@
   	    
   	    <h:messages globalOnly="true"/>
   	    
-  	    <h:form>
+  	    <h:form id="role">
               
           <div class="formRow">
             <h:outputLabel for="role" value="Role" styleClass="formLabel"/>
-            <h:inputText id="role" value="#{roleAction.role}" readonly="#{identityManager.userExists(roleAction.role)}"/>
+            <h:inputText id="name" value="#{roleAction.role}" readonly="#{identityManager.userExists(roleAction.role)}"/>
             <div class="validationError"><h:message for="role"/></div>
           </div>              
 
           <div class="formRow">            
             <h:outputLabel for="groups" value="Member of" styleClass="formLabel"/>
             <div class="selectMany">
-              <h:selectManyCheckbox id="groups" value="#{roleAction.groups}" layout="pageDirection" styleClass="roles">
+              <h:selectManyCheckbox id="roles" value="#{roleAction.groups}" layout="pageDirection" styleClass="roles">
                 <s:selectItems value="#{roleAction.assignableRoles}" var="role" label="#{role}"/>
               </h:selectManyCheckbox>
             </div>
@@ -39,8 +39,8 @@
           </div>
           
           <div class="formButtons">
-            <h:commandButton value="Save" action="#{roleAction.save}" styleClass="formButton"/>
-            <s:button view="/rolemanager.xhtml" value="Cancel" propagation="end" styleClass="formButton"/>
+            <h:commandButton id="save" value="Save" action="#{roleAction.save}" styleClass="formButton"/>
+            <s:button id="cancel" view="/rolemanager.xhtml" value="Cancel" propagation="end" styleClass="formButton"/>
           </div>
     
           <br class="clear"/>

Modified: trunk/examples/seamspace/view/rolemanager.xhtml
===================================================================
--- trunk/examples/seamspace/view/rolemanager.xhtml	2009-01-25 18:33:30 UTC (rev 9979)
+++ trunk/examples/seamspace/view/rolemanager.xhtml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -24,7 +24,7 @@
 
   	    <h2>Role Manager</h2>  
   	    
-        <s:button action="#{roleAction.createRole}" styleClass="newrole" rendered="#{s:hasPermission('seam.account', 'create', null)}"/>
+        <s:button id="newRole" action="#{roleAction.createRole}" styleClass="newrole" rendered="#{s:hasPermission('seam.account', 'create', null)}"/>
   	    
         <h:dataTable 
             id="threads"
@@ -39,16 +39,16 @@
             <f:facet name="header">Role</f:facet>
             #{role}
           </h:column>
-          <h:column width="auto">
+          <h:column id="roles" width="auto">
             <f:facet name="header">Member Of</f:facet>
             #{roleSearch.getRoleGroups(role)}
           </h:column>
           <h:column width="auto">
             <f:facet name="header">Action</f:facet>          
             <s:fragment rendered="#{s:hasPermission('seam.role', 'update')}">
-              <s:link value="Edit" action="#{roleAction.editRole(roleSearch.selectedRole)}"/><span> | </span>
+              <s:link id="edit" value="Edit" action="#{roleAction.editRole(roleSearch.selectedRole)}"/><span> | </span>
             </s:fragment>
-            <s:link value="Delete" action="#{identityManager.deleteRole(roleSearch.selectedRole)}"
+            <s:link id="delete" value="Delete" action="#{identityManager.deleteRole(roleSearch.selectedRole)}"
                     rendered="#{s:hasPermission('seam.role', 'delete')}"
                     onclick="return confirmDelete()"/>              
           </h:column>

Modified: trunk/examples/seamspace/view/security.xhtml
===================================================================
--- trunk/examples/seamspace/view/security.xhtml	2009-01-25 18:33:30 UTC (rev 9979)
+++ trunk/examples/seamspace/view/security.xhtml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -17,8 +17,8 @@
 
   	    <h2>Security</h2>  
   	    
-        <s:button view="/usermanager.xhtml" styleClass="manageusers" value="Manage Users"/><br/>
-        <s:button view="/rolemanager.xhtml" styleClass="manageroles" value="Manage Roles"/>  	    
+        <s:button id="manageUsers" view="/usermanager.xhtml" styleClass="manageusers" value="Manage Users"/><br/>
+        <s:button id="manageRoles" view="/rolemanager.xhtml" styleClass="manageroles" value="Manage Roles"/>  	    
 
 	    </div>
 	    

Modified: trunk/examples/seamspace/view/template.xhtml
===================================================================
--- trunk/examples/seamspace/view/template.xhtml	2009-01-25 18:33:30 UTC (rev 9979)
+++ trunk/examples/seamspace/view/template.xhtml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -20,19 +20,19 @@
       <div class="headerMenu">
 
         <s:fragment rendered="#{identity.loggedIn}">
-          <s:link view="/profile.xhtml" value="My Profile" propagation="none">
+          <s:link id="profile" view="/profile.xhtml" value="My Profile" propagation="none">
             <f:param name="name" value="#{authenticatedMember.memberName}"/>
           </s:link>
           <h:outputText styleClass="divider" value=" | "/>
         </s:fragment>
 
         <s:fragment rendered="#{s:hasRole('admin')}">
-          <s:link view="/security.xhtml" value="Security" propagation="none"/>
+          <s:link id="security" view="/security.xhtml" value="Security" propagation="none"/>
           <h:outputText styleClass="divider" value=" | "/>
         </s:fragment>
         
-        <s:link action="#{identity.logout}" value="Log out" rendered="#{identity.loggedIn}"/>
-        <h:outputLink value="home.seam" rendered="#{not identity.loggedIn}">Log in</h:outputLink>
+        <s:link id="logout" action="#{identity.logout}" value="Log out" rendered="#{identity.loggedIn}"/>
+        <h:outputLink id="login" value="home.seam" rendered="#{not identity.loggedIn}">Log in</h:outputLink>
       </div>
       <br style="clear:both"/>
       <h:form>

Modified: trunk/examples/seamspace/view/userdetail.xhtml
===================================================================
--- trunk/examples/seamspace/view/userdetail.xhtml	2009-01-25 18:33:30 UTC (rev 9979)
+++ trunk/examples/seamspace/view/userdetail.xhtml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -20,7 +20,7 @@
   	    
   	    <h:messages globalOnly="true"/>
   	    
-  	    <h:form>
+  	    <h:form id="user">
   	    
           <div class="formRow">
             <h:outputLabel for="firstname" value="First name" styleClass="formLabel"/>
@@ -67,8 +67,8 @@
           </div>   
                                       
           <div class="formButtons">
-            <h:commandButton value="Save" action="#{userAction.save}" styleClass="formButton"/>
-            <s:button view="/usermanager.xhtml" value="Cancel" propagation="end" styleClass="formButton"/>
+            <h:commandButton id="save" value="Save" action="#{userAction.save}" styleClass="formButton"/>
+            <s:button id="cancel" view="/usermanager.xhtml" value="Cancel" propagation="end" styleClass="formButton"/>
           </div>
     
           <br class="clear"/>

Modified: trunk/examples/seamspace/view/usermanager.xhtml
===================================================================
--- trunk/examples/seamspace/view/usermanager.xhtml	2009-01-25 18:33:30 UTC (rev 9979)
+++ trunk/examples/seamspace/view/usermanager.xhtml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -24,7 +24,7 @@
 
   	    <h2>User Manager</h2>  
   	    
-        <s:button action="#{userAction.createUser}" styleClass="newuser" rendered="#{s:hasPermission('seam.account', 'create')}"/>
+        <s:button id="newUser" action="#{userAction.createUser}" styleClass="newuser" rendered="#{s:hasPermission('seam.account', 'create')}"/>
   	    
         <h:dataTable 
             id="threads"
@@ -47,21 +47,21 @@
             </f:facet>
             #{userSearch.getUserRoles(user)}
           </h:column>
-          <h:column width="auto">
+          <h:column id="enabled" width="auto">
             <f:facet name="header">
               Enabled
             </f:facet>
             <div class="#{identityManager.isUserEnabled(user) ? 'checkmark' : 'cross'}"/>
           </h:column>
-          <h:column width="auto">
+          <h:column id="action" width="auto">
             <f:facet name="header">
               Action
             </f:facet>
           
             <s:fragment rendered="#{s:hasPermission('seam.user', 'update')}">
-              <s:link value="Edit" action="#{userAction.editUser(userSearch.selectedUser)}"/><span> | </span>
+              <s:link id="edit" value="Edit" action="#{userAction.editUser(userSearch.selectedUser)}"/><span> | </span>
             </s:fragment>
-            <s:link value="Delete" action="#{identityManager.deleteUser(userSearch.selectedUser)}" 
+            <s:link id="delete" value="Delete" action="#{identityManager.deleteUser(userSearch.selectedUser)}" 
                     rendered="#{s:hasPermission('seam.user', 'delete')}"
                     onclick="return confirmDelete()"/>
           </h:column>

Modified: trunk/src/test/ftest/build.xml
===================================================================
--- trunk/src/test/ftest/build.xml	2009-01-25 18:33:30 UTC (rev 9979)
+++ trunk/src/test/ftest/build.xml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -66,6 +66,7 @@
    	  <testexample name="registration" />
    	  <testexample name="seambay" />
       <testexample name="seampay" />
+      <testexample name="seamspace" />
       <testexample name="spring" />
       <testexample name="wicket" />
       <antcall target="stop.selenium.server"/>
@@ -144,6 +145,7 @@
    	  <cleanexample name="registration" />
    	  <cleanexample name="seambay" />
       <cleanexample name="seampay" />
+      <cleanexample name="seamspace" />
       <cleanexample name="spring" />
       <cleanexample name="wicket" />
    </target>
@@ -165,6 +167,7 @@
    	  <undeployexample name="registration" />
    	  <undeployexample name="seambay" />
       <undeployexample name="seampay" />
+      <undeployexample name="seamspace" />
       <undeployexample name="spring" />
       <undeployexample name="wicket" />
    </target>

Added: trunk/src/test/ftest/examples/seamspace/build.xml
===================================================================
--- trunk/src/test/ftest/examples/seamspace/build.xml	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamspace/build.xml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+--> 
+<project name="seamspace.ftest.build" basedir="." default="build">
+   <property name="example.name" value="seamspace"/>
+   <property name="jboss.deploy.target" value="deploy"/>
+   <property name="jboss.undeploy.target" value="undeploy"/>
+   <property name="jboss.example.ready.check.url" value="seam-space/home.seam"/>
+  
+   <import file="../build.xml" />
+</project>


Property changes on: trunk/src/test/ftest/examples/seamspace/build.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/src/test/ftest/examples/seamspace/jboss.xml
===================================================================
--- trunk/src/test/ftest/examples/seamspace/jboss.xml	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamspace/jboss.xml	2009-01-26 10:22:43 UTC (rev 9980)
@@ -0,0 +1,34 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+--> 
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="Seamspace example" verbose="2" parallel="false">
+   <test name="seamspace_jboss">
+      <parameter name="PROPERTY_FILE" value="" />
+      <parameter name="CONTEXT_PATH" value="/seam-space" />
+      <classes>
+		<class name="org.jboss.seam.example.seamspace.test.selenium.LoginTest" />
+		<class name="org.jboss.seam.example.seamspace.test.selenium.UserTest" />
+		<class name="org.jboss.seam.example.seamspace.test.selenium.RoleTest" />
+		<class name="org.jboss.seam.example.seamspace.test.selenium.BlogTest" />
+	  </classes>
+   </test>
+</suite>


Property changes on: trunk/src/test/ftest/examples/seamspace/jboss.xml
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + text/plain

Added: trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/BlogTest.java
===================================================================
--- trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/BlogTest.java	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/BlogTest.java	2009-01-26 10:22:43 UTC (rev 9980)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.seamspace.test.selenium;
+
+import java.text.MessageFormat;
+
+import org.testng.annotations.Test;
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.AssertJUnit.assertEquals;
+
+/**
+ * This class tests blog functionality of SeamSpace application
+ * @author Jozef Hartinger
+ *
+ */
+public class BlogTest extends SeleniumSeamSpaceTest
+{
+
+   public static final String CREATE_BLOG_ENTRY = "id=createBlog";
+   public static final String VIEW_BLOG_ENTRY = "id=viewBlog";
+   public static final String BLOG_ENTRY_COUNT = "//div[@class=\"blogEntry\"]";
+   public static final String NEW_BLOG_TITLE = "id=newBlog:title";
+   public static final String NEW_BLOG_TEXT = "id=newBlog:text";
+   public static final String NEW_BLOG_SUBMIT = "id=newBlog:submit";
+   public static final String NEW_BLOG_PREVIEW = "id=newBlog:preview";
+   public static final String BLOG_ENTRY_BY_TITLE = "xpath=//div[@class=\"blogEntry\"][.//div[@class=\"blogTitle\"]/text() = \"{0}\"]";
+   public static final String BLOG_ENTRY_TEXT = "//div[@class=\"blogText\"]";
+   
+   @Test
+   public void createBlogTest() {
+      String title = "What is Seam?";
+      String text = "Seam is a powerful open source development platform for building rich Internet applications in Java. Seam integrates technologies such as Asynchronous JavaScript and XML (AJAX), JavaServer Faces (JSF), Java Persistence (JPA), Enterprise Java Beans (EJB 3.0) and Business Process Management (BPM) into a unified full-stack solution, complete with sophisticated tooling.";
+      int blogCount = 0;
+      
+      browser.clickAndWait(VIEW_BLOG_ENTRY);
+      blogCount = browser.getXpathCount(BLOG_ENTRY_COUNT).intValue();
+      browser.goBackAndWait();
+      browser.clickAndWait(CREATE_BLOG_ENTRY);
+      browser.type(NEW_BLOG_TITLE, title);
+      browser.type(NEW_BLOG_TEXT, text);
+      browser.clickAndWait(NEW_BLOG_SUBMIT);
+      assertEquals("Unexpected number of blog entries.", ++blogCount, browser.getXpathCount(BLOG_ENTRY_COUNT).intValue());
+      String blogEntry = MessageFormat.format(BLOG_ENTRY_BY_TITLE, title);
+      assertTrue("Blog entry not found. " + blogEntry, browser.isElementPresent(blogEntry));
+      assertEquals("Blog entry text has been modified.", text, browser.getText(blogEntry + BLOG_ENTRY_TEXT));
+   }
+   
+}


Property changes on: trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/BlogTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/LoginTest.java
===================================================================
--- trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/LoginTest.java	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/LoginTest.java	2009-01-26 10:22:43 UTC (rev 9980)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.seamspace.test.selenium;
+
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+
+import org.testng.annotations.Test;
+
+/**
+ * Basic test covering user authentication
+ * @author Jozef Hartinger
+ *
+ */
+public class LoginTest extends SeleniumSeamSpaceTest
+{
+   
+   @Test(groups = {"loginTest"})
+   public void loginTest() {
+      assertTrue("Login failed.", isLoggedIn());
+   }
+   
+   @Test(dependsOnMethods = {"loginTest"})
+   public void logoutTest() {
+      browser.clickAndWait(LOGOUT);
+      assertFalse("Logout failed.", isLoggedIn());
+   }
+   
+
+}


Property changes on: trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/LoginTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/RoleTest.java
===================================================================
--- trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/RoleTest.java	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/RoleTest.java	2009-01-26 10:22:43 UTC (rev 9980)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.seamspace.test.selenium;
+
+import java.text.MessageFormat;
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.AssertJUnit.assertFalse;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * This class tests role management in SeamSpace application
+ * @author Jozef Hartinger
+ *
+ */
+public class RoleTest extends SeleniumSeamSpaceTest
+{
+
+   @Override
+   @BeforeMethod
+   public void setUp()
+   {
+      super.setUp();
+      browser.clickAndWait(SECURITY);
+      browser.clickAndWait(MANAGE_ROLES);
+   }
+
+   @Test(dependsOnGroups = {"loginTest"})
+   public void roleCreatingTest()
+   {
+      String roleName = "tester";
+      String[] roles = { "user", "admin" };
+      createNewRole(roleName, roles);
+      // check that new role is added to role list
+      String roleRow = MessageFormat.format(ROLE_TABLE_ROW_BY_NAME, roleName);
+      assertTrue("New role not found in role list.", browser.isElementPresent(roleRow));
+      String roleTableRoles = browser.getText(roleRow + ROLE_TABLE_ROLES);
+      assertTrue("New role is not member of " + roles[0] + " role.", roleTableRoles.contains(roles[0]));
+      assertTrue("New role is not member of " + roles[1] + " role.", roleTableRoles.contains(roles[1]));
+      // check that new role is available to users
+      browser.clickAndWait(SECURITY);
+      browser.clickAndWait(MANAGE_USERS);
+      browser.clickAndWait(CREATE_USER_BUTTON);
+      String expectedRole = MessageFormat.format(USER_ROLE_BY_NAME_CHECKBOX, roleName);
+      assertTrue("New role is not available when creating new user.", browser.isElementPresent(expectedRole));
+   }
+   
+   @Test(dependsOnMethods = {"roleCreatingTest"})
+   public void roleEditingTest() {
+      String oldRoleName = "QA";
+      String[] oldRoles = {"user"};
+      String newRoleName = "QE";
+      String[] newRoles = {"user", "admin"};
+      
+      createNewRole(oldRoleName, oldRoles);
+      String oldRoleRow = MessageFormat.format(ROLE_TABLE_ROW_BY_NAME, oldRoleName);
+      assertTrue("New role not found.", browser.isElementPresent(oldRoleRow));
+      assertFalse("New role should not be member of admin role.", browser.getText(oldRoleRow + ROLE_TABLE_ROLES).contains("admin"));
+      browser.clickAndWait(oldRoleRow + ROLE_TABLE_EDIT);
+      fillRoleDetails(newRoleName, newRoles);
+      browser.clickAndWait(ROLE_SAVE);
+      String newRoleRow = MessageFormat.format(ROLE_TABLE_ROW_BY_NAME, newRoleName);
+      assertFalse("Old role still present.", browser.isElementPresent(oldRoleRow));
+      assertTrue("Updated role not found in role table.", browser.isElementPresent(newRoleRow));
+      String updatedRoleTableRoles = browser.getText(newRoleRow + ROLE_TABLE_ROLES);
+      assertTrue("New role is not member of " + newRoles[0] + " role.", updatedRoleTableRoles.contains(newRoles[0]));
+      assertTrue("New role is not member of " + newRoles[1] + " role.", updatedRoleTableRoles.contains(newRoles[1]));
+   }
+
+   @Test(dependsOnMethods = {"roleCreatingTest"})
+   public void roleDeletingTest() {
+      String roleName = "commiter";
+      String[] roles = {"user"};
+      
+      createNewRole(roleName, roles);
+      String roleRow = MessageFormat.format(ROLE_TABLE_ROW_BY_NAME, roleName);
+      assertTrue("New role not found.", browser.isElementPresent(roleRow));
+      browser.chooseOkOnNextConfirmation();
+      browser.clickAndWait(roleRow + ROLE_TABLE_DELETE);
+      assertFalse("Removed role still present.", browser.isElementPresent(roleRow));
+   }
+   
+   public void createNewRole(String name, String[] roles) {
+      browser.clickAndWait(CREATE_ROLE_BUTTON);
+      fillRoleDetails(name, roles);
+      browser.clickAndWait(ROLE_SAVE);
+   }
+   
+   public void fillRoleDetails(String name, String[] roles)
+   {
+      browser.type(ROLE_NAME, name);
+      for (String role : roles)
+      {
+         assertTrue("Role not available: " + role, browser.isElementPresent(MessageFormat.format(ROLE_MEMBER_OF_BY_NAME_CHECKBOX, role)));
+         browser.check(MessageFormat.format(ROLE_MEMBER_OF_BY_NAME_CHECKBOX, role));
+      }
+   }
+}


Property changes on: trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/RoleTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/SeleniumSeamSpaceTest.java
===================================================================
--- trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/SeleniumSeamSpaceTest.java	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/SeleniumSeamSpaceTest.java	2009-01-26 10:22:43 UTC (rev 9980)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.seamspace.test.selenium;
+
+import org.jboss.seam.example.common.test.selenium.SeamSeleniumTest;
+import org.testng.annotations.BeforeMethod;
+import static org.testng.AssertJUnit.fail;
+
+/**
+ * 
+ * @author Jozef Hartinger
+ *
+ */
+public abstract class SeleniumSeamSpaceTest extends SeamSeleniumTest
+{
+   
+   public static final String LOGIN = "id=login";
+   public static final String LOGOUT = "id=logout";
+   public static final String LOGIN_USERNAME = "id=loginForm:name";
+   public static final String LOGIN_PASSWORD = "id=loginForm:password";
+   public static final String LOGIN_LOGIN = "id=loginForm:login";
+   public static final String HOME_URL = "/home.seam";
+   public static final String SECURITY = "id=security";
+   
+   public static final String MANAGE_USERS = "id=manageUsers";
+   public static final String CREATE_USER_BUTTON = "id=newUser";
+   public static final String USER_FIRSTNAME = "id=user:firstname";
+   public static final String USER_LASTNAME = "id=user:lastname";
+   public static final String USER_NAME = "id=user:username";
+   public static final String USER_PASSWORD = "id=user:password";
+   public static final String USER_CONFIRM = "id=user:confirm";
+   public static final String USER_ROLES = "id=user:roles";
+   public static final String USER_ROLE_BY_NAME_CHECKBOX = "xpath=//input[contains(@id, \"user:roles:\")][normalize-space(../label/text()) = \"{0}\"]";
+   public static final String USER_ENABLED = "id=user:enabled";
+   public static final String USER_SAVE = "id=user:save";
+   public static final String USER_CANCEL = "id=user:cancel";
+   public static final String USER_TABLE_ROW_BY_NAME = "xpath=//table[@id=\"threads\"]/tbody/tr[normalize-space(./td[1]/text()) = \"{0}\"]";
+   // these locators can only be used catenated with USER_TABLE_ROW_BY_NAME
+   public static final String USER_TABLE_ROLES = "/td[2]/text()";
+   public static final String USER_TABLE_CHECKBOX_CHECKED = "/td[3]/div[@class=\"checkmark\"]";
+   public static final String USER_TABLE_CHECKBOX_UNCHECKED = "/td[3]/div[@class=\"cross\"]";
+   public static final String USER_TABLE_DELETE = "//a[contains(@id, \"delete\")]";
+   public static final String USER_TABLE_EDIT = "//a[contains(@id, \"edit\")]";
+   
+   public static final String MANAGE_ROLES = "id=manageRoles";
+   public static final String CREATE_ROLE_BUTTON = "id=newRole";
+   public static final String ROLE_NAME = "id=role:name";
+   public static final String ROLE_ROLES = "id=role:roles";
+   public static final String ROLE_MEMBER_OF_BY_NAME_CHECKBOX = "xpath=//input[contains(@id, \"role:roles:\")][normalize-space(../label/text()) = \"{0}\"]";
+   public static final String ROLE_SAVE = "id=role:save";
+   public static final String ROLE_CANCEL = "id=role:cancel";
+   public static final String ROLE_TABLE_ROW_BY_NAME = "xpath=//table[@id=\"threads\"]/tbody/tr[normalize-space(./td[1]/text()) = \"{0}\"]";
+   // these locators can only be used catenated with ROLE_TABLE_ROW_BY_NAME
+   public static final String ROLE_TABLE_ROLES = "/td[2]/text()";
+   public static final String ROLE_TABLE_DELETE = "//a[contains(@id, \"delete\")]";
+   public static final String ROLE_TABLE_EDIT = "//a[contains(@id, \"edit\")]";
+   
+   public static final String DEFAULT_USERNAME = "demo";
+   public static final String DEFAULT_PASSWORD = "demo";
+   
+   @Override
+   @BeforeMethod
+   public void setUp() {
+      super.setUp();
+      browser.open(CONTEXT_PATH + HOME_URL);
+      login();
+   }
+
+   public void login() {
+      login(DEFAULT_USERNAME, DEFAULT_PASSWORD);
+   }
+   
+   public void login(String username, String password) {
+      if (isLoggedIn()) {
+         fail("User already logged in.");
+      }
+      browser.clickAndWait(LOGIN);
+      browser.type(LOGIN_USERNAME, username);
+      browser.type(LOGIN_PASSWORD, password);
+      browser.clickAndWait(LOGIN_LOGIN);
+   }
+
+   protected boolean isLoggedIn()
+   {
+      return !browser.isElementPresent(LOGIN) && browser.isElementPresent(LOGOUT);
+   }
+}


Property changes on: trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/SeleniumSeamSpaceTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/UserTest.java
===================================================================
--- trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/UserTest.java	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/UserTest.java	2009-01-26 10:22:43 UTC (rev 9980)
@@ -0,0 +1,146 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.seamspace.test.selenium;
+
+import java.text.MessageFormat;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.AssertJUnit.assertFalse;
+
+/**
+ * This class tests user management in SeamSpace application
+ * @author Jozef Hartinger
+ *
+ */
+public class UserTest extends SeleniumSeamSpaceTest
+{
+
+   @Override
+   @BeforeMethod
+   public void setUp()
+   {
+      super.setUp();
+      browser.clickAndWait(SECURITY);
+      browser.clickAndWait(MANAGE_USERS);
+   }
+
+   @Test(dependsOnGroups = {"loginTest"})
+   public void userCreatingTest()
+   {
+      String username = "jharting";
+      String password = "topSecret";
+      String[] roles = {"admin", "user"};
+      createNewUser("Jozef", "Hartinger", username, password, password, roles, true);
+      String userRow = MessageFormat.format(USER_TABLE_ROW_BY_NAME, username);
+      // check user list
+      assertTrue("User not found in userlist.", browser.isElementPresent(userRow));
+      assertTrue("User not in admin role.", browser.getText(userRow + USER_TABLE_ROLES).contains("admin"));
+      assertTrue("User not in user role.", browser.getText(userRow + USER_TABLE_ROLES).contains("user"));
+      assertTrue("User not enabled.", browser.isElementPresent(userRow + USER_TABLE_CHECKBOX_CHECKED));
+      // check new user can login
+      browser.clickAndWait(LOGOUT);
+      login(username, password);
+      assertTrue("Unable to login with new user's credentials.", isLoggedIn());
+   }
+   
+   @Test(dependsOnGroups = {"loginTest"})
+   public void userEditingTest() {
+      String username = "shadowman";
+      String password = "password";
+      String[] roles = {"admin", "user"};
+      String userRow = MessageFormat.format(USER_TABLE_ROW_BY_NAME, username);
+      browser.clickAndWait(userRow + USER_TABLE_EDIT);
+      fillUpdatableUserDetails(password, password, roles, true);
+      browser.clickAndWait(USER_SAVE);
+      assertTrue("User not in admin role.", browser.getText(userRow + USER_TABLE_ROLES).contains("admin"));
+      assertTrue("User not in user role.", browser.getText(userRow + USER_TABLE_ROLES).contains("user"));
+      browser.clickAndWait(LOGOUT);
+      login(username, password);
+      assertTrue("Unable to login with changed password", isLoggedIn());
+   }
+   
+   @Test(dependsOnGroups = {"loginTest"})
+   public void userDeletingTest() {
+      String username = "mona";
+      String userRow = MessageFormat.format(USER_TABLE_ROW_BY_NAME, username);
+      assertTrue("User " + username + " not in user list.", browser.isElementPresent(userRow));
+      browser.chooseOkOnNextConfirmation();
+      browser.click(userRow + USER_TABLE_DELETE);
+      browser.getConfirmation();
+      browser.waitForPageToLoad(TIMEOUT);
+      assertFalse("User " + username + " exists after deletion", browser.isElementPresent(userRow));
+   }
+   
+   @Test(dependsOnGroups = {"loginTest"})
+   public void cancelledUserDeletingTest() throws InterruptedException {
+      String username = "demo";
+      String userRow = MessageFormat.format(USER_TABLE_ROW_BY_NAME, username);
+      assertTrue("User " + username + " not in user list.", browser.isElementPresent(userRow));
+      browser.chooseCancelOnNextConfirmation();
+      browser.click(userRow + USER_TABLE_DELETE);
+      browser.getConfirmation();
+      browser.refreshAndWait();
+      assertTrue("User " + username + " missing in user list after cancelled deletion.", browser.isElementPresent(userRow));
+   }
+   
+   @Test(dependsOnGroups = {"loginTest"}, dependsOnMethods={"userCreatingTest"})
+   public void disablingUserAccountTest() {
+      String username = "johny";
+      String password = "password";
+      String userRow = MessageFormat.format(USER_TABLE_ROW_BY_NAME, username);
+      createNewUser("John", "Doe", username, password, password, new String[]{"user"}, false);
+      assertTrue("User not found in userlist.", browser.isElementPresent(userRow));
+      assertTrue("User account enabled.", browser.isElementPresent(userRow + USER_TABLE_CHECKBOX_UNCHECKED));
+      browser.clickAndWait(LOGOUT);
+      login(username, password);
+      assertFalse("User logged in despite his account was disabled.", isLoggedIn());
+   }
+   
+   private void createNewUser(String firstName, String lastName, String username, String password, String confirm, String[] roles, boolean enabled) {
+      browser.clickAndWait(CREATE_USER_BUTTON);
+      fillNewUserDetails(firstName, lastName, username, password, confirm, roles, enabled);
+      browser.clickAndWait(USER_SAVE);
+   }
+   
+   private void fillNewUserDetails(String firstName, String lastName, String username, String password, String confirm, String[] roles, boolean enabled)
+   {
+      browser.type(USER_FIRSTNAME, firstName);
+      browser.type(USER_LASTNAME, lastName);
+      browser.type(USER_NAME, username);
+      fillUpdatableUserDetails(password, confirm, roles, enabled);
+   }
+   
+   private void fillUpdatableUserDetails(String password, String confirm, String[] roles, boolean enabled) {
+      browser.type(USER_PASSWORD, password);
+      browser.type(USER_CONFIRM, confirm);
+      for (String role : roles) {
+         assertTrue("Unable to add user to role: " + role, browser.isElementPresent(MessageFormat.format(USER_ROLE_BY_NAME_CHECKBOX, role)));
+         browser.check(MessageFormat.format(USER_ROLE_BY_NAME_CHECKBOX, role));
+      }
+      if (enabled)
+      {
+         browser.check(USER_ENABLED);
+      }      
+   }
+}


Property changes on: trunk/src/test/ftest/examples/seamspace/src/org/jboss/seam/example/seamspace/test/selenium/UserTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the seam-commits mailing list