Commits

Vineet Reynolds committed 99a042e

Added Selenium tests for editing and deletion of albums. Modified the facelet tags responsible for display of info/error messages as these were incorrect. Also modified the annotation in the EditAlbumRequest class as these were incorrect.

Moved the Page classes to appropriate packages, and the IntegrationTest class and utility classes to the info.galleria.view package.

Comments (0)

Files changed (16)

galleria-jsf/src/main/java/info/galleria/view/album/EditAlbumRequest.java

 	@Size(min = 1, max = 50, message = "{Album.name.size}")
 	private String name;
 
+	@Size(min = 0, max = 255, message = "{Album.description.size}")
 	private String description;
 
 	public String getName()

galleria-jsf/src/main/webapp/private/album/EditAlbum.xhtml

 			    	</li>
 		    	</ul>
 		    </h:form>
-		    <h:messages id="messages" globalOnly="true" infoClass="infoStyle"
+		    <h:messages id="messages" showSummary="true" showDetail="false" infoClass="infoStyle"
 				warnClass="warnStyle" errorClass="errorStyle" />
 		</div>
 	</ui:define>

galleria-jsf/src/main/webapp/private/album/ViewAlbum.xhtml

 		</div>
 		<div class="actionpane">
 			<p>
-				<h:outputLink id="viewALbums" value="#{request.contextPath}/private/HomePage.xhtml">
+				<h:outputLink id="viewAlbums" value="#{request.contextPath}/private/HomePage.xhtml">
 					<h:outputText value="#{msg['ViewAlbum.viewAlbums.label']}" />
 				</h:outputLink>
 			</p>

galleria-jsf/src/test/java/info/galleria/view/AllPagesIntegrationTest.java

