[weld-commits] Weld SVN: r5992 - in ftest: archetypes and 14 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed Mar 3 08:31:44 EST 2010


Author: mgencur at redhat.com
Date: 2010-03-03 08:31:43 -0500 (Wed, 03 Mar 2010)
New Revision: 5992

Added:
   ftest/archetypes/
   ftest/archetypes/branches/
   ftest/archetypes/tags/
   ftest/archetypes/trunk/
   ftest/archetypes/trunk/pom.xml
   ftest/archetypes/trunk/src/
   ftest/archetypes/trunk/src/main/
   ftest/archetypes/trunk/src/main/java/
   ftest/archetypes/trunk/src/main/java/org/
   ftest/archetypes/trunk/src/main/java/org/jboss/
   ftest/archetypes/trunk/src/main/java/org/jboss/weld/
   ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/
   ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/
   ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/
   ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/selenium/
   ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/selenium/JeeMinimalTest.java
   ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/
   ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/
   ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/selenium/
   ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/selenium/ServletMinimalTest.java
Log:
first part of testsuite for automatic testing of weld archetypes

Added: ftest/archetypes/trunk/pom.xml
===================================================================
--- ftest/archetypes/trunk/pom.xml	                        (rev 0)
+++ ftest/archetypes/trunk/pom.xml	2010-03-03 13:31:43 UTC (rev 5992)
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+   <modelVersion>4.0.0</modelVersion>
+
+   <parent>
+      <groupId>org.jboss.weld.examples.ftest</groupId>
+      <artifactId>ftest-parent</artifactId>
+      <version>0.1</version>
+   </parent>
+
+   <groupId>org.jboss.weld.examples.ftest</groupId>
+   <artifactId>ftest-archetypes</artifactId>
+   <version>0.1</version>
+   <packaging>jar</packaging>
+   <name>Weld Archetypes Ftest: Weld JSF Servlet Minimal</name>
+
+   <dependencies>
+      <dependency>
+         <groupId>org.jboss.weld.examples.ftest</groupId>
+         <artifactId>ftest-common</artifactId>
+         <version>0.1</version>
+      </dependency>
+   </dependencies>
+
+</project>
+

Added: ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/selenium/JeeMinimalTest.java
===================================================================
--- ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/selenium/JeeMinimalTest.java	                        (rev 0)
+++ ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/selenium/JeeMinimalTest.java	2010-03-03 13:31:43 UTC (rev 5992)
@@ -0,0 +1,107 @@
+/*
+ * 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.weld.archetype.jeeminimal.test.selenium;
+
+import static org.testng.Assert.assertTrue;
+import org.jboss.weld.example.common.test.selenium.WeldSeleniumTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Tests Weld JSF JEE Minimal archetypes from Weld
+ * 
+ * @author Martin Gencur
+ * 
+ */
+public class JeeMinimalTest extends WeldSeleniumTest
+{
+   protected String MAIN_PAGE = "/home.jsf";
+   protected String TITLE = "Hello World!";
+   protected String TEXT1 = "Bean Validation examples";
+   protected String TEXT2 = "Find out more";
+   protected String TEXT3 = "Documentation";
+   protected String TEXT4 = "Weld is the reference implementation of CDI";
+
+   protected String INPUT_LETTERS = "id=bv:letters";
+   protected String INPUT_NUMBERS = "id=bv:numbers";
+   protected String INPUT_EMAIL = "id=bv:email";
+   protected String INPUT_CHECK_BUTTON = "id=bv:check";
+
+   protected String NOT_EMPTY_MESSAGE = "may not be empty";
+   protected String NUMBERS_MESSAGE = "numeric value out of bounds (<2 digits>.<0 digits> expected)";
+   protected String ONLY_LETTERS_MESSAGE = "must contain only letters";
+   
+   protected String INVALID_EMAIL_MESSAGE = "not a well-formed email address";
+
+   @BeforeMethod(dependsOnGroups = "seleniumSetUp")
+   public void open()
+   {
+      browser.open(contextPath + MAIN_PAGE);
+      browser.waitForPageToLoad();
+   }
+
+   @Test
+   public void homePageLoadTest()
+   {
+      assertTrue(browser.isTextPresent(TITLE), "Page should contain title");
+      assertTrue(browser.isTextPresent(TEXT1), "Page should contain: " + TEXT1);
+      assertTrue(browser.isTextPresent(TEXT2), "Page should contain: " + TEXT2);
+      assertTrue(browser.isTextPresent(TEXT3), "Page should contain: " + TEXT3);
+      assertTrue(browser.isTextPresent(TEXT4), "Page should contain: " + TEXT4);
+   }
+
+   @Test(dependsOnMethods = { "homePageLoadTest" })
+   public void sendEmptyFormTest()
+   {
+      browser.clickAndWait(INPUT_CHECK_BUTTON);
+      assertTrue(browser.isTextPresent(NOT_EMPTY_MESSAGE), "Page should contain: " + NOT_EMPTY_MESSAGE);
+      //assertTrue(!browser.isTextPresent(NUMBERS_MESSAGE), "Page shouldn't contain: " + NUMBERS_MESSAGE);
+   }
+
+   @Test(dependsOnMethods = { "homePageLoadTest" })
+   public void sendWrongValuesTest()
+   {
+      browser.type(INPUT_LETTERS, "hi32guys");
+      browser.type(INPUT_NUMBERS, "6546");
+      browser.type(INPUT_EMAIL, "smithAndWessonCom");
+
+      browser.clickAndWait(INPUT_CHECK_BUTTON);
+
+      assertTrue(browser.isTextPresent(ONLY_LETTERS_MESSAGE), "Page should contain: " + ONLY_LETTERS_MESSAGE);
+      assertTrue(browser.isTextPresent(NUMBERS_MESSAGE), "Page should contain: " + NUMBERS_MESSAGE);
+      assertTrue(browser.isTextPresent(INVALID_EMAIL_MESSAGE), "Page should contain: " + INVALID_EMAIL_MESSAGE);
+   }
+
+   @Test(dependsOnMethods = { "homePageLoadTest" })
+   public void sendRightValuesTest()
+   {
+      browser.type(INPUT_LETTERS, "hithirtytwoguys");
+      browser.type(INPUT_NUMBERS, "65");
+      browser.type(INPUT_EMAIL, "smith at wesson.com");
+
+      browser.clickAndWait(INPUT_CHECK_BUTTON);
+
+      assertTrue(!browser.isTextPresent(ONLY_LETTERS_MESSAGE), "Page shouldn't contain error messages");
+      assertTrue(!browser.isTextPresent(NUMBERS_MESSAGE), "Page shouldn't contain error messages");
+      assertTrue(!browser.isTextPresent(INVALID_EMAIL_MESSAGE), "Page shouldn't contain error messages");
+   }
+}

