[seam-commits] Seam SVN: r10076 - in trunk: examples/seamdiscs/view/layout and 11 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Feb 23 10:40:58 EST 2009


Author: manaRH
Date: 2009-02-23 10:40:57 -0500 (Mon, 23 Feb 2009)
New Revision: 10076

Added:
   trunk/src/test/ftest/examples/seamdiscs/
   trunk/src/test/ftest/examples/seamdiscs/build.xml
   trunk/src/test/ftest/examples/seamdiscs/jboss.xml
   trunk/src/test/ftest/examples/seamdiscs/src/
   trunk/src/test/ftest/examples/seamdiscs/src/org/
   trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/
   trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/
   trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/
   trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/
   trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/
   trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/
   trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/ArtistsTest.java
   trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/DiscsTest.java
   trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/LoginTest.java
   trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java
Modified:
   trunk/examples/seamdiscs/view/artist.xhtml
   trunk/examples/seamdiscs/view/artists.xhtml
   trunk/examples/seamdiscs/view/disc.xhtml
   trunk/examples/seamdiscs/view/discs.xhtml
   trunk/examples/seamdiscs/view/layout/menu.xhtml
   trunk/examples/seamdiscs/view/layout/template.xhtml
   trunk/examples/seamdiscs/view/login.xhtml
   trunk/src/test/ftest/build.xml
Log:
JBSEAM-3690

Modified: trunk/examples/seamdiscs/view/artist.xhtml
===================================================================
--- trunk/examples/seamdiscs/view/artist.xhtml	2009-02-23 12:36:14 UTC (rev 10075)
+++ trunk/examples/seamdiscs/view/artist.xhtml	2009-02-23 15:40:57 UTC (rev 10076)
@@ -14,10 +14,10 @@
     
     <rich:panel>
     	<f:facet name="header"><tr:outputText value="#{artist.name} (#{messages[artist.class.name]})" rendered="#{artist.name ne null}" /></f:facet>
-	  	<h:form>
+	  	<h:form id="artist">
 	  		<s:validateAll>
 	    	<tr:panelFormLayout>
-	    		<tr:inputText label="Artist" value="#{artist.name}" readOnly="#{not identity.loggedIn}" required="true"/>
+	    		<tr:inputText label="Artist" id="name" value="#{artist.name}" readOnly="#{not identity.loggedIn}" required="true"/>
 	    		<tr:panelLabelAndMessage label="Band Members" rendered="#{artist.class.simpleName eq 'Band'}">
 					<ul>
 			    		<ui:repeat value="#{artist.bandMembers}" var="bandMember">
@@ -32,7 +32,7 @@
 			    		</ui:repeat>
 					</ul>
 		    		<f:facet name="end">
-		    			<h:commandButton action="#{artistHome.addBandMember}" value="Add Band Member" rendered="#{identity.loggedIn}"/>
+		    			<h:commandButton id="addBandMember" action="#{artistHome.addBandMember}" value="Add Band Member" rendered="#{identity.loggedIn}"/>
 		    		</f:facet>
 		    	</tr:panelLabelAndMessage>
 		    	<tr:panelLabelAndMessage label="Details">
@@ -46,7 +46,7 @@
 					</s:div>
 				</tr:panelLabelAndMessage>
 		    	<tr:panelLabelAndMessage label="Discs">
-		    		<tr:table value="#{artist.discs}" var="disc" rows="5" emptyText="None Known">
+		    		<tr:table value="#{artist.discs}" var="disc" rows="5" emptyText="None Known" id="discs">
 			    		<tr:column>
 			    			<f:facet name="header">
 			    				Disc
@@ -67,16 +67,16 @@
 				 		</f:facet>
 			    	</tr:table>
 			    	<f:facet name="end">
-		    			<h:commandButton action="#{artistHome.addDisc}" value="Add Disc" rendered="#{identity.loggedIn}"/>
+		    			<h:commandButton id="addDisc" action="#{artistHome.addDisc}" value="Add Disc" rendered="#{identity.loggedIn}"/>
 		    		</f:facet>
 		    	</tr:panelLabelAndMessage>
 	    	</tr:panelFormLayout>
 	   	</s:validateAll>
 	   	
 	   	<tr:panelButtonBar rendered="#{identity.loggedIn}">
-	   		<h:commandButton action="#{artistHome.update}" value="Save" rendered="#{artistHome.managed}" />
-	   		<h:commandButton action="#{artistHome.persist}" value="Save" rendered="#{not artistHome.managed}" />
-	   		<s:button action="cancel" value="Cancel" />
+	   		<h:commandButton action="#{artistHome.update}" value="Save" rendered="#{artistHome.managed}" id="update"/>
+	   		<h:commandButton action="#{artistHome.persist}" value="Save" rendered="#{not artistHome.managed}" id="persist"/>
+	   		<s:button action="cancel" value="Cancel" id="cancel"/>
 	   	</tr:panelButtonBar>
 	  	</h:form>
     </rich:panel>