+package info.galleria.view;
+
+import static org.junit.Assert.*;
+
+import info.galleria.view.album.*;
+import info.galleria.view.user.*;
+
+import java.io.File;
+import java.net.URI;
+import java.sql.*;
+
+import org.dbunit.DatabaseUnitException;
+import org.dbunit.database.*;
+import org.dbunit.dataset.*;
+import org.dbunit.dataset.filter.SequenceTableFilter;
+import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
+import org.dbunit.operation.DatabaseOperation;
+import org.jboss.arquillian.container.test.api.*;
+import org.jboss.arquillian.core.api.annotation.Observes;
+import org.jboss.arquillian.drone.api.annotation.Drone;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.arquillian.test.spi.event.suite.*;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
+import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;
+import org.junit.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.*;
+import org.openqa.selenium.support.ui.*;
+import org.slf4j.*;
+
+@RunWith(Arquillian.class)
+@RunAsClient
+public class AllPagesIntegrationTest
+{
+
+	private static final Logger logger = LoggerFactory.getLogger(AllPagesIntegrationTest.class);
+
+	@Rule
+	public TestName testMethod = new TestName();
+	
+	@Drone
+	protected WebDriver driver;
+	
+	@ArquillianResource
+	protected URI contextPath;
+
+	@Deployment
+	public static WebArchive createDeployment()
+	{
+		logger.info("Preparing deployment.");
+		// A separate EJB archive is not being created unless Arquillian can
+		// create EnterpriseArchives that can be deployed on Glassfish.
+		// Also, when this EJB archive is added to the WebArchive, the EJB
+		// classloader will fail to load classes required, but located in
+		// WEB-INF/lib, like the Commons-Codec class.
+		//
+		// JavaArchive ejbArchive = ShrinkWrap.create(JavaArchive.class,
+		// "galleria-ejb.jar")
+		// .addPackage("info.galleria.domain")
+		// .addPackages(true, "info.galleria.service")
+		// .addPackage("info.galleria.utilities")
+		// .addAsManifestResource("ValidationMessages.properties")
+		// .addAsManifestResource("ValidationMessages_de.properties")
+		// .addAsManifestResource("META-INF/ejb-jar.xml","ejb-jar.xml")
+		// .addAsManifestResource("META-INF/glassfish-ejb-jar.xml","glassfish-ejb-jar.xml")
+		// .addAsManifestResource("META-INF/persistence.xml","persistence.xml");
+		// System.out.println("******Contents of EJB Archive******");
+		// System.out.println(ejbArchive.toString(true));
+	
+		WebArchive webArchive = ShrinkWrap
+				.create(WebArchive.class, "galleria-jsf.war")
+				.setWebXML(new File("src/main/webapp/WEB-INF/web.xml"))
+				.addPackage("info.galleria.converters")
+				.addPackage("info.galleria.filters")
+				.addPackage("info.galleria.i18n")
+				.addPackage("info.galleria.listeners")
+				.addPackages(true, "info.galleria.view")
+				.addAsResource("resources/messages_en.properties", "resources/messages_en.properties")
+				.addAsResource("resources/messages_de.properties", "resources/messages_de.properties")
+				.addAsResource("resources/StandardIcon.png", "resources/StandardIcon.png")
+				.addAsWebResource(new File("src/main/webapp/templates", "content.xhtml"), "templates/content.xhtml")
+				.addAsWebResource(new File("src/main/webapp/templates", "defaultLayout.xhtml"), "templates/defaultLayout.xhtml")
+				.addAsWebResource(new File("src/main/webapp/templates", "footer.xhtml"), "templates/footer.xhtml")
+				.addAsWebResource(new File("src/main/webapp/templates", "header.xhtml"), "templates/header.xhtml")
+				.addAsWebResource(new File("src/main/webapp/templates", "privateLayout.xhtml"), "templates/privateLayout.xhtml")
+				.addAsWebResource(new File("src/main/webapp/resources/styles", "all.css"), "resources/styles/all.css")
+				.addAsWebResource(new File("src/main/webapp", "Index.xhtml"))
+				.addAsWebResource(new File("src/main/webapp", "Signup.xhtml"))
+				.addAsWebResource(new File("src/main/webapp", "Login.xhtml"))
+				.addAsWebResource(new File("src/main/webapp/private", "HomePage.xhtml"), "private/HomePage.xhtml")
+				.addAsWebResource(new File("src/main/webapp/private/user", "AccountPreferences.xhtml"),	"private/user/AccountPreferences.xhtml")
+				.addAsWebResource(new File("src/main/webapp/private/album", "CreateAlbum.xhtml"), "private/album/CreateAlbum.xhtml")
+				.addAsWebResource(new File("src/main/webapp/private/album", "EditAlbum.xhtml"),	"private/album/EditAlbum.xhtml")
+				.addAsWebResource(new File("src/main/webapp/private/album", "ViewAlbum.xhtml"), "private/album/ViewAlbum.xhtml")
+				.addAsWebResource(new File("src/main/webapp/private/photo", "UploadPhoto.xhtml"), "private/photo/UploadPhoto.xhtml")
+				.addAsWebResource(new File("src/main/webapp/private/photo", "EditPhoto.xhtml"),	"private/photo/EditPhoto.xhtml")
+				.addAsWebResource(new File("src/main/webapp/private/photo", "ViewPhoto.xhtml"),	"private/photo/ViewPhoto.xhtml")
+				.addAsWebInfResource(new File("src/main/webapp/WEB-INF/faces-config.xml"), "faces-config.xml")
+				/* Add glassfish-web.xml as glassfish-ejb-jar.xml will be ignored in the Web archive deployment */
+				.addAsWebInfResource(new File("src/test/resources/glassfish-web.xml"), "glassfish-web.xml")
+				/* .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") */
+				.addAsLibraries(
+						DependencyResolvers.use(MavenDependencyResolver.class)
+								.loadMetadataFromPom("pom.xml")
+								.artifacts("org.primefaces:primefaces:3.0.M2",
+										"commons-io:commons-io:1.4",
+										"commons-fileupload:commons-fileupload:1.2.1",
+										"commons-codec:commons-codec:1.5").resolveAsFiles())
+				.addPackage("info.galleria.domain")
+				.addPackages(true, "info.galleria.service")
+				.addPackage("info.galleria.utilities")
+				.addAsResource("ValidationMessages.properties", "ValidationMessages.properties")
+				.addAsResource("ValidationMessages_de.properties", "ValidationMessages_de.properties")
+				.addAsResource("META-INF/ejb-jar.xml", "ejb-jar.xml")
+				.addAsResource("META-INF/glassfish-ejb-jar.xml", "glassfish-ejb-jar.xml")
+				.addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml");
+		System.out.println("******Contents of WAR Archive******");
+		System.out.println(webArchive.toString(true));
+	
+		//
+		// Don't use Enterprise archives yet, as bug ARQ-527 is not yet resolved
+		// at the time of writing this test.
+		//
+		// EnterpriseArchive enterpriseArchive =
+		// ShrinkWrap.create(EnterpriseArchive.class,"galleria.ear")
+		// .addAsModule(webArchive)
+		// .addAsModule(ejbArchive)
+		// .addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class).artifact("org.hibernate:hibernate-entitymanager:3.6.5.Final").exclusions("org.hibernate:hibernate-validator","org.hibernate:hibernate-validator","org.hibernate.javax.persistence:hibernate-jpa-2.0-api","javax.transaction:jta","org.slf4j:slf4j-api:1.6.1").resolveAsFiles());
+		// System.out.println("******Contents of EAR Archive******");
+		// System.out.println(enterpriseArchive.toString(true));
+	
+		return webArchive;
+	}
+
+	public void startCoverage(@Observes BeforeSuite event)
+	{
+		logger.info("Before Suite");
+	}
+
+	public void stopCoverage(@Observes AfterSuite event)
+	{
+		logger.info("After Suite");
+	}
+
+	@BeforeClass
+	public static void beforeClass()
+	{
+		logger.info("Before Class");
+	}
+
+	@AfterClass
+	public static void afterClass()
+	{
+		logger.info("After Class");
+	}
+
+	/**
+	 * Resets the contents of the database tables before every test using
+	 * DbUnit.
+	 * 
+	 * @throws Exception
+	 */
+	@Before
+	public void setUp()
+	{
+		logger.info("Performing setup before Test {}", testMethod.getMethodName());
+		IDatabaseConnection connection = null;
+		try
+		{
+			connection = getConnection();
+			IDataSet dataSet = getDataSet();
+			// The FilteredDataSet and the SequenceTableFilter is used to
+			// reorder the DELETE operations to prevent failures due to circular
+			// dependencies
+			// between the ALBUMS and PHOTOS tables. The plain XML file does not
+			// contain this information. The DatabaseSequenceFilter class is
+			// avoided as it cannot handle circular dependencies.
+			String[] orderedTableNames = new String[] { "SEQUENCE", "USERS_GROUPS", "USERS", "GROUPS", "ALBUMS", "PHOTOS" };
+			IDataSet filteredDataSet = new FilteredDataSet(new SequenceTableFilter(orderedTableNames), dataSet);
+			DatabaseOperation.CLEAN_INSERT.execute(connection, filteredDataSet);
+		}
+		catch(Exception ex)
+		{
+			ex.printStackTrace();
+		}
+		finally
+		{
+			try
+			{
+				connection.close();
+			}
+			catch (SQLException sqlEx)
+			{
+				logger.warn(sqlEx.getMessage(), sqlEx);
+			}
+		}
+	}
+
+	/**
+	 * Logout the user after every test. This will prevent subsequent tests from
+	 * failing, as the UserRedirectFilter will redirect the Firefox driver to
+	 * the home page instead of the index, login or signup pages.
+	 */
+	@After
+	public void tearDown()
+	{
+		WebElement logoutLink = null;
+		try
+		{
+			logoutLink = driver.findElement(By.id("commonActions:logout"));
+		}
+		catch (NoSuchElementException noElemEx)
+		{
+			// do nothing if the logout link is not present.
+		}
+		if (logoutLink != null)
+		{
+			logoutLink.click();
+			Wait<WebDriver> wait = new WebDriverWait(driver, 15);
+			wait.until(PageUtilities.visibilityOfElementLocated(By.id("publicWrapper")));
+		}
+	}
+
+	private IDatabaseConnection getConnection() throws ClassNotFoundException, SQLException, DatabaseUnitException
+	{
+		Class.forName("org.apache.derby.jdbc.ClientDriver");
+		Connection jdbcConnection = DriverManager.getConnection("jdbc:derby://localhost:1527/GALLERIATEST", "APP", "GALLERIA");
+		IDatabaseConnection databaseConnection = new DatabaseConnection(jdbcConnection);
+		return databaseConnection;
+	}
+
+	/**
+	 * Returns a dataset containing blanked out tables and table-based sequences
+	 * set to 0.
+	 * 
+	 * @return
+	 * @throws Exception
+	 */
+	private IDataSet getDataSet() throws Exception
+	{
+		ClassLoader classLoader = this.getClass().getClassLoader();
+		return new FlatXmlDataSetBuilder().build(classLoader.getResourceAsStream("database-test-setup.xml"));
+	}
+
+	@Test
+	public void testSignupUser() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = {"The new user account has been created. You may now login."};
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+	}
+
+	@Test
+	public void testSignupUserWithNoValues() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		signupPage = signupPage.signupAsExpectingError("", "", "");
+		String[] errorMessages = { "The user Id should be between 1 and 50 characters in length.",
+				"The password should be between 1 and 500 characters in length.",
+				"The confirmed password should be between 1 and 500 characters in length." };
+		assertArrayEquals(errorMessages, signupPage.fetchSignupErrorMessages());
+	}
+
+	@Test
+	public void testSignupUserWithExcessiveValues() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		signupPage = signupPage
+				.signupAsExpectingError(
+						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+		String[] errorMessages = { "The user Id should be between 1 and 50 characters in length.",
+				"The password should be between 1 and 500 characters in length.",
+				"The confirmed password should be between 1 and 500 characters in length." };
+		assertArrayEquals(errorMessages, signupPage.fetchSignupErrorMessages());
+	}
+
+	@Test
+	public void testSignupUserWithMismatchedPasswords() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		signupPage = signupPage.signupAsExpectingError("User#1", "password", "mismatchpassword");
+		String[] errorMessages = { "The entered passwords do not match. Please correct the passwords before retrying." };
+		assertArrayEquals(errorMessages, signupPage.fetchSignupErrorMessages());
+	}
+
+	@Test
+	public void testSignupDuplicateUsers() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		signupPage = indexPage.chooseToSignup();
+		signupPage = signupPage.signupAsExpectingError("User#1", "password", "password");
+		String[] errorMessages = { "The user account Id is already taken. Please choose another." };
+		assertArrayEquals(errorMessages, signupPage.fetchSignupErrorMessages());
+	}
+
+	@Test
+	public void testLoginUserInvalidCredentials() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		loginPage.loginAsExpectingError("User#2", "password");
+		String[] errorMessages = { "The user name or password is incorrect." };
+		assertArrayEquals(errorMessages, loginPage.getLoginErrorMessagesDisplayed());
+	}
+
+	@Test
+	public void testLoginUser() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		loginPage.loginAs("User#1", "password");
+		assertTrue(driver.findElement(By.id("commonActions:AccountPreferences")) != null);
+		assertTrue(driver.findElement(By.id("commonActions:logout")) != null);
+	}
+
+	@Test
+	public void testLogoutUser() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		homePage.logout();
+	}
+
+	@Test
+	public void testModifyPassword() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
+		homePage = accountPreferencesPage.modifyPasswordAs("password", "password1", "password1");
+		String[] successMessage = { "The password has been modified." };
+		assertArrayEquals(successMessage, homePage.fetchSuccessMessages());
+	}
+
+	@Test
+	public void testModifyPasswordWithIncorrectOld() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
+		accountPreferencesPage.modifyPasswordAsExpectingError("password1", "password2", "password2");
+		String[] errorMessages = { "The old password entered does not match your current password." };
+		assertArrayEquals(errorMessages, accountPreferencesPage.fetchErrorMessages());
+	}
+
+	@Test
+	public void testModifyPasswordWithMismatchingNew() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
+		accountPreferencesPage.modifyPasswordAsExpectingError("password", "password1", "password2");
+		String[] errorMessages = { "The new password and the confirm password values do not match." };
+		assertArrayEquals(errorMessages, accountPreferencesPage.fetchErrorMessages());
+	}
+
+	@Test
+	public void testModifyPasswordWithSameOldAndNew() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
+		accountPreferencesPage.modifyPasswordAsExpectingError("password", "password", "password");
+		String[] errorMessages = { "Your new password cannot be the same as the old password." };
+		assertArrayEquals(errorMessages, accountPreferencesPage.fetchErrorMessages());
+	}
+
+	@Test
+	public void testDeleteAccount() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
+		indexPage = accountPreferencesPage.deleteAcccount();
+		String[] messages = { "The account was deleted successfully." };
+		assertArrayEquals(messages, indexPage.fetchSuccessMessages());
+	}
+	
+	@Test
+	public void testCreateAlbum() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
+		homePage = createAlbumPage.createAlbumAs("Album#1", "My first album");
+		String[] messages = { "The album was created successfully." };
+		assertArrayEquals(messages, homePage.fetchSuccessMessages());
+	}
+
+	@Test
+	public void testCreateAlbumWithNoValues() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
+		createAlbumPage = createAlbumPage.createAlbumAsExpectingError("", "");
+		String[] errorMessages = { "The name of the album should be between 1 and 50 characters in length." };
+		assertArrayEquals(errorMessages, createAlbumPage.fetchErrorMessages());
+	}
+
+	@Test
+	public void testCreateAlbumWithExcessiveValues() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
+		createAlbumPage = createAlbumPage
+				.createAlbumAsExpectingError(
+						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+		String[] errorMessages = { "The name of the album should be between 1 and 50 characters in length.",
+				"The description of the album should be between 0 and 255 characters in length." };
+		assertArrayEquals(errorMessages, createAlbumPage.fetchErrorMessages());
+	}
+
+	@Test
+	public void testCreateDuplicateAlbum() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
+		homePage = createAlbumPage.createAlbumAs("Album#1", "My first album");
+		String[] messages = { "The album was created successfully." };
+		assertArrayEquals(messages, homePage.fetchSuccessMessages());
+
+		createAlbumPage = homePage.goToCreateAlbum();
+		createAlbumPage = createAlbumPage.createAlbumAsExpectingError("Album#1", "My first album");
+		String[] errorMessages = { "An existing album with the same name and description was found." };
+		assertArrayEquals(errorMessages, createAlbumPage.fetchErrorMessages());
+	}
+	
+	@Test
+	public void testEditAlbum() throws Exception
+	{
+		String albumName = "Album#1";
+		String albumDescription = "My first album";
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
+		homePage = createAlbumPage.createAlbumAs(albumName, albumDescription);
+		String[] messages = { "The album was created successfully." };
+		assertArrayEquals(messages, homePage.fetchSuccessMessages());
+
+		ViewAlbumPage viewAlbumPage = homePage.viewAlbumWith(albumName, albumDescription);
+		EditAlbumPage editAlbumPage = viewAlbumPage.goToEditAlbumPage();
+		viewAlbumPage = editAlbumPage.editAlbumAs("Album No.1", "My very first album");
+		String[] editMessages = { "The album was edited successfully." };
+		assertArrayEquals(editMessages, viewAlbumPage.fetchSuccessMessages());
+	}
+
+	@Test
+	public void testEditAlbumWithNoValues() throws Exception
+	{
+		String albumName = "Album#1";
+		String albumDescription = "My first album";
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
+		homePage = createAlbumPage.createAlbumAs(albumName, albumDescription);
+		String[] messages = { "The album was created successfully." };
+		assertArrayEquals(messages, homePage.fetchSuccessMessages());
+
+		ViewAlbumPage viewAlbumPage = homePage.viewAlbumWith(albumName, albumDescription);
+		EditAlbumPage editAlbumPage = viewAlbumPage.goToEditAlbumPage();
+		editAlbumPage = editAlbumPage.editAlbumAsExpectingError("", "");
+		String[] editMessages = { "The name of the album should be between 1 and 50 characters in length." };
+		assertArrayEquals(editMessages, editAlbumPage.fetchErrorMessages());
+	}
+
+	@Test
+	public void testEditAlbumWithExcessiveValues() throws Exception
+	{
+		String albumName = "Album#1";
+		String albumDescription = "My first album";
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
+		homePage = createAlbumPage.createAlbumAs(albumName, albumDescription);
+		String[] messages = { "The album was created successfully." };
+		assertArrayEquals(messages, homePage.fetchSuccessMessages());
+
+		ViewAlbumPage viewAlbumPage = homePage.viewAlbumWith(albumName, albumDescription);
+		EditAlbumPage editAlbumPage = viewAlbumPage.goToEditAlbumPage();
+		editAlbumPage = editAlbumPage
+				.editAlbumAsExpectingError(
+						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+		String[] editMessages = { "The name of the album should be between 1 and 50 characters in length.",
+				"The description of the album should be between 0 and 255 characters in length." };
+		assertArrayEquals(editMessages, editAlbumPage.fetchErrorMessages());
+	}
+
+	@Test
+	public void testEditAlbumAsDuplicate() throws Exception
+	{
+		String albumName = "Album#1";
+		String albumDescription = "My first album";
+		String secondAlbumName = "Album#2";
+		String secondAlbumDescription = "My second album";
+
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
+		homePage = createAlbumPage.createAlbumAs(albumName, albumDescription);
+		String[] messages = { "The album was created successfully." };
+		assertArrayEquals(messages, homePage.fetchSuccessMessages());
+
+		createAlbumPage = homePage.goToCreateAlbum();
+		homePage = createAlbumPage.createAlbumAs(secondAlbumName, secondAlbumDescription);
+		assertArrayEquals(messages, homePage.fetchSuccessMessages());
+
+		ViewAlbumPage viewAlbumPage = homePage.viewAlbumWith(secondAlbumName, secondAlbumDescription);
+		EditAlbumPage editAlbumPage = viewAlbumPage.goToEditAlbumPage();
+		editAlbumPage = editAlbumPage.editAlbumAsExpectingError(albumName, albumDescription);
+		String[] editMessages = { "An existing album with the same name and description was found." };
+		assertArrayEquals(editMessages, editAlbumPage.fetchErrorMessages());
+	}
+
+	@Test
+	public void testDeleteAlbum() throws Exception
+	{
+		String albumName = "Album#1";
+		String albumDescription = "My first album";
+
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
+		homePage = createAlbumPage.createAlbumAs(albumName, albumDescription);
+		String[] messages = { "The album was created successfully." };
+		assertArrayEquals(messages, homePage.fetchSuccessMessages());
+
+		ViewAlbumPage viewAlbumPage = homePage.viewAlbumWith(albumName, albumDescription);
+		homePage = viewAlbumPage.deleteAlbum();
+		String[] deletionMessages = { "The album was deleted successfully." };
+		assertArrayEquals(deletionMessages, homePage.fetchSuccessMessages());
+	}
+
+}

