[seam-commits] Seam SVN: r12211 - in modules/faces/trunk: src/main/java/org/jboss/seam/faces and 4 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Mar 17 17:29:10 EDT 2010


Author: lincolnthree
Date: 2010-03-17 17:29:09 -0400 (Wed, 17 Mar 2010)
New Revision: 12211

Added:
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/ExternalContextProducer.java
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/FacesContextProducer.java
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/NavigationHandlerProducer.java
Removed:
   modules/faces/trunk/src/main/java/org/jboss/seam/faces/context/FacesContextProducer.java
   modules/faces/trunk/src/test/resources/org/
   modules/faces/trunk/src/test/resources/test-suite.xml
Modified:
   modules/faces/trunk/pom.xml
   modules/faces/trunk/src/test/java/org/jboss/seam/faces/event/PhaseListenerTests.java
   modules/faces/trunk/src/test/java/org/jboss/seam/faces/event/SystemEventListenerTests.java
Log:
* Fixed POM
* Moved from TestNG to JUnit
* Added Arquillian profile for embedded GFv3
* Restructured producers into faces.producer
* Cleaned up test resources

Modified: modules/faces/trunk/pom.xml
===================================================================
--- modules/faces/trunk/pom.xml	2010-03-17 12:22:42 UTC (rev 12210)
+++ modules/faces/trunk/pom.xml	2010-03-17 21:29:09 UTC (rev 12211)
@@ -1,8 +1,12 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 
+	<artifactId>seam-faces</artifactId>
+	<version>3.0.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Seam Faces Module</name>
+
 	<parent>
 		<artifactId>seam-parent</artifactId>
 		<groupId>org.jboss.seam</groupId>
@@ -14,11 +18,6 @@
 		<jsfmock.version>1.0.1-SNAPSHOT</jsfmock.version>
 	</properties>
 
-	<artifactId>seam-faces</artifactId>
-	<version>3.0.0-SNAPSHOT</version>
-	<packaging>jar</packaging>
-	<name>Seam Faces Module</name>
-
 	<!-- Snapshots repo to get parent -->
 	<repositories>
 		<repository>
@@ -33,37 +32,59 @@
 				<updatePolicy>never</updatePolicy>
 			</snapshots>
 		</repository>
+		<repository>
+			<id>snapshots.jboss.org</id>
+			<name>JBoss Snapshots Repository</name>
+			<url>http://snapshots.jboss.org/maven2</url>
+			<releases>
+				<enabled>false</enabled>
+			</releases>
+			<snapshots>
+				<enabled>true</enabled>
+				<updatePolicy>never</updatePolicy>
+			</snapshots>
+		</repository>
+
+		<repository>
+			<id>Java.NET</id>
+			<name>Java.NET Maven2 Repository</name>
+			<url>http://download.java.net/maven/2/</url>
+		</repository>
 	</repositories>
 
 	<dependencies>
 
 		<dependency>
-			<groupId>javax</groupId>
-			<artifactId>javaee-web-api</artifactId>
-			<version>6.0</version>
+			<!-- This is necessary until a new JSF-API is published to central -->
+			<groupId>com.sun.faces</groupId>
+			<artifactId>jsf-api</artifactId>
+			<version>2.0.2</version>
 			<scope>provided</scope>
 		</dependency>
-
 		<dependency>
 			<groupId>javax.enterprise</groupId>
 			<artifactId>cdi-api</artifactId>
-			<version>1.0-SP1</version>
-		</dependency>		
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>javax.annotation</groupId>
+			<artifactId>jsr250-api</artifactId>
+			<scope>provided</scope>
+		</dependency>
 
 		<dependency>
-			<groupId>org.testng</groupId>
-			<artifactId>testng</artifactId>
-			<version>5.10</version>
-			<classifier>jdk15</classifier>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.6</version>
 			<scope>test</scope>
 		</dependency>
 
 		<dependency>
 			<groupId>org.jboss.arquillian</groupId>