Modified: trunk/examples/seamdiscs/view/artists.xhtml
===================================================================
--- trunk/examples/seamdiscs/view/artists.xhtml	2009-02-23 12:36:14 UTC (rev 10075)
+++ trunk/examples/seamdiscs/view/artists.xhtml	2009-02-23 15:40:57 UTC (rev 10076)
@@ -64,11 +64,11 @@
 				</tr:form>
 			</a:outputPanel>
 			<tr:panelButtonBar rendered="#{identity.loggedIn}">
-				<s:button action="artist" value="Add artist">
+				<s:button action="artist" value="Add artist" id="addArtist">
 					<f:param name="artistId" value="" />
 					<f:param name="type" value="artist" />
 				</s:button>
-				<s:button action="artist" value="Add band">
+				<s:button action="artist" value="Add band" id="addBand">
 					<f:param name="artistId" value="" />
 					<f:param name="type" value="band" />
 				</s:button>

Modified: trunk/examples/seamdiscs/view/disc.xhtml
===================================================================
--- trunk/examples/seamdiscs/view/disc.xhtml	2009-02-23 12:36:14 UTC (rev 10075)
+++ trunk/examples/seamdiscs/view/disc.xhtml	2009-02-23 15:40:57 UTC (rev 10076)
@@ -19,7 +19,7 @@
 		    	<tr:outputText value=" by #{disc.artist.name}" />
 		    </s:fragment>
 		</f:facet>
-    	<tr:form>
+    	<tr:form id="disc">
     		<s:validateAll>
 		    	<tr:panelFormLayout>
 		    		<tr:inputText label="Disc" value="#{disc.name}" readOnly="#{not identity.loggedIn}" required="true" />
@@ -41,10 +41,10 @@
 	    	</s:validateAll>
 	    	
 	    	<tr:panelButtonBar rendered="#{identity.loggedIn}">
-		    	<h:commandButton action="#{discHome.update}" value="Save" rendered="#{discHome.managed}" />
-		    	<h:commandButton action="#{discHome.persist}" value="Save" rendered="#{not discHome.managed}" />
-		    	<h:commandButton action="#{discHome.remove}" value="Delete" rendered="#{discHome.managed}" />
-		    	<s:button action="cancel" value="Cancel" />
+		    	<h:commandButton action="#{discHome.update}" value="Save" rendered="#{discHome.managed}" id="update" />
+		    	<h:commandButton action="#{discHome.persist}" value="Save" rendered="#{not discHome.managed}" id="persist" />
+		    	<h:commandButton action="#{discHome.remove}" value="Delete" rendered="#{discHome.managed}" id="remove" />
+		    	<s:button action="cancel" value="Cancel" id="cancel"/>
 		    </tr:panelButtonBar>
     	</tr:form>
     </rich:panel>

Modified: trunk/examples/seamdiscs/view/discs.xhtml
===================================================================
--- trunk/examples/seamdiscs/view/discs.xhtml	2009-02-23 12:36:14 UTC (rev 10075)
+++ trunk/examples/seamdiscs/view/discs.xhtml	2009-02-23 15:40:57 UTC (rev 10076)
@@ -11,7 +11,7 @@
 
 <ui:define name="body">
     
-    <rich:panel>
+    <rich:panel id="discs">
    		<f:facet name="header">Discs</f:facet>
     	<tr:form>
 	    	<tr:table value="#{discs.dataModel}" var="disc" rows="#{discs.maxResults}">
@@ -38,7 +38,7 @@
 	    		</f:facet>
 	    	</tr:table>
 	    	<tr:panelButtonBar rendered="#{identity.loggedIn}">
-		    	<s:button action="disc" value="Add disc">
+		    	<s:button action="disc" value="Add disc" id="addDisc">
 		    		<f:param name="discId" value="" />
 	    		</s:button>
 		    </tr:panelButtonBar>

Modified: trunk/examples/seamdiscs/view/layout/menu.xhtml
===================================================================
--- trunk/examples/seamdiscs/view/layout/menu.xhtml	2009-02-23 12:36:14 UTC (rev 10075)
+++ trunk/examples/seamdiscs/view/layout/menu.xhtml	2009-02-23 15:40:57 UTC (rev 10076)
@@ -9,12 +9,12 @@
      <rich:toolBarGroup>
          <h:outputText value="#{projectName}:"/>
          <s:link view="/home.xhtml" value="Home" propagation="none"/>
-         <s:link view="/artists.xhtml" value="Artists" propagation="none"/>
-         <s:link view="/discs.xhtml" value="Discs" propagation="none"/>
+         <s:link view="/artists.xhtml" id="manageArtists" value="Artists" propagation="none"/>
+         <s:link view="/discs.xhtml" id="manageDiscs" value="Discs" propagation="none"/>
      </rich:toolBarGroup>
      <rich:toolBarGroup location="right">
          <h:outputText value="Welcome, #{identity.username}" rendered="#{identity.loggedIn}"/>