galleria-jsf/src/test/java/info/galleria/view/PageUtilities.java

+package info.galleria.view;
+
+import org.openqa.selenium.*;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+public class PageUtilities
+{
+	public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By locator)
+	{
+		return new ExpectedCondition<WebElement>()
+			{
+				public WebElement apply(WebDriver driver)
+				{
+					WebElement toReturn = driver.findElement(locator);
+					if (toReturn.isDisplayed())
+					{
+						return toReturn;
+					}
+					return null;
+				}
+			};
+	}
+}

galleria-jsf/src/test/java/info/galleria/view/album/CreateAlbumPage.java

+package info.galleria.view.album;
+
+import info.galleria.view.PageUtilities;
+import info.galleria.view.user.*;
+
+import java.net.URI;
+import java.util.*;
+
+import org.openqa.selenium.*;
+import org.openqa.selenium.support.ui.*;
+
+public class CreateAlbumPage
+{
+
+	private WebDriver driver;
+	private URI contextPath;
+
+	public CreateAlbumPage(WebDriver driver, URI contextPath)
+	{
+		this.driver = driver;
+		this.contextPath = contextPath;
+		Wait<WebDriver> wait = new WebDriverWait(driver, 15);
+		wait.until(PageUtilities.visibilityOfElementLocated(By.id("wrapper")));
+		if (!driver.getTitle().equals("Create an album"))
+		{
+			throw new IllegalStateException("This is not the Create Album page.");
+		}
+	}
+
+	public HomePage createAlbumAs(String albumName, String albumDescription)
+	{
+		driver.findElement(By.id("CreateAlbum:albumName")).clear();
+		driver.findElement(By.id("CreateAlbum:albumName")).sendKeys(albumName);
+		driver.findElement(By.id("CreateAlbum:albumDescription")).clear();
+		driver.findElement(By.id("CreateAlbum:albumDescription")).sendKeys(albumDescription);
+		driver.findElement(By.id("CreateAlbum:createAlbumButton")).click();
+		return new HomePage(driver, contextPath);
+	}
+
+	public CreateAlbumPage createAlbumAsExpectingError(String albumName, String albumDescription)
+	{
+		driver.findElement(By.id("CreateAlbum:albumName")).clear();
+		driver.findElement(By.id("CreateAlbum:albumName")).sendKeys(albumName);
+		driver.findElement(By.id("CreateAlbum:albumDescription")).clear();
+		driver.findElement(By.id("CreateAlbum:albumDescription")).sendKeys(albumDescription);
+		driver.findElement(By.id("CreateAlbum:createAlbumButton")).click();
+		return new CreateAlbumPage(driver, contextPath);
+	}
+
+	public String[] fetchErrorMessages()
+	{
+		List<String> errorMessages = new ArrayList<String>();
+		for (WebElement element : driver.findElements(By.xpath("//ul[@id='messages']/li[@class='errorStyle']")))
+		{
+			errorMessages.add(element.getText());
+		}
+		return errorMessages.toArray(new String[0]);
+	}
+}