-			<artifactId>arquillian-testng</artifactId>
+			<artifactId>arquillian-junit</artifactId>
 			<version>${arquillian.version}</version>
 			<scope>test</scope>
-		</dependency>		
+		</dependency>
 
 		<dependency>
 			<groupId>org.jboss.arquillian.container</groupId>
@@ -76,10 +97,29 @@
 			<artifactId>jsf-mock</artifactId>
 			<version>${jsfmock.version}</version>
 			<scope>test</scope>
-		</dependency>		
+		</dependency>
 
+		<dependency>
+			<groupId>org.jboss.jsfunit</groupId>
+			<artifactId>jboss-jsfunit-core</artifactId>
+			<version>1.2.0.Final</version>
+			<scope>test</scope>
+		</dependency>
+
 	</dependencies>
 
+	<profiles>
+		<profile>
+			<id>arquillian-glassfish-embedded-30</id>
+			<dependencies>
+				<dependency>
+					<groupId>org.jboss.arquillian.container</groupId>
+					<artifactId>arquillian-glassfish-embedded-30</artifactId>
+					<version>${arquillian.version}</version>
+				</dependency>
+			</dependencies>
+		</profile>
+	</profiles>
 
 	<scm>
 		<connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/faces/trunk</connection>

Deleted: modules/faces/trunk/src/main/java/org/jboss/seam/faces/context/FacesContextProducer.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/context/FacesContextProducer.java	2010-03-17 12:22:42 UTC (rev 12210)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/context/FacesContextProducer.java	2010-03-17 21:29:09 UTC (rev 12211)
@@ -1,34 +0,0 @@
-//$Id: FacesContext.java 5350 2007-06-20 17:53:19Z gavin $
-package org.jboss.seam.faces.context;
-
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.inject.Produces;
-import javax.faces.context.FacesContext;
-
-/**
- * <p>
- * A producer which retrieves the current JSF FacesContext by calling
- * {@link FacesContext#getCurrentInstance}, thus allowing it to be injected.
- * </p>
- * 
- * <p>
- * QUESTION should we return null if there is no current phase id? (seems to be
- * a common check)
- * </p>
- * <p>
- * QUESTION is it correct to use a @RequestScoped producer? If it is @Dependent,
- * then a developer could unknowingly bind it to a wider-scoped bean
- * </p>
- * 
- * @author Gavin King
- * @author Dan Allen
- */
-public class FacesContextProducer
-{
-   public @Produces
-   @RequestScoped
-   FacesContext getFacesContext()
-   {
-      return FacesContext.getCurrentInstance();
-   }
-}

Added: modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/ExternalContextProducer.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/ExternalContextProducer.java	                        (rev 0)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/ExternalContextProducer.java	2010-03-17 21:29:09 UTC (rev 12211)
@@ -0,0 +1,34 @@
+//$Id: FacesContext.java 5350 2007-06-20 17:53:19Z gavin $
+package org.jboss.seam.faces.producer;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+
+/**
+ * <p>
+ * A producer which retrieves the current JSF ExternalContext by calling
+ * {@link FacesContext#getCurrentInstance#getExternalContext()}, thus allowing
+ * it to be injected.
+ * </p>
+ * 
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public class ExternalContextProducer
+{
+   @Inject
+   FacesContext context;
+
+   public @Produces
+   @RequestScoped
+   ExternalContext getExternalContext()
+   {
+      if (context != null)
+      {
+         return context.getExternalContext();
+      }
+      return null;
+   }
+}

Added: modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/FacesContextProducer.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/FacesContextProducer.java	                        (rev 0)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/FacesContextProducer.java	2010-03-17 21:29:09 UTC (rev 12211)
@@ -0,0 +1,34 @@
+//$Id: FacesContext.java 5350 2007-06-20 17:53:19Z gavin $
+package org.jboss.seam.faces.producer;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.faces.context.FacesContext;
+
+/**
+ * <p>
+ * A producer which retrieves the current JSF FacesContext by calling
+ * {@link FacesContext#getCurrentInstance}, thus allowing it to be injected.
+ * </p>
+ * 
+ * <p>
+ * QUESTION should we return null if there is no current phase id? (seems to be
+ * a common check)
+ * </p>
+ * <p>
+ * QUESTION is it correct to use a @RequestScoped producer? If it is @Dependent,
+ * then a developer could unknowingly bind it to a wider-scoped bean
+ * </p>
+ * 
+ * @author Gavin King
+ * @author Dan Allen
+ */
+public class FacesContextProducer
+{
+   public @Produces
+   @RequestScoped
+   FacesContext getFacesContext()
+   {
+      return FacesContext.getCurrentInstance();
+   }
+}