-         <s:link view="/login.xhtml" value="Login" rendered="#{not identity.loggedIn}"/>
-         <s:link view="/home.xhtml" action="#{identity.logout}" value="Logout" rendered="#{identity.loggedIn}"/>
+         <s:link view="/login.xhtml" id="loginlink" value="Login" rendered="#{not identity.loggedIn}"/>
+         <s:link view="/home.xhtml" id="logout" action="#{identity.logout}" value="Logout" rendered="#{identity.loggedIn}"/>
      </rich:toolBarGroup>
 </rich:toolBar>

Modified: trunk/examples/seamdiscs/view/layout/template.xhtml
===================================================================
--- trunk/examples/seamdiscs/view/layout/template.xhtml	2009-02-23 12:36:14 UTC (rev 10075)
+++ trunk/examples/seamdiscs/view/layout/template.xhtml	2009-02-23 15:40:57 UTC (rev 10076)
@@ -21,7 +21,7 @@
         <ui:param name="projectName" value="SeamDiscs"/>
     </ui:include>
 
-    <tr:messages globalOnly="true"/>
+    <tr:messages globalOnly="true" id="messages"/>
 
 	<div class="body">
 		<ui:insert name="body"/>

Modified: trunk/examples/seamdiscs/view/login.xhtml
===================================================================
--- trunk/examples/seamdiscs/view/login.xhtml	2009-02-23 12:36:14 UTC (rev 10075)
+++ trunk/examples/seamdiscs/view/login.xhtml	2009-02-23 15:40:57 UTC (rev 10076)
@@ -34,7 +34,7 @@
         </rich:panel>
             
         <div class="actionButtons">
-            <h:commandButton value="Login" action="#{identity.login}"/>
+            <h:commandButton value="Login" id="loginbutton" action="#{identity.login}"/>
         </div>
           
     </h:form>

Modified: trunk/src/test/ftest/build.xml
===================================================================
--- trunk/src/test/ftest/build.xml	2009-02-23 12:36:14 UTC (rev 10075)
+++ trunk/src/test/ftest/build.xml	2009-02-23 15:40:57 UTC (rev 10076)
@@ -71,6 +71,7 @@
 		<testexample name="remoting/chatroom" />
 		<testexample name="rss" />
 		<testexample name="seambay" />
+		<testexample name="seamdiscs" />
 		<testexample name="seampay" />
 		<testexample name="seamspace" />
 		<testexample name="spring" />
@@ -160,6 +161,7 @@
 		<cleanexample name="remoting/chatroom" />
 		<cleanexample name="rss" />
 		<cleanexample name="seambay" />
+		<cleanexample name="seamdiscs" />
 		<cleanexample name="seampay" />
 		<cleanexample name="seamspace" />
 		<cleanexample name="spring" />
@@ -192,6 +194,7 @@
 		<undeployexample name="rss" />
 		<undeployexample name="remoting/chatroom" />
 		<undeployexample name="seambay" />
+		<undeployexample name="seamdiscs" />
 		<undeployexample name="seampay" />
 		<undeployexample name="seamspace" />
 		<undeployexample name="spring" />

Added: trunk/src/test/ftest/examples/seamdiscs/build.xml
===================================================================
--- trunk/src/test/ftest/examples/seamdiscs/build.xml	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamdiscs/build.xml	2009-02-23 15:40:57 UTC (rev 10076)
@@ -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="seamdiscs.ftest.build" basedir="." default="build">
+   <property name="example.name" value="seamdiscs"/>
+   <property name="jboss.deploy.target" value="deploy"/>
+   <property name="jboss.undeploy.target" value="undeploy"/>
+   <property name="jboss.example.ready.check.url" value="seam-discs/home.seam"/>
+  
+   <import file="../build.xml" />
+</project>

Added: trunk/src/test/ftest/examples/seamdiscs/jboss.xml
===================================================================
--- trunk/src/test/ftest/examples/seamdiscs/jboss.xml	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamdiscs/jboss.xml	2009-02-23 15:40:57 UTC (rev 10076)
@@ -0,0 +1,33 @@
+<!--
+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="Seamdiscs example" verbose="2" parallel="false">
+   <test name="seamdiscs_jboss">
+      <parameter name="PROPERTY_FILE" value="" />
+      <parameter name="CONTEXT_PATH" value="/seam-discs" />
+      <classes>
+	    <class name="org.jboss.seam.example.seamdiscs.test.selenium.LoginTest" />
+		<class name="org.jboss.seam.example.seamdiscs.test.selenium.ArtistsTest" />
+		<class name="org.jboss.seam.example.seamdiscs.test.selenium.DiscsTest" />
+	  </classes>
+   </test>
+</suite>