galleria-jsf/src/test/java/info/galleria/view/album/EditAlbumPage.java

+package info.galleria.view.album;
+
+import info.galleria.view.PageUtilities;
+
+import java.net.URI;
+import java.util.*;
+
+import org.openqa.selenium.*;
+import org.openqa.selenium.support.ui.*;
+
+public class EditAlbumPage
+{
+
+	private WebDriver driver;
+	private URI contextPath;
+
+	public EditAlbumPage(WebDriver driver, URI contextPath)
+	{
+		this.driver = driver;
+		this.contextPath = contextPath;
+		Wait<WebDriver> wait = new WebDriverWait(driver, 15);
+		wait.until(PageUtilities.visibilityOfElementLocated(By.id("wrapper")));
+		if (!driver.getTitle().equals("Edit an album"))
+		{
+			throw new IllegalStateException("This is not the Edit Album page.");
+		}
+	}
+
+	public ViewAlbumPage editAlbumAs(String albumName, String albumDescription)
+	{
+		driver.findElement(By.id("editAlbumForm:albumName")).clear();
+		driver.findElement(By.id("editAlbumForm:albumName")).sendKeys(albumName);
+		driver.findElement(By.id("editAlbumForm:albumDescription")).clear();
+		driver.findElement(By.id("editAlbumForm:albumDescription")).sendKeys(albumDescription);
+		driver.findElement(By.id("editAlbumForm:editAlbumButton")).click();
+		return new ViewAlbumPage(driver, contextPath);
+	}
+
+	public EditAlbumPage editAlbumAsExpectingError(String albumName, String albumDescription)
+	{
+		driver.findElement(By.id("editAlbumForm:albumName")).clear();
+		driver.findElement(By.id("editAlbumForm:albumName")).sendKeys(albumName);
+		driver.findElement(By.id("editAlbumForm:albumDescription")).clear();
+		driver.findElement(By.id("editAlbumForm:albumDescription")).sendKeys(albumDescription);
+		driver.findElement(By.id("editAlbumForm:editAlbumButton")).click();
+		return new EditAlbumPage(driver, contextPath);
+	}
+
+	public String[] fetchErrorMessages()
+	{
+		List<String> messages = new ArrayList<String>();
+		for (WebElement element : driver.findElements(By.xpath("//ul[@id='messages']/li[@class='errorStyle']")))
+		{
+			messages.add(element.getText());
+		}
+		return messages.toArray(new String[0]);
+	}
+
+}