Added: modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/NavigationHandlerProducer.java
===================================================================
--- modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/NavigationHandlerProducer.java	                        (rev 0)
+++ modules/faces/trunk/src/main/java/org/jboss/seam/faces/producer/NavigationHandlerProducer.java	2010-03-17 21:29:09 UTC (rev 12211)
@@ -0,0 +1,38 @@
+//$Id: FacesContext.java 5350 2007-06-20 17:53:19Z gavin $
+package org.jboss.seam.faces.producer;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.faces.application.Application;
+import javax.faces.application.NavigationHandler;
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+
+/**
+ * <p>
+ * A producer which retrieves the current JSF NavigationHandler by calling
+ * {@link Application#getNavigationHandler()}, thus allowing it to be injected.
+ * </p>
+ * 
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public class NavigationHandlerProducer
+{
+   @Inject
+   FacesContext context;
+
+   public @Produces
+   @RequestScoped
+   NavigationHandler getNavigationHandler()
+   {
+      if (context != null)
+      {
+         Application application = context.getApplication();
+         if (application != null)
+         {
+            return application.getNavigationHandler();
+         }
+      }
+      return null;
+   }
+}

Modified: modules/faces/trunk/src/test/java/org/jboss/seam/faces/event/PhaseListenerTests.java
===================================================================
--- modules/faces/trunk/src/test/java/org/jboss/seam/faces/event/PhaseListenerTests.java	2010-03-17 12:22:42 UTC (rev 12210)
+++ modules/faces/trunk/src/test/java/org/jboss/seam/faces/event/PhaseListenerTests.java	2010-03-17 21:29:09 UTC (rev 12211)
@@ -5,59 +5,58 @@
 import javax.inject.Inject;
 
 import org.jboss.arquillian.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.shrinkwrap.api.ArchivePaths;
 import org.jboss.shrinkwrap.api.Archives;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
 import org.jboss.test.faces.mock.context.MockFacesContext;
 import org.jboss.test.faces.mock.lifecycle.MockLifecycle;
-import org.testng.annotations.Test;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
- at Test
-public class PhaseListenerTests extends Arquillian
+ at RunWith(Arquillian.class)
+public class PhaseListenerTests
 {
-
    @Deployment
    public static JavaArchive createTestArchive()
    {
-      return Archives.create("test.jar", JavaArchive.class)
-         .addClasses(PhaseListenerObserver.class, PhaseEventListener.class, GenericEventListener.class)
-         .addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+      return Archives.create("test.jar", JavaArchive.class).addClasses(PhaseListenerObserver.class, PhaseEventListener.class, GenericEventListener.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
    }
 
-   @Inject PhaseEventListener phaseEventListener;
+   @Inject
+   PhaseEventListener phaseEventListener;
 
-   private MockFacesContext facesContext = new MockFacesContext();
-   private MockLifecycle lifecycle = new MockLifecycle();
-   
+   private final MockFacesContext facesContext = new MockFacesContext();
+   private final MockLifecycle lifecycle = new MockLifecycle();
+
    @Test
    public void testBeforeRenderResponseObserver()
    {
       phaseEventListener.beforePhase(new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, lifecycle));
       assert PhaseListenerObserver.observeBeforeRenderResponse;
    }
-   
+
    @Test
    public void testAfterRenderResponseObserver()
    {
       phaseEventListener.afterPhase(new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, lifecycle));
       assert PhaseListenerObserver.observeAfterRenderResponse;
    }
-   
+
    @Test
    public void testBeforeApplyRequestValuesObserver()
    {
       phaseEventListener.beforePhase(new PhaseEvent(facesContext, PhaseId.APPLY_REQUEST_VALUES, lifecycle));
       assert PhaseListenerObserver.observeBeforeApplyRequestValues;
    }
-   
+
    @Test
    public void testAfterApplyRequestValuesObserver()
    {
       phaseEventListener.afterPhase(new PhaseEvent(facesContext, PhaseId.APPLY_REQUEST_VALUES, lifecycle));
       assert PhaseListenerObserver.observeAfterApplyRequestValues;
-   }   
+   }
 
    @Test
    public void testBeforeInvokeApplicationObserver()
@@ -65,13 +64,13 @@
       phaseEventListener.beforePhase(new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, lifecycle));
       assert PhaseListenerObserver.observeBeforeInvokeApplication;
    }
-   
+
    @Test
    public void testAfterInvokeApplicationObserver()
    {
       phaseEventListener.afterPhase(new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, lifecycle));
       assert PhaseListenerObserver.observeAfterInvokeApplication;
-   }   
+   }
 
    @Test
    public void testBeforeProcessValidationsObserver()
@@ -79,13 +78,13 @@
       phaseEventListener.beforePhase(new PhaseEvent(facesContext, PhaseId.PROCESS_VALIDATIONS, lifecycle));
       assert PhaseListenerObserver.observeBeforeProcessValidations;
    }
-   
+
    @Test
    public void testAfterProcessValidationsObserver()
    {
       phaseEventListener.afterPhase(new PhaseEvent(facesContext, PhaseId.PROCESS_VALIDATIONS, lifecycle));
       assert PhaseListenerObserver.observeAfterProcessValidations;
-   }   
+   }
 
    @Test
    public void testBeforeRestoreViewObserver()
@@ -93,13 +92,13 @@
       phaseEventListener.beforePhase(new PhaseEvent(facesContext, PhaseId.RESTORE_VIEW, lifecycle));
       assert PhaseListenerObserver.observeBeforeRestoreView;
    }
-   
+
    @Test
    public void testAfterRestoreViewObserver()
    {
       phaseEventListener.afterPhase(new PhaseEvent(facesContext, PhaseId.RESTORE_VIEW, lifecycle));
       assert PhaseListenerObserver.observeAfterRestoreView;
-   }   
+   }
 
    @Test
    public void testBeforeUpdateModelValuesObserver()
@@ -107,12 +106,12 @@
       phaseEventListener.beforePhase(new PhaseEvent(facesContext, PhaseId.UPDATE_MODEL_VALUES, lifecycle));
       assert PhaseListenerObserver.observeBeforeUpdateModelValues;
    }
-   
+
    @Test
    public void testAfterUpdateModelValuesObserver()
    {
       phaseEventListener.afterPhase(new PhaseEvent(facesContext, PhaseId.UPDATE_MODEL_VALUES, lifecycle));
       assert PhaseListenerObserver.observeAfterUpdateModelValues;
-   }   
+   }
 
 }

Modified: modules/faces/trunk/src/test/java/org/jboss/seam/faces/event/SystemEventListenerTests.java
===================================================================
--- modules/faces/trunk/src/test/java/org/jboss/seam/faces/event/SystemEventListenerTests.java	2010-03-17 12:22:42 UTC (rev 12210)
+++ modules/faces/trunk/src/test/java/org/jboss/seam/faces/event/SystemEventListenerTests.java	2010-03-17 21:29:09 UTC (rev 12211)
@@ -13,7 +13,7 @@
 import javax.inject.Inject;
 
 import org.jboss.arquillian.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.shrinkwrap.api.ArchivePaths;
 import org.jboss.shrinkwrap.api.Archives;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
@@ -21,33 +21,35 @@
 import org.jboss.test.faces.mock.application.MockApplication;
 import org.jboss.test.faces.mock.component.MockUIComponent;
 import org.jboss.test.faces.mock.context.MockFacesContext;
-import org.testng.annotations.Test;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
- at Test
-public class SystemEventListenerTests extends Arquillian
+ at RunWith(Arquillian.class)
+public class SystemEventListenerTests
 {
 
    @Deployment
    public static JavaArchive createTestArchive()
    {
-      return Archives.create("test.jar", JavaArchive.class)
-         .addClasses(SystemEventObserver.class, SystemEventListener.class, GenericEventListener.class)
-         .addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+      return Archives.create("test.jar", JavaArchive.class).addClasses(SystemEventObserver.class, SystemEventListener.class, GenericEventListener.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
    }
-   
-   @Inject SystemEventListener systemEventListener;
 
-   private MockFacesContext facesContext = new MockFacesContext();
-   private MockApplication application = new MockApplication();
-   
+   @Inject
+   SystemEventListener systemEventListener;
+
+   private final MockFacesContext facesContext = new MockFacesContext();
+   private final MockApplication application = new MockApplication();
+
    @SuppressWarnings("serial")
    @Test
    public void testComponentSystemEventObserver()
    {
-      systemEventListener.processEvent(new ComponentSystemEvent(new MockUIComponent()){});
+      systemEventListener.processEvent(new ComponentSystemEvent(new MockUIComponent())
+      {
+      });
       assert SystemEventObserver.componentSystemEvent;
-   }   
-   
+   }
+
    @Test
    public void testExceptionQueuedEventObserver()
    {
@@ -55,15 +57,15 @@
       ExceptionQueuedEvent eqe = new ExceptionQueuedEvent(eqec);
       systemEventListener.processEvent(eqe);
       assert SystemEventObserver.excecptionQueuedEvent;
-   }   
-   
+   }
+
    @Test
    public void testPostConstructApplicationEventObserver()
    {
       systemEventListener.processEvent(new PostConstructApplicationEvent(application));
       assert SystemEventObserver.postConstructApplicationEvent;
-   }   
-   
+   }
+
    @Test
    public void testPostConstructCustomScopeEvent()
    {
@@ -71,20 +73,20 @@
       systemEventListener.processEvent(new PostConstructCustomScopeEvent(sc));
       assert SystemEventObserver.postConstructCustomScopeEvent;
    }
-   
+
    @Test
    public void testPreDestroyApplicationEventObserver()
    {
       systemEventListener.processEvent(new PreDestroyApplicationEvent(application));
       assert SystemEventObserver.preDestroyApplicationEvent;
-   }    
-   
+   }
+
    @Test
    public void testPreDestroyCustomScopeEventObserver()
    {
       ScopeContext sc = new ScopeContext("dummyscope", new HashMap<String, Object>());
       systemEventListener.processEvent(new PreDestroyCustomScopeEvent(sc));
       assert SystemEventObserver.preDestroyCustomScopeEvent;
-   }        
-   
+   }
+
 }

Deleted: modules/faces/trunk/src/test/resources/test-suite.xml
===================================================================
--- modules/faces/trunk/src/test/resources/test-suite.xml	2010-03-17 12:22:42 UTC (rev 12210)
+++ modules/faces/trunk/src/test/resources/test-suite.xml	2010-03-17 21:29:09 UTC (rev 12211)
@@ -1,15 +0,0 @@
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="Seam Faces Module Test Suite" verbose="1">
-   <test name="Seam Faces Module - Unit Tests">
-      <!--
-      <method-selectors>
-         <method-selector>
-            <selector-class name="org.jboss.testharness.impl.testng.DisableIntegrationTestsMethodSelector"/>
-         </method-selector>
-      </method-selectors>
-      -->
-      <packages>
-         <package name="org.jboss.seam.faces.*"/>
-      </packages>
-   </test>
-</suite>



More information about the seam-commits mailing list