Added: trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/ArtistsTest.java
===================================================================
--- trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/ArtistsTest.java	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/ArtistsTest.java	2009-02-23 15:40:57 UTC (rev 10076)
@@ -0,0 +1,140 @@
+/*
+ * 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.seamdiscs.test.selenium;
+
+import java.text.MessageFormat;
+
+import static org.testng.AssertJUnit.assertTrue;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * This class tests artists management in SeamDiscs application
+ * @author Ondrej Skutka
+ *
+ */
+public class ArtistsTest extends SeleniumSeamDiscsTest
+{
+
+   @Override
+   @BeforeMethod
+   public void setUp()
+   {
+      super.setUp();
+      browser.clickAndWait(MANAGE_ARTISTS);
+   }
+
+ /*  @Test(dependsOnMethods = {"createWithDiscsTest"})
+   public void paginationTest() 
+   {
+      findAndClickArtist("Fairport Convention"); // should be on second page
+      checkDisc(1, "Liege and Lief", "", "The first folk-rock album ever made in the UK, this was the only studio recording of the classic line up of Sandy Denny, Richard Thompson, Dave Swarbick, Ashley Hutchings and Simon Nicol");
+   }*/
+
+   @Test(dependsOnMethods = {"createWithDiscsTest"})
+   public void filterTest() 
+   {
+      browser.type(ARTIST_FILTER, "Fairport");
+      browser.keyUp(ARTIST_FILTER, "t"); // to trigger ajax search
+      sleep(3000);
+      browser.clickAndWait(ARTISTS_FIRST_ARTIST_LINK);
+      checkDisc(1, "Liege and Lief", "", "The first folk-rock album ever made in the UK, this was the only studio recording of the classic line up of Sandy Denny, Richard Thompson, Dave Swarbick, Ashley Hutchings and Simon Nicol");
+   }
+   
+   @Test(dependsOnGroups = {"loginTest"})
+   public void createWithDiscsTest() 
+   {
+      browser.clickAndWait(CREATE_ARTIST_BUTTON);
+      browser.type(ARTIST_NAME, "Lou Reed");
+      browser.type(ARTIST_DESCRIPTION, "First came to prominence as the guitarist and principal singer-songwriter of The Velvet Underground. Than began a long and eclectic solo career.");
+      createDisc("Metal Machine Music", "1975");
+      createDisc("Sally Can't Dance", "1974");
+      createDisc("Rock and Roll Heart", "1977");
+      browser.clickAndWait(ARTIST_PERSIST);
+      assertTrue("Cannot create artist with discs", browser.isTextPresent("Successfully created"));
+  
+      findAndClickArtist("Lou Reed");
+      
+      // check whether it is the Lou Reed
+      assertTrue("This artist is not Lou Reed!", browser.getAttribute(ARTIST_NAME + "@value").equals("Lou Reed"));
+
+      // check discs (they should be sorted by release date)
+      checkDisc(1, "Sally Can't Dance", "1974", EMPTY_DISC_DESCRIPTION);
+      checkDisc(2, "Metal Machine Music", "1975", EMPTY_DISC_DESCRIPTION);
+      checkDisc(3, "Rock and Roll Heart", "1977", EMPTY_DISC_DESCRIPTION);
+   }
+
+// TODO check creating empty disc
+   
+   
+   @Test(dependsOnMethods = {"createWithDiscsTest"})
+   public void editDiscsTest() 
+   {
+      // correct Rock and Roll Heart releas date
+      findAndClickArtist("Lou Reed");
+      browser.type(MessageFormat.format(ARTIST_NTH_DISC_YEAR, "last()"), "1976");
+      
+      browser.clickAndWait(ARTIST_UPDATE);
+      findAndClickArtist("Lou Reed");
+      
+      checkDisc(1, "Sally Can't Dance", "1974", EMPTY_DISC_DESCRIPTION);
+      checkDisc(2, "Metal Machine Music", "1975", EMPTY_DISC_DESCRIPTION);
+      checkDisc(3, "Rock and Roll Heart", "1976", EMPTY_DISC_DESCRIPTION); // this was altered 
+   }
+   
+   @Test(dependsOnGroups = {"loginTest"})
+   public void addBandTest() 
+   {
+      browser.clickAndWait(CREATE_BAND_BUTTON);
+      browser.type(ARTIST_NAME, "The Velvet Underground");
+      browser.type(ARTIST_DESCRIPTION, "An underground band.");
+      createDisc("White Light/White Heat", "1968");
+      createDisc("The Velvet Underground and Nico", "1967");
+      
+      addBandMember("Lou Reed");
+      addBandMember("Sterling Morrison");
+      addBandMember("John Cale");
+      addBandMember("Maureen Tucker");
+      addBandMember("Nico");
+
+      browser.clickAndWait(ARTIST_PERSIST);
+      assertTrue("Cannot create artist with discs", browser.isTextPresent("Successfully created"));
+
+      findAndClickArtist("The Velvet Underground");
+
+      // check whether it is the Lou Reed
+      assertTrue("This artist is not the Velvet Underground!", browser.getAttribute(ARTIST_NAME + "@value").equals("The Velvet Underground"));
+
+      // check discs (they should be sorted by release date)
+      checkDisc(1, "The Velvet Underground and Nico", "1967", EMPTY_DISC_DESCRIPTION);
+      checkDisc(2, "White Light/White Heat", "1968", EMPTY_DISC_DESCRIPTION);
+      
+      checkBandMember(1, "Lou Reed");
+      checkBandMember(2, "Sterling Morrison");
+      checkBandMember(3, "John Cale");
+      checkBandMember(4, "Maureen Tucker");
+      checkBandMember(5, "Nico");
+   }
+
+
+}