galleria-jsf/src/test/java/info/galleria/view/album/ViewAlbumPage.java

+package info.galleria.view.album;
+
+import info.galleria.view.PageUtilities;
+import info.galleria.view.user.HomePage;
+
+import java.net.URI;
+import java.util.*;
+
+import org.openqa.selenium.*;
+import org.openqa.selenium.support.ui.*;
+
+public class ViewAlbumPage
+{
+
+	private WebDriver driver;
+	private URI contextPath;
+
+	public ViewAlbumPage(WebDriver driver, URI contextPath)
+	{
+		this.driver = driver;
+		this.contextPath = contextPath;
+		Wait<WebDriver> wait = new WebDriverWait(driver, 15);
+		wait.until(PageUtilities.visibilityOfElementLocated(By.id("wrapper")));
+		if (!driver.getTitle().equals("View an album"))
+		{
+			throw new IllegalStateException("This is not the View Album page.");
+		}
+	}
+
+	public HomePage goToHomePage()
+	{
+		driver.findElement(By.id("viewAlbums")).click();
+		return new HomePage(driver, contextPath);
+	}
+
+	public EditAlbumPage goToEditAlbumPage()
+	{
+		driver.findElement(By.id("editAlbumLink")).click();
+		return new EditAlbumPage(driver, contextPath);
+	}
+
+	public HomePage deleteAlbum()
+	{
+		driver.findElement(By.id("deleteAlbumForm:deleteAlbumButton")).click();
+		return new HomePage(driver, contextPath);
+	}
+
+	public String[] fetchSuccessMessages()
+	{
+		List<String> messages = new ArrayList<String>();
+		for (WebElement element : driver.findElements(By.xpath("//ul[@id='messages']/li[@class='infoStyle']")))
+		{
+			messages.add(element.getText());
+		}
+		return messages.toArray(new String[0]);
+	}
+}

galleria-jsf/src/test/java/info/galleria/view/user/AccountPreferencesPage.java

 package info.galleria.view.user;
 
+import info.galleria.view.PageUtilities;
+
 import java.net.URI;
 import java.util.*;
 

galleria-jsf/src/test/java/info/galleria/view/user/AllPagesIntegrationTest.java

