[seam-commits] Seam SVN: r7223 - in trunk: examples/quartz/src/org/jboss/seam/example/quartz/test and 8 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Jan 24 12:08:50 EST 2008


Author: pete.muir at jboss.org
Date: 2008-01-24 12:08:50 -0500 (Thu, 24 Jan 2008)
New Revision: 7223

Added:
   trunk/src/main/org/jboss/seam/mock/AbstractDBUnitSeamTest.java
   trunk/src/main/org/jboss/seam/mock/AbstractSeamTest.java
   trunk/src/main/org/jboss/seam/mock/DBUnitSeamTest.java
   trunk/src/test/integration/src/org/jboss/seam/test/integration/Foo.java
   trunk/src/test/integration/src/org/jboss/seam/test/integration/ImportTest.java
   trunk/src/test/integration/src/org/jboss/seam/test/integration/NamespaceTest.java
   trunk/src/test/integration/src/org/jboss/seam/test/integration/People.java
   trunk/src/test/integration/src/org/jboss/seam/test/integration/databinding/
   trunk/src/test/integration/src/org/jboss/seam/test/integration/databinding/DataModelTest.java
   trunk/src/test/integration/src/org/jboss/seam/test/integration/mock/
   trunk/src/test/integration/src/org/jboss/seam/test/integration/mock/SeamMockELResolverTest.java
   trunk/src/test/integration/src/org/jboss/seam/test/integration/mock/SeamTestTest.java
   trunk/src/test/integration/src/org/jboss/seam/test/integration/security/
   trunk/src/test/integration/src/org/jboss/seam/test/integration/security/SecurityTest.java
Removed:
   trunk/src/main/org/jboss/seam/mock/BaseSeamTest.java
   trunk/src/main/org/jboss/seam/mock/DBUnitSeamTest.java
   trunk/src/test/integration/src/org/jboss/seam/test/integration/SeamMockELResolverTest.java
   trunk/src/test/unit/org/jboss/seam/test/unit/DataModelTest.java
   trunk/src/test/unit/org/jboss/seam/test/unit/ImportTest.java
   trunk/src/test/unit/org/jboss/seam/test/unit/NamespaceTest.java
   trunk/src/test/unit/org/jboss/seam/test/unit/SeamTestTest.java
   trunk/src/test/unit/org/jboss/seam/test/unit/SecurityTest.java
Modified:
   trunk/build.xml
   trunk/examples/quartz/src/org/jboss/seam/example/quartz/test/testng.xml
   trunk/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/testng.xml
   trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/util/DBUnitSeamTest.java
   trunk/src/main/org/jboss/seam/mock/SeamTest.java
   trunk/src/main/org/jboss/seam/mock/package-info.java
   trunk/src/test/integration/src/org/jboss/seam/test/integration/testng.xml
   trunk/src/test/unit/org/jboss/seam/test/unit/testng.xml
Log:
JBSEAM-2468, JBSEAM-2424, JBSEAM-1779, reorg unit and integration tests, JBSEAM-2531, rename BaseSeamTest to AbstractSeamTest to be in line with Seam conventions

Modified: trunk/build.xml
===================================================================
--- trunk/build.xml	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/build.xml	2008-01-24 17:08:50 UTC (rev 7223)
@@ -378,7 +378,7 @@
 		<replace file="${webroot.dir}/seam-examples.html" token="http://localhost:8080" value="" />
 	</target>
 
-	<target name="testall" depends="testcore,build,compiletest, copylib" description="Run the core unit tests and all example tests">
+	<target name="testall" depends="test,build, copylib" description="Run the core unit tests and all example tests">
 		<testexample name="booking" />
 		<testexample name="nestedbooking" />
 		<testexample name="dvdstore" />
@@ -627,7 +627,7 @@
 	</target>
 
 
-	<target name="testcore" depends="inittestcore,compiletest" description="Run the core tests">
+	<target name="unittest" depends="inittestcore,compiletest" description="Run the Unit tests">
 		<taskdef resource="testngtasks" classpathref="test.core.path" />
 		<testng>
 			<jvmarg value="-Demma.coverage.out.file=${coverage.ec}" />
@@ -641,9 +641,17 @@
 			</classpath>
 			<xmlfileset dir="${classes.test.dir}" includes="**/testng.xml" />
 		</testng>
-		<testexample name="integration" path="${seam.dir}/src/test/integration" message=""/>
 		<echo>You can increase the logging by editing bootstrap/log4j.xml</echo>
 	</target>
+	
+	<target name="test" depends="unittest, integrationtest" description="Run Seam Unit Tests and the Seam (core) Integration Tests"/>
+	
+	<target name="integrationtest" description="Run the Seam (core) Inteegration Tests">
+		<testexample name="integration" path="${seam.dir}/src/test/integration" message=""/>
+	</target>
+	
+	<!-- Deprecated -->
+	<target name="testcore" depends="test" />
 
 	<target name="testreport" description="Create a pretty report">
 		<mkdir dir="${report.dir}" />

Modified: trunk/examples/quartz/src/org/jboss/seam/example/quartz/test/testng.xml
===================================================================
--- trunk/examples/quartz/src/org/jboss/seam/example/quartz/test/testng.xml	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/examples/quartz/src/org/jboss/seam/example/quartz/test/testng.xml	2008-01-24 17:08:50 UTC (rev 7223)
@@ -4,6 +4,8 @@
 	<test name="Quartz Example">
       
         <parameter name="datasourceJndiName" value="java:/DefaultDS"/>
+        <parameter name="database" value="HSQL" />
+        <parameter name="binaryDir" value="" />
         
 		<classes>
 			<class name="org.jboss.seam.example.quartz.test.AccountTest" />

Modified: trunk/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/testng.xml
===================================================================
--- trunk/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/testng.xml	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/test/testng.xml	2008-01-24 17:08:50 UTC (rev 7223)
@@ -3,6 +3,8 @@
     <test name="SeamDiscs: Artist Tests">
       
         <parameter name="datasourceJndiName" value="java:/seamdiscsDatasource"/>
+        <parameter name="database" value="HSQL" />
+        <parameter name="binaryDir" value="" />
     
         <classes>
             <class name="org.jboss.seam.example.seamdiscs.test.DisplayArtistTest" />
@@ -14,6 +16,8 @@
     <test name="SeamDiscs: Disc Tests">
       
         <parameter name="datasourceJndiName" value="java:/seamdiscsDatasource"/>
+        <parameter name="database" value="HSQL" />
+        <parameter name="binaryDir" value="" />
     
         <classes>
             <class name="org.jboss.seam.example.seamdiscs.test.DisplayDiscTest" />
@@ -25,6 +29,8 @@
     <test name="SeamDiscs: Login Test">
     
         <parameter name="datasourceJndiName" value="java:/seamdiscsDatasource"/>
+        <parameter name="database" value="HSQL" />
+        <parameter name="binaryDir" value="" />
     
         <classes>
             <class name="org.jboss.seam.example.seamdiscs.test.LoginTest" />

Modified: trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/util/DBUnitSeamTest.java
===================================================================
--- trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/util/DBUnitSeamTest.java	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/util/DBUnitSeamTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -18,6 +18,7 @@
 import org.dbunit.operation.DatabaseOperation;
 import org.jboss.seam.log.Log;
 import org.jboss.seam.log.Logging;
+import org.jboss.seam.mock.AbstractSeamTest;
 import org.jboss.seam.mock.SeamTest;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterMethod;
@@ -96,7 +97,7 @@
  *
  * @author Christian Bauer
  */