Added: trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/DiscsTest.java
===================================================================
--- trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/DiscsTest.java	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/DiscsTest.java	2009-02-23 15:40:57 UTC (rev 10076)
@@ -0,0 +1,159 @@
+/*
+ * 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.seamdiscs.test.selenium;
+
+import static org.testng.AssertJUnit.assertTrue;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * This class tests artists management in SeamDiscs application
+ * @author Ondrej Skutka
+ *
+ */
+public class DiscsTest extends SeleniumSeamDiscsTest
+{
+
+   @Override
+   @BeforeMethod
+   public void setUp()
+   {
+      super.setUp();
+      browser.clickAndWait(MANAGE_DISCS);
+   }
+
+   @Test(dependsOnMethods = {"editDiscsTest"})
+   public void discPaginationTest() 
+   {
+      findAndClickDisc("Rock and Roll Heart"); // should not be on the first page
+      checkDiscDetail("Rock and Roll Heart", "1976", "", "Lou Reed");
+   }
+
+
+   @Test(dependsOnMethods = {"editDiscsTest"})
+   public void editDiscTest() 
+   {
+      // correct Rock and Roll Heart description
+      findAndClickDisc("Rock and Roll Heart"); // should not be on the first page
+      checkDiscDetail("Rock and Roll Heart", "1976", "", "Lou Reed");
+      
+      browser.type(DISC_DETAIL_DESCRIPTION, "A sensitive and revealing look into the prince of darkness.");
+      
+      browser.clickAndWait(DISC_DETAIL_UPDATE);
+      
+      findAndClickDisc("Rock and Roll Heart");
+      checkDiscDetail("Rock and Roll Heart", "1976", "A sensitive and revealing look into the prince of darkness.", "Lou Reed");
+      
+      // check whether it's ok from the artists' perspective
+      browser.clickAndWait(MANAGE_ARTISTS);
+
+      findAndClickArtist("Lou Reed");
+      
+      // check whether it is the Lou Reed
+      assertTrue("This artist is not Lou Reed!", browser.getAttribute(ARTIST_NAME + "@value").equals("Lou Reed"));
+
+      // check discs (they should be sorted by release date)
+      checkDisc(1, "Sally Can't Dance", "1974", EMPTY_DISC_DESCRIPTION);
+      checkDisc(2, "Metal Machine Music", "1975", EMPTY_DISC_DESCRIPTION);
+      checkDisc(3, "Rock and Roll Heart", "1976", "A sensitive and revealing look into the prince of darkness.");
+   }
+   
+   @Test(dependsOnMethods = {"editDiscTest"})
+   public void addDiscTest()
+   {
+      browser.clickAndWait(CREATE_DISC_BUTTON);
+      browser.type(DISC_DETAIL_TITLE, "Berlin");
+      browser.select(DISC_DETAIL_ARTIST, "Lou Reed");
+      browser.type(DISC_DETAIL_RELEASE_DATE, "1973");
+      browser.type(DISC_DETAIL_DESCRIPTION, "A tragic rock opera about a doomed couple that addresses themes of drug use and depression.");
+      browser.clickAndWait(DISC_DETAIL_PERSIST);
+      assertTrue("Cannot create disc", browser.isTextPresent("Successfully created"));
+
+      // check whether it's ok from the artists' perspective
+      browser.clickAndWait(MANAGE_ARTISTS);
+
+      findAndClickArtist("Lou Reed");
+      
+      // check whether it is the Lou Reed
+      assertTrue("This artist is not Lou Reed!", browser.getAttribute(ARTIST_NAME + "@value").equals("Lou Reed"));
+
+      // check discs (they should be sorted by release date)
+      checkDisc(1, "Berlin", "1973", "A tragic rock opera about a doomed couple that addresses themes of drug use and depression.");
+      checkDisc(2, "Sally Can't Dance", "1974", EMPTY_DISC_DESCRIPTION);
+      checkDisc(3, "Metal Machine Music", "1975", EMPTY_DISC_DESCRIPTION);
+      checkDisc(4, "Rock and Roll Heart", "1976", "A sensitive and revealing look into the prince of darkness.");
+   }
+
+
+   @Test(dependsOnMethods = {"addDiscTest"})
+   public void removeDiscTest() 
+   {
+      // correct Rock and Roll Heart description
+      findAndClickDisc("Berlin");
+      checkDiscDetail("Berlin", "1973", "A tragic rock opera about a doomed couple that addresses themes of drug use and depression.", "Lou Reed");
+      
+      browser.clickAndWait(DISC_DETAIL_REMOVE);
+      
+      // check whether it's ok from the artists' perspective
+      browser.clickAndWait(MANAGE_ARTISTS);
+
+      findAndClickArtist("Lou Reed");
+      
+      // check whether it is the Lou Reed
+      assertTrue("This artist is not Lou Reed!", browser.getAttribute(ARTIST_NAME + "@value").equals("Lou Reed"));
+
+      // check discs (they should be sorted by release date)
+      checkDisc(1, "Sally Can't Dance", "1974", EMPTY_DISC_DESCRIPTION);
+      checkDisc(2, "Metal Machine Music", "1975", EMPTY_DISC_DESCRIPTION);
+      checkDisc(3, "Rock and Roll Heart", "1976", "A sensitive and revealing look into the prince of darkness.");
+   }
+
+   @Test(dependsOnMethods = {"removeDiscTest"})
+   public void cancelDiscTest() 
+   {
+      // correct Rock and Roll Heart description
+      findAndClickDisc("Rock and Roll Heart"); // should not be on the first page
+      checkDiscDetail("Rock and Roll Heart", "1976", "A sensitive and revealing look into the prince of darkness.", "Lou Reed");
+      
+      browser.type(DISC_DETAIL_DESCRIPTION, "Pretty lame album.");
+      
+      browser.clickAndWait(DISC_DETAIL_CANCEL);
+      
+      findAndClickDisc("Rock and Roll Heart");
+      checkDiscDetail("Rock and Roll Heart", "1976", "A sensitive and revealing look into the prince of darkness.", "Lou Reed");
+      
+      // check whether it's ok from the artists' perspective
+      browser.clickAndWait(MANAGE_ARTISTS);
+
+      findAndClickArtist("Lou Reed");
+      
+      // check whether it is the Lou Reed
+      assertTrue("This artist is not Lou Reed!", browser.getAttribute(ARTIST_NAME + "@value").equals("Lou Reed"));
+
+      // check discs (they should be sorted by release date)
+      checkDisc(1, "Sally Can't Dance", "1974", EMPTY_DISC_DESCRIPTION);
+      checkDisc(2, "Metal Machine Music", "1975", EMPTY_DISC_DESCRIPTION);
+      checkDisc(3, "Rock and Roll Heart", "1976", "A sensitive and revealing look into the prince of darkness.");
+   }
+   
+}