-package info.galleria.view.user;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.net.URI;
-import java.sql.*;
-
-import org.dbunit.DatabaseUnitException;
-import org.dbunit.database.*;
-import org.dbunit.dataset.*;
-import org.dbunit.dataset.filter.SequenceTableFilter;
-import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
-import org.dbunit.operation.DatabaseOperation;
-import org.jboss.arquillian.container.test.api.*;
-import org.jboss.arquillian.core.api.annotation.Observes;
-import org.jboss.arquillian.drone.api.annotation.Drone;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.arquillian.test.spi.event.suite.*;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
-import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;
-import org.junit.*;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.rules.TestName;
-import org.junit.runner.RunWith;
-import org.openqa.selenium.*;
-import org.openqa.selenium.support.ui.*;
-import org.slf4j.*;
-
-@RunWith(Arquillian.class)
-@RunAsClient
-public class AllPagesIntegrationTest
-{
-
-	private static final Logger logger = LoggerFactory.getLogger(AllPagesIntegrationTest.class);
-
-	@Rule
-	public TestName testMethod = new TestName();
-	
-	@Drone
-	protected WebDriver driver;
-	
-	@ArquillianResource
-	protected URI contextPath;
-
-	@Deployment
-	public static WebArchive createDeployment()
-	{
-		logger.info("Preparing deployment.");
-		// A separate EJB archive is not being created unless Arquillian can
-		// create EnterpriseArchives that can be deployed on Glassfish.
-		// Also, when this EJB archive is added to the WebArchive, the EJB
-		// classloader will fail to load classes required, but located in
-		// WEB-INF/lib, like the Commons-Codec class.
-		//
-		// JavaArchive ejbArchive = ShrinkWrap.create(JavaArchive.class,
-		// "galleria-ejb.jar")
-		// .addPackage("info.galleria.domain")
-		// .addPackages(true, "info.galleria.service")
-		// .addPackage("info.galleria.utilities")
-		// .addAsManifestResource("ValidationMessages.properties")
-		// .addAsManifestResource("ValidationMessages_de.properties")
-		// .addAsManifestResource("META-INF/ejb-jar.xml","ejb-jar.xml")
-		// .addAsManifestResource("META-INF/glassfish-ejb-jar.xml","glassfish-ejb-jar.xml")
-		// .addAsManifestResource("META-INF/persistence.xml","persistence.xml");
-		// System.out.println("******Contents of EJB Archive******");
-		// System.out.println(ejbArchive.toString(true));
-	
-		WebArchive webArchive = ShrinkWrap
-				.create(WebArchive.class, "galleria-jsf.war")
-				.setWebXML(new File("src/main/webapp/WEB-INF/web.xml"))
-				.addPackage("info.galleria.converters")
-				.addPackage("info.galleria.filters")
-				.addPackage("info.galleria.i18n")
-				.addPackage("info.galleria.listeners")
-				.addPackages(true, "info.galleria.view")
-				.addAsResource("resources/messages_en.properties", "resources/messages_en.properties")
-				.addAsResource("resources/messages_de.properties", "resources/messages_de.properties")
-				.addAsResource("resources/StandardIcon.png", "resources/StandardIcon.png")
-				.addAsWebResource(new File("src/main/webapp/templates", "content.xhtml"), "templates/content.xhtml")
-				.addAsWebResource(new File("src/main/webapp/templates", "defaultLayout.xhtml"), "templates/defaultLayout.xhtml")
-				.addAsWebResource(new File("src/main/webapp/templates", "footer.xhtml"), "templates/footer.xhtml")
-				.addAsWebResource(new File("src/main/webapp/templates", "header.xhtml"), "templates/header.xhtml")
-				.addAsWebResource(new File("src/main/webapp/templates", "privateLayout.xhtml"), "templates/privateLayout.xhtml")
-				.addAsWebResource(new File("src/main/webapp/resources/styles", "all.css"), "resources/styles/all.css")
-				.addAsWebResource(new File("src/main/webapp", "Index.xhtml"))
-				.addAsWebResource(new File("src/main/webapp", "Signup.xhtml"))
-				.addAsWebResource(new File("src/main/webapp", "Login.xhtml"))
-				.addAsWebResource(new File("src/main/webapp/private", "HomePage.xhtml"), "private/HomePage.xhtml")
-				.addAsWebResource(new File("src/main/webapp/private/user", "AccountPreferences.xhtml"),	"private/user/AccountPreferences.xhtml")
-				.addAsWebResource(new File("src/main/webapp/private/album", "CreateAlbum.xhtml"), "private/album/CreateAlbum.xhtml")
-				.addAsWebResource(new File("src/main/webapp/private/album", "EditAlbum.xhtml"),	"private/album/EditAlbum.xhtml")
-				.addAsWebResource(new File("src/main/webapp/private/album", "ViewAlbum.xhtml"), "private/album/ViewAlbum.xhtml")
-				.addAsWebResource(new File("src/main/webapp/private/photo", "UploadPhoto.xhtml"), "private/photo/UploadPhoto.xhtml")
-				.addAsWebResource(new File("src/main/webapp/private/photo", "EditPhoto.xhtml"),	"private/photo/EditPhoto.xhtml")
-				.addAsWebResource(new File("src/main/webapp/private/photo", "ViewPhoto.xhtml"),	"private/photo/ViewPhoto.xhtml")
-				.addAsWebInfResource(new File("src/main/webapp/WEB-INF/faces-config.xml"), "faces-config.xml")
-				/* Add glassfish-web.xml as glassfish-ejb-jar.xml will be ignored in the Web archive deployment */
-				.addAsWebInfResource(new File("src/test/resources/glassfish-web.xml"), "glassfish-web.xml")
-				/* .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") */
-				.addAsLibraries(
-						DependencyResolvers.use(MavenDependencyResolver.class)
-								.loadMetadataFromPom("pom.xml")
-								.artifacts("org.primefaces:primefaces:3.0.M2",
-										"commons-io:commons-io:1.4",
-										"commons-fileupload:commons-fileupload:1.2.1",
-										"commons-codec:commons-codec:1.5").resolveAsFiles())
-				.addPackage("info.galleria.domain")
-				.addPackages(true, "info.galleria.service")
-				.addPackage("info.galleria.utilities")
-				.addAsResource("ValidationMessages.properties", "ValidationMessages.properties")
-				.addAsResource("ValidationMessages_de.properties", "ValidationMessages_de.properties")
-				.addAsResource("META-INF/ejb-jar.xml", "ejb-jar.xml")
-				.addAsResource("META-INF/glassfish-ejb-jar.xml", "glassfish-ejb-jar.xml")
-				.addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml");
-		System.out.println("******Contents of WAR Archive******");
-		System.out.println(webArchive.toString(true));
-	
-		//
-		// Don't use Enterprise archives yet, as bug ARQ-527 is not yet resolved
-		// at the time of writing this test.
-		//
-		// EnterpriseArchive enterpriseArchive =
-		// ShrinkWrap.create(EnterpriseArchive.class,"galleria.ear")
-		// .addAsModule(webArchive)
-		// .addAsModule(ejbArchive)
-		// .addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class).artifact("org.hibernate:hibernate-entitymanager:3.6.5.Final").exclusions("org.hibernate:hibernate-validator","org.hibernate:hibernate-validator","org.hibernate.javax.persistence:hibernate-jpa-2.0-api","javax.transaction:jta","org.slf4j:slf4j-api:1.6.1").resolveAsFiles());
-		// System.out.println("******Contents of EAR Archive******");
-		// System.out.println(enterpriseArchive.toString(true));
-	
-		return webArchive;
-	}
-
-	public void startCoverage(@Observes BeforeSuite event)
-	{
-		logger.info("Before Suite");
-	}
-
-	public void stopCoverage(@Observes AfterSuite event)
-	{
-		logger.info("After Suite");
-	}
-
-	@BeforeClass
-	public static void beforeClass()
-	{
-		logger.info("Before Class");
-	}
-
-	@AfterClass
-	public static void afterClass()
-	{
-		logger.info("After Class");
-	}
-
-	/**
-	 * Resets the contents of the database tables before every test using
-	 * DbUnit.
-	 * 
-	 * @throws Exception
-	 */
-	@Before
-	public void setUp()
-	{
-		logger.info("Performing setup before Test {}", testMethod.getMethodName());
-		IDatabaseConnection connection = null;
-		try
-		{
-			connection = getConnection();
-			IDataSet dataSet = getDataSet();
-			// The FilteredDataSet and the SequenceTableFilter is used to
-			// reorder the DELETE operations to prevent failures due to circular
-			// dependencies
-			// between the ALBUMS and PHOTOS tables. The plain XML file does not
-			// contain this information. The DatabaseSequenceFilter class is
-			// avoided as it cannot handle circular dependencies.
-			String[] orderedTableNames = new String[] { "USERS_GROUPS", "USERS", "GROUPS", "ALBUMS", "PHOTOS" };
-			IDataSet filteredDataSet = new FilteredDataSet(new SequenceTableFilter(orderedTableNames), dataSet);
-			DatabaseOperation.CLEAN_INSERT.execute(connection, filteredDataSet);
-		}
-		catch(Exception ex)
-		{
-			ex.printStackTrace();
-		}
-		finally
-		{
-			try
-			{
-				connection.close();
-			}
-			catch (SQLException sqlEx)
-			{
-				logger.warn(sqlEx.getMessage(), sqlEx);
-			}
-		}
-	}
-
-	/**
-	 * Logout the user after every test. This will prevent subsequent tests from
-	 * failing, as the UserRedirectFilter will redirect the Firefox driver to
-	 * the home page instead of the index, login or signup pages.
-	 */
-	@After
-	public void tearDown()
-	{
-		WebElement logoutLink = null;
-		try
-		{
-			logoutLink = driver.findElement(By.id("commonActions:logout"));
-		}
-		catch (NoSuchElementException noElemEx)
-		{
-			// do nothing if the logout link is not present.
-		}
-		if (logoutLink != null)
-		{
-			logoutLink.click();
-			Wait<WebDriver> wait = new WebDriverWait(driver, 15);
-			wait.until(PageUtilities.visibilityOfElementLocated(By.id("publicWrapper")));
-		}
-	}
-
-	private IDatabaseConnection getConnection() throws ClassNotFoundException, SQLException, DatabaseUnitException
-	{
-		Class.forName("org.apache.derby.jdbc.ClientDriver");
-		Connection jdbcConnection = DriverManager.getConnection("jdbc:derby://localhost:1527/GALLERIATEST", "APP", "GALLERIA");
-		IDatabaseConnection databaseConnection = new DatabaseConnection(jdbcConnection);
-		return databaseConnection;
-	}
-
-	/**
-	 * Returns a dataset containing blanked out tables and table-based sequences
-	 * set to 0.
-	 * 
-	 * @return
-	 * @throws Exception
-	 */
-	private IDataSet getDataSet() throws Exception
-	{
-		ClassLoader classLoader = this.getClass().getClassLoader();
-		return new FlatXmlDataSetBuilder().build(classLoader.getResourceAsStream("database-test-setup.xml"));
-	}
-
-	@Test
-	public void testSignupUser() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = {"The new user account has been created. You may now login."};
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-	}
-
-	@Test
-	public void testSignupUserWithNoValues() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		signupPage = signupPage.signupAsExpectingError("", "", "");
-		String[] errorMessages = { "The user Id should be between 1 and 50 characters in length.",
-				"The password should be between 1 and 500 characters in length.",
-				"The confirmed password should be between 1 and 500 characters in length." };
-		assertArrayEquals(errorMessages, signupPage.fetchSignupErrorMessages());
-	}
-
-	@Test
-	public void testSignupUserWithExcessiveValues() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		signupPage = signupPage
-				.signupAsExpectingError(
-						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
-		String[] errorMessages = { "The user Id should be between 1 and 50 characters in length.",
-				"The password should be between 1 and 500 characters in length.",
-				"The confirmed password should be between 1 and 500 characters in length." };
-		assertArrayEquals(errorMessages, signupPage.fetchSignupErrorMessages());
-	}
-
-	@Test
-	public void testSignupUserWithMismatchedPasswords() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		signupPage = signupPage.signupAsExpectingError("User#1", "password", "mismatchpassword");
-		String[] errorMessages = { "The entered passwords do not match. Please correct the passwords before retrying." };
-		assertArrayEquals(errorMessages, signupPage.fetchSignupErrorMessages());
-	}
-
-	@Test
-	public void testSignupDuplicateUsers() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		signupPage = indexPage.chooseToSignup();
-		signupPage = signupPage.signupAsExpectingError("User#1", "password", "password");
-		String[] errorMessages = { "The user account Id is already taken. Please choose another." };
-		assertArrayEquals(errorMessages, signupPage.fetchSignupErrorMessages());
-	}
-
-	@Test
-	public void testLoginUserInvalidCredentials() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		loginPage.loginAsExpectingError("User#2", "password");
-		String[] errorMessages = { "The user name or password is incorrect." };
-		assertArrayEquals(errorMessages, loginPage.getLoginErrorMessagesDisplayed());
-	}
-
-	@Test
-	public void testLoginUser() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		loginPage.loginAs("User#1", "password");
-		assertTrue(driver.findElement(By.id("commonActions:AccountPreferences")) != null);
-		assertTrue(driver.findElement(By.id("commonActions:logout")) != null);
-	}
-
-	@Test
-	public void testLogoutUser() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		HomePage homePage = loginPage.loginAs("User#1", "password");
-		homePage.logout();
-	}
-
-	@Test
-	public void testModifyPassword() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		HomePage homePage = loginPage.loginAs("User#1", "password");
-		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
-		homePage = accountPreferencesPage.modifyPasswordAs("password", "password1", "password1");
-		String[] successMessage = { "The password has been modified." };
-		assertArrayEquals(successMessage, homePage.fetchSuccessMessages());
-	}
-
-	@Test
-	public void testModifyPasswordWithIncorrectOld() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		HomePage homePage = loginPage.loginAs("User#1", "password");
-		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
-		accountPreferencesPage.modifyPasswordAsExpectingError("password1", "password2", "password2");
-		String[] errorMessages = { "The old password entered does not match your current password." };
-		assertArrayEquals(errorMessages, accountPreferencesPage.fetchErrorMessages());
-	}
-
-	@Test
-	public void testModifyPasswordWithMismatchingNew() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		HomePage homePage = loginPage.loginAs("User#1", "password");
-		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
-		accountPreferencesPage.modifyPasswordAsExpectingError("password", "password1", "password2");
-		String[] errorMessages = { "The new password and the confirm password values do not match." };
-		assertArrayEquals(errorMessages, accountPreferencesPage.fetchErrorMessages());
-	}
-
-	@Test
-	public void testModifyPasswordWithSameOldAndNew() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		HomePage homePage = loginPage.loginAs("User#1", "password");
-		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
-		accountPreferencesPage.modifyPasswordAsExpectingError("password", "password", "password");
-		String[] errorMessages = { "Your new password cannot be the same as the old password." };
-		assertArrayEquals(errorMessages, accountPreferencesPage.fetchErrorMessages());
-	}
-
-	@Test
-	public void testDeleteAccount() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		HomePage homePage = loginPage.loginAs("User#1", "password");
-		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
-		indexPage = accountPreferencesPage.deleteAcccount();
-		String[] messages = { "The account was deleted successfully." };
-		assertArrayEquals(messages, indexPage.fetchSuccessMessages());
-	}
-	
-	@Test
-	public void testCreateAlbum() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		HomePage homePage = loginPage.loginAs("User#1", "password");
-		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
-		homePage = createAlbumPage.createAlbumAs("Album#1", "My first album");
-		String[] messages = { "The album was created successfully." };
-		assertArrayEquals(messages, homePage.fetchSuccessMessages());
-	}
-
-	@Test
-	public void testCreateAlbumWithNoValues() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		HomePage homePage = loginPage.loginAs("User#1", "password");
-		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
-		createAlbumPage = createAlbumPage.createAlbumAsExpectingError("", "");
-		String[] errorMessages = { "The name of the album should be between 1 and 50 characters in length." };
-		assertArrayEquals(errorMessages, createAlbumPage.fetchErrorMessages());
-	}
-
-	@Test
-	public void testCreateAlbumWithExcessiveValues() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		HomePage homePage = loginPage.loginAs("User#1", "password");
-		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
-		createAlbumPage = createAlbumPage
-				.createAlbumAsExpectingError(
-						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-						"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
-		String[] errorMessages = { "The name of the album should be between 1 and 50 characters in length.",
-				"The description of the album should be between 0 and 255 characters in length." };
-		assertArrayEquals(errorMessages, createAlbumPage.fetchErrorMessages());
-	}
-
-	@Test
-	public void testCreateDuplicateAlbum() throws Exception
-	{
-		driver.get(contextPath.toString());
-		IndexPage indexPage = new IndexPage(driver, contextPath);
-		SignupPage signupPage = indexPage.chooseToSignup();
-		indexPage = signupPage.signupAs("User#1", "password");
-		String[] message = { "The new user account has been created. You may now login." };
-		assertArrayEquals(message, indexPage.fetchSuccessMessages());
-
-		LoginPage loginPage = indexPage.chooseToLogin();
-		HomePage homePage = loginPage.loginAs("User#1", "password");
-		CreateAlbumPage createAlbumPage = homePage.goToCreateAlbum();
-		homePage = createAlbumPage.createAlbumAs("Album#1", "My first album");
-		String[] messages = { "The album was created successfully." };
-		assertArrayEquals(messages, homePage.fetchSuccessMessages());
-
-		createAlbumPage = homePage.goToCreateAlbum();
-		createAlbumPage = createAlbumPage.createAlbumAsExpectingError("Album#1", "My first album");
-		String[] errorMessages = { "An existing album with the same name and description was found." };
-		assertArrayEquals(errorMessages, createAlbumPage.fetchErrorMessages());
-	}
-
-}