Added: ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/selenium/ServletMinimalTest.java
===================================================================
--- ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/selenium/ServletMinimalTest.java	                        (rev 0)
+++ ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/selenium/ServletMinimalTest.java	2010-03-03 13:31:43 UTC (rev 5992)
@@ -0,0 +1,107 @@
+/*
+ * 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.weld.archetype.servletminimal.test.selenium;
+
+import static org.testng.Assert.assertTrue;
+import org.jboss.weld.example.common.test.selenium.WeldSeleniumTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Tests Weld JSF Servlet archetypes from Weld
+ * 
+ * @author Martin Gencur
+ * 
+ */
+public class ServletMinimalTest extends WeldSeleniumTest
+{
+   protected String MAIN_PAGE = "/home.jsf";
+   protected String TITLE = "Hello World!";
+   protected String TEXT1 = "Bean Validation examples";
+   protected String TEXT2 = "Find out more";
+   protected String TEXT3 = "Documentation";
+   protected String TEXT4 = "Weld is the reference implementation of CDI";
+
+   protected String INPUT_LETTERS = "id=bv:letters";
+   protected String INPUT_NUMBERS = "id=bv:numbers";
+   protected String INPUT_EMAIL = "id=bv:email";
+   protected String INPUT_CHECK_BUTTON = "id=bv:check";
+
+   protected String NOT_EMPTY_MESSAGE = "may not be empty";
+   protected String NUMBERS_MESSAGE = "numeric value out of bounds (<2 digits>.<0 digits> expected)";
+   protected String ONLY_LETTERS_MESSAGE = "must contain only letters";
+   
+   protected String INVALID_EMAIL_MESSAGE = "\"{value}\" is not a valid email address";
+
+   @BeforeMethod(dependsOnGroups = "seleniumSetUp")
+   public void open()
+   {
+      browser.open(contextPath + MAIN_PAGE);
+      browser.waitForPageToLoad();
+   }
+
+   @Test
+   public void homePageLoadTest()
+   {
+      assertTrue(browser.isTextPresent(TITLE), "Page should contain title");
+      assertTrue(browser.isTextPresent(TEXT1), "Page should contain: " + TEXT1);
+      assertTrue(browser.isTextPresent(TEXT2), "Page should contain: " + TEXT2);
+      assertTrue(browser.isTextPresent(TEXT3), "Page should contain: " + TEXT3);
+      assertTrue(browser.isTextPresent(TEXT4), "Page should contain: " + TEXT4);
+   }
+
+   @Test(dependsOnMethods = { "homePageLoadTest" })
+   public void sendEmptyFormTest()
+   {
+      browser.clickAndWait(INPUT_CHECK_BUTTON);
+      assertTrue(browser.isTextPresent(NOT_EMPTY_MESSAGE), "Page should contain: " + NOT_EMPTY_MESSAGE);
+      //assertTrue(!browser.isTextPresent(NUMBERS_MESSAGE), "Page shouldn't contain: " + NUMBERS_MESSAGE);
+   }
+
+   @Test(dependsOnMethods = { "homePageLoadTest" })
+   public void sendWrongValuesTest()
+   {
+      browser.type(INPUT_LETTERS, "hi32guys");
+      browser.type(INPUT_NUMBERS, "6546");
+      browser.type(INPUT_EMAIL, "smithAndWessonCom");
+
+      browser.clickAndWait(INPUT_CHECK_BUTTON);
+
+      assertTrue(browser.isTextPresent(ONLY_LETTERS_MESSAGE), "Page should contain: " + ONLY_LETTERS_MESSAGE);
+      assertTrue(browser.isTextPresent(NUMBERS_MESSAGE), "Page should contain: " + NUMBERS_MESSAGE);
+      assertTrue(browser.isTextPresent(INVALID_EMAIL_MESSAGE), "Page should contain: " + INVALID_EMAIL_MESSAGE);
+   }
+
+   @Test(dependsOnMethods = { "homePageLoadTest" })
+   public void sendRightValuesTest()
+   {
+      browser.type(INPUT_LETTERS, "hithirtytwoguys");
+      browser.type(INPUT_NUMBERS, "65");
+      browser.type(INPUT_EMAIL, "smith at wesson.com");
+
+      browser.clickAndWait(INPUT_CHECK_BUTTON);
+
+      assertTrue(!browser.isTextPresent(ONLY_LETTERS_MESSAGE), "Page shouldn't contain error messages");
+      assertTrue(!browser.isTextPresent(NUMBERS_MESSAGE), "Page shouldn't contain error messages");
+      assertTrue(!browser.isTextPresent(INVALID_EMAIL_MESSAGE), "Page shouldn't contain error messages");
+   }
+}



More information about the weld-commits mailing list