Added: trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/LoginTest.java
===================================================================
--- trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/LoginTest.java	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/LoginTest.java	2009-02-23 15:40:57 UTC (rev 10076)
@@ -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.seamdiscs.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 SeleniumSeamDiscsTest
+{
+   
+   @Test(groups = {"loginTest"})
+   public void loginTest() {
+      assertTrue("Login failed.", isLoggedIn());
+   }
+   
+   @Test(dependsOnMethods = {"loginTest"})
+   public void logoutTest() {
+      browser.clickAndWait(LOGOUT);
+      assertFalse("Logout failed.", isLoggedIn());
+   }
+   
+
+}

Added: trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java
===================================================================
--- trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java	                        (rev 0)
+++ trunk/src/test/ftest/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/selenium/SeleniumSeamDiscsTest.java	2009-02-23 15:40:57 UTC (rev 10076)
@@ -0,0 +1,232 @@
+/*
+ * 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.seamdiscs.test.selenium;
+
+import java.text.MessageFormat;
+
+import org.jboss.seam.example.common.test.selenium.SeamSeleniumTest;
+import org.testng.annotations.BeforeMethod;
+
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.AssertJUnit.fail;
+
+/**
+ * 
+ * @author Ondrej Skutka
+ *
+ */
+public abstract class SeleniumSeamDiscsTest extends SeamSeleniumTest
+{
+   // TODO final
+   public static String LOGIN = "id=loginlink";
+   public static String LOGOUT = "id=logout";
+   public static String LOGIN_USERNAME = "id=login:username";
+   public static String LOGIN_PASSWORD = "id=login:password";
+   public static String LOGIN_LOGIN = "id=login:loginbutton";
+   public static String HOME_URL = "/home.seam";
+//   public static String SECURITY = "id=security";
+//   
+   public static String MANAGE_DISCS = "id=manageDiscs";
+   public static String CREATE_ARTIST_BUTTON = "id=addArtist";
+   public static String CREATE_BAND_BUTTON = "id=addBand";
+   public static String ARTIST_FILTER = "//form[1]//input[@type='text']";
+   public static String ARTIST_NAME = "id=artist:name";
+   public static String ARTIST_CREATE_DISC_BUTTON = "id=artist:addDisc";
+   public static String ARTIST_DESCRIPTION = "id=artist:description";
+   public static String ARTIST_PERSIST = "id=artist:persist";
+   public static String ARTIST_UPDATE = "id=artist:update";
+   public static String ARTIST_CANCEL = "id=artist:cancel";
+   public static String ARTIST_ADD_BAND_MEMBER = "id=artist:addBandMember";
+   public static String ARTIST_NTH_BAND_MEMBER = "xpath=id(\"artist\")//tr[1]//tr[3]/td[2]//ul/li[{0}]//input[@type=\"text\"]";
+   public static String ARTIST_LAST_BAND_MEMBER = MessageFormat.format(ARTIST_NTH_BAND_MEMBER, "last()");
+   
+   
+   public static String ARTIST_NTH_DISC = "xpath=id(\"artist:discs\")/table/tbody/tr/td/table/tbody/tr[{0}]";
+   public static String ARTIST_NTH_DISC_SHOW_DETAILS = ARTIST_NTH_DISC + "/td[1]/div/a[2]";
+   public static String ARTIST_NTH_DISC_NAME = ARTIST_NTH_DISC + "/td[2]/input";
+   public static String ARTIST_NTH_DISC_YEAR = ARTIST_NTH_DISC + "/td[3]//input";
+   public static String ARTIST_NTH_DISC_DETAIL = ARTIST_NTH_DISC + "/td";
+   public static String ARTISTS_FIRST_ARTIST_LINK = "xpath=id(\"artists\")//table/tbody/tr/td/table/tbody/tr[2]/td[2]/a";
+   public static String ARTISTS_NEXT_PAGE_LINK = "xpath=id(\"artists\")//td[1]//td[7]/a";
+   public static String ARTIST_TABLE_ROW_BY_NAME = "xpath=id(\"artists\")//tr[normalize-space(td/a/text())=\"{0}\"]";
+   // these locators can only be used catenated with ARTIST_TABLE_ROW_BY_NAME
+   public static String ARTIST_TABLE_ROW_LINK = ARTIST_TABLE_ROW_BY_NAME + "/td[2]/a";
+
+   
+   public static String MANAGE_ARTISTS = "id=manageArtists";
+   public static String CREATE_DISC_BUTTON = "id=addDisc";
+   public static String DISC_DETAIL_TITLE = "xpath=id(\"disc\")//tr//tr[2]/td[2]/input";
+   public static String DISC_DETAIL_RELEASE_DATE = "xpath=id(\"disc\")//tr//tr[3]/td[2]//input";
+   public static String DISC_DETAIL_ARTIST = "xpath=id(\"disc\")//tr//tr[5]//select";
+   public static String DISC_DETAIL_DESCRIPTION = "id=description";
+   public static String DISC_DETAIL_UPDATE = "id=update";
+   public static String DISC_DETAIL_PERSIST = "id=persist";
+   public static String DISC_DETAIL_REMOVE = "id=remove";
+   public static String DISC_DETAIL_CANCEL = "id=cancel";
+   public static String DISCS_NEXT_PAGE_LINK = "xpath=id(\"discs\")//td[1]//td[7]/a";
+   public static String DISC_TABLE_ROW_BY_NAME = "xpath=id(\"discs\")//tr[normalize-space(td/a/text())=\"{0}\"]";
+   // these locators can only be used catenated with DISC_TABLE_ROW_BY_NAME
+   public static String DISC_TABLE_ROW_LINK = DISC_TABLE_ROW_BY_NAME + "/td[2]/a";
+   
+   public static String EMPTY_DISC_DESCRIPTION = "None known";
+   
+   public static String DEFAULT_USERNAME = "administrator";
+   public static String DEFAULT_PASSWORD = "administrator";
+   
+   @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);
+   }
+
+   /**
+    * Checks whether specified disc contains expected data.
+    */
+   protected void checkDisc(int tableRow, String expectedDiscTitle, String expectedReleaseDate, String expectedDescription) {
+      tableRow++; // first row is header
+      String actualDiscTitle = browser.getAttribute(MessageFormat.format(ARTIST_NTH_DISC_NAME, tableRow) + "@value");
+      assertTrue("This is not expected (" + expectedDiscTitle + ") album (" + actualDiscTitle + ")!", actualDiscTitle.equals(expectedDiscTitle));
+      
+      String actualReleaseDate = "";
+      if (browser.isElementPresent(MessageFormat.format(ARTIST_NTH_DISC_YEAR, tableRow) + "/attribute::value")) {
+         actualReleaseDate = browser.getAttribute(MessageFormat.format(ARTIST_NTH_DISC_YEAR, tableRow) + "@value");
+         assertTrue("This is not expected (" + expectedReleaseDate + ") release date (" + actualReleaseDate + ")!", actualReleaseDate.equals(expectedReleaseDate));
+      }
+
+      browser.clickAndWait(MessageFormat.format(ARTIST_NTH_DISC_SHOW_DETAILS, tableRow));
+      String actualDescription = browser.getText(MessageFormat.format(ARTIST_NTH_DISC_DETAIL, tableRow + 1));
+      assertTrue("This is not expected (" + expectedDescription + ") description (" + actualDescription + ")!", actualDescription.equals(expectedDescription));
+      browser.clickAndWait(MessageFormat.format(ARTIST_NTH_DISC_SHOW_DETAILS, tableRow));
+   }
+
+   /**
+    * Checks whether specified disc contains expected data.
+    */
+   protected void checkDiscDetail(String expectedDiscTitle, String expectedReleaseDate, String expectedDescription, String expectedArtist) {
+      String actualDiscTitle = browser.getAttribute(DISC_DETAIL_TITLE + "@value");
+      assertTrue("This is not expected (" + expectedDiscTitle + ") album: (" + actualDiscTitle + ")!", actualDiscTitle.equals(expectedDiscTitle));
+      
+      String actualReleaseDate = "";
+      if (browser.isElementPresent(DISC_DETAIL_RELEASE_DATE + "/attribute::value")) {
+         actualReleaseDate = browser.getAttribute(DISC_DETAIL_RELEASE_DATE + "@value");
+         assertTrue("This is not expected (" + expectedReleaseDate + ") release date: (" + actualReleaseDate + ")!", actualReleaseDate.equals(expectedReleaseDate));
+      }
+
+      String actualDescription = browser.getText(DISC_DETAIL_DESCRIPTION);
+      assertTrue("This is not expected (" + expectedDescription + ") description: (" + actualDescription + ")!", actualDescription.equals(expectedDescription));
+      
+      String actualArtist = browser.getSelectedLabel(DISC_DETAIL_ARTIST);
+      assertTrue("This is not expected (" + expectedArtist + ") artist: (" + actualArtist + ")!", actualArtist.equals(expectedArtist));
+   }
+
+   /**
+    * Creates new disc.
+    * Expected to be on artist's edit page.
+    * 
+    */
+   protected void createDisc(String title, String year) {
+      browser.clickAndWait(ARTIST_CREATE_DISC_BUTTON);
+      browser.type(MessageFormat.format(ARTIST_NTH_DISC_NAME, "last()"), title);
+      browser.type(MessageFormat.format(ARTIST_NTH_DISC_YEAR, "last()"), year);
+   }
+
+   /**
+    * Finds the specified artist in paginated artists page and clicks it.
+    * Expected to be on artists page.
+    * 
+    */
+   protected void findAndClickArtist(String artistName) {
+      // find the artist's page (it's paginated) and click it
+      String expectedArtist = MessageFormat.format(ARTIST_TABLE_ROW_BY_NAME, artistName);
+      while (!browser.isElementPresent(expectedArtist)) { // click through pages
+         assertTrue("Artist " + artistName + " not found.", browser.isElementPresent(ARTISTS_NEXT_PAGE_LINK));
+         browser.click(ARTISTS_NEXT_PAGE_LINK); // ajax
+         sleep(3000);
+      }
+      
+      browser.clickAndWait(MessageFormat.format(ARTIST_TABLE_ROW_LINK, artistName)); // click artist link
+   }
+
+   /**
+    * Finds the specified disc in paginated discs page and clicks it.
+    * Expected to be on discs page.
+    * 
+    */
+   protected void findAndClickDisc(String discName) {
+      // find the disc page (it's paginated) and click it
+      String expectedDisc = MessageFormat.format(DISC_TABLE_ROW_BY_NAME, discName);
+      while (!browser.isElementPresent(expectedDisc)) { // click through pages
+         assertTrue("Disc " + discName + " not found.", browser.isElementPresent(DISCS_NEXT_PAGE_LINK));
+         browser.click(DISCS_NEXT_PAGE_LINK); // ajax
+         sleep(3000);
+      }
+      
+      browser.clickAndWait(MessageFormat.format(DISC_TABLE_ROW_LINK, discName)); // click disc link
+   }
+
+   /**
+    * @param in milliseconds
+    * 
+    */
+   protected void sleep(int milliseconds) {
+      try {
+         Thread.sleep(milliseconds); // TODO how to do this properly?
+      } catch (InterruptedException e) {
+         throw new RuntimeException(e);
+      }
+
+   }
+   
+   protected void addBandMember(String artistName) {
+       browser.clickAndWait(ARTIST_ADD_BAND_MEMBER);
+       browser.type(ARTIST_LAST_BAND_MEMBER, artistName);
+   }
+   
+   /**
+    * Checks whether specified disc contains expected data.
+    */
+   protected void checkBandMember(int tableRow, String expectedBandMember) {
+      String actualMemberName = browser.getAttribute(MessageFormat.format(ARTIST_NTH_BAND_MEMBER, tableRow) + "@value");
+      assertTrue("This is not expected (" + expectedBandMember + ") album (" + actualMemberName + ")!", actualMemberName.equals(expectedBandMember));
+   }
+}




More information about the seam-commits mailing list