galleria-jsf/src/test/java/info/galleria/view/user/CreateAlbumPage.java

-package info.galleria.view.user;
-
-import java.net.URI;
-import java.util.*;
-
-import org.openqa.selenium.*;
-import org.openqa.selenium.support.ui.*;
-
-public class CreateAlbumPage
-{
-
-	private WebDriver driver;
-	private URI contextPath;
-
-	public CreateAlbumPage(WebDriver driver, URI contextPath)
-	{
-		this.driver = driver;
-		this.contextPath = contextPath;
-		Wait<WebDriver> wait = new WebDriverWait(driver, 15);
-		wait.until(PageUtilities.visibilityOfElementLocated(By.id("wrapper")));
-		if (!driver.getTitle().equals("Create an album"))
-		{
-			throw new IllegalStateException("This is not the Create Album page.");
-		}
-	}
-
-	public HomePage createAlbumAs(String albumName, String albumDescription)
-	{
-		driver.findElement(By.id("CreateAlbum:albumName")).clear();
-		driver.findElement(By.id("CreateAlbum:albumName")).sendKeys(albumName);
-		driver.findElement(By.id("CreateAlbum:albumDescription")).clear();
-		driver.findElement(By.id("CreateAlbum:albumDescription")).sendKeys(albumDescription);
-		driver.findElement(By.id("CreateAlbum:createAlbumButton")).click();
-		return new HomePage(driver, contextPath);
-	}
-
-	public CreateAlbumPage createAlbumAsExpectingError(String albumName, String albumDescription)
-	{
-		driver.findElement(By.id("CreateAlbum:albumName")).clear();
-		driver.findElement(By.id("CreateAlbum:albumName")).sendKeys(albumName);
-		driver.findElement(By.id("CreateAlbum:albumDescription")).clear();
-		driver.findElement(By.id("CreateAlbum:albumDescription")).sendKeys(albumDescription);
-		driver.findElement(By.id("CreateAlbum:createAlbumButton")).click();
-		return new CreateAlbumPage(driver, contextPath);
-	}
-
-	public String[] fetchErrorMessages()
-	{
-		List<String> errorMessages = new ArrayList<String>();
-		for (WebElement element : driver.findElements(By.xpath("//ul[@id='messages']/li[@class='errorStyle']")))
-		{
-			errorMessages.add(element.getText());
-		}
-		return errorMessages.toArray(new String[0]);
-	}
-}

