Seam SVN: r7224 - trunk/seam-gen/resources.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-01-24 18:27:40 -0500 (Thu, 24 Jan 2008)
New Revision: 7224
Modified:
trunk/seam-gen/resources/messages_bg.properties
trunk/seam-gen/resources/messages_de.properties
trunk/seam-gen/resources/messages_en.properties
trunk/seam-gen/resources/messages_fr.properties
trunk/seam-gen/resources/messages_tr.properties
Log:
JBSEAM-2533
Modified: trunk/seam-gen/resources/messages_bg.properties
===================================================================
--- trunk/seam-gen/resources/messages_bg.properties 2008-01-24 17:08:50 UTC (rev 7223)
+++ trunk/seam-gen/resources/messages_bg.properties 2008-01-24 23:27:40 UTC (rev 7224)
@@ -61,15 +61,16 @@
org.jboss.seam.IllegalNavigation = \u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043D\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044F
org.jboss.seam.NoConversation = \u0420\u0430\u0437\u0433\u043E\u0432\u043E\u0440\u044A\u0442 \u0435 \u043F\u0440\u0438\u043A\u043B\u044E\u0447\u0438\u043B, \u0438\u0437\u0442\u0435\u043A\u043B\u043E \u043C\u0443 \u0435 \u0432\u0440\u0435\u043C\u0435\u0442\u043E \u0438\u043B\u0438 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0432\u0430 \u0434\u0440\u0443\u0433\u0430 \u0437\u0430\u044F\u0432\u043A\u0430
-org.jboss.seam.NotLoggedIn = \u041C\u043E\u043B\u044F \u043F\u044A\u0440\u0432\u043E \u0441\u0435 \u0438\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0430\u0439\u0442\u0435
org.jboss.seam.ProcessEnded = \u041F\u0440\u043E\u0446\u0435\u0441 #0 \u0435 \u043F\u0440\u0438\u043A\u043B\u044E\u0447\u0438\u043B
org.jboss.seam.ProcessNotFound = \u041F\u0440\u043E\u0446\u0435\u0441 #0 \u043D\u0435 \u0435 \u043D\u0430\u043C\u0435\u0440\u0435\u043D
org.jboss.seam.TaskEnded = \u0417\u0430\u0434\u0430\u0447\u0430 #0 \u0435 \u043F\u0440\u0438\u043A\u043B\u044E\u0447\u0438\u043B\u0430
org.jboss.seam.TaskNotFound = \u0417\u0430\u0434\u0430\u0447\u0430 #0 \u043D\u0435 \u0435 \u043D\u0430\u043C\u0435\u0440\u0435\u043D\u0430
org.jboss.seam.TransactionFailed = \u0422\u0440\u0430\u043D\u0437\u0430\u043A\u0446\u0438\u044F \u043D\u0435 \u0435 \u0443\u0441\u043F\u044F\u043B\u0430
-org.jboss.seam.loginFailed = \u041D\u0435\u0443\u0441\u043F\u0435\u0448\u0435\u043D \u0432\u0445\u043E\u0434
-org.jboss.seam.loginSuccessful = \u0417\u0434\u0440\u0430\u0432\u0435\u0439, #0
+org.jboss.seam.security.loginFailed = \u041D\u0435\u0443\u0441\u043F\u0435\u0448\u0435\u043D \u0432\u0445\u043E\u0434
+org.jboss.seam.security.loginSuccessful = \u0417\u0434\u0440\u0430\u0432\u0435\u0439, #0
+org.jboss.seam.security.notLoggedIn = \u041C\u043E\u043B\u044F \u043F\u044A\u0440\u0432\u043E \u0441\u0435 \u0438\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0430\u0439\u0442\u0435
+
right = \u203A
up = \u2191
Modified: trunk/seam-gen/resources/messages_de.properties
===================================================================
--- trunk/seam-gen/resources/messages_de.properties 2008-01-24 17:08:50 UTC (rev 7223)
+++ trunk/seam-gen/resources/messages_de.properties 2008-01-24 23:27:40 UTC (rev 7224)
@@ -16,8 +16,9 @@
validator.size=die Gr\u00F6\u00DFe muss zischen {min} und {max} liegen
validator.email=muss einer wohlgeformten E-Mailadresse entsprechen
-org.jboss.seam.loginFailed=Anmeldung fehlgeschlagen
-org.jboss.seam.loginSuccessful=Willkommen, #0
+org.jboss.seam.security.loginFailed=Anmeldung fehlgeschlagen
+org.jboss.seam.security.loginSuccessful=Willkommen, #0
+org.jboss.seam.security.notLoggedIn=Bitte melden Sie sich zun\u00E4chst an
org.jboss.seam.TransactionFailed=Transaktion fehlgeschlagen
org.jboss.seam.NoConversation=Der Vorgang wurde bereits beendet, verarbeitet eine andere Abfrage oder ergab eine Zeit\u00FCberschreitung
@@ -26,7 +27,6 @@
org.jboss.seam.ProcessNotFound=Prozess #0 nicht gefunden
org.jboss.seam.TaskEnded=Funktion #0 wurde bereits beendet
org.jboss.seam.TaskNotFound=Funktion #0 nicht gefunden
-org.jboss.seam.NotLoggedIn=Bitte melden Sie sich zun\u00E4chst an
javax.faces.component.UIInput.CONVERSION=Wert konnte nicht in den erwarteten Typ umgewandelt werden
javax.faces.component.UIInput.REQUIRED=Wert erforderlich
Modified: trunk/seam-gen/resources/messages_en.properties
===================================================================
--- trunk/seam-gen/resources/messages_en.properties 2008-01-24 17:08:50 UTC (rev 7223)
+++ trunk/seam-gen/resources/messages_en.properties 2008-01-24 23:27:40 UTC (rev 7224)
@@ -16,8 +16,9 @@
validator.size=size must be between {min} and {max}
validator.email=must be a well-formed email address
-org.jboss.seam.loginFailed=Login failed
-org.jboss.seam.loginSuccessful=Welcome, #0
+org.jboss.seam.security.loginFailed=Login failed
+org.jboss.seam.security.loginSuccessful=Welcome, #0
+org.jboss.seam.security.notLoggedIn=Please log in first
org.jboss.seam.TransactionFailed=Transaction failed
org.jboss.seam.NoConversation=The conversation ended, timed out or was processing another request
@@ -26,7 +27,6 @@
org.jboss.seam.ProcessNotFound=Process #0 not found
org.jboss.seam.TaskEnded=Task #0 already ended
org.jboss.seam.TaskNotFound=Task #0 not found
-org.jboss.seam.NotLoggedIn=Please log in first
javax.faces.component.UIInput.CONVERSION=value could not be converted to the expected type
javax.faces.component.UIInput.REQUIRED=value is required
Modified: trunk/seam-gen/resources/messages_fr.properties
===================================================================
--- trunk/seam-gen/resources/messages_fr.properties 2008-01-24 17:08:50 UTC (rev 7223)
+++ trunk/seam-gen/resources/messages_fr.properties 2008-01-24 23:27:40 UTC (rev 7224)
@@ -24,8 +24,9 @@
org.jboss.seam.security.NotLoggedInException = Veuillez d'abord vous connecter
org.jboss.seam.unexpected.error = Erreur inattendue. Veuillez essayez de nouveau.
-org.jboss.seam.loginFailed = La connexion a �chou�.
-org.jboss.seam.loginSuccessful = Bienvenue, {0}
+org.jboss.seam.security.loginFailed = La connexion a �chou�.
+org.jboss.seam.security.loginSuccessful = Bienvenue, {0}
+org.jboss.seam.notLoggedIn = Veuillez d'abord vous connecter.
org.jboss.seam.TransactionFailed = La transaction a �chou�.
org.jboss.seam.NoConversation = La conversation s'est interrompue, a d�pass� les d�lais ou traite une autre requ�te.
@@ -34,7 +35,6 @@
org.jboss.seam.ProcessNotFound = Le processus #0 n'a pas �t� trouv�.
org.jboss.seam.TaskEnded = T�che #0 d�j� achev�e
org.jboss.seam.TaskNotFound = La t�che #0 n'a pas �t� trouv�e.
-org.jboss.seam.NotLoggedIn = Veuillez d'abord vous connecter.
javax.faces.component.UIInput.CONVERSION = La valeur ne peut �tre convertie dans le type attendu
javax.faces.component.UIInput.REQUIRED = Une valeur est requise.
Modified: trunk/seam-gen/resources/messages_tr.properties
===================================================================
--- trunk/seam-gen/resources/messages_tr.properties 2008-01-24 17:08:50 UTC (rev 7223)
+++ trunk/seam-gen/resources/messages_tr.properties 2008-01-24 23:27:40 UTC (rev 7224)
@@ -16,8 +16,9 @@
validator.size=girilen de\u011ferin boyut {min} ile {max} aras\u0131nda olmal\u0131d\u0131r
validator.email=girilen de\u011fer e-posta adresi format\u0131na uygun olmal\u0131d\u0131r
-org.jboss.seam.loginFailed=Oturum a\u00e7\u0131lamad\u0131
-org.jboss.seam.loginSuccessful=Ho\u015fgeldiniz, #0
+org.jboss.seam.security.loginFailed=Oturum a\u00e7\u0131lamad\u0131
+org.jboss.seam.security.loginSuccessful=Ho\u015fgeldiniz, #0
+org.jboss.seam.notLoggedIn=L\u00fctfen \u00f6ncelikle oturum a\u00e7\u0131n
org.jboss.seam.TransactionFailed=\u0130\u015flem tamamlanamad\u0131
org.jboss.seam.NoConversation=Konu\u015fma sonland\u0131, zaman a\u015f\u0131m\u0131na u\u011frad\u0131 ya da ba\u015fka bir talebi i\u015fliyordu
@@ -26,7 +27,6 @@
org.jboss.seam.ProcessNotFound=#0 s\u00fcreci bulunamad\u0131
org.jboss.seam.TaskEnded=#0 g\u00f6revi sonlanm\u0131\u015f
org.jboss.seam.TaskNotFound=#0 g\u00f6revi bulunamad\u0131
-org.jboss.seam.NotLoggedIn=L\u00fctfen \u00f6ncelikle oturum a\u00e7\u0131n
javax.faces.component.UIInput.CONVERSION=girilen de\u011fer, beklenen tipe d\u00f6n\u00fc\u015ft\u00fcr\u00fclemedi
javax.faces.component.UIInput.REQUIRED=bir de\u011fer girilmesi gereklidir
16 years, 11 months
Seam SVN: r7223 - in trunk: examples/quartz/src/org/jboss/seam/example/quartz/test and 8 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)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@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@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@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@jboss.org">Thomas Heute </a>
+ * @version $Revision: 6435 $
+ */
+@Name("foo")
+(a)Scope(ScopeType.SESSION)
+@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;
+
+@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>
16 years, 11 months
Seam SVN: r7222 - branches/Seam_2_0/src/main/org/jboss/seam/framework.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-01-24 09:04:36 -0500 (Thu, 24 Jan 2008)
New Revision: 7222
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityIdentifier.java
branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityIdentifier.java
Log:
Backport JBSEAM-2527
Modified: branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityIdentifier.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityIdentifier.java 2008-01-24 13:55:21 UTC (rev 7221)
+++ branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityIdentifier.java 2008-01-24 14:04:36 UTC (rev 7222)
@@ -3,7 +3,6 @@
import javax.persistence.EntityManager;
import javax.transaction.SystemException;
-import org.jboss.seam.Entity;
import org.jboss.seam.persistence.PersistenceProvider;
import org.jboss.seam.transaction.Transaction;
@@ -11,7 +10,8 @@
{
public EntityIdentifier(Object entity, EntityManager entityManager)
{
- super(Entity.forClass(entity.getClass()).getBeanClass(), PersistenceProvider.instance().getId(entity, entityManager));
+ super(PersistenceProvider.instance().getBeanClass(entity), PersistenceProvider.instance().getId(entity, entityManager));
+
}
public EntityIdentifier(Class clazz, Object id)
Modified: branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityIdentifier.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityIdentifier.java 2008-01-24 13:55:21 UTC (rev 7221)
+++ branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityIdentifier.java 2008-01-24 14:04:36 UTC (rev 7222)
@@ -3,13 +3,14 @@
import java.io.Serializable;
import org.hibernate.Session;
+import org.jboss.seam.persistence.HibernatePersistenceProvider;
public class HibernateEntityIdentifier extends Identifier<Session>
{
public HibernateEntityIdentifier(Object entity, Session session)
{
- super(entity.getClass(), session.getIdentifier(entity));
+ super(HibernatePersistenceProvider.instance().getBeanClass(entity), session.getIdentifier(entity));
}
public HibernateEntityIdentifier(Class clazz, Object id)
16 years, 11 months
Seam SVN: r7221 - trunk/src/main/org/jboss/seam/framework.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-01-24 08:55:21 -0500 (Thu, 24 Jan 2008)
New Revision: 7221
Modified:
trunk/src/main/org/jboss/seam/framework/EntityIdentifier.java
trunk/src/main/org/jboss/seam/framework/HibernateEntityIdentifier.java
Log:
JBSEAM-2527
Modified: trunk/src/main/org/jboss/seam/framework/EntityIdentifier.java
===================================================================
--- trunk/src/main/org/jboss/seam/framework/EntityIdentifier.java 2008-01-24 12:40:17 UTC (rev 7220)
+++ trunk/src/main/org/jboss/seam/framework/EntityIdentifier.java 2008-01-24 13:55:21 UTC (rev 7221)
@@ -3,7 +3,6 @@
import javax.persistence.EntityManager;
import javax.transaction.SystemException;
-import org.jboss.seam.Entity;
import org.jboss.seam.persistence.PersistenceProvider;
import org.jboss.seam.transaction.Transaction;
@@ -11,7 +10,8 @@
{
public EntityIdentifier(Object entity, EntityManager entityManager)
{
- super(Entity.forClass(entity.getClass()).getBeanClass(), PersistenceProvider.instance().getId(entity, entityManager));
+ super(PersistenceProvider.instance().getBeanClass(entity), PersistenceProvider.instance().getId(entity, entityManager));
+
}
public EntityIdentifier(Class clazz, Object id)
Modified: trunk/src/main/org/jboss/seam/framework/HibernateEntityIdentifier.java
===================================================================
--- trunk/src/main/org/jboss/seam/framework/HibernateEntityIdentifier.java 2008-01-24 12:40:17 UTC (rev 7220)
+++ trunk/src/main/org/jboss/seam/framework/HibernateEntityIdentifier.java 2008-01-24 13:55:21 UTC (rev 7221)
@@ -3,13 +3,14 @@
import java.io.Serializable;
import org.hibernate.Session;
+import org.jboss.seam.persistence.HibernatePersistenceProvider;
public class HibernateEntityIdentifier extends Identifier<Session>
{
public HibernateEntityIdentifier(Object entity, Session session)
{
- super(entity.getClass(), session.getIdentifier(entity));
+ super(HibernatePersistenceProvider.instance().getBeanClass(entity), session.getIdentifier(entity));
}
public HibernateEntityIdentifier(Class clazz, Object id)
16 years, 11 months
Seam SVN: r7220 - branches/Seam_2_0/build.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-01-24 07:40:17 -0500 (Thu, 24 Jan 2008)
New Revision: 7220
Modified:
branches/Seam_2_0/build/default.build.properties
Log:
restore default qualifier
Modified: branches/Seam_2_0/build/default.build.properties
===================================================================
--- branches/Seam_2_0/build/default.build.properties 2008-01-24 12:31:24 UTC (rev 7219)
+++ branches/Seam_2_0/build/default.build.properties 2008-01-24 12:40:17 UTC (rev 7220)
@@ -8,7 +8,7 @@
major.version 2
minor.version .0
patchlevel .1
-qualifier .CR2
+qualifier -SNAPSHOT
#
# Other program locations
# -----------------------
16 years, 11 months
Seam SVN: r7219 - trunk/build.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-01-24 07:31:24 -0500 (Thu, 24 Jan 2008)
New Revision: 7219
Modified:
trunk/build/default.build.properties
Log:
Update to 2.1.0 for trunk
Modified: trunk/build/default.build.properties
===================================================================
--- trunk/build/default.build.properties 2008-01-24 01:46:19 UTC (rev 7218)
+++ trunk/build/default.build.properties 2008-01-24 12:31:24 UTC (rev 7219)
@@ -6,9 +6,9 @@
# Seam Version
# ------------
major.version 2
-minor.version .0
-patchlevel .1
-qualifier .CR2
+minor.version .1
+patchlevel .0
+qualifier -SNAPSHOT
#
# Other program locations
# -----------------------
16 years, 11 months
Seam SVN: r7218 - branches.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-01-23 20:46:19 -0500 (Wed, 23 Jan 2008)
New Revision: 7218
Added:
branches/Seam_2_0/
Log:
create 2.0 branch
Copied: branches/Seam_2_0 (from rev 7217, trunk)
16 years, 11 months
Seam SVN: r7217 - trunk.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-01-23 14:30:54 -0500 (Wed, 23 Jan 2008)
New Revision: 7217
Modified:
trunk/release-process.txt
Log:
change instructions for svn
Modified: trunk/release-process.txt
===================================================================
--- trunk/release-process.txt 2008-01-23 19:30:26 UTC (rev 7216)
+++ trunk/release-process.txt 2008-01-23 19:30:54 UTC (rev 7217)
@@ -14,7 +14,7 @@
Tests
-----
* "ant cleanall testall testreport" with validate.xml = true in build.properties, check report/junit-noframes.html
-* Sanity check the following example applications on JBoss 4.2.1
+* Sanity check the following example applications on JBoss 4.2.2
- booking
- dvdstore
- jpa
@@ -59,7 +59,7 @@
CONSTRAINT `owner` FOREIGN KEY (`ownerUsername`) REFERENCES `person` (`username`)
) ENGINE=InnoDB
-* run "seam setup new-project generate-entities explode"
+* run "seam setup create-project generate-entities explode"
- test the app, at least the list and edit pages for Person
* run "seam new-action new-form restart"
- test both generated pages
@@ -75,9 +75,10 @@
-Tag CVS
+Tag SVN
-------
-* "cvs rtag JBoss_Seam_x_x_x_XX jboss-seam"
+* "svn copy trunk tags/JBoss_Seam_x_x_x_XX"
+* "svn commit tags/JBoss_Seam_x_x_x_XX"
Build + Upload
--------------
16 years, 11 months
Seam SVN: r7216 - trunk/build.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-01-23 14:30:26 -0500 (Wed, 23 Jan 2008)
New Revision: 7216
Modified:
trunk/build/sample.build.properties
Log:
fix jboss ref
Modified: trunk/build/sample.build.properties
===================================================================
--- trunk/build/sample.build.properties 2008-01-23 17:26:31 UTC (rev 7215)
+++ trunk/build/sample.build.properties 2008-01-23 19:30:26 UTC (rev 7216)
@@ -3,9 +3,9 @@
#
# Location of JBoss AS and Tomcat
# -------------------------------
-#jboss.home /Applications/jboss-4.2.1.GA # Default
+#jboss.home /Applications/jboss-4.2.2.GA # Default
#tomcat.home /Applications/apache-tomcat-6.0 # Default
-#jboss.home C:\\jboss-4.2.1.GA
+#jboss.home C:\\jboss-4.2.2.GA
#tomcat.home C:\\Tomcat-6.0
#
# Misc Settings
@@ -15,4 +15,4 @@
# Directory in which to put build distribution, defaults to ../jboss-seam-${version}.${patchlevel}
#dist.dir ../jboss-seam-dist
# alphanumeric qualifier for the version number
-#qualifier -SNAPSHOT
\ No newline at end of file
+#qualifier -SNAPSHOT
16 years, 11 months
Seam SVN: r7215 - trunk/build.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-01-23 12:26:31 -0500 (Wed, 23 Jan 2008)
New Revision: 7215
Modified:
trunk/build/ci.build.xml
Log:
minor
Modified: trunk/build/ci.build.xml
===================================================================
--- trunk/build/ci.build.xml 2008-01-23 17:25:11 UTC (rev 7214)
+++ trunk/build/ci.build.xml 2008-01-23 17:26:31 UTC (rev 7215)
@@ -20,7 +20,7 @@
<deploySnapshotPom pom="${parent.pom}" />
<deploySnapshot pom="${core.pom}" jar="${lib.dir}/jboss-seam.jar" srcjar="${lib.dir}/src/jboss-seam-sources.jar" />
<deploySnapshot pom="${debug.pom}" jar="${lib.dir}/jboss-seam-debug.jar" srcjar="${lib.dir}/src/jboss-seam-debug-sources.jar"/>
- <deploySnapshot pom="${jbas5.pom}" jar="${lib.dir}/interop/jboss-seam-jbas5.jar" srcjar="${lib.dir}/src/jboss-seam-jbas5-sources.jar"/>
+ <deploySnapshot pom="${jbas5.pom}" jar="${lib.dir}/interop/jboss-seam-jbas5.jar" srcjar="${lib.dir}/interop/src/jboss-seam-jbas5-sources.jar"/>
<deploySnapshot pom="${gen.pom}" jar="${lib.dir}/jboss-seam-gen.jar" srcjar="${lib.dir}/src/jboss-seam-gen-sources.jar"/>
<deploySnapshot pom="${ioc.pom}" jar="${lib.dir}/jboss-seam-ioc.jar" srcjar="${lib.dir}/src/jboss-seam-ioc-sources.jar"/>
<deploySnapshot pom="${mail.pom}" jar="${lib.dir}/jboss-seam-mail.jar" srcjar="${lib.dir}/src/jboss-seam-mail-sources.jar"/>
16 years, 11 months