-public abstract class DBUnitSeamTest extends SeamTest {
+public abstract class DBUnitSeamTest extends AbstractSeamTest {
 
     public enum Database {
         hsql, mysql
@@ -139,6 +140,7 @@
         this.database = Database.valueOf(database);
     }
 
+    @Override
     @BeforeClass
     public void setupClass() throws Exception {
         super.setupClass();
@@ -147,38 +149,25 @@
     
     @Override
     @AfterClass
-    protected void cleanupClass() throws Exception
+    public void cleanupClass() throws Exception
     {
         super.cleanupClass();
     }
     
     @Override
     @BeforeSuite
-    protected void startSeam() throws Exception
+    public void startSeam() throws Exception
     {
         super.startSeam();
     }
     
     @Override
     @AfterSuite
-    protected void stopSeam() throws Exception
+    public void stopSeam() throws Exception
     {
         super.stopSeam();
     }
     
-    @Override
-    public void init() throws Exception
-    {
-        // no-op
-    }
-   
-    @Override
-    public void cleanup() throws Exception
-    {
-        // no-op
-    }
-    
-    
 
     @BeforeMethod
     @Override

Copied: trunk/src/main/org/jboss/seam/mock/AbstractDBUnitSeamTest.java (from rev 7222, trunk/src/main/org/jboss/seam/mock/DBUnitSeamTest.java)
===================================================================
--- trunk/src/main/org/jboss/seam/mock/AbstractDBUnitSeamTest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/seam/mock/AbstractDBUnitSeamTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -0,0 +1,432 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.seam.mock;
+
+import static org.jboss.seam.mock.AbstractDBUnitSeamTest.Database.HSQL;
+import static org.jboss.seam.mock.AbstractDBUnitSeamTest.Database.MYSQL;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import org.dbunit.database.DatabaseConfig;
+import org.dbunit.database.DatabaseConnection;
+import org.dbunit.database.IDatabaseConnection;
+import org.dbunit.dataset.IDataSet;
+import org.dbunit.dataset.ReplacementDataSet;
+import org.dbunit.dataset.datatype.DataType;
+import org.dbunit.dataset.datatype.DataTypeException;
+import org.dbunit.dataset.datatype.DefaultDataTypeFactory;
+import org.dbunit.dataset.xml.FlatXmlDataSet;
+import org.dbunit.operation.DatabaseOperation;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+
+/**
+ * Utility for integration testing with Seam and DBUnit datasets.
+ * <p>
+ * Subclass this class instead of <tt>SeamTest</tt> if you need to insert or clean data in
+ * your database before and after a test. You need to implement <tt>prepareDBUnitOperations()</tt> and
+ * add instances of <tt>DataSetOperation</tt>s to the * <tt>beforeTestOperations</tt> and
+ * <tt>afterTestOperations</tt> lists. An example:
+ * <pre>
+ * public class MyTest extends DBUnitSeamTest {
+ *
+ *   protected void prepareDBUnitOperations() {
+ *       beforeTestOperations.add(
+ *          new DataSetOperation("my/datasets/BaseData.xml")
+ *       );
+ *       beforeTestOperations.add(
+ *           new DataSetOperation("my/datasets/AdditionalData.xml", DatabaseOperation.INSERT)
+ *       );
+ *   }
+ * ... // Various test methods with @Test annotation
+ * }
+ * </pre>
+ * <p>
+ * Note that <tt>DataSetOperation</tt> defaults to <tt>DatabaseOperation.CLEAN_INSERT</tt> if no
+ * other operation is specified as a constructor argument. The above example cleans all tables defined
+ * in <tt>BaseData.xml</tt>, then inserts all rows declared in <tt>BaseData.xml</tt>, then inserts
+ * all the rows declared in <tt>AdditionalData.xml</tt>. This executes before every each test method
+ * is invoked. If you require extra cleanup after a test method executes, add operations to the
+ * <tt>afterTestOperations</tt> list.
+ * </p>
+ * <p>
+ * A test class obtains the database connection for loading and cleaning of datasets in one of the following ways:
+ * </p>
+ * <dl>
+ * <li>A TestNG test parameter named <tt>datasourceJndiName</tt> is provided by the TestNG test runner, which
+ * automatically calls <tt>setDatasourceJndiName()</tt> on the test class before a logical test runs.</li>
+ * 
+ * <li>An instance of a test class is created manually and the <tt>datasourceJndiName</tt> is passed as a
+ * constructor argument.</li>
+ *
+ * <li>An instance of a test class is created manually and the <tt>setDatasourceJndiName()</tt> method is
+ * called after creation and before a test runs.</li>
+ *
+ * <li>A subclass overrides the <tt>getConnection()</tt> method and returns a custom database connection.</li>
+ *
+ * </dl>
+ * <p>
+ * Referential integrity checks (foreign keys) will be or have to be disabled on the database connection
+ * used for DBUnit operations. This makes adding circular references in datasets easier. Referential integrity checks
+ * are enabled again after the connection has been used.
+ * </p>
+ * <p>
+ * <b>Note that the methods <tt>disableReferentialIntegrity()</tt>,
+ * <tt>enableReferentialIntegrity()</tt>, and <tt>editConfig()</tt> are implemented for HSQL DB. If you want to run 
+ * unit tests on any other DBMS, you need to override these methods and implement them for your DBMS.</b>
+ * </p>
+ *
+ * @author Christian Bauer
+ */
+public abstract class AbstractDBUnitSeamTest extends AbstractSeamTest 
+{
+
+    public enum Database 
+    {
+        HSQL, MYSQL
+    }
+
+    private LogProvider log = Logging.getLogProvider(DBUnitSeamTest.class);
+    
+    private String datasourceJndiName;
+    private String binaryDir;
+    private Database database = HSQL;
+    protected List<DataSetOperation> beforeTestOperations = new ArrayList<DataSetOperation>();
+    protected List<DataSetOperation> afterTestOperations = new ArrayList<DataSetOperation>();
+
+    protected AbstractDBUnitSeamTest() 
+    {
+    }
+
+    protected AbstractDBUnitSeamTest(String datasourceJndiName) 
+    {
+        this.datasourceJndiName = datasourceJndiName;
+    }
+
+    public void setDatasourceJndiName(String datasourceJndiName) 
+    {
+        this.datasourceJndiName = datasourceJndiName;
+    }
+
+    public void setBinaryDir(String binaryDir) 
+    {
+        this.binaryDir = binaryDir;
+    }
+
+    public void setDatabase(String database) 
+    {
+       if (database != null)
+       {
+          this.database = Database.valueOf(database.toUpperCase());
+       }
+    }
+
+    @Override
+    public void setupClass() throws Exception 
+    {
+        super.setupClass();
+        prepareDBUnitOperations();
+    }
+
+    @Override
+    public void begin() 
+    {
+        super.begin();
+        executeOperations(beforeTestOperations);
+    }
+    
+    @Override
+    public void end() 
+    {
+        super.end();
+        executeOperations(afterTestOperations);
+    }
+
+    private void executeOperations(List<DataSetOperation> list) 
+    {
+        IDatabaseConnection con = null;
+        try 
+        {
+            con = getConnection();
+            disableReferentialIntegrity(con);
+            for (DataSetOperation op : list) 
+            {
+                op.execute(con);
+            }
+            enableReferentialIntegrity(con);
+        } 
+        finally 
+        {
+            if (con != null) 
+            {
+                try 
+                {
+                    con.close();
+                }
+                catch (Exception ex) 
+                {
+                    ex.printStackTrace(System.err);
+                }
+            }
+        }
+    }
+
+    protected class DataSetOperation 
+    {
+        String dataSetLocation;
+        ReplacementDataSet dataSet;
+        DatabaseOperation operation;
+
+        /**
+         * Defaults to <tt>DatabaseOperation.CLEAN_INSERT</tt>
+         * @param dataSetLocation location of DBUnit dataset
+         */
+        public DataSetOperation(String dataSetLocation)
+        {
+            this(dataSetLocation, DatabaseOperation.CLEAN_INSERT);
+        }
+
+        public DataSetOperation(String dataSetLocation, DatabaseOperation operation) 
+        {
+            log.info(">>> Preparing dataset: " + dataSetLocation + " <<<");
+
+            // Load the base dataset file
+            InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(dataSetLocation);
+            try 
+            {
+                this.dataSet = new ReplacementDataSet( new FlatXmlDataSet(input) );
+            }
+            catch (Exception ex) 
+            {
+                throw new RuntimeException(ex);
+            }
+            this.dataSet.addReplacementObject("[NULL]", null);
+            if (binaryDir != null) 
+            {
+                this.dataSet.addReplacementSubstring("[BINARY_DIR]", getBinaryDirFullpath().toString());
+            }
+            this.operation = operation;
+            this.dataSetLocation = dataSetLocation;
+        }
+
+        public IDataSet getDataSet() 
+        {
+            return dataSet;
+        }
+
+        public DatabaseOperation getOperation() 
+        {
+            return operation;
+        }
+
+        public void execute(IDatabaseConnection connection) 
+        {
+            try 
+            {
+                this.operation.execute(connection, dataSet);
+            }
+            catch (Exception ex) 
+            {
+                throw new RuntimeException(ex);
+            }
+        }
+
+        public String toString() 
+        {
+            // TODO: This is not pretty because DBUnit's DatabaseOperation doesn't implement toString() properly
+            return operation.getClass() + " with dataset: " + dataSetLocation;
+        }
+    }
+
+    // Subclasses can/have to override the following methods
+
+    /**
+     * Override this method if you want to provide your own DBUnit <tt>IDatabaseConnection</tt> instance.
+     * <p/>
+     * If you do not override this, default behavior is to use the * configured datasource name and
+     * to obtain a connection with a JNDI lookup.
+     *
+     * @return a DBUnit database connection (wrapped)
+     */
+    protected IDatabaseConnection getConnection() 
+    {
+        try 
+        {
+            DataSource datasource = ((DataSource)getInitialContext().lookup(datasourceJndiName));
+
+            // Get a JDBC connection from JNDI datasource
+            Connection con = datasource.getConnection();
+            IDatabaseConnection dbUnitCon = new DatabaseConnection(con);
+            editConfig(dbUnitCon.getConfig());
+            return dbUnitCon;
+        }
+        catch (Exception ex) 
+        {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    /**
+     * Override this method if you aren't using HSQL DB.
+     * <p/>
+     * Execute whatever statement is necessary to either defer or disable foreign
+     * key constraint checking on the given database connection, which is used by
+     * DBUnit to import datasets.
+     *
+     * @param con A DBUnit connection wrapper, which is used afterwards for dataset operations
+     */
+    protected void disableReferentialIntegrity(IDatabaseConnection con) 
+    {
+        try 
+        {
+            if (database.equals(HSQL)) 
+            {
+                con.getConnection().prepareStatement("set referential_integrity FALSE").execute(); // HSQL DB
+            }
+            else if (database.equals(MYSQL)) 
+            {
+                con.getConnection().prepareStatement("set foreign_key_checks=0").execute(); // MySQL > 4.1.1
+            }
+        }
+        catch (Exception ex) 
+        {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    /**
+     * Override this method if you aren't using HSQL DB.
+     * <p/>
+     * Execute whatever statement is necessary to enable integrity constraint checks after
+     * dataset operations.
+     *
+     * @param con A DBUnit connection wrapper, before it is used by the application again
+     */
+    protected void enableReferentialIntegrity(IDatabaseConnection con) {
+        try {
+            if (database.equals(HSQL)) 
+            {
+                con.getConnection().prepareStatement("set referential_integrity TRUE").execute();  // HSQL DB
+            }
+            else if (database.equals(MYSQL)) 
+            {
+                con.getConnection().prepareStatement("set foreign_key_checks=1").execute(); // MySQL > 4.1.1
+            }
+        }
+        catch (Exception ex) 
+        {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    /**
+     * Override this method if you require DBUnit configuration features or additional properties.
+     * <p>
+     * Called after a connection has been obtaind and before the connection is used. Can be a
+     * NOOP method if no additional settings are necessary for your DBUnit/DBMS setup.
+     *
+     * @param config A DBUnit <tt>DatabaseConfig</tt> object for setting properties and features
+     */
+    protected void editConfig(DatabaseConfig config) 
+    {
+        if (database.equals(HSQL)) {
+            // DBUnit/HSQL bugfix
+            // http://www.carbonfive.com/community/archives/2005/07/dbunit_hsql_and.html
+            config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new DefaultDataTypeFactory() 
+            {
+                public DataType createDataType(int sqlType, String sqlTypeName)
+                  throws DataTypeException 
+                  {
+                   if (sqlType == Types.BOOLEAN) 
+                   {
+                      return DataType.BOOLEAN;
+                    }
+                   return super.createDataType(sqlType, sqlTypeName);
+                 }
+            });
+        }
+    }
+
+    /**
+     * Resolves the binary dir location with the help of the classloader, we need the
+     * absolute full path of that directory.
+     *
+     * @return URL full absolute path of the binary directory
+     */
+    protected URL getBinaryDirFullpath() 
+    {
+        if (binaryDir == null) {
+            throw new RuntimeException("Please set binaryDir property to location of binary test files");
+        }
+        return getResourceURL(binaryDir);
+    }
+
+    protected URL getResourceURL(String resource) 
+    {
+        URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
+        if (url == null) 
+        {
+            throw new RuntimeException("Could not find resource with classloader: " + resource);
+        }
+        return url;
+    }
+
+    protected byte[] getBinaryFile(String filename) throws Exception 
+    {
+        File file = new File(getResourceURL(binaryDir + "/" + filename).toURI());
+        InputStream is = new FileInputStream(file);
+
+        // Get the size of the file
+        long length = file.length();
+
+        if (length > Integer.MAX_VALUE) 
+        {
+            // File is too large
+        }
+
+        // Create the byte array to hold the data
+        byte[] bytes = new byte[(int)length];
+
+        // Read in the bytes
+        int offset = 0;
+        int numRead;
+        while (offset < bytes.length
+               && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) 
+        {
+            offset += numRead;
+        }
+
+        // Ensure all the bytes have been read in
+        if (offset < bytes.length) 
+        {
+            throw new IOException("Could not completely read file "+file.getName());
+        }
+    
+        // Close the input stream and return bytes
+        is.close();
+        return bytes;
+    }
+
+    /**
+     * Implement this in a subclass.
+     * <p>
+     * Use it to stack DBUnit <tt>DataSetOperation</tt>'s with
+     * the <tt>beforeTestOperations</tt> and <tt>afterTestOperations</tt> lists.
+     */
+    protected abstract void prepareDBUnitOperations();
+
+}


Property changes on: trunk/src/main/org/jboss/seam/mock/AbstractDBUnitSeamTest.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: trunk/src/main/org/jboss/seam/mock/AbstractSeamTest.java (from rev 7222, trunk/src/main/org/jboss/seam/mock/BaseSeamTest.java)
===================================================================
--- trunk/src/main/org/jboss/seam/mock/AbstractSeamTest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/seam/mock/AbstractSeamTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -0,0 +1,1021 @@
+package org.jboss.seam.mock;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.AbstractSet;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.el.ELResolver;
+import javax.el.ValueExpression;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.mail.internet.MimeMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.transaction.UserTransaction;
+
+import org.hibernate.validator.ClassValidator;
+import org.hibernate.validator.InvalidValue;
+import org.jboss.seam.Component;
+import org.jboss.seam.Seam;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.FacesLifecycle;
+import org.jboss.seam.contexts.ServletLifecycle;
+import org.jboss.seam.contexts.TestLifecycle;
+import org.jboss.seam.core.Expressions;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.core.Validators;
+import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.faces.Renderer;
+import org.jboss.seam.init.Initialization;
+import org.jboss.seam.jsf.SeamApplication;
+import org.jboss.seam.jsf.SeamPhaseListener;
+import org.jboss.seam.mail.MailSession;
+import org.jboss.seam.pageflow.Pageflow;
+import org.jboss.seam.servlet.SeamFilter;
+import org.jboss.seam.servlet.ServletSessionMap;
+import org.jboss.seam.transaction.Transaction;
+import org.jboss.seam.util.Naming;
+import org.jboss.seam.util.Reflections;
+
+/**
+ * Base class for integration tests for JSF/Seam applications. This class can be
+ * extended or referenced directly for integration with various testing
+ * frameworks.
+ * 
+ * @author Gavin King
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ */
+public class AbstractSeamTest
+{
+
+   private Application application;
+   private MockServletContext servletContext;
+   private static SeamPhaseListener phases;
+   private MockHttpSession session;
+   private Map<String, Map> conversationViewRootAttributes;
+   private Filter seamFilter;
+   
+   static 
+   {
+      phases = new SeamPhaseListener();
+   }
+
+   protected boolean isSessionInvalid()
+   {
+      return session.isInvalid();
+   }
+
+   protected HttpSession getSession()
+   {
+      return session;
+   }
+
+   /**
+    * Helper method for resolving components in the test script.
+    */
+   protected Object getInstance(Class clazz)
+   {
+      return Component.getInstance(clazz);
+   }
+
+   /**
+    * Helper method for resolving components in the test script.
+    */
+   protected Object getInstance(String name)
+   {
+      return Component.getInstance(name);
+   }
+
+   /**
+    * Is there a long running conversation associated with the current request?
+    */
+   protected boolean isLongRunningConversation()
+   {
+      return Manager.instance().isLongRunningConversation();
+   }
+
+   /**
+    * Search in all contexts
+    */
+   public Object lookup(String name)
+   {
+      return Contexts.lookupInStatefulContexts(name);
+   }
+
+   public abstract class ComponentTest
+   {
+      /**
+       * Call a method binding
+       */
+      protected Object invokeMethod(String methodExpression)
+      {
+         return Expressions.instance().createMethodExpression(methodExpression).invoke();
+      }
+
+      /**
+       * Evaluate (get) a value binding
+       */
+      protected Object getValue(String valueExpression)
+      {
+         return Expressions.instance().createValueExpression(valueExpression).getValue();
+      }
+
+      /**
+       * Set a value binding
+       */
+      protected void setValue(String valueExpression, Object value)
+      {
+         Expressions.instance().createValueExpression(valueExpression).setValue(value);
+      }
+
+      protected abstract void testComponents() throws Exception;
+
+      public void run() throws Exception
+      {
+         TestLifecycle.beginTest(servletContext, new ServletSessionMap(session));
+         try
+         {
+            testComponents();
+         }
+         finally
+         {
+            TestLifecycle.endTest();
+         }
+      }
+   }
+
+   /**
+    * Request is an abstract superclass for usually anonymous inner classes that
+    * test JSF interactions.
+    * 
+    * @author Gavin King
+    */
+   abstract class Request
+   {
+      private String conversationId;
+      private String outcome;
+      private String action;
+      private boolean validationFailed;
+      private String viewId;
+
+      private boolean renderResponseBegun;
+      private boolean renderResponseComplete;
+      private boolean invokeApplicationBegun;
+      private boolean invokeApplicationComplete;
+
+      private HttpServletRequest request;
+      private HttpServletResponse response;
+      private MockFacesContext facesContext;
+      private MockExternalContext externalContext;
+      private Map<String, Object> pageParameters = new HashMap<String, Object>();
+
+      protected void setPageParameter(String name, Object value)
+      {
+         pageParameters.put(name, value);
+      }
+
+      protected void setParameter(String name, String value)
+      {
+         getParameters().put(name, new String[] { value });
+      }
+
+      protected Map<String, String[]> getParameters()
+      {
+         return ((MockHttpServletRequest) externalContext.getRequest()).getParameters();
+      }
+
+      protected Map<String, String[]> getHeaders()
+      {
+         return ((MockHttpServletRequest) externalContext.getRequest()).getHeaders();
+      }
+
+      /**
+       * Override to define the name of the current principal
+       * 
+       * @return "gavin" by default
+       */
+      public String getPrincipalName()
+      {
+         return "gavin";
+      }
+
+      /**
+       * Override to define the roles assigned to the current principal
+       * 
+       * @return a Set of all roles by default
+       */
+      public Set<String> getPrincipalRoles()
+      {
+         return new AbstractSet<String>()
+         {
+            @Override
+            public boolean contains(Object o)
+            {
+               return true;
+            }
+
+            @Override
+            public Iterator<String> iterator()
+            {
+               throw new UnsupportedOperationException();
+            }
+
+            @Override
+            public int size()
+            {
+               throw new UnsupportedOperationException();
+            }
+         };
+      }
+
+      public List<Cookie> getCookies()
+      {
+         return Collections.EMPTY_LIST;
+      }
+
+      /**
+       * A script for a JSF interaction with no existing long-running
+       * conversation.
+       */
+      protected Request()
+      {
+      }
+
+      /**
+       * A script for a JSF interaction in the scope of an existing long-running
+       * conversation.
+       */
+      protected Request(String conversationId)
+      {
+         this.conversationId = conversationId;
+      }
+
+      /**
+       * Is this a non-faces request? Override if it is.
+       * 
+       * @return false by default
+       */
+      protected boolean isGetRequest()
+      {
+         return false;
+      }
+
+      /**
+       * The JSF view id of the form that is being submitted or of the page that
+       * is being rendered in a non-faces request. (override if you need page
+       * actions to be called, and page parameters applied)
+       */
+      protected String getViewId()
+      {
+         return viewId;
+      }
+
+      protected void setViewId(String viewId)
+      {
+         this.viewId = viewId;
+      }
+
+      /**
+       * Override to implement the interactions between the JSF page and your
+       * components that occurs during the apply request values phase.
+       */
+      protected void applyRequestValues() throws Exception
+      {
+      }
+
+      /**
+       * Override to implement the interactions between the JSF page and your
+       * components that occurs during the process validations phase.
+       */
+      protected void processValidations() throws Exception
+      {
+      }
+
+      /**
+       * Override to implement the interactions between the JSF page and your
+       * components that occurs during the update model values phase.
+       */
+      protected void updateModelValues() throws Exception
+      {
+      }
+
+      /**
+       * Override to implement the interactions between the JSF page and your
+       * components that occurs during the invoke application phase.
+       */
+      protected void invokeApplication() throws Exception
+      {
+      }
+
+      /**
+       * Set the outcome of the INVOKE_APPLICATION phase
+       */
+      protected void setOutcome(String outcome)
+      {
+         this.outcome = outcome;
+      }
+
+      /**
+       * The outcome of the INVOKE_APPLICATION phase
+       */
+      protected String getOutcome()
+      {
+         return outcome;
+      }
+
+      /**
+       * Get the outcome of the INVOKE_APPLICATION phase
+       */
+      protected String getInvokeApplicationOutcome()
+      {
+         return outcome;
+      }
+
+      /**
+       * Override to implement the interactions between the JSF page and your
+       * components that occurs during the render response phase.
+       */
+      protected void renderResponse() throws Exception
+      {
+      }
+
+      /**
+       * Make some assertions, after the end of the request.
+       */
+      protected void afterRequest()
+      {
+      }
+
+      /**
+       * Do anything you like, after the start of the request. Especially, set
+       * up any request parameters for the request.
+       */
+      protected void beforeRequest()
+      {
+      }
+
+      /**
+       * Get the view id to be rendered
+       * 
+       * @return the JSF view id
+       */
+      protected String getRenderedViewId()
+      {
+         if (Init.instance().isJbpmInstalled() && Pageflow.instance().isInProcess())
+         {
+            return Pageflow.instance().getPageViewId();
+         }
+         else
+         {
+            // TODO: not working right now, 'cos no mock navigation handler!
+            return getFacesContext().getViewRoot().getViewId();
+         }
+      }
+
+      /**
+       * Did a validation failure occur during a call to validate()?
+       */
+      protected boolean isValidationFailure()
+      {
+         return validationFailed;
+      }
+
+      protected FacesContext getFacesContext()
+      {
+         return facesContext;
+      }
+
+      protected String getConversationId()
+      {
+         return conversationId;
+      }
+
+      /**
+       * Evaluate (get) a value binding
+       */
+      protected Object getValue(String valueExpression)
+      {
+         return application.evaluateExpressionGet(facesContext, valueExpression, Object.class);
+      }
+
+      /**
+       * Set a value binding
+       */
+      protected void setValue(String valueExpression, Object value)
+      {
+         application.getExpressionFactory().createValueExpression(facesContext.getELContext(), valueExpression, Object.class).setValue(facesContext.getELContext(), value);
+      }
+
+      /**
+       * Validate the value against model-based constraints return true if the
+       * value is valid
+       */
+      protected boolean validateValue(String valueExpression, Object value)
+      {
+         ValueExpression ve = application.getExpressionFactory().createValueExpression(facesContext.getELContext(), valueExpression, Object.class);
+         InvalidValue[] ivs = Validators.instance().validate(ve, facesContext.getELContext(), value);
+         if (ivs.length > 0)
+         {
+            validationFailed = true;
+            facesContext.addMessage(null, FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, ivs[0].getMessage()));
+            return false;
+         }
+         else
+         {
+            return true;
+         }
+      }
+
+      protected void onException(Exception e)
+      {
+         throw new AssertionError(e);
+      }
+
+      /**
+       * Call a method binding
+       */
+      protected Object invokeMethod(String methodExpression)
+      {
+         return application.getExpressionFactory().createMethodExpression(facesContext.getELContext(), methodExpression, Object.class, new Class[0]).invoke(facesContext.getELContext(), null);
+      }
+
+      /**
+       * Simulate an action method
+       */
+      protected Object invokeAction(String actionMethodExpression)
+      {
+         action = actionMethodExpression;
+         Object result = invokeMethod(actionMethodExpression);
+         if (result != null)
+         {
+            setOutcome(result.toString());
+         }
+         return result;
+      }
+
+      /**
+       * @return the conversation id
+       * @throws Exception to fail the test
+       */
+      public String run() throws Exception
+      {
+         try
+         {
+            init();
+            beforeRequest();
+            setStandardJspVariables();
+            seamFilter.doFilter(request, response, new FilterChain()
+            {
+               public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException
+               {
+                  try
+                  {
+                     if (emulateJsfLifecycle())
+                     {
+                        saveConversationViewRoot();
+                     }
+                  }
+                  catch (Exception e)
+                  {
+                     onException(e);
+                     throw new ServletException(e);
+                  }
+               }
+            });
+            seamFilter.destroy();
+            afterRequest();
+            return conversationId;
+         }
+         finally
+         {
+            if (Contexts.isEventContextActive())
+            {
+               FacesLifecycle.endRequest(externalContext);
+            }
+         }
+
+      }
+
+      private void saveConversationViewRoot()
+      {
+         Map renderedViewRootAttributes = facesContext.getViewRoot().getAttributes();
+         if (renderedViewRootAttributes != null && conversationId != null)
+         {
+            Map conversationState = new HashMap();
+            conversationState.putAll(renderedViewRootAttributes);
+            conversationViewRootAttributes.put(conversationId, conversationState);
+         }
+      }
+
+      protected void init()
+      {
+         Cookie[] cookieArray = getCookies().toArray(new Cookie[] {});
+         request = new MockHttpServletRequest(session, getPrincipalName(), getPrincipalRoles(), cookieArray, isGetRequest() ? "GET" : "POST");
+         response = new MockHttpServletResponse();
+         externalContext = new MockExternalContext(servletContext, request, response);
+         facesContext = new MockFacesContext(externalContext, application);
+         facesContext.setCurrent();
+      }
+
+      private void setStandardJspVariables()
+      {
+         // TODO: looks like we should also set request, session, application,
+         // page...
+         Map<String, String> params = new HashMap<String, String>();
+         for (Map.Entry<String, String[]> e : ((Map<String, String[]>) request.getParameterMap()).entrySet())
+         {
+            if (e.getValue().length == 1)
+            {
+               params.put(e.getKey(), e.getValue()[0]);
+            }
+         }
+         request.setAttribute("param", params);
+      }
+
+      /**
+       * @return true if a response was rendered
+       */
+      private boolean emulateJsfLifecycle() throws Exception
+      {
+         restoreViewPhase();
+         if (!isGetRequest() && !skipToRender())
+         {
+            applyRequestValuesPhase();
+            if (!skipToRender())
+            {
+               processValidationsPhase();
+               if (!skipToRender())
+               {
+                  updateModelValuesPhase();
+                  if (!skipToRender())
+                  {
+                     invokeApplicationPhase();
+                  }
+               }
+            }
+         }
+
+         if (skipRender())
+         {
+            // we really should look at redirect parameters here!
+            return false;
+         }
+         else
+         {
+            renderResponsePhase();
+            return true;
+         }
+      }
+
+      private void renderResponsePhase() throws Exception
+      {
+         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, MockLifecycle.INSTANCE));
+
+         try
+         {
+            updateConversationId();
+
+            renderResponseBegun = true;
+
+            renderResponse();
+
+            renderResponseComplete = true;
+
+            facesContext.getApplication().getStateManager().saveView(facesContext);
+
+            updateConversationId();
+         }
+         finally
+         {
+            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, MockLifecycle.INSTANCE));
+         }
+      }
+
+      private void invokeApplicationPhase() throws Exception
+      {
+         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, MockLifecycle.INSTANCE));
+         try
+         {
+            updateConversationId();
+
+            invokeApplicationBegun = true;
+
+            invokeApplication();
+
+            invokeApplicationComplete = true;
+
+            String outcome = getInvokeApplicationOutcome();
+            facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, action, outcome);
+
+            viewId = getRenderedViewId();
+
+            updateConversationId();
+         }
+         finally
+         {
+            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, MockLifecycle.INSTANCE));
+         }
+      }
+
+      private void updateModelValuesPhase() throws Exception
+      {
+         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.UPDATE_MODEL_VALUES, MockLifecycle.INSTANCE));
+         try
+         {
+            updateConversationId();
+
+            updateModelValues();
+
+            updateConversationId();
+         }
+         finally
+         {
+            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.UPDATE_MODEL_VALUES, MockLifecycle.INSTANCE));
+         }
+      }
+
+      private void processValidationsPhase() throws Exception
+      {
+         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.PROCESS_VALIDATIONS, MockLifecycle.INSTANCE));
+         try
+         {
+            updateConversationId();
+
+            processValidations();
+
+            updateConversationId();
+
+            if (isValidationFailure())
+            {
+               facesContext.renderResponse();
+            }
+         }
+         finally
+         {
+            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.PROCESS_VALIDATIONS, MockLifecycle.INSTANCE));
+         }
+      }
+
+      private void applyRequestValuesPhase() throws Exception
+      {
+         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.APPLY_REQUEST_VALUES, MockLifecycle.INSTANCE));
+         try
+         {
+            updateConversationId();
+
+            applyRequestValues();
+
+            updateConversationId();
+         }
+         finally
+         {
+            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.APPLY_REQUEST_VALUES, MockLifecycle.INSTANCE));
+         }
+      }
+
+      private void restoreViewPhase()
+      {
+         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.RESTORE_VIEW, MockLifecycle.INSTANCE));
+         try
+         {
+            UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext, getViewId());
+            facesContext.setViewRoot(viewRoot);
+            Map restoredViewRootAttributes = facesContext.getViewRoot().getAttributes();
+            if (conversationId != null)
+            {
+               if (isGetRequest())
+               {
+                  setParameter(Manager.instance().getConversationIdParameter(), conversationId);
+                  // TODO: what about conversationIsLongRunning????
+               }
+               else
+               {
+                  if (conversationViewRootAttributes.containsKey(conversationId))
+                  {
+                     // should really only do this if the view id matches (not
+                     // really possible to implement)
+                     Map state = conversationViewRootAttributes.get(conversationId);
+                     restoredViewRootAttributes.putAll(state);
+                  }
+               }
+            }
+            if (isGetRequest())
+            {
+               facesContext.renderResponse();
+            }
+            else
+            {
+               restoredViewRootAttributes.putAll(pageParameters);
+            }
+         }
+         finally
+         {
+            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.RESTORE_VIEW, MockLifecycle.INSTANCE));
+         }
+      }
+
+      private void updateConversationId()
+      {
+         Manager manager = Manager.instance();
+         conversationId = manager.isLongRunningConversation() ? manager.getCurrentConversationId() : manager.getParentConversationId();
+      }
+
+      private boolean skipRender()
+      {
+         return FacesContext.getCurrentInstance().getResponseComplete();
+      }
+
+      private boolean skipToRender()
+      {
+         return FacesContext.getCurrentInstance().getRenderResponse() || FacesContext.getCurrentInstance().getResponseComplete();
+      }
+
+      protected boolean isInvokeApplicationBegun()
+      {
+         return invokeApplicationBegun;
+      }
+
+      protected boolean isInvokeApplicationComplete()
+      {
+         return invokeApplicationComplete;
+      }
+
+      protected boolean isRenderResponseBegun()
+      {
+         return renderResponseBegun;
+      }
+
+      protected boolean isRenderResponseComplete()
+      {
+         return renderResponseComplete;
+      }
+
+      protected MimeMessage getRenderedMailMessage(String viewId)
+      {
+         installMockTransport();
+         MockTransport.clearMailMessage();
+         Renderer.instance().render(viewId);
+         return MockTransport.getMailMessage();
+      }
+
+   }
+
+   public class NonFacesRequest extends Request
+   {
+      public NonFacesRequest()
+      {
+      }
+
+      /**
+       * @param viewId the view id to be rendered
+       */
+      public NonFacesRequest(String viewId)
+      {
+         setViewId(viewId);
+      }
+
+      /**
+       * @param viewId the view id to be rendered
+       * @param conversationId the conversation id
+       */
+      public NonFacesRequest(String viewId, String conversationId)
+      {
+         super(conversationId);
+         setViewId(viewId);
+      }
+
+      @Override
+      protected final boolean isGetRequest()
+      {
+         return true;
+      }
+
+      @Override
+      protected final void applyRequestValues() throws Exception
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      @Override
+      protected final void processValidations() throws Exception
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      @Override
+      protected final void updateModelValues() throws Exception
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      @Override
+      protected final void invokeApplication() throws Exception
+      {
+         throw new UnsupportedOperationException();
+      }
+
+   }
+
+   public class FacesRequest extends Request
+   {
+
+      public FacesRequest()
+      {
+      }
+
+      /**
+       * @param viewId the view id of the form that was submitted
+       */
+      public FacesRequest(String viewId)
+      {
+         setViewId(viewId);
+      }
+
+      /**
+       * @param viewId the view id of the form that was submitted
+       * @param conversationId the conversation id
+       */
+      public FacesRequest(String viewId, String conversationId)
+      {
+         super(conversationId);
+         setViewId(viewId);
+      }
+
+      @Override
+      protected final boolean isGetRequest()
+      {
+         return false;
+      }
+
+   }
+
+   public void begin()
+   {
+      session = new MockHttpSession(servletContext);
+      ServletLifecycle.beginSession(session);
+   }
+
+   public void end()
+   {
+      ServletLifecycle.endSession(session);
+      session = null;
+   }
+   
+   /**
+    * Boot Seam. Can be used at class, test group or suite level (e.g.
+    * @BeforeClass, @BeforeTest, @BeforeSuite)
+    * Use in conjunction with {@link #stopSeam()}.
+    * @throws Exception
+    */
+   protected void startSeam() throws Exception
+   {
+      startJbossEmbeddedIfNecessary();
+      servletContext = new MockServletContext();
+      initServletContext(servletContext.getInitParameters());
+      ServletLifecycle.beginApplication(servletContext);
+      new Initialization(servletContext).create().init();
+      ((Init) servletContext.getAttribute(Seam.getComponentName(Init.class))).setDebug(false);
+   }
+   
+   /**
+    * Shutdown Seam. Can be used at class, test group or suite level (e.g
+    * @AfterClass, @AfterTest, @AfterSuite)
+    * Use in conjunction with {@link #startSeam()}.
+    * @throws Exception
+    */
+   protected void stopSeam() throws Exception
+   {
+      ServletLifecycle.endApplication();
+   }
+   
+   /**
+    * Setup this test class instance
+    * Must be run for each test class instance (e.g. @BeforeClass)
+    * @throws Exception
+    */
+   protected void setupClass() throws Exception
+   {
+      servletContext = (MockServletContext) ServletLifecycle.getServletContext();
+      application = new SeamApplication(new MockApplication());
+      conversationViewRootAttributes = new HashMap<String, Map>();
+      seamFilter = createSeamFilter();
+      
+      for (ELResolver elResolver : getELResolvers())
+      {
+         application.addELResolver(elResolver);
+      }
+   }
+   
+   /**
+    * Cleanup this test class instance
+    * Must be run for each test class instance (e.g. @AfterClass)
+    */
+   protected void cleanupClass() throws Exception
+   {
+      seamFilter.destroy();
+      conversationViewRootAttributes = null;
+   }
+
+   protected Filter createSeamFilter() throws ServletException
+   {
+      SeamFilter seamFilter = new SeamFilter();
+      seamFilter.init(new MockFilterConfig(servletContext));
+      return seamFilter;
+   }
+
+   /**
+    * Override to set up any servlet context attributes.
+    */
+   public void initServletContext(Map initParams)
+   {
+   }
+
+   protected InitialContext getInitialContext() throws NamingException
+   {
+      return Naming.getInitialContext();
+   }
+
+   protected UserTransaction getUserTransaction() throws NamingException
+   {
+      return Transaction.instance();
+   }
+
+   /**
+    * Get the value of an object field, by reflection.
+    */
+   protected Object getField(Object object, String fieldName)
+   {
+      Field field = Reflections.getField(object.getClass(), fieldName);
+      if (!field.isAccessible())
+         field.setAccessible(true);
+      return Reflections.getAndWrap(field, object);
+   }
+
+   /**
+    * Set the value of an object field, by reflection.
+    */
+   protected void setField(Object object, String fieldName, Object value)
+   {
+      Field field = Reflections.getField(object.getClass(), fieldName);
+      if (!field.isAccessible())
+         field.setAccessible(true);
+      Reflections.setAndWrap(field, object, value);
+   }
+
+   private static boolean started;
+
+   protected void startJbossEmbeddedIfNecessary() throws Exception
+   {
+      if (!started && embeddedJBossAvailable())
+      {
+         new EmbeddedBootstrap().startAndDeployResources();
+      }
+
+      started = true;
+   }
+
+   private boolean embeddedJBossAvailable()
+   {
+      try
+      {
+         Class.forName("org.jboss.embedded.Bootstrap");
+         return true;
+      }
+      catch (ClassNotFoundException e)
+      {
+         return false;
+      }
+   }
+
+   protected ELResolver[] getELResolvers()
+   {
+      return new ELResolver[0];
+   }
+
+   protected void installMockTransport()
+   {
+      Contexts.getApplicationContext().set(Seam.getComponentName(MailSession.class), new MailSession("mock").create());
+
+   }
+
+}