galleria-jsf/src/test/java/info/galleria/view/user/HomePage.java

 package info.galleria.view.user;
 
+import info.galleria.view.PageUtilities;
+import info.galleria.view.album.*;
+
 import java.net.URI;
 import java.util.*;
 
 		return new CreateAlbumPage(driver, contextPath);
 	}
 
+	public ViewAlbumPage viewAlbumWith(String albumName, String albumDescription)
+	{
+		List<WebElement> photoWrappers = driver.findElements(By.xpath("//ul[@class='photoWrapper']"));
+		for (WebElement element : photoWrappers)
+		{
+			WebElement name = element.findElement(By.className("name"));
+			WebElement description = element.findElement(By.className("description"));
+			if (name.getText().equals(albumName) && description.getText().equals(albumDescription))
+			{
+				element.findElement(By.className("photolink")).click();
+				return new ViewAlbumPage(driver, contextPath);
+			}
+		}
+		return null;
+	}
+
 }

galleria-jsf/src/test/java/info/galleria/view/user/IndexPage.java

 package info.galleria.view.user;
 
+import info.galleria.view.PageUtilities;
+
 import java.net.URI;
 import java.util.*;
 

galleria-jsf/src/test/java/info/galleria/view/user/LoginPage.java

 package info.galleria.view.user;
 
+import info.galleria.view.PageUtilities;
+
 import java.net.URI;
 import java.util.*;
 

galleria-jsf/src/test/java/info/galleria/view/user/PageUtilities.java

-package info.galleria.view.user;
-
-import org.openqa.selenium.*;
-import org.openqa.selenium.support.ui.ExpectedCondition;
-
-public class PageUtilities
-{
-	public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By locator)
-	{
-		return new ExpectedCondition<WebElement>()
-			{
-				public WebElement apply(WebDriver driver)
-				{
-					WebElement toReturn = driver.findElement(locator);
-					if (toReturn.isDisplayed())
-					{
-						return toReturn;
-					}
-					return null;
-				}
-			};
-	}
-}

galleria-jsf/src/test/java/info/galleria/view/user/SignupPage.java

 package info.galleria.view.user;
 
+import info.galleria.view.PageUtilities;
+
 import java.net.URI;
 import java.util.*;