Property changes on: trunk/src/main/org/jboss/seam/mock/AbstractSeamTest.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Deleted: trunk/src/main/org/jboss/seam/mock/BaseSeamTest.java
===================================================================
--- trunk/src/main/org/jboss/seam/mock/BaseSeamTest.java	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/main/org/jboss/seam/mock/BaseSeamTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -1,1071 +0,0 @@
-package org.jboss.seam.mock;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.AbstractSet;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.el.ELResolver;
-import javax.el.ValueExpression;
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseEvent;
-import javax.faces.event.PhaseId;
-import javax.mail.internet.MimeMessage;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.transaction.UserTransaction;
-
-import org.hibernate.validator.ClassValidator;
-import org.hibernate.validator.InvalidValue;
-import org.jboss.seam.Component;
-import org.jboss.seam.Seam;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.contexts.FacesLifecycle;
-import org.jboss.seam.contexts.ServletLifecycle;
-import org.jboss.seam.contexts.TestLifecycle;
-import org.jboss.seam.core.Expressions;
-import org.jboss.seam.core.Init;
-import org.jboss.seam.core.Manager;
-import org.jboss.seam.core.Validators;
-import org.jboss.seam.faces.FacesMessages;
-import org.jboss.seam.faces.Renderer;
-import org.jboss.seam.init.Initialization;
-import org.jboss.seam.jsf.SeamApplication;
-import org.jboss.seam.jsf.SeamPhaseListener;
-import org.jboss.seam.mail.MailSession;
-import org.jboss.seam.pageflow.Pageflow;
-import org.jboss.seam.servlet.SeamFilter;
-import org.jboss.seam.servlet.ServletSessionMap;
-import org.jboss.seam.transaction.Transaction;
-import org.jboss.seam.util.Naming;
-import org.jboss.seam.util.Reflections;
-
-/**
- * Base class for integration tests for JSF/Seam applications. This class can be
- * extended or referenced directly for integration with various testing
- * frameworks.
- * 
- * @author Gavin King
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- */
-public class BaseSeamTest
-{
-
-   private Application application;
-   private MockServletContext servletContext;
-   private SeamPhaseListener phases;
-   private MockHttpSession session;
-   private Map<String, Map> conversationViewRootAttributes;
-   private Filter seamFilter;
-
-   protected boolean isSessionInvalid()
-   {
-      return session.isInvalid();
-   }
-
-   protected HttpSession getSession()
-   {
-      return session;
-   }
-
-   /**
-    * Helper method for resolving components in the test script.
-    */
-   protected Object getInstance(Class clazz)
-   {
-      return Component.getInstance(clazz);
-   }
-
-   /**
-    * Helper method for resolving components in the test script.
-    */
-   protected Object getInstance(String name)
-   {
-      return Component.getInstance(name);
-   }
-
-   /**
-    * Is there a long running conversation associated with the current request?
-    */
-   protected boolean isLongRunningConversation()
-   {
-      return Manager.instance().isLongRunningConversation();
-   }
-
-   /**
-    * Search in all contexts
-    */
-   public Object lookup(String name)
-   {
-      return Contexts.lookupInStatefulContexts(name);
-   }
-
-   /**
-    * @deprecated use FacesRequest or NonFacesRequest
-    * @author Gavin King
-    */
-   public abstract class Script extends Request
-   {
-      public Script()
-      {
-      }
-
-      public Script(String conversationId)
-      {
-         super(conversationId);
-      }
-   }
-
-   public abstract class ComponentTest
-   {
-      /**
-       * Call a method binding
-       */
-      protected Object invokeMethod(String methodExpression)
-      {
-         return Expressions.instance().createMethodExpression(methodExpression).invoke();
-      }
-
-      /**
-       * Evaluate (get) a value binding
-       */
-      protected Object getValue(String valueExpression)
-      {
-         return Expressions.instance().createValueExpression(valueExpression).getValue();
-      }
-
-      /**
-       * Set a value binding
-       */
-      protected void setValue(String valueExpression, Object value)
-      {
-         Expressions.instance().createValueExpression(valueExpression).setValue(value);
-      }
-
-      protected abstract void testComponents() throws Exception;
-
-      public void run() throws Exception
-      {
-         TestLifecycle.beginTest(servletContext, new ServletSessionMap(session));
-         try
-         {
-            testComponents();
-         }
-         finally
-         {
-            TestLifecycle.endTest();
-         }
-      }
-   }
-
-   /**
-    * Request is an abstract superclass for usually anonymous inner classes that
-    * test JSF interactions.
-    * 
-    * @author Gavin King
-    */
-   abstract class Request
-   {
-      private String conversationId;
-      private String outcome;
-      private String action;
-      private boolean validationFailed;
-      private String viewId;
-
-      private boolean renderResponseBegun;
-      private boolean renderResponseComplete;
-      private boolean invokeApplicationBegun;
-      private boolean invokeApplicationComplete;
-
-      private HttpServletRequest request;
-      private HttpServletResponse response;
-      private MockFacesContext facesContext;
-      private MockExternalContext externalContext;
-      private Map<String, Object> pageParameters = new HashMap<String, Object>();
-
-      protected void setPageParameter(String name, Object value)
-      {
-         pageParameters.put(name, value);
-      }
-
-      protected void setParameter(String name, String value)
-      {
-         getParameters().put(name, new String[] { value });
-      }
-
-      protected Map<String, String[]> getParameters()
-      {
-         return ((MockHttpServletRequest) externalContext.getRequest()).getParameters();
-      }
-
-      protected Map<String, String[]> getHeaders()
-      {
-         return ((MockHttpServletRequest) externalContext.getRequest()).getHeaders();
-      }
-
-      /**
-       * Override to define the name of the current principal
-       * 
-       * @return "gavin" by default
-       */
-      public String getPrincipalName()
-      {
-         return "gavin";
-      }
-
-      /**
-       * Override to define the roles assigned to the current principal
-       * 
-       * @return a Set of all roles by default
-       */
-      public Set<String> getPrincipalRoles()
-      {
-         return new AbstractSet<String>()
-         {
-            @Override
-            public boolean contains(Object o)
-            {
-               return true;
-            }
-
-            @Override
-            public Iterator<String> iterator()
-            {
-               throw new UnsupportedOperationException();
-            }
-
-            @Override
-            public int size()
-            {
-               throw new UnsupportedOperationException();
-            }
-         };
-      }
-
-      public List<Cookie> getCookies()
-      {
-         return Collections.EMPTY_LIST;
-      }
-
-      /**
-       * A script for a JSF interaction with no existing long-running
-       * conversation.
-       */
-      protected Request()
-      {
-      }
-
-      /**
-       * A script for a JSF interaction in the scope of an existing long-running
-       * conversation.
-       */
-      protected Request(String conversationId)
-      {
-         this.conversationId = conversationId;
-      }
-
-      /**
-       * Is this a non-faces request? Override if it is.
-       * 
-       * @return false by default
-       */
-      protected boolean isGetRequest()
-      {
-         return false;
-      }
-
-      /**
-       * The JSF view id of the form that is being submitted or of the page that
-       * is being rendered in a non-faces request. (override if you need page
-       * actions to be called, and page parameters applied)
-       */
-      protected String getViewId()
-      {
-         return viewId;
-      }
-
-      protected void setViewId(String viewId)
-      {
-         this.viewId = viewId;
-      }
-
-      /**
-       * Override to implement the interactions between the JSF page and your
-       * components that occurs during the apply request values phase.
-       */
-      protected void applyRequestValues() throws Exception
-      {
-      }
-
-      /**
-       * Override to implement the interactions between the JSF page and your
-       * components that occurs during the process validations phase.
-       */
-      protected void processValidations() throws Exception
-      {
-      }
-
-      /**
-       * Override to implement the interactions between the JSF page and your
-       * components that occurs during the update model values phase.
-       */
-      protected void updateModelValues() throws Exception
-      {
-      }
-
-      /**
-       * Override to implement the interactions between the JSF page and your
-       * components that occurs during the invoke application phase.
-       */
-      protected void invokeApplication() throws Exception
-      {
-      }
-
-      /**
-       * Set the outcome of the INVOKE_APPLICATION phase
-       */
-      protected void setOutcome(String outcome)
-      {
-         this.outcome = outcome;
-      }
-
-      /**
-       * The outcome of the INVOKE_APPLICATION phase
-       */
-      protected String getOutcome()
-      {
-         return outcome;
-      }
-
-      /**
-       * Get the outcome of the INVOKE_APPLICATION phase
-       */
-      protected String getInvokeApplicationOutcome()
-      {
-         return outcome;
-      }
-
-      /**
-       * Override to implement the interactions between the JSF page and your
-       * components that occurs during the render response phase.
-       */
-      protected void renderResponse() throws Exception
-      {
-      }
-
-      /**
-       * Override to set up any request parameters for the request.
-       * 
-       * @deprecated use beforeRequest()
-       */
-      protected void setup()
-      {
-      }
-
-      /**
-       * Make some assertions, after the end of the request.
-       */
-      protected void afterRequest()
-      {
-      }
-
-      /**
-       * Do anything you like, after the start of the request. Especially, set
-       * up any request parameters for the request.
-       */
-      protected void beforeRequest()
-      {
-         setup();
-      }
-
-      /**
-       * Get the view id to be rendered
-       * 
-       * @return the JSF view id
-       */
-      protected String getRenderedViewId()
-      {
-         if (Init.instance().isJbpmInstalled() && Pageflow.instance().isInProcess())
-         {
-            return Pageflow.instance().getPageViewId();
-         }
-         else
-         {
-            // TODO: not working right now, 'cos no mock navigation handler!
-            return getFacesContext().getViewRoot().getViewId();
-         }
-      }
-
-      /**
-       * @deprecated use validateValue()
-       */
-      protected void validate(Class modelClass, String property, Object value)
-      {
-         ClassValidator validator = Validators.instance().getValidator(modelClass);
-         InvalidValue[] ivs = validator.getPotentialInvalidValues(property, value);
-         if (ivs.length > 0)
-         {
-            validationFailed = true;
-            FacesMessage message = FacesMessages.createFacesMessage(FacesMessage.SEVERITY_WARN, ivs[0].getMessage());
-            FacesContext.getCurrentInstance().addMessage(property, /* TODO */message);
-            FacesContext.getCurrentInstance().renderResponse();
-         }
-      }
-
-      /**
-       * Did a validation failure occur during a call to validate()?
-       */
-      protected boolean isValidationFailure()
-      {
-         return validationFailed;
-      }
-
-      protected FacesContext getFacesContext()
-      {
-         return facesContext;
-      }
-
-      protected String getConversationId()
-      {
-         return conversationId;
-      }
-
-      /**
-       * Evaluate (get) a value binding
-       */
-      protected Object getValue(String valueExpression)
-      {
-         return application.evaluateExpressionGet(facesContext, valueExpression, Object.class);
-      }
-
-      /**
-       * Set a value binding
-       */
-      protected void setValue(String valueExpression, Object value)
-      {
-         application.getExpressionFactory().createValueExpression(facesContext.getELContext(), valueExpression, Object.class).setValue(facesContext.getELContext(), value);
-      }
-
-      /**
-       * Validate the value against model-based constraints return true if the
-       * value is valid
-       */
-      protected boolean validateValue(String valueExpression, Object value)
-      {
-         ValueExpression ve = application.getExpressionFactory().createValueExpression(facesContext.getELContext(), valueExpression, Object.class);
-         InvalidValue[] ivs = Validators.instance().validate(ve, facesContext.getELContext(), value);
-         if (ivs.length > 0)
-         {
-            validationFailed = true;
-            facesContext.addMessage(null, FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, ivs[0].getMessage()));
-            return false;
-         }
-         else
-         {
-            return true;
-         }
-      }
-
-      protected void onException(Exception e)
-      {
-         throw new AssertionError(e);
-      }
-
-      /**
-       * Call a method binding
-       */
-      protected Object invokeMethod(String methodExpression)
-      {
-         return application.getExpressionFactory().createMethodExpression(facesContext.getELContext(), methodExpression, Object.class, new Class[0]).invoke(facesContext.getELContext(), null);
-      }
-
-      /**
-       * Simulate an action method
-       */
-      protected Object invokeAction(String actionMethodExpression)
-      {
-         action = actionMethodExpression;
-         Object result = invokeMethod(actionMethodExpression);
-         if (result != null)
-         {
-            setOutcome(result.toString());
-         }
-         return result;
-      }
-
-      /**
-       * @return the conversation id
-       * @throws Exception to fail the test
-       */
-      public String run() throws Exception
-      {
-         try
-         {
-            init();
-            beforeRequest();
-            setStandardJspVariables();
-            seamFilter.doFilter(request, response, new FilterChain()
-            {
-               public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException
-               {
-                  try
-                  {
-                     if (emulateJsfLifecycle())
-                     {
-                        saveConversationViewRoot();
-                     }
-                  }
-                  catch (Exception e)
-                  {
-                     onException(e);
-                     throw new ServletException(e);
-                  }
-               }
-            });
-            seamFilter.destroy();
-            afterRequest();
-            return conversationId;
-         }
-         finally
-         {
-            if (Contexts.isEventContextActive())
-            {
-               FacesLifecycle.endRequest(externalContext);
-            }
-         }
-
-      }
-
-      private void saveConversationViewRoot()
-      {
-         Map renderedViewRootAttributes = facesContext.getViewRoot().getAttributes();
-         if (renderedViewRootAttributes != null && conversationId != null)
-         {
-            Map conversationState = new HashMap();
-            conversationState.putAll(renderedViewRootAttributes);
-            conversationViewRootAttributes.put(conversationId, conversationState);
-         }
-      }
-
-      protected void init()
-      {
-         Cookie[] cookieArray = getCookies().toArray(new Cookie[] {});
-         request = new MockHttpServletRequest(session, getPrincipalName(), getPrincipalRoles(), cookieArray, isGetRequest() ? "GET" : "POST");
-         response = new MockHttpServletResponse();
-         externalContext = new MockExternalContext(servletContext, request, response);
-         facesContext = new MockFacesContext(externalContext, application);
-         facesContext.setCurrent();
-      }
-
-      private void setStandardJspVariables()
-      {
-         // TODO: looks like we should also set request, session, application,
-         // page...
-         Map<String, String> params = new HashMap<String, String>();
-         for (Map.Entry<String, String[]> e : ((Map<String, String[]>) request.getParameterMap()).entrySet())
-         {
-            if (e.getValue().length == 1)
-            {
-               params.put(e.getKey(), e.getValue()[0]);
-            }
-         }
-         request.setAttribute("param", params);
-      }
-
-      /**
-       * @return true if a response was rendered
-       */
-      private boolean emulateJsfLifecycle() throws Exception
-      {
-         restoreViewPhase();
-         if (!isGetRequest() && !skipToRender())
-         {
-            applyRequestValuesPhase();
-            if (!skipToRender())
-            {
-               processValidationsPhase();
-               if (!skipToRender())
-               {
-                  updateModelValuesPhase();
-                  if (!skipToRender())
-                  {
-                     invokeApplicationPhase();
-                  }
-               }
-            }
-         }
-
-         if (skipRender())
-         {
-            // we really should look at redirect parameters here!
-            return false;
-         }
-         else
-         {
-            renderResponsePhase();
-            return true;
-         }
-      }
-
-      private void renderResponsePhase() throws Exception
-      {
-         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, MockLifecycle.INSTANCE));
-
-         try
-         {
-            updateConversationId();
-
-            renderResponseBegun = true;
-
-            renderResponse();
-
-            renderResponseComplete = true;
-
-            facesContext.getApplication().getStateManager().saveView(facesContext);
-
-            updateConversationId();
-         }
-         finally
-         {
-            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, MockLifecycle.INSTANCE));
-         }
-      }
-
-      private void invokeApplicationPhase() throws Exception
-      {
-         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, MockLifecycle.INSTANCE));
-         try
-         {
-            updateConversationId();
-
-            invokeApplicationBegun = true;
-
-            invokeApplication();
-
-            invokeApplicationComplete = true;
-
-            String outcome = getInvokeApplicationOutcome();
-            facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, action, outcome);
-
-            viewId = getRenderedViewId();
-
-            updateConversationId();
-         }
-         finally
-         {
-            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, MockLifecycle.INSTANCE));
-         }
-      }
-
-      private void updateModelValuesPhase() throws Exception
-      {
-         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.UPDATE_MODEL_VALUES, MockLifecycle.INSTANCE));
-         try
-         {
-            updateConversationId();
-
-            updateModelValues();
-
-            updateConversationId();
-         }
-         finally
-         {
-            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.UPDATE_MODEL_VALUES, MockLifecycle.INSTANCE));
-         }
-      }
-
-      private void processValidationsPhase() throws Exception
-      {
-         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.PROCESS_VALIDATIONS, MockLifecycle.INSTANCE));
-         try
-         {
-            updateConversationId();
-
-            processValidations();
-
-            updateConversationId();
-
-            if (isValidationFailure())
-            {
-               facesContext.renderResponse();
-            }
-         }
-         finally
-         {
-            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.PROCESS_VALIDATIONS, MockLifecycle.INSTANCE));
-         }
-      }
-
-      private void applyRequestValuesPhase() throws Exception
-      {
-         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.APPLY_REQUEST_VALUES, MockLifecycle.INSTANCE));
-         try
-         {
-            updateConversationId();
-
-            applyRequestValues();
-
-            updateConversationId();
-         }
-         finally
-         {
-            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.APPLY_REQUEST_VALUES, MockLifecycle.INSTANCE));
-         }
-      }
-
-      private void restoreViewPhase()
-      {
-         phases.beforePhase(new PhaseEvent(facesContext, PhaseId.RESTORE_VIEW, MockLifecycle.INSTANCE));
-         try
-         {
-            UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext, getViewId());
-            facesContext.setViewRoot(viewRoot);
-            Map restoredViewRootAttributes = facesContext.getViewRoot().getAttributes();
-            if (conversationId != null)
-            {
-               if (isGetRequest())
-               {
-                  setParameter(Manager.instance().getConversationIdParameter(), conversationId);
-                  // TODO: what about conversationIsLongRunning????
-               }
-               else
-               {
-                  if (conversationViewRootAttributes.containsKey(conversationId))
-                  {
-                     // should really only do this if the view id matches (not
-                     // really possible to implement)
-                     Map state = conversationViewRootAttributes.get(conversationId);
-                     restoredViewRootAttributes.putAll(state);
-                  }
-               }
-            }
-            if (isGetRequest())
-            {
-               facesContext.renderResponse();
-            }
-            else
-            {
-               restoredViewRootAttributes.putAll(pageParameters);
-            }
-         }
-         finally
-         {
-            phases.afterPhase(new PhaseEvent(facesContext, PhaseId.RESTORE_VIEW, MockLifecycle.INSTANCE));
-         }
-      }
-
-      private void updateConversationId()
-      {
-         Manager manager = Manager.instance();
-         conversationId = manager.isLongRunningConversation() ? manager.getCurrentConversationId() : manager.getParentConversationId();
-      }
-
-      private boolean skipRender()
-      {
-         return FacesContext.getCurrentInstance().getResponseComplete();
-      }
-
-      private boolean skipToRender()
-      {
-         return FacesContext.getCurrentInstance().getRenderResponse() || FacesContext.getCurrentInstance().getResponseComplete();
-      }
-
-      protected boolean isInvokeApplicationBegun()
-      {
-         return invokeApplicationBegun;
-      }
-
-      protected boolean isInvokeApplicationComplete()
-      {
-         return invokeApplicationComplete;
-      }
-
-      protected boolean isRenderResponseBegun()
-      {
-         return renderResponseBegun;
-      }
-
-      protected boolean isRenderResponseComplete()
-      {
-         return renderResponseComplete;
-      }
-
-      protected MimeMessage getRenderedMailMessage(String viewId)
-      {
-         installMockTransport();
-         MockTransport.clearMailMessage();
-         Renderer.instance().render(viewId);
-         return MockTransport.getMailMessage();
-      }
-
-   }
-
-   public class NonFacesRequest extends Request
-   {
-      public NonFacesRequest()
-      {
-      }
-
-      /**
-       * @param viewId the view id to be rendered
-       */
-      public NonFacesRequest(String viewId)
-      {
-         setViewId(viewId);
-      }
-
-      /**
-       * @param viewId the view id to be rendered
-       * @param conversationId the conversation id
-       */
-      public NonFacesRequest(String viewId, String conversationId)
-      {
-         super(conversationId);
-         setViewId(viewId);
-      }
-
-      @Override
-      protected final boolean isGetRequest()
-      {
-         return true;
-      }
-
-      @Override
-      protected final void applyRequestValues() throws Exception
-      {
-         throw new UnsupportedOperationException();
-      }
-
-      @Override
-      protected final void processValidations() throws Exception
-      {
-         throw new UnsupportedOperationException();
-      }
-
-      @Override
-      protected final void updateModelValues() throws Exception
-      {
-         throw new UnsupportedOperationException();
-      }
-
-      @Override
-      protected final void invokeApplication() throws Exception
-      {
-         throw new UnsupportedOperationException();
-      }
-
-   }
-
-   public class FacesRequest extends Request
-   {
-
-      public FacesRequest()
-      {
-      }
-
-      /**
-       * @param viewId the view id of the form that was submitted
-       */
-      public FacesRequest(String viewId)
-      {
-         setViewId(viewId);
-      }
-
-      /**
-       * @param viewId the view id of the form that was submitted
-       * @param conversationId the conversation id
-       */
-      public FacesRequest(String viewId, String conversationId)
-      {
-         super(conversationId);
-         setViewId(viewId);
-      }
-
-      @Override
-      protected final boolean isGetRequest()
-      {
-         return false;
-      }
-
-   }
-
-   public void begin()
-   {
-      session = new MockHttpSession(servletContext);
-      ServletLifecycle.beginSession(session);
-   }
-
-   public void end()
-   {
-      ServletLifecycle.endSession(session);
-      session = null;
-   }
-
-   public void init() throws Exception
-   {
-      startSeam();
-      setupClass();
-   }
-   
-   /**
-    * Boot Seam. Can be used at class, test group or suite level (e.g.
-    * @BeforeClass, @BeforeTest, @BeforeSuite)
-    * Use in conjunction with {@link #stopSeam()}.
-    * @throws Exception
-    */
-   protected void startSeam() throws Exception
-   {
-      startJbossEmbeddedIfNecessary();
-      servletContext = new MockServletContext();
-      initServletContext(servletContext.getInitParameters());
-      ServletLifecycle.beginApplication(servletContext);
-      new Initialization(servletContext).create().init();
-      ((Init) servletContext.getAttribute(Seam.getComponentName(Init.class))).setDebug(false);
-   }
-   
-   /**
-    * Shutdown Seam. Can be used at class, test group or suite level (e.g
-    * @AfterClass, @AfterTest, @AfterSuite)
-    * Use in conjunction with {@link #startSeam()}.
-    * @throws Exception
-    */
-   protected void stopSeam() throws Exception
-   {
-      ServletLifecycle.endApplication();
-   }
-   
-   /**
-    * Setup this test class instance
-    * Must be run for each test class instance (e.g. @BeforeClass)
-    * @throws Exception
-    */
-   protected void setupClass() throws Exception
-   {
-      servletContext = (MockServletContext) ServletLifecycle.getServletContext();
-      application = new SeamApplication(new MockApplication());
-      phases = new SeamPhaseListener();
-      conversationViewRootAttributes = new HashMap<String, Map>();
-      seamFilter = createSeamFilter();
-      
-      for (ELResolver elResolver : getELResolvers())
-      {
-         application.addELResolver(elResolver);
-      }
-   }
-   
-   /**
-    * Cleanup this test class instance
-    * Must be run for each test class instance (e.g. @AfterClass)
-    */
-   protected void cleanupClass() throws Exception
-   {
-      seamFilter.destroy();
-      conversationViewRootAttributes = null;
-   }
-
-   public void cleanup() throws Exception
-   {
-      cleanupClass();
-      stopSeam();
-   }
-
-   protected Filter createSeamFilter() throws ServletException
-   {
-      SeamFilter seamFilter = new SeamFilter();
-      seamFilter.init(new MockFilterConfig(servletContext));
-      return seamFilter;
-   }
-
-   /**
-    * Override to set up any servlet context attributes.
-    */
-   public void initServletContext(Map initParams)
-   {
-   }
-
-   protected InitialContext getInitialContext() throws NamingException
-   {
-      return Naming.getInitialContext();
-   }
-
-   protected UserTransaction getUserTransaction() throws NamingException
-   {
-      return Transaction.instance();
-   }
-
-   /**
-    * Get the value of an object field, by reflection.
-    */
-   protected Object getField(Object object, String fieldName)
-   {
-      Field field = Reflections.getField(object.getClass(), fieldName);
-      if (!field.isAccessible())
-         field.setAccessible(true);
-      return Reflections.getAndWrap(field, object);
-   }
-
-   /**
-    * Set the value of an object field, by reflection.
-    */
-   protected void setField(Object object, String fieldName, Object value)
-   {
-      Field field = Reflections.getField(object.getClass(), fieldName);
-      if (!field.isAccessible())
-         field.setAccessible(true);
-      Reflections.setAndWrap(field, object, value);
-   }
-
-   private static boolean started;
-
-   protected void startJbossEmbeddedIfNecessary() throws Exception
-   {
-      if (!started && embeddedJBossAvailable())
-      {
-         new EmbeddedBootstrap().startAndDeployResources();
-      }
-
-      started = true;
-   }
-
-   private boolean embeddedJBossAvailable()
-   {
-      try
-      {
-         Class.forName("org.jboss.embedded.Bootstrap");
-         return true;
-      }
-      catch (ClassNotFoundException e)
-      {
-         return false;
-      }
-   }
-
-   protected ELResolver[] getELResolvers()
-   {
-      return new ELResolver[0];
-   }
-
-   protected void installMockTransport()
-   {
-      Contexts.getApplicationContext().set(Seam.getComponentName(MailSession.class), new MailSession("mock").create());
-
-   }
-
-}

Deleted: trunk/src/main/org/jboss/seam/mock/DBUnitSeamTest.java
===================================================================
--- trunk/src/main/org/jboss/seam/mock/DBUnitSeamTest.java	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/main/org/jboss/seam/mock/DBUnitSeamTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -1,291 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.seam.mock;
-
-import org.dbunit.database.DatabaseConfig;
-import org.dbunit.database.DatabaseConnection;
-import org.dbunit.database.IDatabaseConnection;
-import org.dbunit.dataset.IDataSet;
-import org.dbunit.dataset.ReplacementDataSet;
-import org.dbunit.dataset.datatype.DataType;
-import org.dbunit.dataset.datatype.DataTypeException;
-import org.dbunit.dataset.datatype.DefaultDataTypeFactory;
-import org.dbunit.dataset.xml.FlatXmlDataSet;
-import org.dbunit.operation.DatabaseOperation;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.log.Logging;
-import org.testng.annotations.*;
-
-import javax.sql.DataSource;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Utility for integration testing with Seam and DBUnit datasets.
- * <p>
- * Subclass this class instead of <tt>SeamTest</tt> if you need to insert or clean data in
- * your database before and after a test. You need to implement <tt>prepareDBUnitOperations()</tt> and
- * add instances of <tt>DataSetOperation</tt>s to the * <tt>beforeTestOperations</tt> and
- * <tt>afterTestOperations</tt> lists. An example:
- * <pre>
- * public class MyTest extends DBUnitSeamTest {
- *
- *   protected void prepareDBUnitOperations() {
- *       beforeTestOperations.add(
- *          new DataSetOperation("my/datasets/BaseData.xml")
- *       );
- *       beforeTestOperations.add(
- *           new DataSetOperation("my/datasets/AdditionalData.xml", DatabaseOperation.INSERT)
- *       );
- *   }
- * ... // Various test methods with @Test annotation
- * }
- * </pre>
- * <p>
- * Note that <tt>DataSetOperation</tt> defaults to <tt>DatabaseOperation.CLEAN_INSERT</tt> if no
- * other operation is specified as a constructor argument. The above example cleans all tables defined
- * in <tt>BaseData.xml</tt>, then inserts all rows declared in <tt>BaseData.xml</tt>, then inserts
- * all the rows declared in <tt>AdditionalData.xml</tt>. This executes before every each test method
- * is invoked. If you require extra cleanup after a test method executes, add operations to the
- * <tt>afterTestOperations</tt> list.
- * </p>
- * <p>
- * A test class obtains the database connection for loading and cleaning of datasets in one of the following ways:
- * </p>
- * <dl>
- * <li>A TestNG test parameter named <tt>datasourceJndiName</tt> is provided by the TestNG test runner, which
- * automatically calls <tt>setDatasourceJndiName()</tt> on the test class before a logical test runs.</li>
- * 
- * <li>An instance of a test class is created manually and the <tt>datasourceJndiName</tt> is passed as a
- * constructor argument.</li>
- *
- * <li>An instance of a test class is created manually and the <tt>setDatasourceJndiName()</tt> method is
- * called after creation and before a test runs.</li>
- *
- * <li>A subclass overrides the <tt>getConnection()</tt> method and returns a custom database connection.</li>
- *
- * </dl>
- * <p>
- * Referential integrity checks (foreign keys) will be or have to be disabled on the database connection
- * used for DBUnit operations. This makes adding circular references in datasets easier. Referential integrity checks
- * are enabled again after the connection has been used.
- * </p>
- * <p>
- * <b>Note that the methods <tt>disableReferentialIntegrity()</tt>,
- * <tt>enableReferentialIntegrity()</tt>, and <tt>editConfig()</tt> are implemented for HSQL DB. If you want to run 
- * unit tests on any other DBMS, you need to override these methods and implement them for your DBMS.</b>
- * </p>
- *
- * @author Christian Bauer
- */
-public abstract class DBUnitSeamTest extends SeamTest {
-
-    private Log log = Logging.getLog(DBUnitSeamTest.class);
-
-    protected String datasourceJndiName;
-    protected List<DataSetOperation> beforeTestOperations = new ArrayList<DataSetOperation>();
-    protected List<DataSetOperation> afterTestOperations = new ArrayList<DataSetOperation>();
-
-    protected DBUnitSeamTest() {}
-
-    protected DBUnitSeamTest(String datasourceJndiName) {
-        this.datasourceJndiName = datasourceJndiName;
-    }
-
-    @BeforeClass
-    @Parameters("datasourceJndiName")
-    public void setDatasourceJndiName(String datasourceJndiName) {
-        this.datasourceJndiName = datasourceJndiName;
-    }
-
-    @BeforeClass
-    @Override
-    public void setupClass() throws Exception {
-        super.setupClass();
-        prepareDBUnitOperations();
-    }
-
-    @BeforeMethod
-    @Override
-    public void begin() {
-        super.begin();
-        executeOperations(beforeTestOperations);
-    }
-
-    @AfterMethod
-    @Override
-    public void end() {
-        super.end();
-        executeOperations(afterTestOperations);
-    }
-
-    private void executeOperations(List<DataSetOperation> list) {
-        IDatabaseConnection con = null;
-        try {
-            con = getConnection();
-            disableReferentialIntegrity(con);
-            for (DataSetOperation op : list) {
-                log.info("executing DBUnit operation: " + op);
-                op.execute(con);
-            }
-            enableReferentialIntegrity(con);
-        } finally {
-            if (con != null) {
-                try {
-                    con.close();
-                } catch (Exception ex) {
-                    ex.printStackTrace(System.err);
-                }
-            }
-        }
-    }
-
-    protected class DataSetOperation {
-        String dataSetLocation;
-        ReplacementDataSet dataSet;
-        DatabaseOperation operation;
-
-        /**
-         * Defaults to <tt>DatabaseOperation.CLEAN_INSERT</tt>
-         */
-        public DataSetOperation(String dataSetLocation){
-            this(dataSetLocation, DatabaseOperation.CLEAN_INSERT);
-        }
-
-        public DataSetOperation(String dataSetLocation, DatabaseOperation operation) {
-            log.info("preparing dataset: " + dataSetLocation);
-
-            // Load the base dataset file
-            InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(dataSetLocation);
-            try {
-                this.dataSet = new ReplacementDataSet( new FlatXmlDataSet(input) );
-            } catch (Exception ex) {
-                throw new RuntimeException(ex);
-            }
-            this.dataSet.addReplacementObject("[NULL]", null);
-            this.operation = operation;
-            this.dataSetLocation = dataSetLocation;
-        }
-
-        public IDataSet getDataSet() {
-            return dataSet;
-        }
-
-        public DatabaseOperation getOperation() {
-            return operation;
-        }
-
-        public void execute(IDatabaseConnection connection) {
-            try {
-                this.operation.execute(connection, dataSet);
-            } catch (Exception ex) {
-                throw new RuntimeException(ex);
-            }
-        }
-
-        @Override
-        public String toString() {
-            // TODO: This is not pretty because DBUnit's DatabaseOperation doesn't implement toString() properly
-            return operation.getClass() + " with dataset: " + dataSetLocation;
-        }
-    }
-
-    // Subclasses can/have to override the following methods
-
-    /**
-     * Override this method if you want to provide your own DBUnit <tt>IDatabaseConnection</tt> instance.
-     * <p/>
-     * If you do not override this, default behavior is to use the * configured datasource name and
-     * to obtain a connection with a JNDI lookup.
-     *
-     * @return a DBUnit database connection (wrapped)
-     */
-    protected IDatabaseConnection getConnection() {
-        try {
-            DataSource datasource = ((DataSource)getInitialContext().lookup(datasourceJndiName));
-
-            // Get a JDBC connection from JNDI datasource
-            Connection con = datasource.getConnection();
-            IDatabaseConnection dbUnitCon = new DatabaseConnection(con);
-            editConfig(dbUnitCon.getConfig());
-            return dbUnitCon;
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    /**
-     * Override this method if you aren't using HSQL DB.
-     * <p/>
-     * Execute whatever statement is necessary to either defer or disable foreign
-     * key constraint checking on the given database connection, which is used by
-     * DBUnit to import datasets.
-     *
-     * @param con A DBUnit connection wrapper, which is used afterwards for dataset operations
-     */
-    protected void disableReferentialIntegrity(IDatabaseConnection con) {
-        try {
-            con.getConnection().prepareStatement("set referential_integrity FALSE").execute(); // HSQL DB
-            //con.getConnection().prepareStatement("set foreign_key_checks=0").execute(); // MySQL > 4.1.1
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    /**
-     * Override this method if you aren't using HSQL DB.
-     * <p/>
-     * Execute whatever statement is necessary to enable integrity constraint checks after
-     * dataset operations.
-     *
-     * @param con A DBUnit connection wrapper, before it is used by the application again
-     */
-    protected void enableReferentialIntegrity(IDatabaseConnection con) {
-        try {
-            con.getConnection().prepareStatement("set referential_integrity TRUE").execute();  // HSQL DB
-            //con.getConnection().prepareStatement("set foreign_key_checks=1").execute(); // MySQL > 4.1.1
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    /**
-     * Override this method if you require DBUnit configuration features or additional properties.
-     * <p>
-     * Called after a connection has been obtaind and before the connection is used. Can be a
-     * NOOP method if no additional settings are necessary for your DBUnit/DBMS setup.
-     *
-     * @param config A DBUnit <tt>DatabaseConfig</tt> object for setting properties and features
-     */
-    protected void editConfig(DatabaseConfig config) {
-
-        // TODO: DBUnit/HSQL bugfix
-        // http://www.carbonfive.com/community/archives/2005/07/dbunit_hsql_and.html
-        config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new DefaultDataTypeFactory() {
-           @Override
-            public DataType createDataType(int sqlType, String sqlTypeName)
-              throws DataTypeException {
-               if (sqlType == Types.BOOLEAN) {
-                  return DataType.BOOLEAN;
-                }
-               return super.createDataType(sqlType, sqlTypeName);
-             }
-        });
-    }
-
-    /**
-     * Implement this in a subclass.
-     * <p>
-     * Use it to stack DBUnit <tt>DataSetOperation</tt>'s with
-     * the <tt>beforeTestOperations</tt> and <tt>afterTestOperations</tt> lists.
-     */
-    protected abstract void prepareDBUnitOperations();
-
-}

Added: trunk/src/main/org/jboss/seam/mock/DBUnitSeamTest.java
===================================================================
--- trunk/src/main/org/jboss/seam/mock/DBUnitSeamTest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/seam/mock/DBUnitSeamTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -0,0 +1,81 @@
+package org.jboss.seam.mock;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Parameters;
+
+public abstract class DBUnitSeamTest extends AbstractDBUnitSeamTest
+{
+
+   @Override
+   @BeforeClass
+   @Parameters("datasourceJndiName")
+   public void setDatasourceJndiName(String datasourceJndiName) 
+   {
+      super.setDatasourceJndiName(datasourceJndiName);
+   }
+
+   @Override
+   @BeforeClass
+   @Parameters("binaryDir")
+   public void setBinaryDir(String binaryDir) 
+   {
+       super.setBinaryDir(binaryDir);
+   }
+
+   @Override
+   @BeforeClass
+   @Parameters("database")
+   public void setDatabase(String database) 
+   {
+       super.setDatabase(database);
+   }
+
+   @Override
+   @BeforeClass
+   public void setupClass() throws Exception 
+   {
+       super.setupClass();
+   }
+   
+   @Override
+   @AfterClass
+   protected void cleanupClass() throws Exception
+   {
+       super.cleanupClass();
+   }
+   
+   @Override
+   @BeforeSuite
+   protected void startSeam() throws Exception
+   {
+       super.startSeam();
+   }
+   
+   @Override
+   @AfterSuite
+   protected void stopSeam() throws Exception
+   {
+       super.stopSeam();
+   } 
+   
+
+   @BeforeMethod
+   @Override
+   public void begin() 
+   {
+       super.begin();
+   }
+
+   @AfterMethod
+   @Override
+   public void end() 
+   {
+       super.end();
+   }
+   
+}


Property changes on: trunk/src/main/org/jboss/seam/mock/DBUnitSeamTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/src/main/org/jboss/seam/mock/SeamTest.java
===================================================================
--- trunk/src/main/org/jboss/seam/mock/SeamTest.java	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/main/org/jboss/seam/mock/SeamTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -8,8 +8,10 @@
 
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
 
 /**
  * Provides BaseSeamTest functionality for TestNG integration tests.
@@ -18,7 +20,7 @@
  * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  * @author Mike Youngstrom
  */
-public class SeamTest extends BaseSeamTest
+public class SeamTest extends AbstractSeamTest
 {
    
    @BeforeMethod
@@ -34,105 +36,33 @@
    {
       super.end();
    }
-
+   
    @Override
    @BeforeClass
-   public void init() throws Exception
+   public void setupClass() throws Exception
    {
-      super.init();
+      super.setupClass();
    }
-
+   
    @Override
    @AfterClass
-   public void cleanup() throws Exception
+   public void cleanupClass() throws Exception
    {
-      super.cleanup();
+      super.cleanupClass();
    }
-
-   /**
-    * A pass through to BaseSeamTest.FacesRequest. 
-    * 
-    * Deprecated, use BaseSeamTest.FacesRequest instead
-    */
-   public class FacesRequest extends BaseSeamTest.FacesRequest
+   
+   @Override
+   @BeforeSuite
+   public void startSeam() throws Exception
    {
-
-      public FacesRequest()
-      {
-         super();
-      }
-
-      public FacesRequest(String viewId, String conversationId)
-      {
-         super(viewId, conversationId);
-      }
-
-      public FacesRequest(String viewId)
-      {
-         super(viewId);
-      }
-
+      super.startSeam();
    }
-
-   /**
-    * A pass through to BaseSeamTest.NonFacesRequest.
-    * 
-    * Deprecated, use BaseSeamTest.NonFacesRequest instead
-    */
-   public class NonFacesRequest extends BaseSeamTest.NonFacesRequest
+   
+   @Override
+   @AfterSuite
+   protected void stopSeam() throws Exception
    {
-
-      public NonFacesRequest()
-      {
-         super();
-      }
-
-      public NonFacesRequest(String viewId, String conversationId)
-      {
-         super(viewId, conversationId);
-      }
-
-      public NonFacesRequest(String viewId)
-      {
-         super(viewId);
-      }
-
+      super.stopSeam();
    }
 
-   /**
-    * A pass through to BaseSeamTest.Request.
-    * 
-    * Deprecated, use BaseSeamTest.Request instead
-    */
-   public abstract class Request extends BaseSeamTest.Request
-   {
-
-      public Request()
-      {
-         super();
-      }
-
-      public Request(String conversationId)
-      {
-         super(conversationId);
-      }
-
-   }
-
-   /**
-    * @deprecated Use BaseSeamTest.FacesRequest or BaseSeamTest.NonFacesRequest instead
-    */
-   public abstract class Script extends BaseSeamTest.Script
-   {
-
-      public Script()
-      {
-         super();
-      }
-
-      public Script(String conversationId)
-      {
-         super(conversationId);
-      }
-   }
 }

Modified: trunk/src/main/org/jboss/seam/mock/package-info.java
===================================================================
--- trunk/src/main/org/jboss/seam/mock/package-info.java	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/main/org/jboss/seam/mock/package-info.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -3,6 +3,6 @@
  * Seam components, with built-in support for TestNG.
  * 
  * @see org.jboss.seam.mock.SeamTest 
- * @see org.jboss.seam.mock.BaseSeamTest 
+ * @see org.jboss.seam.mock.AbstractSeamTest 
  */
 package org.jboss.seam.mock;
\ No newline at end of file

Added: trunk/src/test/integration/src/org/jboss/seam/test/integration/Foo.java
===================================================================
--- trunk/src/test/integration/src/org/jboss/seam/test/integration/Foo.java	                        (rev 0)
+++ trunk/src/test/integration/src/org/jboss/seam/test/integration/Foo.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.seam.test.integration;
+
+import java.io.Serializable;
+
+import javax.ejb.Remove;
+
+import org.hibernate.validator.NotNull;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.End;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
+ * @version $Revision: 6435 $
+ */
+ at Name("foo")
+ at Scope(ScopeType.SESSION)
+ at SuppressWarnings("deprecation")
+public class Foo implements Serializable
+{
+   private static final long serialVersionUID = -5448030633067107049L;
+   
+   private String value;
+   
+   public String foo() { return "foo"; }
+
+   @Remove
+   public void destroy() {}
+
+   @NotNull
+   public String getValue()
+   {
+      return value;
+   }
+
+   public void setValue(String value)
+   {
+      this.value = value;
+   }
+   
+   public String bar()
+   {
+      return "bar";
+   }
+   
+   @Begin
+   public String begin()
+   {
+      return "begun";
+   }
+   @End
+   public String end()
+   {
+      return "ended";
+   }
+   
+   @Begin
+   public String beginNull()
+   {
+      return null;
+   }
+   @End
+   public String endNull()
+   {
+      return null;
+   }
+   
+   @Begin
+   public void beginVoid() { }
+   @End
+   public void endVoid() { }
+   
+   @Begin(ifOutcome="success")
+   public String beginIf()
+   {
+      return "success";
+   }
+   @End(ifOutcome="success")
+   public String endIf()
+   {
+      return "success";
+   }
+   
+}
+
+


Property changes on: trunk/src/test/integration/src/org/jboss/seam/test/integration/Foo.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: trunk/src/test/integration/src/org/jboss/seam/test/integration/ImportTest.java (from rev 7222, trunk/src/test/unit/org/jboss/seam/test/unit/ImportTest.java)
===================================================================
--- trunk/src/test/integration/src/org/jboss/seam/test/integration/ImportTest.java	                        (rev 0)
+++ trunk/src/test/integration/src/org/jboss/seam/test/integration/ImportTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -0,0 +1,46 @@
+package org.jboss.seam.test.integration;
+
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.Import;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.mock.SeamTest;
+import org.testng.annotations.Test;
+
+public class ImportTest
+    extends SeamTest
+{
+    
+    @Test
+    public void testImport() 
+        throws Exception 
+    {
+        
+        new FacesRequest() {
+            @Override
+            protected void invokeApplication()
+                throws Exception
+            {
+                assert getValue("#{importTest.otherValue}").equals("foobar2");                 
+            }        
+        }.run();
+    }
+   
+    
+    @Name("importTest")
+    @Import("importTest.ns2")
+    public static class Importer {
+        @In
+        String otherValue;
+
+        public String getOtherValue() {
+            return otherValue;
+        }
+
+        @Factory(value="importTest.ns2.otherValue", autoCreate=true)
+        public String createOtherValue() {
+            return "foobar2";
+        }
+    }
+
+}


Property changes on: trunk/src/test/integration/src/org/jboss/seam/test/integration/ImportTest.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: trunk/src/test/integration/src/org/jboss/seam/test/integration/NamespaceTest.java (from rev 7222, trunk/src/test/unit/org/jboss/seam/test/unit/NamespaceTest.java)
===================================================================
--- trunk/src/test/integration/src/org/jboss/seam/test/integration/NamespaceTest.java	                        (rev 0)
+++ trunk/src/test/integration/src/org/jboss/seam/test/integration/NamespaceTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -0,0 +1,114 @@
+package org.jboss.seam.test.integration;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.mock.SeamTest;
+import org.testng.annotations.Test;
+
+public class NamespaceTest 
+    extends SeamTest 
+{
+    @Override
+    protected void startJbossEmbeddedIfNecessary() 
+          throws org.jboss.deployers.spi.DeploymentException,
+                 java.io.IOException 
+    {
+       // don't deploy   
+    }
+    
+    
+    @Test
+    public void nameSpaceComponent() 
+        throws Exception 
+    {
+        new ComponentTest() {
+            @Override
+            protected void testComponents() throws Exception {
+                assert getValue("#{namespaceTest.fooFactory}") != null;
+            }
+        }.run();
+    }
+
+    @Test
+    public void nameSpaceFactory() 
+        throws Exception 
+    {
+        new ComponentTest() {
+            @Override
+            protected void testComponents() throws Exception {
+                assert getValue("#{namespaceTest.ns1.factory}") != null;
+            }
+        }.run();
+    }
+    
+
+    @Test
+    public void namespaceOutjection() 
+        throws Exception 
+    {
+        new ComponentTest() {
+            @Override
+            protected void testComponents() throws Exception {
+                FooFactory factory = (FooFactory) getValue("#{namespaceTest.fooFactory}");
+                factory.someMethod();
+                assert getValue("#{namespaceTest.ns2.outject}") != null;
+            }
+        }.run();
+    }
+
+    
+    @Test
+    public void factoryMethodExpression() 
+        throws Exception 
+    {
+        new ComponentTest() {
+            @Override
+            protected void testComponents() throws Exception {
+                Init init = Init.instance();
+                init.addFactoryMethodExpression("namespaceTest.ns3.factory", "#{namespaceTest.fooFactory.createFoo}", ScopeType.SESSION);
+                
+                assert getValue("#{namespaceTest.ns3.factory}") != null;
+            }
+        }.run();
+    }
+    
+    @Test
+    public void factoryValueExpression() 
+        throws Exception 
+    {
+        new ComponentTest() {
+            @Override
+            protected void testComponents() throws Exception {
+                Init init = Init.instance();
+                init.addFactoryValueExpression("namespaceTest.ns4.factory", "#{namespaceTest.fooFactory.createFoo()}", ScopeType.SESSION);
+                
+                assert getValue("#{namespaceTest.ns4.factory}") != null;
+            }
+        }.run();
+    }
+
+
+    @Name("namespaceTest.fooFactory")
+    static public class FooFactory {
+        public class Foo {}
+        
+        @Factory("namespaceTest.ns1.factory")
+        public Foo createFoo() {
+            return new Foo();
+        }        
+
+        @Out("namespaceTest.ns2.outject")
+        public Foo outjectFoo() {
+            return new Foo();
+        }
+        
+        public void someMethod() {
+        }
+    }
+    
+
+
+}


Property changes on: trunk/src/test/integration/src/org/jboss/seam/test/integration/NamespaceTest.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: trunk/src/test/integration/src/org/jboss/seam/test/integration/People.java
===================================================================
--- trunk/src/test/integration/src/org/jboss/seam/test/integration/People.java	                        (rev 0)
+++ trunk/src/test/integration/src/org/jboss/seam/test/integration/People.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -0,0 +1,35 @@
+package org.jboss.seam.test.integration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.datamodel.DataModelSelection;
+
+ at Name("people")
+public class People
+{
+   @org.jboss.seam.annotations.datamodel.DataModel(scope=ScopeType.PAGE)
+   private List<Person> peopleList;
+   
+   @DataModelSelection
+   private Person selectedPerson;
+   
+   @Factory("peopleList")
+   public void peopleFactory()
+   {
+      peopleList = new ArrayList<Person>();
+      peopleList.add(new Person("Gavin"));
+      peopleList.add(new Person("Pete"));
+      peopleList.add(new Person("Shane"));
+      peopleList.add(new Person("Norman"));
+   }
+   
+   public Person getSelectedPerson()
+   {
+      return selectedPerson;
+   }
+
+}


Property changes on: trunk/src/test/integration/src/org/jboss/seam/test/integration/People.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: trunk/src/test/integration/src/org/jboss/seam/test/integration/SeamMockELResolverTest.java
===================================================================
--- trunk/src/test/integration/src/org/jboss/seam/test/integration/SeamMockELResolverTest.java	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/test/integration/src/org/jboss/seam/test/integration/SeamMockELResolverTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -1,152 +0,0 @@
-package org.jboss.seam.test.integration;
-
-import java.beans.FeatureDescriptor;
-import java.util.Iterator;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.ELResolver;
-import javax.el.PropertyNotFoundException;
-import javax.el.PropertyNotWritableException;
-
-import org.jboss.seam.mock.SeamTest;
-import org.testng.annotations.Test;
-
-/**
- * Test for adding EL resolvers to Seam MockFacesContext
- * 
- * @author Pete Muir
- * 
- */
-public class SeamMockELResolverTest extends SeamTest
-{
-   
-   private static final String property = "customELResolverTest";
-
-   @Override
-   protected ELResolver[] getELResolvers()
-   {
-      ELResolver[] resolvers = new ELResolver[2];
-      resolvers[0] = new ELResolver()
-      {
-
-         @Override
-         public Class<?> getCommonPropertyType(ELContext arg0, Object arg1)
-         {
-            return null;
-         }
-
-         @Override
-         public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext arg0, Object arg1)
-         {
-            return null;
-         }
-
-         @Override
-         public Class<?> getType(ELContext arg0, Object base, Object property)
-                  throws NullPointerException, PropertyNotFoundException, ELException
-         {
-            return null;
-         }
-
-         @Override
-         public Object getValue(ELContext context, Object base, Object property)
-                  throws NullPointerException, PropertyNotFoundException, ELException
-         {
-            if (SeamMockELResolverTest.property.equals(property))
-            {
-               context.setPropertyResolved(true);
-               return "found";
-            }
-            return null;
-         }
-
-         @Override
-         public boolean isReadOnly(ELContext arg0, Object base, Object property)
-                  throws NullPointerException, PropertyNotFoundException, ELException
-         {
-            if (SeamMockELResolverTest.property.equals(property))
-            {
-               return false;
-            }
-            return false;
-         }
-
-         @Override
-         public void setValue(ELContext context, Object base, Object property, Object value)
-                  throws NullPointerException, PropertyNotFoundException,
-                  PropertyNotWritableException, ELException
-         {
-            if (SeamMockELResolverTest.property.equals(property))
-            {
-               throw new PropertyNotWritableException();
-            }
-         }
-
-      };
-      resolvers[1] = new ELResolver() {
-
-          @Override
-          public Class<?> getCommonPropertyType(ELContext arg0, Object arg1)
-          {
-             return null;
-          }
-
-          @Override
-          public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext arg0, Object arg1)
-          {
-             return null;
-          }
-
-          @Override
-          public Class<?> getType(ELContext arg0, Object base, Object property)
-                   throws NullPointerException, PropertyNotFoundException, ELException
-          {
-             return null;
-          }
-
-          @Override
-          public Object getValue(ELContext context, Object base, Object property)
-                   throws NullPointerException, PropertyNotFoundException, ELException
-          {
-             if (base != null && "className".equals(property))
-             {
-                context.setPropertyResolved(true);
-                return base.getClass().getSimpleName();
-             }
-             return null;
-          }
-
-          @Override
-          public boolean isReadOnly(ELContext arg0, Object base, Object property)
-                   throws NullPointerException, PropertyNotFoundException, ELException
-          {
-             return true;
-          }
-
-          @Override
-          public void setValue(ELContext context, Object base, Object property, Object value)
-                   throws NullPointerException, PropertyNotFoundException,
-                   PropertyNotWritableException, ELException
-          {
-             throw new PropertyNotWritableException();
-          }
-      };
-      return resolvers;
-   }
-
-   @Test
-   public void testCustomELResolver() throws Exception
-   {
-      new FacesRequest()
-      {
-         @Override
-         protected void invokeApplication() throws Exception
-         {
-            assert "found".equals(getValue("#{" + property + "}"));
-            assert "String".equals(getValue("#{" + property + ".className}"));
-         }
-      }.run();
-   }
-
-}

Added: trunk/src/test/integration/src/org/jboss/seam/test/integration/databinding/DataModelTest.java
===================================================================
--- trunk/src/test/integration/src/org/jboss/seam/test/integration/databinding/DataModelTest.java	                        (rev 0)
+++ trunk/src/test/integration/src/org/jboss/seam/test/integration/databinding/DataModelTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -0,0 +1,330 @@
+package org.jboss.seam.test.integration.databinding;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+
+import org.jboss.seam.faces.DataModels;
+import org.jboss.seam.jsf.ArrayDataModel;
+import org.jboss.seam.jsf.MapDataModel;
+import org.jboss.seam.jsf.SetDataModel;
+import org.jboss.seam.mock.SeamTest;
+import org.jboss.seam.test.integration.Foo;
+import org.jboss.seam.test.integration.Person;
+import org.testng.annotations.Test;
+
+public class DataModelTest extends SeamTest
+{
+   
+   @Test
+   public void testDataModels() throws Exception
+   {
+    
+      new FacesRequest()
+      {
+         @Override
+         protected void invokeApplication() throws Exception
+         {
+            DataModels dataModels = DataModels.instance();
+            
+            assert dataModels.getDataModel(new ArrayList()) instanceof ListDataModel;
+            assert dataModels.getDataModel(new HashMap()) instanceof MapDataModel;
+            assert dataModels.getDataModel(new HashSet()) instanceof SetDataModel;
+            assert dataModels.getDataModel(new Object[0]) instanceof ArrayDataModel;
+            // TODO assert dataModels.getDataModel(query) instanceof ListDataModel;
+            
+            boolean failed = false;
+            try
+            {
+               dataModels.getDataModel(new Foo());
+            }
+            catch (IllegalArgumentException e)
+            {
+               failed = true;
+            }
+            assert failed;
+         }
+      }.run();
+   }
+   
+   @Test
+   public void testArrayDataModelSerialization() throws Exception
+   {
+      String[] array = {"Seam", "Hibernate"};
+      javax.faces.model.ArrayDataModel arrayDataModel = new ArrayDataModel(array);
+      arrayDataModel.setRowIndex(1);
+      
+      Object object = null;
+      try
+      {
+         object = serialize(arrayDataModel);
+      }
+      catch (NotSerializableException e) 
+      {
+         assert false;
+      }
+      assert object instanceof javax.faces.model.ArrayDataModel;
+      
+      javax.faces.model.ArrayDataModel serializedArrayDataModel = (javax.faces.model.ArrayDataModel) object;
+      
+      assert serializedArrayDataModel.getRowIndex() == 1;
+      
+      String[] serializedArray = (String[]) serializedArrayDataModel.getWrappedData();
+      
+      assert array[0].equals(serializedArray[0]);
+      
+      assert array[1].equals(serializedArray[1]);
+   }
+   
+   // Utility to serialize an object
+   private Object serialize(Object object) throws Exception
+   {
+      ByteArrayOutputStream bos = new ByteArrayOutputStream();
+      ObjectOutputStream oos = new ObjectOutputStream(bos);
+      oos.writeObject(object);  
+      ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+      ObjectInputStream ois = new ObjectInputStream(bis);
+      return ois.readObject();
+   }
+   
+   @Test
+   public void testListDataModelSerialization() throws Exception
+   {
+      
+      List<String> list = Arrays.asList("Seam", "Hibernate");
+      javax.faces.model.ListDataModel listDataModel = new org.jboss.seam.jsf.ListDataModel(list);
+      listDataModel.setRowIndex(1);
+      
+      Object object = null;
+      try
+      {
+         object = serialize(listDataModel);
+      }
+      catch (NotSerializableException e) 
+      {
+         assert false;
+      }
+      
+      assert object instanceof javax.faces.model.ListDataModel;
+      javax.faces.model.ListDataModel serializedListDataModel = (javax.faces.model.ListDataModel) object;
+      List<String> serializedList = (List<String>) serializedListDataModel.getWrappedData();
+      
+      assert serializedListDataModel.getRowIndex() == 1;
+      assert list.get(0).equals(serializedList.get(0)); 
+      assert list.get(1).equals(serializedList.get(1));
+   }
+   
+   @Test
+   public void testMapDataModel() throws IOException, ClassNotFoundException
+   {
+      Map<String, Person> map = new HashMap<String, Person>();
+      map.put("0", new Person("Gavin"));
+      map.put("1", new Person("Tom"));
+      
+      javax.faces.model.DataModel mapDataModel = new MapDataModel();
+      
+      assert mapDataModel.getRowCount() == -1;
+      assert mapDataModel.getRowData() == null;
+      assert !mapDataModel.isRowAvailable();
+      
+      mapDataModel = new MapDataModel(map);
+      
+      assert mapDataModel.getWrappedData() instanceof Map;
+      
+      assert map.get("0").equals(((Map) mapDataModel.getWrappedData()).get("0"));
+      assert map.get("1").equals(((Map) mapDataModel.getWrappedData()).get("1"));
+      
+      mapDataModel.setRowIndex(10);
+      
+      assert !mapDataModel.isRowAvailable();
+      
+      boolean failed = false;
+      try
+      {
+         mapDataModel.getRowData();
+      }
+      catch (IllegalArgumentException e) 
+      {
+         failed = true;
+      }
+      
+      assert failed;
+      
+      mapDataModel.setRowIndex(1);
+      
+      assert mapDataModel.isRowAvailable();
+      assert mapDataModel.getRowIndex() == 1;
+      assert mapDataModel.getRowCount() == 2;
+      
+      // JBSEAM-1660
+      /*try 
+      {
+         mapDataModel.setWrappedData(null);
+      }
+      catch (NullPointerException e) 
+      {
+         // Spec allows passing null
+         assert false;
+      }*/
+   }
+   
+   //JBSEAM-1659
+   
+   /*@Test
+   public void testMapDataModelSerialization() throws Exception
+   {
+      
+      Map<String, Person> map = new HashMap<String, Person>();
+      map.put("0", new Person("Gavin"));
+      map.put("1", new Person("Tom"));
+      
+      javax.faces.model.DataModel mapDataModel = new MapDataModel(map);    
+      mapDataModel.setRowIndex(1);
+
+      Object object = null;
+      try
+      {
+         object = serialize(mapDataModel);
+      }
+      catch (NotSerializableException e) 
+      {
+         assert false;
+      }
+      
+      
+      assert object instanceof javax.faces.model.DataModel;
+      javax.faces.model.DataModel serializedMapDataModel = (javax.faces.model.DataModel) object;
+      Map<String, Person> serializedMap = (Map<String, Person>) serializedMapDataModel.getWrappedData();
+      
+      assert serializedMapDataModel.getRowIndex() == 1;
+      assert map.get("0").equals(serializedMap.get("0")); 
+      assert map.get("1").equals(serializedMap.get("1"));
+   }*/
+   
+   @Test
+   public void testSetDataModel() throws IOException, ClassNotFoundException
+   {
+      Person gavin = new Person("Gavin");
+      Person tom = new Person("Tom");
+      
+      Set<Person> set = new HashSet<Person>();
+      set.add(gavin);
+      set.add(tom);
+      
+      javax.faces.model.DataModel setDataModel = new SetDataModel();
+      
+      assert setDataModel.getRowCount() == -1;
+      assert setDataModel.getRowData() == null;
+      assert !setDataModel.isRowAvailable();
+      
+      setDataModel = new SetDataModel(set);
+      
+      assert setDataModel.getWrappedData() instanceof Set;
+      
+      assert set.contains(gavin);
+      assert set.contains(tom);
+      
+      setDataModel.setRowIndex(10);
+      
+      assert !setDataModel.isRowAvailable();
+      
+      boolean failed = false;
+      try
+      {
+         setDataModel.getRowData();
+      }
+      catch (IllegalArgumentException e) 
+      {
+         failed = true;
+      }
+      
+      assert failed;
+      
+      setDataModel.setRowIndex(1);
+      
+      assert setDataModel.isRowAvailable();
+      assert setDataModel.getRowIndex() == 1;
+      assert setDataModel.getRowCount() == 2;
+      
+      // JBSEAM-1660
+      /*try 
+      {
+         setDataModel.setWrappedData(null);
+      }
+      catch (NullPointerException e) 
+      {
+         // Spec allows passing null
+         assert false;
+      }*/
+   }
+   
+   @Test
+   public void testSetDataModelSerialization() throws Exception
+   {
+      
+      Person gavin = new Person("Gavin");
+      Person tom = new Person("Tom");
+      
+      Set<Person> set = new HashSet<Person>();
+      set.add(gavin);
+      set.add(tom);
+      
+      javax.faces.model.DataModel setDataModel = new SetDataModel(set);    
+      setDataModel.setRowIndex(1);
+
+      Object object = null;
+      try
+      {
+         object = serialize(setDataModel);
+      }
+      catch (NotSerializableException e) 
+      {
+         assert false;
+      }
+      
+      
+      assert object instanceof javax.faces.model.DataModel;
+      javax.faces.model.DataModel serializedSetDataModel = (javax.faces.model.DataModel) object;
+      Set<Person> serializedSet = (Set<Person>) serializedSetDataModel.getWrappedData();
+      
+      assert serializedSetDataModel.getRowIndex() == 1;
+      assert serializedSet.contains(gavin);
+      assert serializedSet.contains(tom);
+   }
+   
+   @Test
+   public void testDataModelOutjection() throws Exception
+   {
+      new FacesRequest()
+      {
+         
+         @Override
+         protected void renderResponse() throws Exception
+         {
+            Object people = getValue("#{peopleList}");
+            System.out.println(people);
+            assert people instanceof DataModel;
+            DataModel dataModel = (DataModel) people;
+            assert dataModel.getRowCount() == 4;
+            dataModel.setRowIndex(1);
+         }     
+         
+      }.run();
+      
+   }
+
+}

Copied: trunk/src/test/integration/src/org/jboss/seam/test/integration/mock/SeamMockELResolverTest.java (from rev 7222, trunk/src/test/integration/src/org/jboss/seam/test/integration/SeamMockELResolverTest.java)
===================================================================
--- trunk/src/test/integration/src/org/jboss/seam/test/integration/mock/SeamMockELResolverTest.java	                        (rev 0)
+++ trunk/src/test/integration/src/org/jboss/seam/test/integration/mock/SeamMockELResolverTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -0,0 +1,152 @@
+package org.jboss.seam.test.integration.mock;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.PropertyNotFoundException;
+import javax.el.PropertyNotWritableException;
+
+import org.jboss.seam.mock.SeamTest;
+import org.testng.annotations.Test;
+
+/**
+ * Test for adding EL resolvers to Seam MockFacesContext
+ * 
+ * @author Pete Muir
+ * 
+ */
+public class SeamMockELResolverTest extends SeamTest
+{
+   
+   private static final String property = "customELResolverTest";
+
+   @Override
+   protected ELResolver[] getELResolvers()
+   {
+      ELResolver[] resolvers = new ELResolver[2];
+      resolvers[0] = new ELResolver()
+      {
+
+         @Override
+         public Class<?> getCommonPropertyType(ELContext arg0, Object arg1)
+         {
+            return null;
+         }
+
+         @Override
+         public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext arg0, Object arg1)
+         {
+            return null;
+         }
+
+         @Override
+         public Class<?> getType(ELContext arg0, Object base, Object property)
+                  throws NullPointerException, PropertyNotFoundException, ELException
+         {
+            return null;
+         }
+
+         @Override
+         public Object getValue(ELContext context, Object base, Object property)
+                  throws NullPointerException, PropertyNotFoundException, ELException
+         {
+            if (SeamMockELResolverTest.property.equals(property))
+            {
+               context.setPropertyResolved(true);
+               return "found";
+            }
+            return null;
+         }
+
+         @Override
+         public boolean isReadOnly(ELContext arg0, Object base, Object property)
+                  throws NullPointerException, PropertyNotFoundException, ELException
+         {
+            if (SeamMockELResolverTest.property.equals(property))
+            {
+               return false;
+            }
+            return false;
+         }
+
+         @Override
+         public void setValue(ELContext context, Object base, Object property, Object value)
+                  throws NullPointerException, PropertyNotFoundException,
+                  PropertyNotWritableException, ELException
+         {
+            if (SeamMockELResolverTest.property.equals(property))
+            {
+               throw new PropertyNotWritableException();
+            }
+         }
+
+      };
+      resolvers[1] = new ELResolver() {
+
+          @Override
+          public Class<?> getCommonPropertyType(ELContext arg0, Object arg1)
+          {
+             return null;
+          }
+
+          @Override
+          public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext arg0, Object arg1)
+          {
+             return null;
+          }
+
+          @Override
+          public Class<?> getType(ELContext arg0, Object base, Object property)
+                   throws NullPointerException, PropertyNotFoundException, ELException
+          {
+             return null;
+          }
+
+          @Override
+          public Object getValue(ELContext context, Object base, Object property)
+                   throws NullPointerException, PropertyNotFoundException, ELException
+          {
+             if (base != null && "className".equals(property))
+             {
+                context.setPropertyResolved(true);
+                return base.getClass().getSimpleName();
+             }
+             return null;
+          }
+
+          @Override
+          public boolean isReadOnly(ELContext arg0, Object base, Object property)
+                   throws NullPointerException, PropertyNotFoundException, ELException
+          {
+             return true;
+          }
+
+          @Override
+          public void setValue(ELContext context, Object base, Object property, Object value)
+                   throws NullPointerException, PropertyNotFoundException,
+                   PropertyNotWritableException, ELException
+          {
+             throw new PropertyNotWritableException();
+          }
+      };
+      return resolvers;
+   }
+
+   @Test
+   public void testCustomELResolver() throws Exception
+   {
+      new FacesRequest()
+      {
+         @Override
+         protected void invokeApplication() throws Exception
+         {
+            assert "found".equals(getValue("#{" + property + "}"));
+            assert "String".equals(getValue("#{" + property + ".className}"));
+         }
+      }.run();
+   }
+
+}


Property changes on: trunk/src/test/integration/src/org/jboss/seam/test/integration/mock/SeamMockELResolverTest.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: trunk/src/test/integration/src/org/jboss/seam/test/integration/mock/SeamTestTest.java (from rev 7222, trunk/src/test/unit/org/jboss/seam/test/unit/SeamTestTest.java)
===================================================================
--- trunk/src/test/integration/src/org/jboss/seam/test/integration/mock/SeamTestTest.java	                        (rev 0)
+++ trunk/src/test/integration/src/org/jboss/seam/test/integration/mock/SeamTestTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -0,0 +1,64 @@
+package org.jboss.seam.test.integration.mock;
+
+import org.jboss.seam.mock.SeamTest;
+import org.testng.annotations.Test;
+
+public class SeamTestTest extends SeamTest
+{
+   
+   @Override
+   protected void startJbossEmbeddedIfNecessary() 
+   throws org.jboss.deployers.spi.DeploymentException ,java.io.IOException {}
+   
+   private static final String PETER_NAME = "Pete Muir";
+   private static final String PETER_USERNAME = "pmuir";
+   
+   @Test
+   public void testEl() throws Exception
+   {
+      new FacesRequest() 
+      {  
+         
+         @Override
+         protected void updateModelValues() throws Exception
+         {
+            setValue("#{person.name}", PETER_NAME);
+         }
+         
+         @Override
+         protected void renderResponse() throws Exception
+         {
+            assert getValue("#{person.name}").equals(PETER_NAME);
+         }
+         
+         @Override
+         protected void invokeApplication() throws Exception
+         {
+            invokeAction("#{action.go}");
+            String result = getOutcome();
+            assert "success".equals(result);
+         }
+      }.run();
+   }
+   
+   @Test
+   public void testSeamSecurity() throws Exception
+   {
+      new FacesRequest() 
+      {  
+         
+         @Override
+         protected void updateModelValues() throws Exception
+         {
+            setValue("#{identity.username}", PETER_USERNAME);
+         }
+         
+         @Override
+         protected void renderResponse() throws Exception
+         {
+            assert getValue("#{identity.username}").equals(PETER_USERNAME);
+         }
+      }.run();
+   }
+
+}


Property changes on: trunk/src/test/integration/src/org/jboss/seam/test/integration/mock/SeamTestTest.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: trunk/src/test/integration/src/org/jboss/seam/test/integration/security/SecurityTest.java (from rev 7222, trunk/src/test/unit/org/jboss/seam/test/unit/SecurityTest.java)
===================================================================
--- trunk/src/test/integration/src/org/jboss/seam/test/integration/security/SecurityTest.java	                        (rev 0)
+++ trunk/src/test/integration/src/org/jboss/seam/test/integration/security/SecurityTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -0,0 +1,168 @@
+package org.jboss.seam.test.integration.security;
+
+import java.util.HashMap;
+
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.mock.AbstractSeamTest;
+import org.jboss.seam.mock.MockLoginModule;
+import org.jboss.seam.security.AuthorizationException;
+import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.NotLoggedInException;
+import org.jboss.seam.web.Session;
+import org.testng.annotations.Test;
+
+/**
+ * Seam Security Unit Tests
+ * 
+ * @author Shane Bryzak
+ */
+public class SecurityTest extends AbstractSeamTest
+{     
+   private Configuration createMockJAASConfiguration()
+   {
+      return new Configuration()
+      {
+         private AppConfigurationEntry[] aces = { new AppConfigurationEntry( 
+               MockLoginModule.class.getName(), 
+               LoginModuleControlFlag.REQUIRED, 
+               new HashMap<String,String>() 
+            ) };
+         
+         @Override
+         public AppConfigurationEntry[] getAppConfigurationEntry(String name)
+         {
+            return aces;
+         }
+         
+         @Override
+         public void refresh() {}
+      };      
+   }
+   
+   public class MockIdentity extends Identity
+   {
+      @Override
+      protected LoginContext getLoginContext() throws LoginException
+      {
+         return new LoginContext("default", getSubject(), getDefaultCallbackHandler(), 
+               createMockJAASConfiguration());
+      }            
+   }
+
+   @Test
+   public void testLogin()
+   {      
+      try
+      {
+         Lifecycle.beginApplication(new HashMap<String,Object>());
+         Lifecycle.beginCall();
+         
+         // Create a mock session
+         Contexts.getSessionContext().set(Component.getComponentName(Session.class), new Session());
+         
+         Identity identity = new MockIdentity();
+         identity.create();
+         
+         // Put the identity into our session context 
+         Contexts.getSessionContext().set(Component.getComponentName(Identity.class), identity);         
+         
+         // Test addRole()
+         identity.addRole("admin");
+         
+         assert(!identity.hasRole("admin"));
+         
+         try
+         {
+            // This should throw a NotLoggedInException
+            identity.checkRole("admin");
+            assert(false);
+         }
+         catch (NotLoggedInException ex)
+         {
+            // expected
+         }         
+                  
+         identity.setUsername("foo");
+         identity.setPassword("bar");
+         
+         assert("foo".equals(identity.getUsername()));
+         assert("bar".equals(identity.getPassword()));
+         
+         assert("loggedIn".equals(identity.login()));
+         assert(identity.isLoggedIn());
+         
+         // Pre-authenticated roles are cleared before authenticating, 
+         // so this should still return false
+         assert(!identity.hasRole("admin"));
+         
+         // The foo role is added by MockLoginModule
+         assert(identity.hasRole("foo"));
+         
+         identity.removeRole("foo");
+         assert(!identity.hasRole("foo"));
+         
+         try
+         {
+            // This should throw an AuthorizationException
+            identity.checkRole("foo");
+            assert(false);
+         }
+         catch (AuthorizationException ex)
+         {
+            // expected
+         }
+         
+         // Now that we're authenticated, adding a role should have an immediate effect
+         identity.addRole("admin");
+         assert(identity.hasRole("admin"));
+                  
+         identity.logout();
+         
+         assert(!identity.hasRole("admin"));         
+         assert(!identity.isLoggedIn());
+      }
+      finally
+      {
+         Lifecycle.endApplication();
+      }
+   }
+   
+   @Test
+   public void testDisableSecurity()
+   {
+      try
+      {      
+         Identity identity = new Identity();
+         identity.create();
+         
+         // Disable security
+         Identity.setSecurityEnabled(false);
+         
+         assert(!Identity.isSecurityEnabled());
+         assert(identity.hasRole("admin"));
+         assert(identity.hasPermission("foo", "bar"));
+   
+         // This shouldn't throw an exception while security is disabled
+         identity.checkRestriction("foo");
+         
+         // Enable security
+         Identity.setSecurityEnabled(true);
+         assert(Identity.isSecurityEnabled());
+         assert(!identity.hasRole("admin"));
+         assert(!identity.hasPermission("foo", "bar"));
+      }
+      finally
+      {
+         Identity.setSecurityEnabled(true);
+      }      
+   }
+
+}


Property changes on: trunk/src/test/integration/src/org/jboss/seam/test/integration/security/SecurityTest.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/src/test/integration/src/org/jboss/seam/test/integration/testng.xml
===================================================================
--- trunk/src/test/integration/src/org/jboss/seam/test/integration/testng.xml	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/test/integration/src/org/jboss/seam/test/integration/testng.xml	2008-01-24 17:08:50 UTC (rev 7223)
@@ -1,73 +1,83 @@
 <!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
 
-<suite name="Seam Core Tests" verbose="2" parallel="false">
-    <test name="Seam Core - Integration: Contexts">
+<suite name="Seam Integration Testsuite" verbose="2" parallel="false">
+    <test name="Seam Integration Tests: Contexts and Components">
         <classes>
             <class name="org.jboss.seam.test.integration.PageContextTest"/>
             <class name="org.jboss.seam.test.integration.ConversationTest" />
+            <class name="org.jboss.seam.test.integration.ImportTest" />
+            <class name="org.jboss.seam.test.integration.NamespaceTest" />
+            <class name="org.jboss.seam.test.integration.JavaBeanEqualsTest"/>
         </classes>
     </test>
    
-    <test name="Seam Core - Integration: Persistence">
+    <test name="Seam Integration Tests: Persistence">
         <classes>
             <class name="org.jboss.seam.test.integration.EntityTest"/>
             <class name="org.jboss.seam.test.integration.EntityPassivationTest" />
         </classes>
     </test>
    
-    <test name="Seam Core - Integration: Events">
+    <test name="Seam Integration Tests: Events">
         <classes>
             <class name="org.jboss.seam.test.integration.EventTest"/>
         </classes>
     </test>
    
-    <test name="Seam Core - Integration: EL">
+    <test name="Seam Integration Tests: EL">
         <classes>
             <class name="org.jboss.seam.test.integration.ELTest"/>
         </classes>
     </test>
    
-    <test name="Seam Core - Integration: Framework">
+    <test name="Seam Integration Tests: Framework">
         <classes>
             <class name="org.jboss.seam.test.integration.IdentifierTest"/>
         </classes>
     </test>
 
-    <test name="Seam Core - Integration: i8ln">
+    <test name="Seam Integration Tests: i8ln">
         <classes>
             <class name="org.jboss.seam.test.integration.i8ln.TimeZoneTest"/>
             <class name="org.jboss.seam.test.integration.i8ln.LocaleTest"/>
         </classes>
     </test>
 
-    <test name="Seam Core - Integration: Components">
+    <test name="Seam Integration Tests: BPM">
         <classes>
-            <class name="org.jboss.seam.test.integration.JavaBeanEqualsTest"/>
-        </classes>
-    </test>
-
-    <test name="Seam Core - Integration: BPM">
-        <classes>
    	        <class name="org.jboss.seam.test.integration.BusinessProcessTest" />
             <class name="org.jboss.seam.test.integration.bpm.SeamExpressionEvaluatorTest" />
         </classes>
     </test>
 
-    <test name="Seam Core - Integration: JMS">
+    <test name="Seam Integration Tests: JMS">
    	    <classes>
    		    <class name="org.jboss.seam.test.integration.MessagingTest" />
         </classes>
     </test>
     
-    <test name="Seam Core - Integration: Mocks">
+    <test name="Seam Integration Tests: Mocks">
         <classes>
-          <class name="org.jboss.seam.test.integration.SeamMockELResolverTest" />
+          <class name="org.jboss.seam.test.integration.mock.SeamMockELResolverTest" />
+          <class name="org.jboss.seam.test.integration.mock.SeamTestTest" />
         </classes>
     </test>
     
-    <test name="Seam Core - Integration: Pages.xml">
+    <test name="Seam Integration Tests: Pages dot xml">
         <classes>
           <class name="org.jboss.seam.test.integration.PageParamTest" />
         </classes>
     </test>
+    
+    <test name="Seam Integration Tests: DataBinding">
+        <classes>
+          <class name="org.jboss.seam.test.integration.databinding.DataModelTest" />
+        </classes>
+    </test>
+    
+    <test name="Seam Integration Tests: Security">
+        <classes>
+          <class name="org.jboss.seam.test.integration.security.SecurityTest" />
+        </classes>
+    </test>
 </suite>

Deleted: trunk/src/test/unit/org/jboss/seam/test/unit/DataModelTest.java
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/DataModelTest.java	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/DataModelTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -1,330 +0,0 @@
-package org.jboss.seam.test.unit;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.NotSerializableException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.model.DataModel;
-import javax.faces.model.ListDataModel;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.seam.faces.DataModels;
-import org.jboss.seam.jsf.ArrayDataModel;
-import org.jboss.seam.jsf.MapDataModel;
-import org.jboss.seam.jsf.SetDataModel;
-import org.jboss.seam.mock.SeamTest;
-import org.testng.annotations.Test;
-
-public class DataModelTest extends SeamTest
-{
-   
-   @Override
-   protected void startJbossEmbeddedIfNecessary() throws DeploymentException, IOException {}
-   
-   @Test
-   public void testDataModels() throws Exception
-   {
-    
-      new FacesRequest()
-      {
-         @Override
-         protected void invokeApplication() throws Exception
-         {
-            DataModels dataModels = DataModels.instance();
-            
-            assert dataModels.getDataModel(new ArrayList()) instanceof ListDataModel;
-            assert dataModels.getDataModel(new HashMap()) instanceof MapDataModel;
-            assert dataModels.getDataModel(new HashSet()) instanceof SetDataModel;
-            assert dataModels.getDataModel(new Object[0]) instanceof ArrayDataModel;
-            // TODO assert dataModels.getDataModel(query) instanceof ListDataModel;
-            
-            boolean failed = false;
-            try
-            {
-               dataModels.getDataModel(new Foo());
-            }
-            catch (IllegalArgumentException e)
-            {
-               failed = true;
-            }
-            assert failed;
-         }
-      }.run();
-   }
-   
-   @Test
-   public void testArrayDataModelSerialization() throws Exception
-   {
-      String[] array = {"Seam", "Hibernate"};
-      javax.faces.model.ArrayDataModel arrayDataModel = new ArrayDataModel(array);
-      arrayDataModel.setRowIndex(1);
-      
-      Object object = null;
-      try
-      {
-         object = serialize(arrayDataModel);
-      }
-      catch (NotSerializableException e) 
-      {
-         assert false;
-      }
-      assert object instanceof javax.faces.model.ArrayDataModel;
-      
-      javax.faces.model.ArrayDataModel serializedArrayDataModel = (javax.faces.model.ArrayDataModel) object;
-      
-      assert serializedArrayDataModel.getRowIndex() == 1;
-      
-      String[] serializedArray = (String[]) serializedArrayDataModel.getWrappedData();
-      
-      assert array[0].equals(serializedArray[0]);
-      
-      assert array[1].equals(serializedArray[1]);
-   }
-   
-   // Utility to serialize an object
-   private Object serialize(Object object) throws Exception
-   {
-      ByteArrayOutputStream bos = new ByteArrayOutputStream();
-      ObjectOutputStream oos = new ObjectOutputStream(bos);
-      oos.writeObject(object);  
-      ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
-      ObjectInputStream ois = new ObjectInputStream(bis);
-      return ois.readObject();
-   }
-   
-   @Test
-   public void testListDataModelSerialization() throws Exception
-   {
-      
-      List<String> list = Arrays.asList("Seam", "Hibernate");
-      javax.faces.model.ListDataModel listDataModel = new org.jboss.seam.jsf.ListDataModel(list);
-      listDataModel.setRowIndex(1);
-      
-      Object object = null;
-      try
-      {
-         object = serialize(listDataModel);
-      }
-      catch (NotSerializableException e) 
-      {
-         assert false;
-      }
-      
-      assert object instanceof javax.faces.model.ListDataModel;
-      javax.faces.model.ListDataModel serializedListDataModel = (javax.faces.model.ListDataModel) object;
-      List<String> serializedList = (List<String>) serializedListDataModel.getWrappedData();
-      
-      assert serializedListDataModel.getRowIndex() == 1;
-      assert list.get(0).equals(serializedList.get(0)); 
-      assert list.get(1).equals(serializedList.get(1));
-   }
-   
-   @Test
-   public void testMapDataModel() throws IOException, ClassNotFoundException
-   {
-      Map<String, Person> map = new HashMap<String, Person>();
-      map.put("0", new Person("Gavin"));
-      map.put("1", new Person("Tom"));
-      
-      javax.faces.model.DataModel mapDataModel = new MapDataModel();
-      
-      assert mapDataModel.getRowCount() == -1;
-      assert mapDataModel.getRowData() == null;
-      assert !mapDataModel.isRowAvailable();
-      
-      mapDataModel = new MapDataModel(map);
-      
-      assert mapDataModel.getWrappedData() instanceof Map;
-      
-      assert map.get("0").equals(((Map) mapDataModel.getWrappedData()).get("0"));
-      assert map.get("1").equals(((Map) mapDataModel.getWrappedData()).get("1"));
-      
-      mapDataModel.setRowIndex(10);
-      
-      assert !mapDataModel.isRowAvailable();
-      
-      boolean failed = false;
-      try
-      {
-         mapDataModel.getRowData();
-      }
-      catch (IllegalArgumentException e) 
-      {
-         failed = true;
-      }
-      
-      assert failed;
-      
-      mapDataModel.setRowIndex(1);
-      
-      assert mapDataModel.isRowAvailable();
-      assert mapDataModel.getRowIndex() == 1;
-      assert mapDataModel.getRowCount() == 2;
-      
-      // JBSEAM-1660
-      /*try 
-      {
-         mapDataModel.setWrappedData(null);
-      }
-      catch (NullPointerException e) 
-      {
-         // Spec allows passing null
-         assert false;
-      }*/
-   }
-   
-   //JBSEAM-1659
-   
-   /*@Test
-   public void testMapDataModelSerialization() throws Exception
-   {
-      
-      Map<String, Person> map = new HashMap<String, Person>();
-      map.put("0", new Person("Gavin"));
-      map.put("1", new Person("Tom"));
-      
-      javax.faces.model.DataModel mapDataModel = new MapDataModel(map);    
-      mapDataModel.setRowIndex(1);
-
-      Object object = null;
-      try
-      {
-         object = serialize(mapDataModel);
-      }
-      catch (NotSerializableException e) 
-      {
-         assert false;
-      }
-      
-      
-      assert object instanceof javax.faces.model.DataModel;
-      javax.faces.model.DataModel serializedMapDataModel = (javax.faces.model.DataModel) object;
-      Map<String, Person> serializedMap = (Map<String, Person>) serializedMapDataModel.getWrappedData();
-      
-      assert serializedMapDataModel.getRowIndex() == 1;
-      assert map.get("0").equals(serializedMap.get("0")); 
-      assert map.get("1").equals(serializedMap.get("1"));
-   }*/
-   
-   @Test
-   public void testSetDataModel() throws IOException, ClassNotFoundException
-   {
-      Person gavin = new Person("Gavin");
-      Person tom = new Person("Tom");
-      
-      Set<Person> set = new HashSet<Person>();
-      set.add(gavin);
-      set.add(tom);
-      
-      javax.faces.model.DataModel setDataModel = new SetDataModel();
-      
-      assert setDataModel.getRowCount() == -1;
-      assert setDataModel.getRowData() == null;
-      assert !setDataModel.isRowAvailable();
-      
-      setDataModel = new SetDataModel(set);
-      
-      assert setDataModel.getWrappedData() instanceof Set;
-      
-      assert set.contains(gavin);
-      assert set.contains(tom);
-      
-      setDataModel.setRowIndex(10);
-      
-      assert !setDataModel.isRowAvailable();
-      
-      boolean failed = false;
-      try
-      {
-         setDataModel.getRowData();
-      }
-      catch (IllegalArgumentException e) 
-      {
-         failed = true;
-      }
-      
-      assert failed;
-      
-      setDataModel.setRowIndex(1);
-      
-      assert setDataModel.isRowAvailable();
-      assert setDataModel.getRowIndex() == 1;
-      assert setDataModel.getRowCount() == 2;
-      
-      // JBSEAM-1660
-      /*try 
-      {
-         setDataModel.setWrappedData(null);
-      }
-      catch (NullPointerException e) 
-      {
-         // Spec allows passing null
-         assert false;
-      }*/
-   }
-   
-   @Test
-   public void testSetDataModelSerialization() throws Exception
-   {
-      
-      Person gavin = new Person("Gavin");
-      Person tom = new Person("Tom");
-      
-      Set<Person> set = new HashSet<Person>();
-      set.add(gavin);
-      set.add(tom);
-      
-      javax.faces.model.DataModel setDataModel = new SetDataModel(set);    
-      setDataModel.setRowIndex(1);
-
-      Object object = null;
-      try
-      {
-         object = serialize(setDataModel);
-      }
-      catch (NotSerializableException e) 
-      {
-         assert false;
-      }
-      
-      
-      assert object instanceof javax.faces.model.DataModel;
-      javax.faces.model.DataModel serializedSetDataModel = (javax.faces.model.DataModel) object;
-      Set<Person> serializedSet = (Set<Person>) serializedSetDataModel.getWrappedData();
-      
-      assert serializedSetDataModel.getRowIndex() == 1;
-      assert serializedSet.contains(gavin);
-      assert serializedSet.contains(tom);
-   }
-   
-   @Test
-   public void testDataModelOutjection() throws Exception
-   {
-      new FacesRequest()
-      {
-         
-         @Override
-         protected void renderResponse() throws Exception
-         {
-            Object people = getValue("#{peopleList}");
-            assert people instanceof DataModel;
-            DataModel dataModel = (DataModel) people;
-            assert dataModel.getRowCount() == 4;
-            dataModel.setRowIndex(1);
-         }     
-         
-      }.run();
-      
-   }
-
-}

Deleted: trunk/src/test/unit/org/jboss/seam/test/unit/ImportTest.java
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/ImportTest.java	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/ImportTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -1,54 +0,0 @@
-package org.jboss.seam.test.unit;
-
-import org.jboss.seam.annotations.Factory;
-import org.jboss.seam.annotations.Import;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.mock.SeamTest;
-import org.testng.annotations.Test;
-
-public class ImportTest
-    extends SeamTest
-{
-
-    @Override
-    protected void startJbossEmbeddedIfNecessary() 
-          throws org.jboss.deployers.spi.DeploymentException,
-                 java.io.IOException 
-    {
-       // don't deploy
-    }
-    
-    @Test
-    public void testImport() 
-        throws Exception 
-    {
-        
-        new FacesRequest() {
-            @Override
-            protected void invokeApplication()
-                throws Exception
-            {
-                assert getValue("#{importTest.otherValue}").equals("foobar2");                 
-            }        
-        }.run();
-    }
-   
-    
-    @Name("importTest")
-    @Import("importTest.ns2")
-    public static class Importer {
-        @In
-        String otherValue;
-
-        public String getOtherValue() {
-            return otherValue;
-        }
-
-        @Factory(value="importTest.ns2.otherValue", autoCreate=true)
-        public String createOtherValue() {
-            return "foobar2";
-        }
-    }
-
-}

Deleted: trunk/src/test/unit/org/jboss/seam/test/unit/NamespaceTest.java
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/NamespaceTest.java	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/NamespaceTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -1,114 +0,0 @@
-package org.jboss.seam.test.unit;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Factory;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Out;
-import org.jboss.seam.core.Init;
-import org.jboss.seam.mock.SeamTest;
-import org.testng.annotations.Test;
-
-public class NamespaceTest 
-    extends SeamTest 
-{
-    @Override
-    protected void startJbossEmbeddedIfNecessary() 
-          throws org.jboss.deployers.spi.DeploymentException,
-                 java.io.IOException 
-    {
-       // don't deploy   
-    }
-    
-    
-    @Test
-    public void nameSpaceComponent() 
-        throws Exception 
-    {
-        new ComponentTest() {
-            @Override
-            protected void testComponents() throws Exception {
-                assert getValue("#{namespaceTest.fooFactory}") != null;
-            }
-        }.run();
-    }
-
-    @Test
-    public void nameSpaceFactory() 
-        throws Exception 
-    {
-        new ComponentTest() {
-            @Override
-            protected void testComponents() throws Exception {
-                assert getValue("#{namespaceTest.ns1.factory}") != null;
-            }
-        }.run();
-    }
-    
-
-    @Test
-    public void namespaceOutjection() 
-        throws Exception 
-    {
-        new ComponentTest() {
-            @Override
-            protected void testComponents() throws Exception {
-                FooFactory factory = (FooFactory) getValue("#{namespaceTest.fooFactory}");
-                factory.someMethod();
-                assert getValue("#{namespaceTest.ns2.outject}") != null;
-            }
-        }.run();
-    }
-
-    
-    @Test
-    public void factoryMethodExpression() 
-        throws Exception 
-    {
-        new ComponentTest() {
-            @Override
-            protected void testComponents() throws Exception {
-                Init init = Init.instance();
-                init.addFactoryMethodExpression("namespaceTest.ns3.factory", "#{namespaceTest.fooFactory.createFoo}", ScopeType.SESSION);
-                
-                assert getValue("#{namespaceTest.ns3.factory}") != null;
-            }
-        }.run();
-    }
-    
-    @Test
-    public void factoryValueExpression() 
-        throws Exception 
-    {
-        new ComponentTest() {
-            @Override
-            protected void testComponents() throws Exception {
-                Init init = Init.instance();
-                init.addFactoryValueExpression("namespaceTest.ns4.factory", "#{namespaceTest.fooFactory.createFoo()}", ScopeType.SESSION);
-                
-                assert getValue("#{namespaceTest.ns4.factory}") != null;
-            }
-        }.run();
-    }
-
-
-    @Name("namespaceTest.fooFactory")
-    static public class FooFactory {
-        public class Foo {}
-        
-        @Factory("namespaceTest.ns1.factory")
-        public Foo createFoo() {
-            return new Foo();
-        }        
-
-        @Out("namespaceTest.ns2.outject")
-        public Foo outjectFoo() {
-            return new Foo();
-        }
-        
-        public void someMethod() {
-        }
-    }
-    
-
-
-}

Deleted: trunk/src/test/unit/org/jboss/seam/test/unit/SeamTestTest.java
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/SeamTestTest.java	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/SeamTestTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -1,64 +0,0 @@
-package org.jboss.seam.test.unit;
-
-import org.jboss.seam.mock.SeamTest;
-import org.testng.annotations.Test;
-
-public class SeamTestTest extends SeamTest
-{
-   
-   @Override
-   protected void startJbossEmbeddedIfNecessary() 
-   throws org.jboss.deployers.spi.DeploymentException ,java.io.IOException {}
-   
-   private static final String PETER_NAME = "Pete Muir";
-   private static final String PETER_USERNAME = "pmuir";
-   
-   @Test
-   public void testEl() throws Exception
-   {
-      new FacesRequest() 
-      {  
-         
-         @Override
-         protected void updateModelValues() throws Exception
-         {
-            setValue("#{person.name}", PETER_NAME);
-         }
-         
-         @Override
-         protected void renderResponse() throws Exception
-         {
-            assert getValue("#{person.name}").equals(PETER_NAME);
-         }
-         
-         @Override
-         protected void invokeApplication() throws Exception
-         {
-            invokeAction("#{action.go}");
-            String result = getOutcome();
-            assert "success".equals(result);
-         }
-      }.run();
-   }
-   
-   @Test
-   public void testSeamSecurity() throws Exception
-   {
-      new FacesRequest() 
-      {  
-         
-         @Override
-         protected void updateModelValues() throws Exception
-         {
-            setValue("#{identity.username}", PETER_USERNAME);
-         }
-         
-         @Override
-         protected void renderResponse() throws Exception
-         {
-            assert getValue("#{identity.username}").equals(PETER_USERNAME);
-         }
-      }.run();
-   }
-
-}

Deleted: trunk/src/test/unit/org/jboss/seam/test/unit/SecurityTest.java
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/SecurityTest.java	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/SecurityTest.java	2008-01-24 17:08:50 UTC (rev 7223)
@@ -1,168 +0,0 @@
-package org.jboss.seam.test.unit;
-
-import java.util.HashMap;
-
-import javax.security.auth.login.AppConfigurationEntry;
-import javax.security.auth.login.Configuration;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.contexts.Lifecycle;
-import org.jboss.seam.mock.BaseSeamTest;
-import org.jboss.seam.mock.MockLoginModule;
-import org.jboss.seam.security.AuthorizationException;
-import org.jboss.seam.security.Identity;
-import org.jboss.seam.security.NotLoggedInException;
-import org.jboss.seam.web.Session;
-import org.testng.annotations.Test;
-
-/**
- * Seam Security Unit Tests
- * 
- * @author Shane Bryzak
- */
-public class SecurityTest extends BaseSeamTest
-{     
-   private Configuration createMockJAASConfiguration()
-   {
-      return new Configuration()
-      {
-         private AppConfigurationEntry[] aces = { new AppConfigurationEntry( 
-               MockLoginModule.class.getName(), 
-               LoginModuleControlFlag.REQUIRED, 
-               new HashMap<String,String>() 
-            ) };
-         
-         @Override
-         public AppConfigurationEntry[] getAppConfigurationEntry(String name)
-         {
-            return aces;
-         }
-         
-         @Override
-         public void refresh() {}
-      };      
-   }
-   
-   public class MockIdentity extends Identity
-   {
-      @Override
-      protected LoginContext getLoginContext() throws LoginException
-      {
-         return new LoginContext("default", getSubject(), getDefaultCallbackHandler(), 
-               createMockJAASConfiguration());
-      }            
-   }
-
-   @Test
-   public void testLogin()
-   {      
-      try
-      {
-         Lifecycle.beginApplication(new HashMap<String,Object>());
-         Lifecycle.beginCall();
-         
-         // Create a mock session
-         Contexts.getSessionContext().set(Component.getComponentName(Session.class), new Session());
-         
-         Identity identity = new MockIdentity();
-         identity.create();
-         
-         // Put the identity into our session context 
-         Contexts.getSessionContext().set(Component.getComponentName(Identity.class), identity);         
-         
-         // Test addRole()
-         identity.addRole("admin");
-         
-         assert(!identity.hasRole("admin"));
-         
-         try
-         {
-            // This should throw a NotLoggedInException
-            identity.checkRole("admin");
-            assert(false);
-         }
-         catch (NotLoggedInException ex)
-         {
-            // expected
-         }         
-                  
-         identity.setUsername("foo");
-         identity.setPassword("bar");
-         
-         assert("foo".equals(identity.getUsername()));
-         assert("bar".equals(identity.getPassword()));
-         
-         assert("loggedIn".equals(identity.login()));
-         assert(identity.isLoggedIn());
-         
-         // Pre-authenticated roles are cleared before authenticating, 
-         // so this should still return false
-         assert(!identity.hasRole("admin"));
-         
-         // The foo role is added by MockLoginModule
-         assert(identity.hasRole("foo"));
-         
-         identity.removeRole("foo");
-         assert(!identity.hasRole("foo"));
-         
-         try
-         {
-            // This should throw an AuthorizationException
-            identity.checkRole("foo");
-            assert(false);
-         }
-         catch (AuthorizationException ex)
-         {
-            // expected
-         }
-         
-         // Now that we're authenticated, adding a role should have an immediate effect
-         identity.addRole("admin");
-         assert(identity.hasRole("admin"));
-                  
-         identity.logout();
-         
-         assert(!identity.hasRole("admin"));         
-         assert(!identity.isLoggedIn());
-      }
-      finally
-      {
-         Lifecycle.endApplication();
-      }
-   }
-   
-   @Test
-   public void testDisableSecurity()
-   {
-      try
-      {      
-         Identity identity = new Identity();
-         identity.create();
-         
-         // Disable security
-         Identity.setSecurityEnabled(false);
-         
-         assert(!Identity.isSecurityEnabled());
-         assert(identity.hasRole("admin"));
-         assert(identity.hasPermission("foo", "bar"));
-   
-         // This shouldn't throw an exception while security is disabled
-         identity.checkRestriction("foo");
-         
-         // Enable security
-         Identity.setSecurityEnabled(true);
-         assert(Identity.isSecurityEnabled());
-         assert(!identity.hasRole("admin"));
-         assert(!identity.hasPermission("foo", "bar"));
-      }
-      finally
-      {
-         Identity.setSecurityEnabled(true);
-      }      
-   }
-
-}

Modified: trunk/src/test/unit/org/jboss/seam/test/unit/testng.xml
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/testng.xml	2008-01-24 14:04:36 UTC (rev 7222)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/testng.xml	2008-01-24 17:08:50 UTC (rev 7223)
@@ -1,31 +1,65 @@
 <!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
 
-<suite name="Seam Core Tests" verbose="2" parallel="false">
-   <test name="Unit">
+<suite name="Seam Unit Testsuite" verbose="2" parallel="false">
+   <test name="Seam Unit Tests: Core">
      <classes>
        <class name="org.jboss.seam.test.unit.CoreTest"/>
        <class name="org.jboss.seam.test.unit.InitializationTest"/>
-       <class name="org.jboss.seam.test.unit.PhaseListenerTest"/>
        <class name="org.jboss.seam.test.unit.InterceptorTest"/>
        <class name="org.jboss.seam.test.unit.ComponentTest"/>
        <class name="org.jboss.seam.test.unit.ContextTest"/>
-       <class name="org.jboss.seam.test.unit.PhaseListenerTest"/>
-       <class name="org.jboss.seam.test.unit.RemotingTest"/>
-       <class name="org.jboss.seam.test.unit.SecurityTest"/>
-       <class name="org.jboss.seam.test.unit.InterpolatorTest"/>
        <class name="org.jboss.seam.test.unit.DependencyTest"/>
-       <class name="org.jboss.seam.test.unit.SeamTestTest"/>
-       <class name="org.jboss.seam.test.unit.MailTest"/>
-       <class name="org.jboss.seam.test.unit.DataModelTest"/>
-       <class name="org.jboss.seam.test.unit.PageflowTest"/>
-       <class name="org.jboss.seam.test.unit.PageActionsTest" />
-       <class name="org.jboss.seam.test.unit.PageParamTest" />
-       <class name="org.jboss.seam.test.unit.HomeTest" />
-       <class name="org.jboss.seam.test.unit.NamespaceTest" />
-       <class name="org.jboss.seam.test.unit.ImportTest"/>
-       <class name="org.jboss.seam.test.unit.web.MultipartRequestTest" />
-       <class name="org.jboss.seam.test.unit.bpm.ActorTest" />
-       <class name="org.jboss.seam.test.unit.bpm.TaskListTest" />
      </classes>
    </test>
+   
+   <test name="Seam Unit Tests: Mail">
+     <classes>
+        <class name="org.jboss.seam.test.unit.MailTest"/>
+     </classes>
+   </test>
+   
+   <test name="Seam Unit Tests: BPM and Pageflow">
+     <classes>
+        <class name="org.jboss.seam.test.unit.bpm.ActorTest" />
+        <class name="org.jboss.seam.test.unit.bpm.TaskListTest" />
+        <class name="org.jboss.seam.test.unit.PageflowTest"/>
+     </classes>
+   </test>
+   
+   <test name="Seam Unit Tests: Pages dot xml">
+     <classes>
+        <class name="org.jboss.seam.test.unit.PageActionsTest" />
+        <class name="org.jboss.seam.test.unit.PageParamTest" />
+     </classes>
+   </test>
+   
+   <test name="Seam Unit Tests: JSF integration">
+     <classes>
+        <class name="org.jboss.seam.test.unit.PhaseListenerTest"/>
+     </classes>
+   </test>
+   
+   <test name="Seam Unit Tests: Remoting">
+     <classes>
+        <class name="org.jboss.seam.test.unit.RemotingTest"/>
+     </classes>
+   </test>
+   
+   <test name="Seam Unit Tests: Framework">
+     <classes>
+        <class name="org.jboss.seam.test.unit.HomeTest" />
+     </classes>
+   </test>
+   
+   <test name="Seam Unit Tests: Filters">
+     <classes>
+        <class name="org.jboss.seam.test.unit.web.MultipartRequestTest" />
+     </classes>
+   </test>
+   
+   <test name="Seam Unit Tests: Resources and i8ln">
+     <classes>
+        <class name="org.jboss.seam.test.unit.InterpolatorTest"/>
+     </classes>
+   </test>
 </suite>




More information about the seam-commits mailing list