Seam SVN: r10675 - in branches/community/Seam_2_1/examples: tasks and 13 other directories.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2009-04-28 07:35:20 -0400 (Tue, 28 Apr 2009)
New Revision: 10675
Added:
branches/community/Seam_2_1/examples/tasks/
branches/community/Seam_2_1/examples/tasks/build.xml
branches/community/Seam_2_1/examples/tasks/resources/
branches/community/Seam_2_1/examples/tasks/resources/components.properties
branches/community/Seam_2_1/examples/tasks/resources/import.sql
branches/community/Seam_2_1/examples/tasks/resources/jboss-seam-tasks-ds.xml
branches/community/Seam_2_1/examples/tasks/resources/seam.properties
branches/community/Seam_2_1/examples/tasks/src/
branches/community/Seam_2_1/examples/tasks/src/main/
branches/community/Seam_2_1/examples/tasks/src/main/org/
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/Authenticator.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ContextHome.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ResourceNotFoundException.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/TaskHome.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/UserHome.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Context.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Task.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/User.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/ContextResource.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/ResolvedTaskResourceQuery.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/TaskResourceHome.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/TaskResourceQuery.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/UserResourceHome.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ContextResourceTest.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/TaskResourceTest.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/UserFactory.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/DelegatingServletInputStream.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/DelegatingServletOutputStream.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/HeaderValueHolder.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockHttpServletRequest.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockHttpServletResponse.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockRequestDispatcher.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/ResourceSeamTest.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/testng.xml
branches/community/Seam_2_1/examples/tasks/view/
branches/community/Seam_2_1/examples/tasks/view/seam-tasks-client.js
Log:
seam tasks example server part
Added: branches/community/Seam_2_1/examples/tasks/build.xml
===================================================================
--- branches/community/Seam_2_1/examples/tasks/build.xml (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/build.xml 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+
+<project name="Tasks" default="deploy" basedir=".">
+
+ <!-- Naming -->
+ <property name="Name" value="JBoss Tasks Example"/>
+ <property name="example.name" value="jboss-seam-tasks"/>
+
+ <!-- Libraries to include -->
+ <property name="seam.ui.lib" value="yes"/>
+ <property name="seam.debug.lib" value="yes"/>
+ <property name="facelets.lib" value="yes"/>
+ <!--<property name="richfaces.lib" value="yes"/>-->
+ <property name="seam.resteasy.lib" value="yes"/>
+
+ <!-- Datasource -->
+ <property name="example.ds" value="jboss-seam-tasks-ds.xml"/>
+
+ <import file="../build.xml"/>
+</project>
Property changes on: branches/community/Seam_2_1/examples/tasks/build.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/resources/components.properties
===================================================================
--- branches/community/Seam_2_1/examples/tasks/resources/components.properties (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/resources/components.properties 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,3 @@
+# The pattern in components.xml is replaced by an application server specific value in the ant build. This value is used for running tests
+
+jndiPattern \#{ejbName}/local
Property changes on: branches/community/Seam_2_1/examples/tasks/resources/components.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/resources/import.sql
===================================================================
--- branches/community/Seam_2_1/examples/tasks/resources/import.sql (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/resources/import.sql 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,20 @@
+insert into User (username, password, admin) values ('demo', 'demo', false)
+insert into User (username, password, admin) values ('admin', 'password', true)
+insert into Context (id, name, owner_username) values (1, 'School', 'demo')
+ insert into Task (id, name, resolved, created, updated, context_id) values (2, 'Build the Turing machine', false, '2009-04-19 16:11:05', null, 1)
+ insert into Task (id, name, resolved, created, updated, context_id) values (3, 'Finish the RESTEasy-Seam integration example', false, '2009-04-19 16:11:05', null, 1)
+ insert into Task (id, name, resolved, created, updated, context_id) values (4, 'Learn new vocab for English conversations', false, '2009-04-19 16:11:05', null, 1)
+ insert into Task (id, name, resolved, created, updated, context_id) values (5, 'Prepare a presentation for webdesign seminar', false, '2009-04-19 16:11:05', null, 1)
+
+insert into Context (id, name, owner_username) values (2, 'Work', 'demo')
+ insert into Task (id, name, resolved, created, updated, context_id) values (6, 'Pick up meal tickets', false, '2009-04-19 16:11:05', null, 2)
+insert into Context (id, name, owner_username) values (3, 'Buy', 'demo')
+ insert into Task (id, name, resolved, created, updated, context_id) values (7, 'Buy milk', false, '2009-04-19 16:11:05', null, 3)
+ insert into Task (id, name, resolved, created, updated, context_id) values (8, 'Buy an infinite tape', false, '2009-04-19 16:11:05', null, 3)
+ insert into Task (id, name, resolved, created, updated, context_id) values (9, 'Order books', false, '2009-04-19 16:11:05', null, 3)
+ insert into Task (id, name, resolved, created, updated, context_id) values (10, 'Buy a turtle', true, '2009-04-19 16:11:05', '2009-04-22 13:15:33', 3)
+insert into Context (id, name, owner_username) values (4, 'Other stuff', 'demo')
+ insert into Task (id, name, resolved, created, updated, context_id) values (11, 'Learn to fly', false, '2009-04-19 16:11:05', null, 4)
+ insert into Task (id, name, resolved, created, updated, context_id) values (12, 'Visit grandma', false, '2009-04-19 16:11:05', null, 4)
+ insert into Task (id, name, resolved, created, updated, context_id) values (13, 'Extend passport', false, '2009-04-19 16:11:05', null, 4)
+ insert into Task (id, name, resolved, created, updated, context_id) values (14, 'Get a haircut', false, '2009-04-19 16:11:05', null, 4)
Added: branches/community/Seam_2_1/examples/tasks/resources/jboss-seam-tasks-ds.xml
===================================================================
--- branches/community/Seam_2_1/examples/tasks/resources/jboss-seam-tasks-ds.xml (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/resources/jboss-seam-tasks-ds.xml 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE datasources
+ PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
+
+<datasources>
+ <local-tx-datasource>
+ <jndi-name>tasksDatasource</jndi-name>
+ <connection-url>jdbc:hsqldb:.</connection-url>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+ <user-name>sa</user-name>
+ <password></password>
+ </local-tx-datasource>
+</datasources>
+
Property changes on: branches/community/Seam_2_1/examples/tasks/resources/jboss-seam-tasks-ds.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/resources/seam.properties
===================================================================
Property changes on: branches/community/Seam_2_1/examples/tasks/resources/seam.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/Authenticator.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/Authenticator.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/Authenticator.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,51 @@
+package org.jboss.seam.example.tasks;
+
+import javax.persistence.EntityManager;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.example.tasks.entity.User;
+import org.jboss.seam.security.Credentials;
+import org.jboss.seam.security.Identity;
+
+/**
+ * Application authenticator. User is added to admin role if the admin property
+ * is set to true.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+@Name("authenticator")
+(a)Scope(ScopeType.EVENT)
+public class Authenticator
+{
+
+ @In
+ private Identity identity;
+ @In
+ private Credentials credentials;
+ @In
+ private EntityManager entityManager;
+ @Out(scope = ScopeType.SESSION)
+ private User user;
+
+ public boolean authenticate()
+ {
+ user = entityManager.find(User.class, credentials.getUsername());
+ if ((user != null) || (user.getPassword().equals(credentials.getPassword())))
+ {
+ if (user.isAdmin())
+ {
+ identity.addRole("admin");
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/Authenticator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ContextHome.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ContextHome.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ContextHome.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,19 @@
+package org.jboss.seam.example.tasks;
+
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.example.tasks.entity.Context;
+import org.jboss.seam.framework.EntityHome;
+
+@Name("contextHome")
+@AutoCreate
+public class ContextHome extends EntityHome<Context>
+{
+
+ public Context findByUsernameAndContext(String username, String context)
+ {
+ setInstance((Context) getEntityManager().createNamedQuery("contextByNameAndUser").setParameter("username", username).setParameter("context", context).getSingleResult());
+ return getInstance();
+ }
+
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ContextHome.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ResourceNotFoundException.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ResourceNotFoundException.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ResourceNotFoundException.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,20 @@
+package org.jboss.seam.example.tasks;
+
+/**
+ * This exception is mapped to 404 HTTP response code.
+ * @author Jozef Hartinger
+ *
+ */
+public class ResourceNotFoundException extends RuntimeException
+{
+
+ public ResourceNotFoundException()
+ {
+ }
+
+ public ResourceNotFoundException(String message)
+ {
+ super(message);
+ }
+
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ResourceNotFoundException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/TaskHome.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/TaskHome.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/TaskHome.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,17 @@
+package org.jboss.seam.example.tasks;
+
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.example.tasks.entity.Task;
+import org.jboss.seam.framework.EntityHome;
+
+@Name("taskHome")
+@AutoCreate
+public class TaskHome extends EntityHome<Task>
+{
+ public Task findTask(Long context, String task) {
+ setInstance((Task) getEntityManager().createNamedQuery("taskByNameAndContext").setParameter("task", task).setParameter("context", context).getSingleResult());
+ return getInstance();
+ }
+
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/TaskHome.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/UserHome.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/UserHome.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/UserHome.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,13 @@
+package org.jboss.seam.example.tasks;
+
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.example.tasks.entity.User;
+import org.jboss.seam.framework.EntityHome;
+
+@Name("userHome")
+@AutoCreate
+public class UserHome extends EntityHome<User>
+{
+
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/UserHome.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Context.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Context.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Context.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,90 @@
+package org.jboss.seam.example.tasks.entity;
+
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.hibernate.validator.NotNull;
+
+@Entity
+@XmlRootElement
+@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "NAME", "OWNER_USERNAME" }))
+@NamedQuery(name = "contextByNameAndUser", query = "select context from Context context where context.owner.username like :username and context.name like :context")
+public class Context
+{
+ private Long id;
+ private String name;
+ private List<Task> tasks;
+ private User owner;
+
+ public Context()
+ {
+ }
+
+ public Context(Long id, String name, List<Task> tasks, User owner)
+ {
+ this.id = id;
+ this.name = name;
+ this.tasks = tasks;
+ this.owner = owner;
+ }
+
+ @Id
+ @GeneratedValue
+ @XmlTransient
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @NotNull
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @OneToMany(mappedBy = "context", cascade = CascadeType.REMOVE)
+ @XmlTransient
+ public List<Task> getTasks()
+ {
+ return tasks;
+ }
+
+ public void setTasks(List<Task> tasks)
+ {
+ this.tasks = tasks;
+ }
+
+ @ManyToOne
+ @XmlTransient
+ public User getOwner()
+ {
+ return owner;
+ }
+
+ public void setOwner(User owner)
+ {
+ this.owner = owner;
+ }
+
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Context.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Task.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Task.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Task.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,114 @@
+package org.jboss.seam.example.tasks.entity;
+
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.hibernate.validator.NotNull;
+
+@Entity
+@XmlRootElement
+@NamedQuery(name="taskByNameAndContext", query="select task from Task task where task.name like :task and task.context.id = :context")
+public class Task
+{
+ private Long id;
+ private String name;
+ private boolean resolved;
+ private Date created;
+ private Date updated;
+ private Context context;
+
+ @Id
+ @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @NotNull
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @NotNull
+ public boolean isResolved()
+ {
+ return resolved;
+ }
+
+ public void setResolved(boolean resolved)
+ {
+ this.resolved = resolved;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @XmlElement(name="created")
+ @NotNull
+ public Date getCreated()
+ {
+ return created;
+ }
+
+ public void setCreated(Date created)
+ {
+ this.created = created;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ public Date getUpdated()
+ {
+ return updated;
+ }
+
+ public void setUpdated(Date updated)
+ {
+ this.updated = updated;
+ }
+
+ @ManyToOne
+ @XmlTransient
+ @NotNull
+ public Context getContext()
+ {
+ return context;
+ }
+
+
+ public void setContext(Context context)
+ {
+ this.context = context;
+ }
+
+ @Transient
+ @XmlElement(name="context")
+ public String getContextName() {
+ return context.getName();
+ }
+
+ @Transient
+ public User getOwner() {
+ return context.getOwner();
+ }
+
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Task.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/User.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/User.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/User.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,65 @@
+package org.jboss.seam.example.tasks.entity;
+
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.hibernate.validator.NotNull;
+
+@Entity
+@XmlRootElement
+public class User
+{
+ private String username;
+ private String password;
+ private List<Context> contexts;
+ private boolean admin;
+
+ @Id
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ @NotNull
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ @OneToMany(mappedBy = "owner")
+ @XmlTransient
+ public List<Context> getContexts()
+ {
+ return contexts;
+ }
+
+ public void setContexts(List<Context> contexts)
+ {
+ this.contexts = contexts;
+ }
+
+ public boolean isAdmin()
+ {
+ return admin;
+ }
+
+ public void setAdmin(boolean admin)
+ {
+ this.admin = admin;
+ }
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/User.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/ContextResource.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/ContextResource.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/ContextResource.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.tasks.resource;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.example.tasks.ContextHome;
+import org.jboss.seam.example.tasks.entity.User;
+
+/**
+ * This resource demonstrates use of plain JAX-RS resource (no ResourceHome
+ * component) with Seam. It allows retrieving (GET), creating (PUT) and deleting
+ * (DELETE) of task contexts. To create new context, simply send a PUT request
+ * without entity body to /auth/context/name where "name" is the name of
+ * context. Same path applies for retrieving and deleting of context.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+
+@Path("/auth/context/{context}")
+@Name("contextResource")
+@Produces( { "application/xml", "application/json", "application/fastinfoset" })
+@Consumes( { "application/xml", "application/json", "application/fastinfoset" })
+public class ContextResource
+{
+ @In
+ private ContextHome contextHome;
+
+ @javax.ws.rs.core.Context
+ private UriInfo uriInfo;
+
+ @In
+ private User user;
+
+ @PathParam("context")
+ private String context;
+
+ @GET
+ public Response getContext()
+ {
+ return Response.ok(contextHome.findByUsernameAndContext(user.getUsername(), context)).build();
+ }
+
+ @PUT
+ public Response putContext()
+ {
+ contextHome.getInstance().setName(context);
+ contextHome.getInstance().setOwner(user);
+ // may cause exception if user already has a Context with that name
+ // in that case the exception is handled by exception mapper
+ contextHome.persist();
+ return Response.created(uriInfo.getAbsolutePath()).build();
+ }
+
+ @DELETE
+ public void deleteContext()
+ {
+ contextHome.findByUsernameAndContext(user.getUsername(), context);
+ contextHome.remove();
+ }
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/ContextResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/ResolvedTaskResourceQuery.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/ResolvedTaskResourceQuery.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/ResolvedTaskResourceQuery.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.tasks.resource;
+
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import org.jboss.resteasy.plugins.providers.atom.Entry;
+import org.jboss.resteasy.plugins.providers.atom.Feed;
+import org.jboss.resteasy.plugins.providers.atom.Person;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.example.tasks.ResourceNotFoundException;
+import org.jboss.seam.example.tasks.entity.Task;
+import org.jboss.seam.resteasy.ResourceQuery;
+
+/**
+ * This resource exposes a list of resolved tasks for a particular user using
+ * ResourceQuery component. This list is available publicly without
+ * authentication needed. The list can be marshalled to XML, JSON, Fastinfoset.
+ * ResourceQuery component is extended in order to provide Atom feed.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+@Name("resolvedTaskResourceQuery")
+@Path("/user/{username}/tasks/resolved")
+public class ResolvedTaskResourceQuery extends ResourceQuery<Task>
+{
+
+ @PathParam("username")
+ private String username;
+
+ public ResolvedTaskResourceQuery()
+ {
+ setMediaTypes(new String[] { "application/xml", "application/json", "application/fastinfoset" });
+ }
+
+ @Override
+ @Create
+ public void create()
+ {
+ super.create();
+ List<String> restrictions = new ArrayList<String>();
+ restrictions.add("context.owner.username = #{username} AND resolved = true");
+ getEntityQuery().setRestrictionExpressionStrings(restrictions);
+ getEntityQuery().setOrderColumn("updated");
+ getEntityQuery().setOrderDirection("desc");
+ }
+
+ @Produces("application/atom+xml")
+ @GET
+ public Feed getFeed() throws URISyntaxException
+ {
+ List<Task> tasks = getEntityList(0, 0);
+ if (tasks.size() == 0)
+ {
+ // TODO make difference between empty list and nonsense user
+ throw new ResourceNotFoundException();
+ }
+
+ Feed feed = new Feed();
+ feed.setTitle("Resolved feeds for " + username);
+ feed.getAuthors().add(new Person(username));
+ feed.setUpdated(new Date(0));
+
+ for (Task task : tasks)
+ {
+ Entry entry = new Entry();
+ entry.setTitle(task.getName());
+ entry.setSummary(task.getName());
+ entry.setPublished(task.getCreated());
+ entry.setUpdated(task.getUpdated());
+ feed.getEntries().add(entry);
+ }
+ return feed;
+ }
+
+ @Factory("username")
+ public String getUsername()
+ {
+ return username;
+ }
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/ResolvedTaskResourceQuery.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/TaskResourceHome.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/TaskResourceHome.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/TaskResourceHome.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.tasks.resource;
+
+import java.io.InputStream;
+import java.util.Date;
+
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.example.tasks.ContextHome;
+import org.jboss.seam.example.tasks.ResourceNotFoundException;
+import org.jboss.seam.example.tasks.TaskHome;
+import org.jboss.seam.example.tasks.entity.Task;
+import org.jboss.seam.example.tasks.entity.User;
+import org.jboss.seam.framework.Home;
+import org.jboss.seam.resteasy.ResourceHome;
+
+/**
+ * This class exposes CRUD interface for manipulating tasks. ResourceHome
+ * component is used as the base and is significantly customized to correspond
+ * with usecase.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+@Path("/auth/context/{context}/{status}")
+@Name("taskResourceHome")
+public class TaskResourceHome extends ResourceHome<Task, Long>
+{
+
+ @PathParam("status")
+ private String taskStatus;
+ @In
+ private User user;
+ @In
+ private ContextHome contextHome;
+ @In
+ private TaskHome taskHome;
+ @PathParam("context")
+ private String contextName;
+
+ public TaskResourceHome()
+ {
+ setMediaTypes(new String[] { "application/xml", "application/json", "application/fastinfoset" });
+ }
+
+ @Override
+ public Task getEntity(Long id)
+ {
+ Task task = super.getEntity(id);
+ if (!task.getContext().getName().equals(contextName) || !task.getOwner().getUsername().equals(user.getUsername()))
+ {
+ throw new ResourceNotFoundException("Task not found");
+ }
+ if (!task.isResolved() == isResolved())
+ {
+ throw new ResourceNotFoundException("Task found, but in different state.");
+ }
+ return task;
+ }
+
+ @Override
+ @POST
+ public Response createResource(InputStream messageBody)
+ {
+ if (isResolved())
+ {
+ // do not allow creating already resolved tasks
+ return Response.status(405).build();
+ }
+ return super.createResource(messageBody);
+ }
+
+ @Override
+ public Long createEntity(Task entity)
+ {
+ entity.setContext(contextHome.findByUsernameAndContext(user.getUsername(), contextName));
+ entity.setResolved(false);
+ entity.setCreated(new Date());
+ return super.createEntity(entity);
+ }
+
+ @Override
+ public void updateEntity(Task entity, Long id)
+ {
+ Task task = super.getEntity(id);
+ task.setContext(contextHome.findByUsernameAndContext(user.getUsername(), contextName));
+ task.setResolved(isResolved());
+ if (entity.getName() != null)
+ {
+ task.setName(entity.getName());
+ }
+ if (isResolved())
+ {
+ task.setUpdated(new Date());
+ }
+ taskHome.update();
+ }
+
+ @Override
+ public Home<?, Task> getEntityHome()
+ {
+ return taskHome;
+ }
+
+ private boolean isResolved()
+ {
+ if (taskStatus.equals("resolved"))
+ {
+ return true;
+ }
+ else if (taskStatus.equals("unresolved"))
+ {
+ return false;
+ }
+ else
+ {
+ throw new ResourceNotFoundException();
+ }
+ }
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/TaskResourceHome.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/TaskResourceQuery.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/TaskResourceQuery.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/TaskResourceQuery.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.tasks.resource;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.example.tasks.ResourceNotFoundException;
+import org.jboss.seam.example.tasks.entity.Task;
+import org.jboss.seam.resteasy.ResourceQuery;
+
+/**
+ * This class exposes two lists of tasks for every context. Unresolved tasks can
+ * be obtained by sending HTTP GET request to context/{context}/unresolved URI.
+ * To obtain a list of already resolved tasks, use context/{context}/resolved
+ * URI.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+@Name("taskResourceQuery")
+@Path("/auth/context/{context}/{status}")
+public class TaskResourceQuery extends ResourceQuery<Task>
+{
+
+ @PathParam("context")
+ private String contextName;
+ @PathParam("status")
+ private String taskStatus;
+
+ public TaskResourceQuery()
+ {
+ setMediaTypes(new String[] { "application/xml", "application/json", "application/fastinfoset" });
+ }
+
+ @Override
+ @Create
+ public void create()
+ {
+ super.create();
+ List<String> restrictions = new ArrayList<String>();
+ restrictions.add("context.name = #{contextName}");
+ restrictions.add("resolved = #{taskStatus}");
+ restrictions.add("context.owner.username = #{user.username}");
+ getEntityQuery().setRestrictionExpressionStrings(restrictions);
+ }
+
+ @Factory("contextName")
+ public String getContextName()
+ {
+ return contextName;
+ }
+
+ @Factory("taskStatus")
+ public boolean isResolved()
+ {
+ if (taskStatus.equals("resolved"))
+ {
+ return true;
+ }
+ else if (taskStatus.equals("unresolved"))
+ {
+ return false;
+ }
+ else
+ {
+ throw new ResourceNotFoundException();
+ }
+ }
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/TaskResourceQuery.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/UserResourceHome.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/UserResourceHome.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/UserResourceHome.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.tasks.resource;
+
+import javax.ws.rs.Path;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.security.Admin;
+import org.jboss.seam.example.tasks.UserHome;
+import org.jboss.seam.example.tasks.entity.User;
+import org.jboss.seam.framework.EntityHome;
+import org.jboss.seam.resteasy.ResourceHome;
+
+/**
+ * This resource demonstrates use of ResourceHome component together with Seam
+ * security. This resource exposes user management as a web service, howeve only
+ * users with admin permission are allowed to access it.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+@Path("/auth/user")
+@Name("userResourceHome")
+@Admin
+public class UserResourceHome extends ResourceHome<User, String>
+{
+
+ public UserResourceHome()
+ {
+ setMediaTypes(new String[] { "application/xml", "application/json", "application/fastinfoset" });
+ }
+
+ @In
+ private UserHome userHome;
+
+ @Override
+ public EntityHome getEntityHome()
+ {
+ return userHome;
+ }
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/UserResourceHome.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ContextResourceTest.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ContextResourceTest.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ContextResourceTest.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,168 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.tasks.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.jboss.seam.example.tasks.test.fwk.MockHttpServletRequest;
+import org.jboss.seam.example.tasks.test.fwk.MockHttpServletResponse;
+import org.jboss.seam.example.tasks.test.fwk.ResourceSeamTest;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Test class for /context part of API
+ * @author Jozef Hartinger
+ *
+ */
+public class ContextResourceTest extends ResourceSeamTest
+{
+ @DataProvider(name = "query")
+ public String[][] getQueryData()
+ {
+ return new String[][] { new String[] { "application/xml", "<context><name>School</name></context>" }, new String[] { "application/json", "{\"context\":{\"name\":\"School\"}}" } };
+ }
+
+ @Test(dataProvider = "query")
+ public void getContextListTest(final String contentType, final String expectedResponse) throws Exception
+ {
+ new ResourceRequest(Method.GET, "/v1/auth/context")
+ {
+
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", contentType);
+ request.addHeader("Authorization", "BASIC ZGVtbzpkZW1v"); // demo:demo
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ super.onResponse(response);
+ assertEquals(response.getStatus(), 200, "Unexpected response code.");
+ assertTrue(response.getContentAsString().contains(expectedResponse), "Unexpected response.");
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void deleteContextTest() throws Exception
+ {
+ new ResourceRequest(Method.DELETE, "/v1/auth/context/Work")
+ {
+
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", "application/xml");
+ request.addHeader("Authorization", "BASIC ZGVtbzpkZW1v"); // demo:demo
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ super.onResponse(response);
+ assertEquals(response.getStatus(), 204, "Unexpected response code.");
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void createContextTest() throws Exception
+ {
+
+ final String uri = "/v1/auth/context/Test%20Context";
+ final String mimeType = "application/json";
+ final String expectedResponse = "{\"context\":{\"name\":\"Test Context\"}}";
+
+ new ResourceRequest(Method.PUT, uri)
+ {
+
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Authorization", "BASIC ZGVtbzpkZW1v"); // demo:demo
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ super.onResponse(response);
+ assertEquals(response.getStatus(), 201, "Unexpected response code.");
+ }
+
+ }.run();
+
+ new ResourceRequest(Method.GET, uri)
+ {
+
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", mimeType);
+ request.addHeader("Authorization", "BASIC ZGVtbzpkZW1v"); // demo:demo
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ super.onResponse(response);
+ assertEquals(response.getStatus(), 200, "Unexpected response code.");
+ assertEquals(response.getContentAsString(), expectedResponse, "Unexpected response.");
+ }
+
+ }.run();
+ }
+
+ // @Test
+ // TODO uncomment once JBSEAM-4152 is resolved
+ public void noAuthorizationHeaderTest() throws Exception
+ {
+ new ResourceRequest(Method.GET, "/v1/auth/context")
+ {
+
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", "application/xml");
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ super.onResponse(response);
+ assertEquals(response.getStatus(), 401, "Unexpected response code.");
+ }
+
+ }.run();
+ }
+
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ContextResourceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.tasks.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.jboss.seam.example.tasks.test.fwk.MockHttpServletRequest;
+import org.jboss.seam.example.tasks.test.fwk.MockHttpServletResponse;
+import org.jboss.seam.example.tasks.test.fwk.ResourceSeamTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Test class for /user/{username}/tasks/resolved part of API.
+ * @author Jozef Hartinger
+ *
+ */
+public class ResolvedTaskResourceQueryTest extends ResourceSeamTest
+{
+
+ @BeforeClass
+ public void resolveTask() throws Exception {
+
+ final String mimeType = "application/xml";
+ final String representation = "<task><id>14</id></task>";
+
+ new ResourceRequest(Method.PUT, "/v1/auth/context/School/resolved/14")
+ {
+
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Authorization", "BASIC ZGVtbzpkZW1v"); // demo:demo
+ request.addHeader("Content-Type", mimeType);
+ request.setContentType(mimeType);
+ request.setContent(representation.getBytes());
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ super.onResponse(response);
+ assertEquals(response.getStatus(), 204, "Unexpected response code.");
+ }
+
+ }.run();
+ }
+
+ @DataProvider(name="data")
+ public String[][] getData() {
+ return new String[][] {
+ new String[] {"application/xml", "<name>Get a haircut</name>"},
+ new String[] {"application/json", "\"name\":\"Get a haircut\""},
+ new String[] {"application/atom+xml", "<atom:title>Get a haircut</atom:title>"}
+ };
+ }
+
+ @Test(dataProvider="data")
+ public void editTaskTest(final String mimeType, final String expectedResponsePart) throws Exception
+ {
+ new ResourceRequest(Method.GET, "/v1/user/demo/tasks/resolved")
+ {
+
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", mimeType);
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ super.onResponse(response);
+ assertEquals(response.getStatus(), 200, "Unexpected response code.");
+ assertTrue(response.getContentAsString().contains(expectedResponsePart), "Unexpected response.");
+ }
+
+ }.run();
+ }
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/TaskResourceTest.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/TaskResourceTest.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/TaskResourceTest.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.tasks.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.jboss.seam.example.tasks.test.fwk.ResourceSeamTest;
+import org.jboss.seam.example.tasks.test.fwk.MockHttpServletRequest;
+import org.jboss.seam.example.tasks.test.fwk.MockHttpServletResponse;
+import org.testng.annotations.Test;
+
+/**
+ * Test class for TaskResourceHome and TaskResourceQuery components.
+ * @author Jozef Hartinger
+ *
+ */
+public class TaskResourceTest extends ResourceSeamTest
+{
+ @Test
+ public void createTaskTest() throws Exception
+ {
+ final String mimeType = "application/json";
+ final String representation = "{\"task\":{\"name\":\"Test task\"}}";
+
+ new ResourceRequest(Method.POST, "/v1/auth/context/School/unresolved")
+ {
+
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Authorization", "BASIC ZGVtbzpkZW1v"); // demo:demo
+ request.addHeader("Content-Type", mimeType);
+ request.setContentType(mimeType);
+ request.setContent(representation.getBytes());
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ super.onResponse(response);
+ assertEquals(response.getStatus(), 201, "Unexpected response code.");
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void editTaskTest() throws Exception
+ {
+ final String mimeType = "application/xml";
+ final String representation = "<task><id>4</id><name>Learn new English vocabulary</name></task>";
+
+ new ResourceRequest(Method.PUT, "/v1/auth/context/School/unresolved/4")
+ {
+
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Authorization", "BASIC ZGVtbzpkZW1v"); // demo:demo
+ request.addHeader("Content-Type", mimeType);
+ request.setContentType(mimeType);
+ request.setContent(representation.getBytes());
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ super.onResponse(response);
+ assertEquals(response.getStatus(), 204, "Unexpected response code.");
+ }
+
+ }.run();
+
+ new ResourceRequest(Method.GET, "/v1/auth/context/School/unresolved/4")
+ {
+
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", "application/xml");
+ request.addHeader("Authorization", "BASIC ZGVtbzpkZW1v"); // demo:demo
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ super.onResponse(response);
+ assertEquals(response.getStatus(), 200, "Unexpected response code.");
+ assertTrue(response.getContentAsString().contains("Learn new English vocabulary"), "Unexpected response.");
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void deleteTaskTest() throws Exception
+ {
+ new ResourceRequest(Method.DELETE, "/v1/auth/context/School/unresolved/2")
+ {
+
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Authorization", "BASIC ZGVtbzpkZW1v"); // demo:demo
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ super.onResponse(response);
+ assertEquals(response.getStatus(), 204, "Unexpected response code.");
+ }
+
+ }.run();
+ }
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/TaskResourceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/UserFactory.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/UserFactory.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/UserFactory.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,27 @@
+package org.jboss.seam.example.tasks.test;
+
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.example.tasks.UserHome;
+import org.jboss.seam.example.tasks.entity.User;
+
+/**
+ * Ugly hack that allows the tests tu run until JBSEAM-4152 is resolved.
+ * @author Jozef Hartinger
+ *
+ */
+
+@Name("userFactory")
+public class UserFactory
+{
+
+ @In private UserHome userHome;
+
+ @Factory(autoCreate=true, value="user")
+ public User getDemo() {
+ userHome.setId("demo");
+ return userHome.find();
+ }
+
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/UserFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/DelegatingServletInputStream.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/DelegatingServletInputStream.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/DelegatingServletInputStream.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.seam.example.tasks.test.fwk;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ServletInputStream;
+
+/**
+ * Delegating implementation of {@link javax.servlet.ServletInputStream}.
+ *
+ * <p>Used by {@link MockHttpServletRequest}; typically not directly
+ * used for testing application controllers.
+ *
+ * @author Juergen Hoeller
+ * @since 1.0.2
+ * @see MockHttpServletRequest
+ */
+public class DelegatingServletInputStream extends ServletInputStream {
+
+ private final InputStream sourceStream;
+
+
+ /**
+ * Create a DelegatingServletInputStream for the given source stream.
+ * @param sourceStream the source stream (never <code>null</code>)
+ */
+ public DelegatingServletInputStream(InputStream sourceStream) {
+ this.sourceStream = sourceStream;
+ }
+
+ /**
+ * Return the underlying source stream (never <code>null</code>).
+ */
+ public final InputStream getSourceStream() {
+ return this.sourceStream;
+ }
+
+
+ public int read() throws IOException {
+ return this.sourceStream.read();
+ }
+
+ public void close() throws IOException {
+ super.close();
+ this.sourceStream.close();
+ }
+
+}
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/DelegatingServletInputStream.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/DelegatingServletOutputStream.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/DelegatingServletOutputStream.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/DelegatingServletOutputStream.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.seam.example.tasks.test.fwk;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.servlet.ServletOutputStream;
+
+
+/**
+ * Delegating implementation of {@link javax.servlet.ServletOutputStream}.
+ * <p/>
+ * <p>Used by {@link org.jboss.seam.example.restbay.test.fwk.MockHttpServletResponse}; typically not directly
+ * used for testing application controllers.
+ *
+ * @author Juergen Hoeller
+ * @see org.jboss.seam.example.restbay.test.fwk.MockHttpServletResponse
+ * @since 1.0.2
+ */
+public class DelegatingServletOutputStream extends ServletOutputStream
+{
+
+ private final OutputStream targetStream;
+
+
+ /**
+ * Create a DelegatingServletOutputStream for the given target stream.
+ *
+ * @param targetStream the target stream (never <code>null</code>)
+ */
+ public DelegatingServletOutputStream(OutputStream targetStream)
+ {
+ this.targetStream = targetStream;
+ }
+
+ /**
+ * Return the underlying target stream (never <code>null</code>).
+ */
+ public final OutputStream getTargetStream()
+ {
+ return this.targetStream;
+ }
+
+
+ public void write(int b) throws IOException
+ {
+ this.targetStream.write(b);
+ }
+
+ public void flush() throws IOException
+ {
+ super.flush();
+ this.targetStream.flush();
+ }
+
+ public void close() throws IOException
+ {
+ super.close();
+ this.targetStream.close();
+ }
+
+}
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/DelegatingServletOutputStream.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/HeaderValueHolder.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/HeaderValueHolder.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/HeaderValueHolder.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.seam.example.tasks.test.fwk;
+
+import java.util.*;
+import java.lang.reflect.Array;
+
+/**
+ * Internal helper class that serves as value holder for request headers.
+ *
+ * @author Juergen Hoeller
+ * @author Rick Evans
+ * @since 2.0.1
+ */
+class HeaderValueHolder {
+
+ private final List values = new LinkedList();
+
+
+ public void setValue(Object value) {
+ this.values.clear();
+ this.values.add(value);
+ }
+
+ public void addValue(Object value) {
+ this.values.add(value);
+ }
+
+ public void addValues(Collection values) {
+ this.values.addAll(values);
+ }
+
+ public void addValueArray(Object values) {
+ Object[] arr = toObjectArray(values);
+ this.values.addAll(Arrays.asList(arr));
+ }
+
+ public List getValues() {
+ return Collections.unmodifiableList(this.values);
+ }
+
+ public Object getValue() {
+ return (!this.values.isEmpty() ? this.values.get(0) : null);
+ }
+
+
+ /**
+ * Find a HeaderValueHolder by name, ignoring casing.
+ * @param headers the Map of header names to HeaderValueHolders
+ * @param name the name of the desired header
+ * @return the corresponding HeaderValueHolder,
+ * or <code>null</code> if none found
+ */
+ public static HeaderValueHolder getByName(Map headers, String name) {
+ for (Iterator it = headers.keySet().iterator(); it.hasNext();) {
+ String headerName = (String) it.next();
+ if (headerName.equalsIgnoreCase(name)) {
+ return (HeaderValueHolder) headers.get(headerName);
+ }
+ }
+ return null;
+ }
+
+ public static Object[] toObjectArray(Object source) {
+ if (source instanceof Object[]) {
+ return (Object[]) source;
+ }
+ if (source == null) {
+ return new Object[0];
+ }
+ if (!source.getClass().isArray()) {
+ throw new IllegalArgumentException("Source is not an array: " + source);
+ }
+ int length = Array.getLength(source);
+ if (length == 0) {
+ return new Object[0];
+ }
+ Class wrapperType = Array.get(source, 0).getClass();
+ Object[] newArray = (Object[]) Array.newInstance(wrapperType, length);
+ for (int i = 0; i < length; i++) {
+ newArray[i] = Array.get(source, i);
+ }
+ return newArray;
+ }
+
+}
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/HeaderValueHolder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockHttpServletRequest.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockHttpServletRequest.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockHttpServletRequest.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,879 @@
+/*
+ * Copyright 2002-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.seam.example.tasks.test.fwk;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.*;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.jboss.seam.mock.MockServletContext;
+import org.jboss.seam.mock.MockHttpSession;
+
+/**
+ * Mock implementation of the {@link javax.servlet.http.HttpServletRequest}
+ * interface. Supports the Servlet 2.4 API level.
+ *
+ * <p>Used for testing the web framework; also useful for testing
+ * application controllers.
+ *
+ * @author Juergen Hoeller
+ * @author Rod Johnson
+ * @author Rick Evans
+ * @author Mark Fisher
+ * @since 1.0.2
+ */
+public class MockHttpServletRequest implements HttpServletRequest {
+
+ /**
+ * The default protocol: 'http'.
+ */
+ public static final String DEFAULT_PROTOCOL = "http";
+
+ /**
+ * The default server address: '127.0.0.1'.
+ */
+ public static final String DEFAULT_SERVER_ADDR = "127.0.0.1";
+
+ /**
+ * The default server name: 'localhost'.
+ */
+ public static final String DEFAULT_SERVER_NAME = "localhost";
+
+ /**
+ * The default server port: '80'.
+ */
+ public static final int DEFAULT_SERVER_PORT = 80;
+
+ /**
+ * The default remote address: '127.0.0.1'.
+ */
+ public static final String DEFAULT_REMOTE_ADDR = "127.0.0.1";
+
+ /**
+ * The default remote host: 'localhost'.
+ */
+ public static final String DEFAULT_REMOTE_HOST = "localhost";
+
+ private boolean active = true;
+
+
+ //---------------------------------------------------------------------
+ // ServletRequest properties
+ //---------------------------------------------------------------------
+
+ private final Hashtable attributes = new Hashtable();
+
+ private String characterEncoding;
+
+ private byte[] content;
+
+ private String contentType;
+
+ private final Map parameters = new LinkedHashMap(16);
+
+ private String protocol = DEFAULT_PROTOCOL;
+
+ private String scheme = DEFAULT_PROTOCOL;
+
+ private String serverName = DEFAULT_SERVER_NAME;
+
+ private int serverPort = DEFAULT_SERVER_PORT;
+
+ private String remoteAddr = DEFAULT_REMOTE_ADDR;
+
+ private String remoteHost = DEFAULT_REMOTE_HOST;
+
+ /** List of locales in descending order */
+ private final Vector locales = new Vector();
+
+ private boolean secure = false;
+
+ private final ServletContext servletContext;
+
+ private int remotePort = DEFAULT_SERVER_PORT;
+
+ private String localName = DEFAULT_SERVER_NAME;
+
+ private String localAddr = DEFAULT_SERVER_ADDR;
+
+ private int localPort = DEFAULT_SERVER_PORT;
+
+
+ //---------------------------------------------------------------------
+ // HttpServletRequest properties
+ //---------------------------------------------------------------------
+
+ private String authType;
+
+ private Cookie[] cookies;
+
+ /**
+ * The key is the lowercase header name; the value is a {@link HeaderValueHolder} object.
+ */
+ private final Hashtable headers = new Hashtable();
+
+ private String method;
+
+ private String pathInfo;
+
+ private String contextPath = "";
+
+ private String queryString;
+
+ private Map<String,String> queryParameters = new HashMap();
+
+ private String remoteUser;
+
+ private final Set userRoles = new HashSet();
+
+ private Principal userPrincipal;
+
+ private String requestURI;
+
+ private String servletPath = "";
+
+ private HttpSession session;
+
+ private boolean requestedSessionIdValid = true;
+
+ private boolean requestedSessionIdFromCookie = true;
+
+ private boolean requestedSessionIdFromURL = false;
+
+
+ //---------------------------------------------------------------------
+ // Constructors
+ //---------------------------------------------------------------------
+
+ /**
+ * Create a new MockHttpServletRequest with a default
+ * {@link MockServletContext}.
+ * @see MockServletContext
+ */
+ public MockHttpServletRequest() {
+ this(null, "", "");
+ }
+
+ /**
+ * Create a new MockHttpServletRequest with a default
+ * {@link MockServletContext}.
+ * @param method the request method (may be <code>null</code>)
+ * @param requestURI the request URI (may be <code>null</code>)
+ * @see #setMethod
+ * @see #setRequestURI
+ * @see MockServletContext
+ */
+ public MockHttpServletRequest(String method, String requestURI) {
+ this(null, method, requestURI);
+ }
+
+ /**
+ * Create a new MockHttpServletRequest.
+ * @param servletContext the ServletContext that the request runs in
+ * (may be <code>null</code> to use a default MockServletContext)
+ * @see MockServletContext
+ */
+ public MockHttpServletRequest(ServletContext servletContext) {
+ this(servletContext, "", "");
+ }
+
+ /**
+ * Create a new MockHttpServletRequest.
+ * @param servletContext the ServletContext that the request runs in
+ * (may be <code>null</code> to use a default MockServletContext)
+ * @param method the request method (may be <code>null</code>)
+ * @param requestURI the request URI (may be <code>null</code>)
+ * @see #setMethod
+ * @see #setRequestURI
+ * @see MockServletContext
+ */
+ public MockHttpServletRequest(ServletContext servletContext, String method, String requestURI) {
+ this.servletContext = (servletContext != null ? servletContext : new MockServletContext());
+ this.method = method;
+ this.requestURI = requestURI;
+ this.locales.add(Locale.ENGLISH);
+ }
+
+
+ //---------------------------------------------------------------------
+ // Lifecycle methods
+ //---------------------------------------------------------------------
+
+ /**
+ * Return the ServletContext that this request is associated with.
+ * (Not available in the standard HttpServletRequest interface for some reason.)
+ */
+ public ServletContext getServletContext() {
+ return this.servletContext;
+ }
+
+ /**
+ * Return whether this request is still active (that is, not completed yet).
+ */
+ public boolean isActive() {
+ return this.active;
+ }
+
+ /**
+ * Mark this request as completed, keeping its state.
+ */
+ public void close() {
+ this.active = false;
+ }
+
+ /**
+ * Invalidate this request, clearing its state.
+ */
+ public void invalidate() {
+ close();
+ clearAttributes();
+ }
+
+ /**
+ * Check whether this request is still active (that is, not completed yet),
+ * throwing an IllegalStateException if not active anymore.
+ */
+ protected void checkActive() throws IllegalStateException {
+ if (!this.active) {
+ throw new IllegalStateException("Request is not active anymore");
+ }
+ }
+
+
+ //---------------------------------------------------------------------
+ // ServletRequest interface
+ //---------------------------------------------------------------------
+
+ public Object getAttribute(String name) {
+ checkActive();
+ return this.attributes.get(name);
+ }
+
+ public Enumeration getAttributeNames() {
+ checkActive();
+ return this.attributes.keys();
+ }
+
+ public String getCharacterEncoding() {
+ return this.characterEncoding;
+ }
+
+ public void setCharacterEncoding(String characterEncoding) {
+ this.characterEncoding = characterEncoding;
+ }
+
+ public void setContent(byte[] content) {
+ this.content = content;
+ }
+
+ public int getContentLength() {
+ return (this.content != null ? this.content.length : -1);
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ public String getContentType() {
+ return this.contentType;
+ }
+
+ public ServletInputStream getInputStream() {
+ if (this.content != null) {
+ return new DelegatingServletInputStream(new ByteArrayInputStream(this.content));
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Set a single value for the specified HTTP parameter.
+ * <p>If there are already one or more values registered for the given
+ * parameter name, they will be replaced.
+ */
+ public void setParameter(String name, String value) {
+ setParameter(name, new String[] {value});
+ }
+
+ /**
+ * Set an array of values for the specified HTTP parameter.
+ * <p>If there are already one or more values registered for the given
+ * parameter name, they will be replaced.
+ */
+ public void setParameter(String name, String[] values) {
+ this.parameters.put(name, values);
+ }
+
+ /**
+ * Sets all provided parameters <emphasis>replacing</emphasis> any
+ * existing values for the provided parameter names. To add without
+ * replacing existing values, use {@link #addParameters(Map)}.
+ */
+ public void setParameters(Map params) {
+ for (Iterator it = params.keySet().iterator(); it.hasNext();) {
+ Object key = it.next();
+ Object value = params.get(key);
+ if (value instanceof String) {
+ this.setParameter((String) key, (String) value);
+ }
+ else if (value instanceof String[]) {
+ this.setParameter((String) key, (String[]) value);
+ }
+ else {
+ throw new IllegalArgumentException("Parameter map value must be single value " +
+ " or array of type [" + String.class.getName() + "]");
+ }
+ }
+ }
+
+ /**
+ * Add a single value for the specified HTTP parameter.
+ * <p>If there are already one or more values registered for the given
+ * parameter name, the given value will be added to the end of the list.
+ */
+ public void addParameter(String name, String value) {
+ addParameter(name, new String[] {value});
+ }
+
+ /**
+ * Add an array of values for the specified HTTP parameter.
+ * <p>If there are already one or more values registered for the given
+ * parameter name, the given values will be added to the end of the list.
+ */
+ public void addParameter(String name, String[] values) {
+ String[] oldArr = (String[]) this.parameters.get(name);
+ if (oldArr != null) {
+ String[] newArr = new String[oldArr.length + values.length];
+ System.arraycopy(oldArr, 0, newArr, 0, oldArr.length);
+ System.arraycopy(values, 0, newArr, oldArr.length, values.length);
+ this.parameters.put(name, newArr);
+ }
+ else {
+ this.parameters.put(name, values);
+ }
+ }
+
+ /**
+ * Adds all provided parameters <emphasis>without</emphasis> replacing
+ * any existing values. To replace existing values, use
+ * {@link #setParameters(Map)}.
+ */
+ public void addParameters(Map params) {
+ for (Iterator it = params.keySet().iterator(); it.hasNext();) {
+ Object key = it.next();
+ Object value = params.get(key);
+ if (value instanceof String) {
+ this.addParameter((String) key, (String) value);
+ }
+ else if (value instanceof String[]) {
+ this.addParameter((String) key, (String[]) value);
+ }
+ else {
+ throw new IllegalArgumentException("Parameter map value must be single value " +
+ " or array of type [" + String.class.getName() + "]");
+ }
+ }
+ }
+
+ /**
+ * Remove already registered values for the specified HTTP parameter, if any.
+ */
+ public void removeParameter(String name) {
+ this.parameters.remove(name);
+ }
+
+ /**
+ * Removes all existing parameters.
+ */
+ public void removeAllParameters() {
+ this.parameters.clear();
+ }
+
+ public String getParameter(String name) {
+ String[] arr = (String[]) this.parameters.get(name);
+ return (arr != null && arr.length > 0 ? arr[0] : null);
+ }
+
+ public Enumeration getParameterNames() {
+ return Collections.enumeration(this.parameters.keySet());
+ }
+
+ public String[] getParameterValues(String name) {
+ return (String[]) this.parameters.get(name);
+ }
+
+ public Map getParameterMap() {
+ return Collections.unmodifiableMap(this.parameters);
+ }
+
+ /**
+ * Add a query parameter that will be appended to the URI query string.
+ */
+ public void addQueryParameter(String name, String value) {
+ addParameter(name, value);
+ this.queryParameters.put(name, value);
+ }
+
+ public void removeQueryParameter(String name) {
+ removeParameter(name);
+ this.queryParameters.remove(name);
+ }
+
+ public Map<String, String> getQueryParameters()
+ {
+ return queryParameters;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getProtocol() {
+ return this.protocol;
+ }
+
+ public void setScheme(String scheme) {
+ this.scheme = scheme;
+ }
+
+ public String getScheme() {
+ return this.scheme;
+ }
+
+ public void setServerName(String serverName) {
+ this.serverName = serverName;
+ }
+
+ public String getServerName() {
+ return this.serverName;
+ }
+
+ public void setServerPort(int serverPort) {
+ this.serverPort = serverPort;
+ }
+
+ public int getServerPort() {
+ return this.serverPort;
+ }
+
+ public BufferedReader getReader() throws UnsupportedEncodingException {
+ if (this.content != null) {
+ InputStream sourceStream = new ByteArrayInputStream(this.content);
+ Reader sourceReader = (this.characterEncoding != null) ?
+ new InputStreamReader(sourceStream, this.characterEncoding) : new InputStreamReader(sourceStream);
+ return new BufferedReader(sourceReader);
+ }
+ else {
+ return null;
+ }
+ }
+
+ public void setRemoteAddr(String remoteAddr) {
+ this.remoteAddr = remoteAddr;
+ }
+
+ public String getRemoteAddr() {
+ return this.remoteAddr;
+ }
+
+ public void setRemoteHost(String remoteHost) {
+ this.remoteHost = remoteHost;
+ }
+
+ public String getRemoteHost() {
+ return this.remoteHost;
+ }
+
+ public void setAttribute(String name, Object value) {
+ checkActive();
+ if (value != null) {
+ this.attributes.put(name, value);
+ }
+ else {
+ this.attributes.remove(name);
+ }
+ }
+
+ public void removeAttribute(String name) {
+ checkActive();
+ this.attributes.remove(name);
+ }
+
+ /**
+ * Clear all of this request's attributes.
+ */
+ public void clearAttributes() {
+ this.attributes.clear();
+ }
+
+ /**
+ * Add a new preferred locale, before any existing locales.
+ */
+ public void addPreferredLocale(Locale locale) {
+ this.locales.add(0, locale);
+ }
+
+ public Locale getLocale() {
+ return (Locale) this.locales.get(0);
+ }
+
+ public Enumeration getLocales() {
+ return this.locales.elements();
+ }
+
+ public void setSecure(boolean secure) {
+ this.secure = secure;
+ }
+
+ public boolean isSecure() {
+ return this.secure;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String path) {
+ return new MockRequestDispatcher(path);
+ }
+
+ public String getRealPath(String path) {
+ return this.servletContext.getRealPath(path);
+ }
+
+ public void setRemotePort(int remotePort) {
+ this.remotePort = remotePort;
+ }
+
+ public int getRemotePort() {
+ return this.remotePort;
+ }
+
+ public void setLocalName(String localName) {
+ this.localName = localName;
+ }
+
+ public String getLocalName() {
+ return this.localName;
+ }
+
+ public void setLocalAddr(String localAddr) {
+ this.localAddr = localAddr;
+ }
+
+ public String getLocalAddr() {
+ return this.localAddr;
+ }
+
+ public void setLocalPort(int localPort) {
+ this.localPort = localPort;
+ }
+
+ public int getLocalPort() {
+ return this.localPort;
+ }
+
+
+ //---------------------------------------------------------------------
+ // HttpServletRequest interface
+ //---------------------------------------------------------------------
+
+ public void setAuthType(String authType) {
+ this.authType = authType;
+ }
+
+ public String getAuthType() {
+ return this.authType;
+ }
+
+ public void setCookies(Cookie[] cookies) {
+ this.cookies = cookies;
+ }
+
+ public Cookie[] getCookies() {
+ return this.cookies;
+ }
+
+ public void addCookie(Cookie cookie) {
+ this.cookies = new Cookie[this.cookies.length+1];
+ this.cookies[this.cookies.length-1] = cookie;
+ }
+
+ /**
+ * Add a header entry for the given name.
+ * <p>If there was no entry for that header name before,
+ * the value will be used as-is. In case of an existing entry,
+ * a String array will be created, adding the given value (more
+ * specifically, its toString representation) as further element.
+ * <p>Multiple values can only be stored as list of Strings,
+ * following the Servlet spec (see <code>getHeaders</code> accessor).
+ * As alternative to repeated <code>addHeader</code> calls for
+ * individual elements, you can use a single call with an entire
+ * array or Collection of values as parameter.
+ * @see #getHeaderNames
+ * @see #getHeader
+ * @see #getHeaders
+ * @see #getDateHeader
+ * @see #getIntHeader
+ */
+ public void addHeader(String name, Object value) {
+ HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
+ if (header == null) {
+ header = new HeaderValueHolder();
+ this.headers.put(name, header);
+ }
+ if (value instanceof Collection) {
+ header.addValues((Collection) value);
+ }
+ else if (value.getClass().isArray()) {
+ header.addValueArray(value);
+ }
+ else {
+ header.addValue(value);
+ }
+ }
+
+ public long getDateHeader(String name) {
+ HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
+ Object value = (header != null ? header.getValue() : null);
+ if (value instanceof Date) {
+ return ((Date) value).getTime();
+ }
+ else if (value instanceof Number) {
+ return ((Number) value).longValue();
+ }
+ else if (value != null) {
+ throw new IllegalArgumentException(
+ "Value for header '" + name + "' is neither a Date nor a Number: " + value);
+ }
+ else {
+ return -1L;
+ }
+ }
+
+ public String getHeader(String name) {
+ HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
+ return (header != null ? header.getValue().toString() : null);
+ }
+
+ public Enumeration getHeaders(String name) {
+ HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
+ return Collections.enumeration(header != null ? header.getValues() : Collections.EMPTY_LIST);
+ }
+
+ public Enumeration getHeaderNames() {
+ return this.headers.keys();
+ }
+
+ public int getIntHeader(String name) {
+ HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
+ Object value = (header != null ? header.getValue() : null);
+ if (value instanceof Number) {
+ return ((Number) value).intValue();
+ }
+ else if (value instanceof String) {
+ return Integer.parseInt((String) value);
+ }
+ else if (value != null) {
+ throw new NumberFormatException("Value for header '" + name + "' is not a Number: " + value);
+ }
+ else {
+ return -1;
+ }
+ }
+
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+ public String getMethod() {
+ return this.method;
+ }
+
+ public void setPathInfo(String pathInfo) {
+ this.pathInfo = pathInfo;
+ }
+
+ public String getPathInfo() {
+ return this.pathInfo;
+ }
+
+ public String getPathTranslated() {
+ return (this.pathInfo != null ? getRealPath(this.pathInfo) : null);
+ }
+
+ public void setContextPath(String contextPath) {
+ this.contextPath = contextPath;
+ }
+
+ public String getContextPath() {
+ return this.contextPath;
+ }
+
+ public void setQueryString(String queryString) {
+ this.queryString = queryString;
+ }
+
+ public String getQueryString() {
+ if (getQueryParameters().size() > 0) {
+ StringBuilder q = new StringBuilder(queryString);
+ if (!queryString.endsWith("&")) q.append("&");
+ for (Map.Entry<String, String> entry : getQueryParameters().entrySet())
+ {
+ q.append(entry.getKey());
+ q.append("=");
+ q.append(entry.getValue());
+ q.append("&");
+ }
+ if (q.toString().endsWith("&")) {
+ q.deleteCharAt(q.length()-1);
+ }
+ return q.toString();
+ }
+ return this.queryString;
+ }
+
+ public void setRemoteUser(String remoteUser) {
+ this.remoteUser = remoteUser;
+ }
+
+ public String getRemoteUser() {
+ return this.remoteUser;
+ }
+
+ /**
+ * @deprecated in favor of addUserRole
+ * @see #addUserRole
+ */
+ public void addRole(String role) {
+ addUserRole(role);
+ }
+
+ public void addUserRole(String role) {
+ this.userRoles.add(role);
+ }
+
+ public boolean isUserInRole(String role) {
+ return this.userRoles.contains(role);
+ }
+
+ public void setUserPrincipal(Principal userPrincipal) {
+ this.userPrincipal = userPrincipal;
+ }
+
+ public Principal getUserPrincipal() {
+ return this.userPrincipal;
+ }
+
+ public String getRequestedSessionId() {
+ HttpSession session = getSession();
+ return (session != null ? session.getId() : null);
+ }
+
+ public void setRequestURI(String requestURI) {
+ this.requestURI = requestURI;
+ }
+
+ public String getRequestURI() {
+ return this.requestURI;
+ }
+
+ public StringBuffer getRequestURL() {
+ StringBuffer url = new StringBuffer(this.scheme);
+ url.append("://").append(this.serverName).append(':').append(this.serverPort);
+ url.append(getRequestURI());
+ return url;
+ }
+
+ public void setServletPath(String servletPath) {
+ this.servletPath = servletPath;
+ }
+
+ public String getServletPath() {
+ return this.servletPath;
+ }
+
+ public void setSession(HttpSession session) {
+ this.session = session;
+ // TODO: We don't need session handling?
+ /*
+ if (session instanceof MockHttpSession) {
+ MockHttpSession mockSession = ((MockHttpSession) session);
+ mockSession.access();
+ }
+ */
+ }
+
+ public HttpSession getSession(boolean create) {
+ checkActive();
+ // Reset session if invalidated.
+ if (this.session instanceof MockHttpSession && ((MockHttpSession) this.session).isInvalid()) {
+ this.session = null;
+ }
+ // Create new session if necessary.
+ if (this.session == null && create) {
+ this.session = new MockHttpSession(this.servletContext);
+ }
+ return this.session;
+ }
+
+ public HttpSession getSession() {
+ return getSession(true);
+ }
+
+ public void setRequestedSessionIdValid(boolean requestedSessionIdValid) {
+ this.requestedSessionIdValid = requestedSessionIdValid;
+ }
+
+ public boolean isRequestedSessionIdValid() {
+ return this.requestedSessionIdValid;
+ }
+
+ public void setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie) {
+ this.requestedSessionIdFromCookie = requestedSessionIdFromCookie;
+ }
+
+ public boolean isRequestedSessionIdFromCookie() {
+ return this.requestedSessionIdFromCookie;
+ }
+
+ public void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL) {
+ this.requestedSessionIdFromURL = requestedSessionIdFromURL;
+ }
+
+ public boolean isRequestedSessionIdFromURL() {
+ return this.requestedSessionIdFromURL;
+ }
+
+ public boolean isRequestedSessionIdFromUrl() {
+ return isRequestedSessionIdFromURL();
+ }
+
+ public boolean isAllParametersInQueryString() {
+ return true;
+ }
+
+}
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockHttpServletRequest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockHttpServletResponse.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockHttpServletResponse.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockHttpServletResponse.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,518 @@
+/*
+ * Copyright 2002-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.seam.example.tasks.test.fwk;
+
+import org.jboss.seam.example.tasks.test.fwk.DelegatingServletOutputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * Mock implementation of the {@link javax.servlet.http.HttpServletResponse}
+ * interface. Supports the Servlet 2.4 API level.
+ *
+ * <p>Used for testing the web framework; also useful for testing
+ * application controllers.
+ *
+ * @author Juergen Hoeller
+ * @author Rod Johnson
+ * @since 1.0.2
+ */
+public class MockHttpServletResponse implements HttpServletResponse {
+
+ public static final int DEFAULT_SERVER_PORT = 80;
+
+ private static final String CHARSET_PREFIX = "charset=";
+
+
+ //---------------------------------------------------------------------
+ // ServletResponse properties
+ //---------------------------------------------------------------------
+
+ private boolean outputStreamAccessAllowed = true;
+
+ private boolean writerAccessAllowed = true;
+
+ private String characterEncoding = "ISO-8859-1";
+
+ private final ByteArrayOutputStream content = new ByteArrayOutputStream();
+
+ private final ServletOutputStream outputStream = new ResponseServletOutputStream(this.content);
+
+ private PrintWriter writer;
+
+ private int contentLength = 0;
+
+ private String contentType;
+
+ private int bufferSize = 4096;
+
+ private boolean committed;
+
+ private Locale locale = Locale.getDefault();
+
+
+ //---------------------------------------------------------------------
+ // HttpServletResponse properties
+ //---------------------------------------------------------------------
+
+ private final List cookies = new ArrayList();
+
+ /**
+ * The key is the lowercase header name; the value is a {@link HeaderValueHolder} object.
+ */
+ private final Map headers = new HashMap();
+
+ private int status = HttpServletResponse.SC_OK;
+
+ private String statusMessage;
+
+ private String redirectedUrl;
+
+ private String forwardedUrl;
+
+ private String includedUrl;
+
+
+ //---------------------------------------------------------------------
+ // ServletResponse interface
+ //---------------------------------------------------------------------
+
+ /**
+ * Set whether {@link #getOutputStream()} access is allowed.
+ * <p>Default is <code>true</code>.
+ */
+ public void setOutputStreamAccessAllowed(boolean outputStreamAccessAllowed) {
+ this.outputStreamAccessAllowed = outputStreamAccessAllowed;
+ }
+
+ /**
+ * Return whether {@link #getOutputStream()} access is allowed.
+ */
+ public boolean isOutputStreamAccessAllowed() {
+ return this.outputStreamAccessAllowed;
+ }
+
+ /**
+ * Set whether {@link #getWriter()} access is allowed.
+ * <p>Default is <code>true</code>.
+ */
+ public void setWriterAccessAllowed(boolean writerAccessAllowed) {
+ this.writerAccessAllowed = writerAccessAllowed;
+ }
+
+ /**
+ * Return whether {@link #getOutputStream()} access is allowed.
+ */
+ public boolean isWriterAccessAllowed() {
+ return this.writerAccessAllowed;
+ }
+
+ public void setCharacterEncoding(String characterEncoding) {
+ this.characterEncoding = characterEncoding;
+ }
+
+ public String getCharacterEncoding() {
+ return this.characterEncoding;
+ }
+
+ public ServletOutputStream getOutputStream() {
+ if (!this.outputStreamAccessAllowed) {
+ throw new IllegalStateException("OutputStream access not allowed");
+ }
+ return this.outputStream;
+ }
+
+ public PrintWriter getWriter() throws UnsupportedEncodingException {
+ if (!this.writerAccessAllowed) {
+ throw new IllegalStateException("Writer access not allowed");
+ }
+ if (this.writer == null) {
+ Writer targetWriter = (this.characterEncoding != null ?
+ new OutputStreamWriter(this.content, this.characterEncoding) : new OutputStreamWriter(this.content));
+ this.writer = new ResponsePrintWriter(targetWriter);
+ }
+ return this.writer;
+ }
+
+ public byte[] getContentAsByteArray() {
+ flushBuffer();
+ return this.content.toByteArray();
+ }
+
+ public String getContentAsString() {
+ flushBuffer();
+ try {
+ return (this.characterEncoding != null) ?
+ this.content.toString(this.characterEncoding) : this.content.toString();
+ } catch (UnsupportedEncodingException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public void setContentLength(int contentLength) {
+ this.contentLength = contentLength;
+ }
+
+ public int getContentLength() {
+ return this.contentLength;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ if (contentType != null) {
+ int charsetIndex = contentType.toLowerCase().indexOf(CHARSET_PREFIX);
+ if (charsetIndex != -1) {
+ String encoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length());
+ setCharacterEncoding(encoding);
+ }
+ }
+ }
+
+ public String getContentType() {
+ return this.contentType;
+ }
+
+ public void setBufferSize(int bufferSize) {
+ this.bufferSize = bufferSize;
+ }
+
+ public int getBufferSize() {
+ return this.bufferSize;
+ }
+
+ public void flushBuffer() {
+ setCommitted(true);
+ }
+
+ public void resetBuffer() {
+ if (isCommitted()) {
+ throw new IllegalStateException("Cannot reset buffer - response is already committed");
+ }
+ this.content.reset();
+ }
+
+ private void setCommittedIfBufferSizeExceeded() {
+ int bufSize = getBufferSize();
+ if (bufSize > 0 && this.content.size() > bufSize) {
+ setCommitted(true);
+ }
+ }
+
+ public void setCommitted(boolean committed) {
+ this.committed = committed;
+ }
+
+ public boolean isCommitted() {
+ return this.committed;
+ }
+
+ public void reset() {
+ resetBuffer();
+ this.characterEncoding = null;
+ this.contentLength = 0;
+ this.contentType = null;
+ this.locale = null;
+ this.cookies.clear();
+ this.headers.clear();
+ this.status = HttpServletResponse.SC_OK;
+ this.statusMessage = null;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ public Locale getLocale() {
+ return this.locale;
+ }
+
+
+ //---------------------------------------------------------------------
+ // HttpServletResponse interface
+ //---------------------------------------------------------------------
+
+ public void addCookie(Cookie cookie) {
+ this.cookies.add(cookie);
+ }
+
+ public Cookie[] getCookies() {
+ return (Cookie[]) this.cookies.toArray(new Cookie[this.cookies.size()]);
+ }
+
+ public Cookie getCookie(String name) {
+ for (Iterator it = this.cookies.iterator(); it.hasNext();) {
+ Cookie cookie = (Cookie) it.next();
+ if (name.equals(cookie.getName())) {
+ return cookie;
+ }
+ }
+ return null;
+ }
+
+ public boolean containsHeader(String name) {
+ return (HeaderValueHolder.getByName(this.headers, name) != null);
+ }
+
+ /**
+ * Return the names of all specified headers as a Set of Strings.
+ * @return the <code>Set</code> of header name <code>Strings</code>, or an empty <code>Set</code> if none
+ */
+ public Set getHeaderNames() {
+ return this.headers.keySet();
+ }
+
+ /**
+ * Return the primary value for the given header, if any.
+ * <p>Will return the first value in case of multiple values.
+ * @param name the name of the header
+ * @return the associated header value, or <code>null<code> if none
+ */
+ public Object getHeader(String name) {
+ HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
+ return (header != null ? header.getValue() : null);
+ }
+
+ /**
+ * Return all values for the given header as a List of value objects.
+ * @param name the name of the header
+ * @return the associated header values, or an empty List if none
+ */
+ public List getHeaders(String name) {
+ HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
+ return (header != null ? header.getValues() : Collections.EMPTY_LIST);
+ }
+
+ /**
+ * The default implementation returns the given URL String as-is.
+ * <p>Can be overridden in subclasses, appending a session id or the like.
+ */
+ public String encodeURL(String url) {
+ return url;
+ }
+
+ /**
+ * The default implementation delegates to {@link #encodeURL},
+ * returning the given URL String as-is.
+ * <p>Can be overridden in subclasses, appending a session id or the like
+ * in a redirect-specific fashion. For general URL encoding rules,
+ * override the common {@link #encodeURL} method instead, appyling
+ * to redirect URLs as well as to general URLs.
+ */
+ public String encodeRedirectURL(String url) {
+ return encodeURL(url);
+ }
+
+ public String encodeUrl(String url) {
+ return encodeURL(url);
+ }
+
+ public String encodeRedirectUrl(String url) {
+ return encodeRedirectURL(url);
+ }
+
+ public void sendError(int status, String errorMessage) throws IOException {
+ if (isCommitted()) {
+ throw new IllegalStateException("Cannot set error status - response is already committed");
+ }
+ this.status = status;
+ this.statusMessage = errorMessage;
+ setCommitted(true);
+ }
+
+ public void sendError(int status) throws IOException {
+ if (isCommitted()) {
+ throw new IllegalStateException("Cannot set error status - response is already committed");
+ }
+ this.status = status;
+ setCommitted(true);
+ }
+
+ public void sendRedirect(String url) throws IOException {
+ if (isCommitted()) {
+ throw new IllegalStateException("Cannot send redirect - response is already committed");
+ }
+ this.redirectedUrl = url;
+ setCommitted(true);
+ }
+
+ public String getRedirectedUrl() {
+ return this.redirectedUrl;
+ }
+
+ public void setDateHeader(String name, long value) {
+ setHeaderValue(name, new Long(value));
+ }
+
+ public void addDateHeader(String name, long value) {
+ addHeaderValue(name, new Long(value));
+ }
+
+ public void setHeader(String name, String value) {
+ setHeaderValue(name, value);
+ }
+
+ public void addHeader(String name, String value) {
+ addHeaderValue(name, value);
+ }
+
+ public void setIntHeader(String name, int value) {
+ setHeaderValue(name, new Integer(value));
+ }
+
+ public void addIntHeader(String name, int value) {
+ addHeaderValue(name, new Integer(value));
+ }
+
+ private void setHeaderValue(String name, Object value) {
+ doAddHeaderValue(name, value, true);
+ }
+
+ private void addHeaderValue(String name, Object value) {
+ doAddHeaderValue(name, value, false);
+ }
+
+ private void doAddHeaderValue(String name, Object value, boolean replace) {
+ HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
+ if (header == null) {
+ header = new HeaderValueHolder();
+ this.headers.put(name, header);
+ }
+ if (replace) {
+ header.setValue(value);
+ }
+ else {
+ header.addValue(value);
+ }
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public void setStatus(int status, String statusMessage) {
+ this.status = status;
+ this.statusMessage = statusMessage;
+ }
+
+ public int getStatus() {
+ return this.status;
+ }
+
+ public String getStatusMessage() {
+ return this.statusMessage;
+ }
+
+
+ //---------------------------------------------------------------------
+ // Methods for MockRequestDispatcher
+ //---------------------------------------------------------------------
+
+ public void setForwardedUrl(String forwardedUrl) {
+ this.forwardedUrl = forwardedUrl;
+ }
+
+ public String getForwardedUrl() {
+ return this.forwardedUrl;
+ }
+
+ public void setIncludedUrl(String includedUrl) {
+ this.includedUrl = includedUrl;
+ }
+
+ public String getIncludedUrl() {
+ return this.includedUrl;
+ }
+
+
+ /**
+ * Inner class that adapts the ServletOutputStream to mark the
+ * response as committed once the buffer size is exceeded.
+ */
+ private class ResponseServletOutputStream extends DelegatingServletOutputStream
+ {
+
+ public ResponseServletOutputStream(OutputStream out) {
+ super(out);
+ }
+
+ public void write(int b) throws IOException {
+ super.write(b);
+ super.flush();
+ setCommittedIfBufferSizeExceeded();
+ }
+
+ public void flush() throws IOException {
+ super.flush();
+ setCommitted(true);
+ }
+ }
+
+
+ /**
+ * Inner class that adapts the PrintWriter to mark the
+ * response as committed once the buffer size is exceeded.
+ */
+ private class ResponsePrintWriter extends PrintWriter {
+
+ public ResponsePrintWriter(Writer out) {
+ super(out, true);
+ }
+
+ public void write(char buf[], int off, int len) {
+ super.write(buf, off, len);
+ super.flush();
+ setCommittedIfBufferSizeExceeded();
+ }
+
+ public void write(String s, int off, int len) {
+ super.write(s, off, len);
+ super.flush();
+ setCommittedIfBufferSizeExceeded();
+ }
+
+ public void write(int c) {
+ super.write(c);
+ super.flush();
+ setCommittedIfBufferSizeExceeded();
+ }
+
+ public void flush() {
+ super.flush();
+ setCommitted(true);
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockHttpServletResponse.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockRequestDispatcher.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockRequestDispatcher.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockRequestDispatcher.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.seam.example.tasks.test.fwk;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Mock implementation of the {@link javax.servlet.RequestDispatcher} interface.
+ *
+ * <p>Used for testing the web framework; typically not necessary for
+ * testing application controllers.
+ *
+ * @author Rod Johnson
+ * @author Juergen Hoeller
+ * @since 1.0.2
+ */
+public class MockRequestDispatcher implements RequestDispatcher {
+
+ private final Log logger = LogFactory.getLog(getClass());
+
+ private final String url;
+
+
+ /**
+ * Create a new MockRequestDispatcher for the given URL.
+ * @param url the URL to dispatch to.
+ */
+ public MockRequestDispatcher(String url) {
+ this.url = url;
+ }
+
+
+ public void forward(ServletRequest request, ServletResponse response) {
+ if (response.isCommitted()) {
+ throw new IllegalStateException("Cannot perform forward - response is already committed");
+ }
+ getMockHttpServletResponse(response).setForwardedUrl(this.url);
+ if (logger.isDebugEnabled()) {
+ logger.debug("MockRequestDispatcher: forwarding to URL [" + this.url + "]");
+ }
+ }
+
+ public void include(ServletRequest request, ServletResponse response) {
+ getMockHttpServletResponse(response).setIncludedUrl(this.url);
+ if (logger.isDebugEnabled()) {
+ logger.debug("MockRequestDispatcher: including URL [" + this.url + "]");
+ }
+ }
+
+ /**
+ * Obtain the underlying MockHttpServletResponse,
+ * unwrapping {@link HttpServletResponseWrapper} decorators if necessary.
+ */
+ protected MockHttpServletResponse getMockHttpServletResponse(ServletResponse response) {
+ if (response instanceof MockHttpServletResponse) {
+ return (MockHttpServletResponse) response;
+ }
+ if (response instanceof HttpServletResponseWrapper) {
+ return getMockHttpServletResponse(((HttpServletResponseWrapper) response).getResponse());
+ }
+ throw new IllegalArgumentException("MockRequestDispatcher requires MockHttpServletResponse");
+ }
+
+}
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/MockRequestDispatcher.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/ResourceSeamTest.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/ResourceSeamTest.java (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/ResourceSeamTest.java 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,179 @@
+package org.jboss.seam.example.tasks.test.fwk;
+
+import org.jboss.seam.mock.SeamTest;
+import org.jboss.seam.servlet.SeamResourceServlet;
+import org.testng.annotations.BeforeClass;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.Cookie;
+import java.util.*;
+import java.io.IOException;
+import java.security.Principal;
+
+/**
+ * @author Christian Bauer
+ */
+public class ResourceSeamTest extends SeamTest
+{
+
+ public enum Method
+ {
+ GET, PUT, POST, DELETE, HEAD, OPTIONS
+ }
+
+ protected SeamResourceServlet resourceServlet;
+
+ @BeforeClass
+ public void initResourceServlet() throws Exception
+ {
+ resourceServlet = new SeamResourceServlet();
+ resourceServlet.init(
+ new ServletConfig()
+ {
+ public String getServletName()
+ {
+ return "Seam Resource Servlet";
+ }
+
+ public ServletContext getServletContext()
+ {
+ return servletContext;
+ }
+
+ public String getInitParameter(String s)
+ {
+ return null;
+ }
+
+ public Enumeration getInitParameterNames()
+ {
+ return null;
+ }
+ }
+ );
+
+ }
+
+ public abstract class ResourceRequest
+ {
+
+ private Method httpMethod;
+ private String requestPath;
+ private MockHttpServletRequest request;
+ private MockHttpServletResponse response;
+
+ protected ResourceRequest(Method httpMethod, String requestPath)
+ {
+ this.httpMethod = httpMethod;
+ this.requestPath = getServletPath() + (requestPath.startsWith("/") ? requestPath : "/" + requestPath);
+ }
+
+ public void run() throws Exception
+ {
+ init();
+ prepareRequest(request);
+ seamFilter.doFilter(request, response, new FilterChain()
+ {
+ public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException
+ {
+ resourceServlet.service(request, response);
+ }
+ });
+ seamFilter.destroy();
+ onResponse(getResponse());
+ }
+
+ protected void init()
+ {
+ request = createRequest();
+ response = createResponse();
+
+ request.setMethod(httpMethod.toString());
+ request.setRequestURI(requestPath);
+
+ request.setServletPath(getServletPath());
+
+ request.setCookies(getCookies().toArray(new Cookie[getCookies().size()]));
+
+ for (Map.Entry<String, Object> entry : getDefaultHeaders().entrySet())
+ {
+ request.addHeader(entry.getKey(), entry.getValue());
+ }
+
+ request.setUserPrincipal(
+ new Principal()
+ {
+ public String getName()
+ {
+ return getPrincipalName();
+ }
+ }
+ );
+ for (String role : getPrincipalRoles())
+ {
+ request.addUserRole(role);
+ }
+
+ }
+
+ protected MockHttpServletRequest createRequest()
+ {
+ return new MockHttpServletRequest();
+ }
+
+ protected MockHttpServletResponse createResponse()
+ {
+ return new MockHttpServletResponse();
+ }
+
+ protected Map<String, String> getRequestQueryParameters()
+ {
+ return Collections.EMPTY_MAP;
+ }
+
+ protected List<Cookie> getCookies()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ protected String getPrincipalName()
+ {
+ return null;
+ }
+
+ protected Set<String> getPrincipalRoles()
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ }
+
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ }
+
+ public HttpServletRequest getRequest()
+ {
+ return request;
+ }
+
+ public MockHttpServletResponse getResponse()
+ {
+ return response;
+ }
+
+ }
+
+ public String getServletPath()
+ {
+ return "/seam/resource";
+ }
+
+ public Map<String, Object> getDefaultHeaders() {
+ return Collections.EMPTY_MAP;
+ }
+
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/fwk/ResourceSeamTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/testng.xml
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/testng.xml (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/testng.xml 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,12 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="Tasks" verbose="2" parallel="false">
+
+ <test name="Tasks">
+ <classes>
+ <class name="org.jboss.seam.example.tasks.test.ContextResourceTest"/>
+ <class name="org.jboss.seam.example.tasks.test.TaskResourceTest"/>
+ <class name="org.jboss.seam.example.tasks.test.ResolvedTaskResourceQueryTest"/>
+ </classes>
+ </test>
+</suite>
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/testng.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/view/seam-tasks-client.js
===================================================================
--- branches/community/Seam_2_1/examples/tasks/view/seam-tasks-client.js (rev 0)
+++ branches/community/Seam_2_1/examples/tasks/view/seam-tasks-client.js 2009-04-28 11:35:20 UTC (rev 10675)
@@ -0,0 +1,79 @@
+function getContexts(callback) {
+ $.get("seam/resource/v1/auth/context", callback);
+}
+
+function putContext(contextName, callback) {
+ $.ajax({
+ type: "PUT",
+ url: "seam/resource/v1/auth/context/" + contextName,
+ contentType: "application/xml",
+ success: callback
+ });
+}
+
+function deleteContext(contextName, callback) {
+ $.ajax({
+ type: "DELETE",
+ url: "seam/resource/v1/auth/context/" + contextName,
+ success: callback
+ });
+}
+
+function getTask(contextName, taskId, taskDone, callback) {
+ var URI = escape("seam/resource/v1/auth/context/" + contextName + (taskDone ? "/resolved" : "/unresolved"));
+ $.get(URI, callback);
+}
+
+function getTasksForContext(contextName, taskDone, callback) {
+ var URI = escape("seam/resource/v1/auth/context/" + contextName + (taskDone ? "/resolved" : "/unresolved"));
+ $.get(URI, function(data) {
+ callback(data);
+ });
+}
+
+function getResolvedTasks(username, start, show, callback) {
+ var URI = escape("seam/resource/v1/user/" + username + "/tasks/resolved.xml");
+ URI += "?start=" + start + "&show=" + show;
+ $.get(URI, function(data) {
+ callback(data);
+ });
+}
+
+function postTask(contextName, taskName, callback) {
+ var URI = escape("seam/resource/v1/auth/context/" + contextName + "/unresolved");
+ var data = '<task><name>' + taskName + '</name></task>';
+ var request = $.ajax({
+ type: "POST",
+ url: URI,
+ contentType: "application/xml",
+ dataType: "application/xml",
+ data: data,
+ success: function() {
+ callback(request.getResponseHeader('Location'));
+ }
+ });
+}
+
+function putTask(contextName, taskId, taskName, taskDone, callback) {
+ var URI = escape("seam/resource/v1/auth/context/" + contextName + (taskDone ? "/resolved/" : "/unresolved/") + taskId);
+ var data = '<task><id>' + taskId + '</id><name>' + taskName + '</name></task>'
+ $.ajax({
+ type: "PUT",
+ url: URI,
+ contentType: "application/xml",
+ data: data,
+ success: function() {
+ callback(data);
+ }
+ });
+}
+
+function deleteTask(contextName, taskId, taskDone, callback) {
+ var URI = escape("seam/resource/v1/auth/context/" + contextName + (taskDone ? "/resolved/" : "/unresolved/") + taskId);
+ $.ajax({
+ type: "DELETE",
+ url: URI,
+ dataType: "application/xml",
+ success: callback
+ });
+}
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/view/seam-tasks-client.js
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years
Seam SVN: r10674 - in branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view: layout and 1 other directory.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2009-04-28 07:14:04 -0400 (Tue, 28 Apr 2009)
New Revision: 10674
Modified:
branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/edit.xhtml.ftl
branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/layout/menu.xhtml
branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/layout/menu.xhtml.ftl
branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/list.xhtml.ftl
branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/login.xhtml
Log:
JBPAPP-1899
Modified: branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/edit.xhtml.ftl
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/edit.xhtml.ftl 2009-04-28 11:13:00 UTC (rev 10673)
+++ branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/edit.xhtml.ftl 2009-04-28 11:14:04 UTC (rev 10674)
@@ -134,7 +134,7 @@
<#if parentPojo.shortName!=pojo.shortName>
<div class="actionButtons">
- <s:button value="${'#'}{${homeName}.instance.${property.name} != null ? 'Change' : 'Select'} ${property.name}"
+ <s:button id="${'#'}{${homeName}.instance.${property.name} != null ? 'changeParent' : 'selectParent'}" value="${'#'}{${homeName}.instance.${property.name} != null ? 'Change' : 'Select'} ${property.name}"
view="/${parentPageName}List.xhtml">
<f:param name="from" value="${pageName}Edit"/>
</s:button>
Modified: branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/layout/menu.xhtml
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/layout/menu.xhtml 2009-04-28 11:13:00 UTC (rev 10673)
+++ branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/layout/menu.xhtml 2009-04-28 11:14:04 UTC (rev 10674)
@@ -7,12 +7,12 @@
xmlns:rich="http://richfaces.org/rich">
<rich:toolBarGroup>
<h:outputText value="#{projectName}:"/>
- <s:link view="/home.xhtml" value="Home" propagation="none"/>
+ <s:link id="menuHomeId" view="/home.xhtml" value="Home" propagation="none"/>
</rich:toolBarGroup>
<!-- @newMenuItem@ -->
<rich:toolBarGroup location="right">
- <h:outputText value="signed in as: #{identity.username}" rendered="#{identity.loggedIn}"/>
- <s:link view="/login.xhtml" value="Login" rendered="#{not identity.loggedIn}" propagation="none"/>
- <s:link view="/home.xhtml" action="#{identity.logout}" value="Logout" rendered="#{identity.loggedIn}" propagation="none"/>
+ <h:outputText id="menuWelcomeId" value="signed in as: #{identity.username}" rendered="#{identity.loggedIn}"/>
+ <s:link id="menuLoginId" view="/login.xhtml" value="Login" rendered="#{not identity.loggedIn}" propagation="none"/>
+ <s:link id="menuLogoutId" view="/home.xhtml" action="#{identity.logout}" value="Logout" rendered="#{identity.loggedIn}" propagation="none"/>
</rich:toolBarGroup>
</rich:toolBar>
Modified: branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/layout/menu.xhtml.ftl
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/layout/menu.xhtml.ftl 2009-04-28 11:13:00 UTC (rev 10673)
+++ branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/layout/menu.xhtml.ftl 2009-04-28 11:14:04 UTC (rev 10674)
@@ -7,18 +7,19 @@
xmlns:rich="http://richfaces.org/rich">
<rich:toolBarGroup>
<h:outputText value="${'#'}{projectName}:"/>
- <s:link view="/home.xhtml" value="Home" propagation="none"/>
+ <s:link id="menuHomeId" view="/home.xhtml" value="Home" propagation="none"/>
</rich:toolBarGroup>
<#foreach entity in c2j.getPOJOIterator(cfg.classMappings)>
<s:link view="/${entity.shortName}List.xhtml"
value="${entity.shortName} List"
+ id="${entity.shortName}Id"
includePageParams="false"
propagation="none"/>
</#foreach>
<!-- @newMenuItem@ -->
<rich:toolBarGroup location="right">
- <h:outputText value="signed in as: ${'#'}{identity.username}" rendered="${'#'}{identity.loggedIn}"/>
- <s:link view="/login.xhtml" value="Login" rendered="${'#'}{not identity.loggedIn}" propagation="none"/>
- <s:link view="/home.xhtml" action="${'#'}{identity.logout}" value="Logout" rendered="${'#'}{identity.loggedIn}" propagation="none"/>
+ <h:outputText id="menuWelcomeId" value="signed in as: ${'#'}{identity.username}" rendered="${'#'}{identity.loggedIn}"/>
+ <s:link id="menuLoginId" view="/login.xhtml" value="Login" rendered="${'#'}{not identity.loggedIn}" propagation="none"/>
+ <s:link id="menuLogoutId" view="/home.xhtml" action="${'#'}{identity.logout}" value="Logout" rendered="${'#'}{identity.loggedIn}" propagation="none"/>
</rich:toolBarGroup>
</rich:toolBar>
Modified: branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/list.xhtml.ftl
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/list.xhtml.ftl 2009-04-28 11:13:00 UTC (rev 10673)
+++ branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/list.xhtml.ftl 2009-04-28 11:14:04 UTC (rev 10674)
@@ -127,7 +127,7 @@
<s:link view="/${'#'}{empty from ? '${pageName}' : from}.xhtml"
value="${'#'}{empty from ? 'View' : 'Select'}"
propagation="${'#'}{empty from ? 'none' : 'default'}"
- id="${componentName}">
+ id="${componentName}ViewId">
<#if pojo.isComponent(pojo.identifierProperty)>
<#foreach componentProperty in pojo.identifierProperty.value.propertyIterator>
<f:param name="${componentName}${componentProperty.name?cap_first}"
Modified: branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/login.xhtml
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/login.xhtml 2009-04-28 11:13:00 UTC (rev 10673)
+++ branches/enterprise/JBPAPP_4_3_FP01/seam-gen/view/login.xhtml 2009-04-28 11:14:04 UTC (rev 10674)
@@ -12,7 +12,7 @@
<!-- <h:messages styleClass="message"/>-->
- <h:form id="login">
+ <h:form id="loginForm">
<rich:panel>
<f:facet name="header">Login</f:facet>
@@ -40,7 +40,7 @@
</rich:panel>
<div class="actionButtons">
- <h:commandButton value="Login" action="#{identity.login}"/>
+ <h:commandButton id="submit" value="Login" action="#{identity.login}"/>
</div>
</h:form>
15 years
Seam SVN: r10673 - in branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest: lib and 30 other directories.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2009-04-28 07:13:00 -0400 (Tue, 28 Apr 2009)
New Revision: 10673
Added:
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/lib/ant-launcher.jar
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/lib/ant.jar
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/lib/jboss-test-1.0.5.GA.jar
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build.xml
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/AjaxTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/BackButtonTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/ChangePasswordTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/ConversationTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/RegistrationTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest$1.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest$2.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest$3.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SimpleBookingTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/numberguess/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/numberguess/selenium/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/numberguess/selenium/CommonNumberGuessTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/seampay/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/seampay/selenium/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/seampay/selenium/PaymentTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSelenium$1.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSelenium$2.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSelenium.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/DatabaseTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest$1.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/NewActionTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/NewFormTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/NewProjectTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/PersonTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/SeamGenTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/VehicleTest.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/generate-entities.sql
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/utils/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter$1.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.class
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/readme.txt
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/richfaces.xml
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/smoke.xml
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/DatabaseTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewProjectTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/PersonTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/VehicleTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/generate-entities.sql
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.java
Modified:
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java
Log:
JBPAPP-1899
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties 2009-04-28 07:36:10 UTC (rev 10672)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties 2009-04-28 11:13:00 UTC (rev 10673)
@@ -29,7 +29,7 @@
selenium.browser.port=8080
selenium.browser.url=http://127.0.0.1:8080
selenium.speed=0
-selenium.timeout=30000
+selenium.timeout=120000
# enter any commands wanted for the testng run
selenium.testng.jvmargs=-Dfoo
@@ -43,8 +43,33 @@
jboss.deploy.target=deploy
jboss.undeploy.target=undeploy
# default wait times
-jboss.deploy.waittime=120
+jboss.deploy.waittime=300
# default wait urls
jboss.example.ready.check.url=seam-${example.name}/
+# seam-gen specific properties
+#seamgen.delete.project=true
+# workspace for new projects
+workspace.home=/home/mnovotny/tmp
+# seam-gen project properties
+database.type=mysql
+database.exists=y
+database.drop=n
+driver.jar=/usr/share/java/mysql.jar
+driver.license.jar=
+hibernate.connection.username=medium
+hibernate.connection.password=medium
+hibernate.connection.driver_class=com.mysql.jdbc.Driver
+hibernate.connection.dataSource_class=com.mysql.jdbc.jdbc2.optional.MysqlDataSource
+hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
+hibernate.default_catalog.null=
+hibernate.default_schema.null=
+hibernate.dialect=org.hibernate.dialect.MySQLDialect
+hibernate.connection.url=jdbc\:mysql\:///test
+model.package=com.example
+action.package=com.example
+test.package=com.example.test
+richfaces.skin=classic
+jboss.domain=default
+seam.dir=/home/mnovotny/workspaces/jboss/jboss-seam-fp
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/lib/ant-launcher.jar
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/lib/ant-launcher.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/lib/ant.jar
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/lib/ant.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/lib/jboss-test-1.0.5.GA.jar
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/lib/jboss-test-1.0.5.GA.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/AjaxTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/AjaxTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/BackButtonTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/BackButtonTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/ChangePasswordTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/ChangePasswordTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/ConversationTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/ConversationTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/RegistrationTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/RegistrationTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest$1.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest$1.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest$2.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest$2.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest$3.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest$3.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SimpleBookingTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/booking/selenium/SimpleBookingTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/numberguess/selenium/CommonNumberGuessTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/numberguess/selenium/CommonNumberGuessTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/seampay/selenium/PaymentTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/seampay/selenium/PaymentTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSelenium$1.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSelenium$1.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSelenium$2.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSelenium$2.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSelenium.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSelenium.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/DatabaseTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/DatabaseTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest$1.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest$1.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/NewActionTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/NewActionTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/NewFormTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/NewFormTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/NewProjectTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/NewProjectTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/PersonTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/PersonTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/SeamGenTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/SeamGenTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/VehicleTest.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/VehicleTest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/generate-entities.sql
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/generate-entities.sql (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/generate-entities.sql 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,26 @@
+# This script is executed prior to "generate-entitiesTest" phase of a testsuite to feed the database with test data.
+#
+# by Jozef Hartinger
+#
+
+# drop itentity management tables from previous run
+DROP TABLE IF EXISTS user_account;
+DROP TABLE IF EXISTS user_account_role;
+DROP TABLE IF EXISTS user_permission;
+DROP TABLE IF EXISTS user_role;
+DROP TABLE IF EXISTS user_role_group;
+
+# empty testing tables
+DELETE FROM Vehicle;
+DELETE FROM Person;
+
+# Person table inserts
+INSERT INTO Person (username, name, birthdate, address) values ('johny', 'John Doe', '2009-01-01', 'test address'); # updatePersonTest
+INSERT INTO Person (username, name, birthdate, address) values ('jane', 'Jane Doe', '2009-01-01', 'test address'); # removePersonTest
+INSERT INTO Person (username, name, birthdate, address) values ('jharting', 'Jozef Hartinger', '1987-01-01', 'Purkynova 99, Brno'); # selectVehicleTest
+
+# Vehicle table inserts
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Honda', 'Civic', '2008', '11111111', 'CZ'); # updateVehicleTest
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Nissan', '350z', '2006', '22222222', 'CZ'); # removeVehicleTest
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Audi', 'A5', '2009', '99999991', 'CZ'); # searchTest
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Audi', 'A4', '2009', '99999992', 'CZ'); # searchTest
\ No newline at end of file
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter$1.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter$1.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.class
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build/classes/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build.xml
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build.xml (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build.xml 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<project name="ftest.seamgen" basedir="." default="build" xmlns:server="http://jboss.org/ns/test/ant/server">
+
+ <!-- Location of Seam -->
+ <dirname property="seam.dir" file="${ant.file.ftest.seamgen}/../../../../" />
+
+ <!-- default property setup -->
+ <property name="ftest.dir" value="${seam.dir}/src/test/ftest" />
+ <property name="common.src.dir" value="${ftest.dir}/src/main" />
+ <property name="src.dir" value="src/main" />
+ <property name="build.dir" value="build" />
+ <property name="classes.dir" value="${build.dir}/classes" />
+ <property name="test.output.dir" value="${seam.dir}/test-output" />
+ <property name="ftest.lib.dir" value="${ftest.dir}/lib" />
+
+ <property file="${seam.dir}/src/test/ftest/ftest.properties" />
+
+ <!-- common path setup -->
+
+ <path id="classpath.build">
+ <fileset dir="${ftest.lib.dir}" includes="**/*.jar" />
+ </path>
+
+ <path id="classpath.test">
+ <path refid="classpath.build" />
+ <path location="${classes.dir}" />
+ <fileset dir="${seam.dir}/lib/gen" includes="*.jar" />
+ <fileset file="${java.home}/../lib/tools.jar"/>
+ <fileset file="${driver.jar}"/>
+ <!-- TODO why do we need this? -->
+ <fileset dir="${seam.dir}/lib" includes="*.jar" />
+ </path>
+
+ <target name="clean" description="Delete all generated files">
+ <delete dir="${build.dir}" />
+ <delete dir="${test.output.dir}" />
+ <delete dir="${report.dir}" />
+ <delete dir="${log.dir}" />
+ </target>
+
+ <target name="build" depends="build.common" description="Compiles the Test">
+ <mkdir dir="${classes.dir}" />
+ <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath.build" debug="true" />
+ <copy todir="${classes.dir}">
+ <fileset dir="${src.dir}">
+ <exclude name="**/*.java" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="build.common" description="Compiles the common selenium test code">
+ <mkdir dir="${classes.dir}" />
+ <javac srcdir="${common.src.dir}" destdir="${classes.dir}" classpathref="classpath.build" debug="true" />
+ <copy todir="${classes.dir}">
+ <fileset dir="${src.dir}">
+ <include name="**/SeamSelenium.java" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="seam-gen.testsuite" depends="build" description="Run Richfaces testsuite">
+ <run.selenium.test suite="richfaces" />
+ </target>
+
+ <target name="seam-gen.smoke.testsuite" depends="build" description="Run smoke testsuite">
+ <run.selenium.test suite="smoke" />
+ </target>
+
+ <macrodef name="run.selenium.test">
+ <attribute name="suite" />
+ <sequential>
+ <!--<ant antfile="${seam.dir}/build.xml" target="copyseam"/>-->
+ <taskdef resource="testngtasks" classpathref="classpath.test" />
+ <!-- execute testng tests -->
+ <testng haltonfailure="false" outputdir="${test.output.dir}" classpathref="classpath.test">
+ <xmlfileset file="@{suite}.xml" />
+ <sysproperty key="seam.dir" value="${seam.dir}" />
+ </testng>
+ </sequential>
+ </macrodef>
+
+</project>
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/readme.txt
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/readme.txt (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/readme.txt 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,105 @@
+#
+ # JBoss, Home of Professional Open Source
+ # Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ # by the @authors tag. See the copyright.txt in the distribution for a
+ # full listing of individual contributors.
+ #
+ # This is free software; you can redistribute it and/or modify it
+ # under the terms of the GNU Lesser General Public License as
+ # published by the Free Software Foundation; either version 2.1 of
+ # the License, or (at your option) any later version.
+ #
+ # This software is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ # Lesser General Public License for more details.
+ #
+ # You should have received a copy of the GNU Lesser General Public
+ # License along with this software; if not, write to the Free
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ #
+
+Seam-gen functional testsuite
+------------------------------------
+
+UNDER DEVELOPMENT NOT COMPLETE
+
+How to run the testsuite:
+----------------------
+To run seam-gen functional testsuite, please follow these steps:
+
+1.) Export following script to MySQL database
+
+CREATE TABLE `Person` (
+ `username` varchar(10) NOT NULL,
+ `name` varchar(100) NOT NULL,
+ `birthdate` date default NULL,
+ `address` varchar(600) NOT NULL,
+ PRIMARY KEY (`username`)
+) ENGINE=InnoDB;
+
+CREATE TABLE `Vehicle` (
+ `ownerUsername` varchar(10) default NULL,
+ `make` varchar(50) NOT NULL,
+ `model` varchar(50) NOT NULL,
+ `year` int(11) NOT NULL,
+ `registration` varchar(8) NOT NULL,
+ `state` varchar(2) NOT NULL,
+ PRIMARY KEY USING BTREE (`registration`,`state`),
+ KEY `ownerUsername` (`ownerUsername`),
+ CONSTRAINT `owner` FOREIGN KEY (`ownerUsername`) REFERENCES `Person` (`username`)
+) ENGINE=InnoDB;
+
+
+2.) Check setup in ../ftest.properties
+ a) check that selenium.browser property is set to your desired browser
+ b) check that container property is set to either jboss4 or jboss5
+ c) check that jboss*.deploy.waittime is set to sensible value
+ d) check that jboss*.home points to the location of your application server
+ e) check that seamgen.delete.project property is set to true if you want the generated applications
+ to be deleted immediately after testrun
+ f) check that workspace.home property points to a folder where generated applications should be stored temporarily
+ g) check that seam-gen project properties (at the end of ftest.properties) are set correctly.
+ Pay special attention to database connection related properties (Configure to use MySQL with exported tables).
+
+3.) Start application server. Make sure there are no application deployed from previous test run.
+#TODO automate this step
+
+4.) Run tests.
+ Run "ant seam-gen.testsuite" to test seam-gen.
+
+ The matrix describing these testsuites follows:
+ ---------------------------------------------
+ | EAR WAR |
+ |use deploy target X X |
+ |use explode target X X |
+ ---------------------------------------------
+
+
+5.) Run "ant testreport" in ${seam.dir} to generate nice looking testreports.
+ For every failed test, there is a screenshot and HTML source stored in test-output/functional-framework
+
+
+Known Limitations:
+---------------------
+* Container must be started (preferably with nothing deployed)
+
+Running tests from Eclipse
+---------------------
+In order to run the testsuite from IDE, you need testng plugin http://testng.org/doc/eclipse.html
+The procedure of running the testsuite from Eclipse is identical to instructions above, however you must replace step 3 with
+following steps:
+a) Rightclick on the testsuite's xml file, choose 'Run As' and then 'Run Configurations'
+b) Modify the classpath to contain ${seam.dir}/lib/gen folder as well as mysql driver jar file
+c) Run the testsuite by rightclick -> 'Run As' -> 'TestNG Suite'
+
+
+Testsuite customization
+---------------------
+To customize the testsuite, edit particular xml file in this folder.
+You can use following parameters to influence seam-gen application type:
+1.) type - set to ear or war, ear is the default value
+2.) explode - set to true or false, if set to false, application will be deployed and undeployed using (un)deploy target.
+ (un)explode target will be used otherwise. True is the default value.
+3.) suffix - value of this parameter will be appended to the application name.
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/richfaces.xml
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/richfaces.xml (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/richfaces.xml 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="seam-gen RichFaces suite" parallel="false" verbose="3">
+ <listeners>
+ <listener
+ class-name="org.jboss.seam.test.functional.seamgen.utils.SeleniumTestListener" />
+ </listeners>
+ <parameter name="suffix" value="001" />
+ <test name="RichFaces exploded Ear Test">
+ <parameter name="type" value="ear" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class
+ name="org.jboss.seam.test.functional.seamgen.HotDeploymentStaticTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ </classes>
+ </test>
+ <test name="RichFaces exploded War Test">
+ <parameter name="type" value="war" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class
+ name="org.jboss.seam.test.functional.seamgen.HotDeploymentNewFormTest" />
+ <class
+ name="org.jboss.seam.test.functional.seamgen.HotDeploymentStaticTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ </classes>
+ </test>
+ <test name="RichFaces Ear Test">
+ <parameter name="type" value="ear" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ </classes>
+ </test>
+ <test name="RichFaces War Test">
+ <parameter name="type" value="war" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ </classes>
+ </test>
+</suite>
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/smoke.xml
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/smoke.xml (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/smoke.xml 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="seam-gen smoke testsuite" parallel="false" verbose="3">
+ <listeners>
+ <listener
+ class-name="org.jboss.seam.test.functional.seamgen.utils.SeleniumTestListener"></listener>
+ </listeners>
+ <parameter name="suffix" value="smoke001"/>
+ <test name="RichFaces exploded Ear Test">
+ <parameter name="type" value="ear" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest" />
+ </classes>
+ </test>
+ <test name="RichFaces exploded War Test">
+ <parameter name="type" value="war" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest" />
+ </classes>
+ </test>
+ <test name="RichFaces Ear Test">
+ <parameter name="type" value="ear" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest" />
+ </classes>
+ </test>
+ <test name="RichFaces War Test">
+ <parameter name="type" value="war" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest" />
+ </classes>
+ </test>
+</suite>
\ No newline at end of file
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/DatabaseTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/DatabaseTest.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/DatabaseTest.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+/**
+ * Every test that uses database and needs import script to be executed should
+ * extend this class.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class DatabaseTest extends SeleniumSeamGenTest
+{
+
+ /**
+ * Execute import script against the database defined in import.sql
+ */
+ public void executeImportScript(InputStream is)
+ {
+ Connection conn = null;
+ try
+ {
+ Class.forName(ftestProperties.getProperty("hibernate.connection.driver_class"));
+ String url = ftestProperties.getProperty("hibernate.connection.url");
+ conn = DriverManager.getConnection(url, ftestProperties.getProperty("hibernate.connection.username"), ftestProperties.getProperty("hibernate.connection.username"));
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ String line = reader.readLine();
+ while (line != null)
+ {
+ if (!line.equals(new String())) // don't execute empty lines
+ {
+ conn.createStatement().execute(line);
+ }
+ line = reader.readLine();
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Database import script failed.", e);
+ }
+ finally
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen;
+
+import java.io.InputStream;
+import java.util.Date;
+
+import org.testng.annotations.BeforeGroups;
+
+import com.thoughtworks.selenium.Wait;
+
+/**
+ * This class and its subclasses test seam-gen's "generate-entities" feature.
+ * Every test method should be part of "generate-entitiesTest" in order to get
+ * entities generated before its execution.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class GenerateEntitiesTest extends DatabaseTest
+{
+
+ public static final String PERSON_LINK = "id=PersonId";
+ public static final String PERSON_USERNAME = "id=person:usernameField:username";
+ public static final String PERSON_ADDRESS = "id=person:addressField:address";
+ public static final String PERSON_BIRTHDAY = "id=person:birthdateField:birthdate";
+ public static final String PERSON_NAME = "id=person:nameField:name";
+ public static final String PERSON_SAVE = "id=person:save";
+ public static final String PERSON_CANCEL = "id=person:cancel";
+ public static final String PERSON_DELETE = "id=person:delete";
+ public static final String PERSON_UPDATE = "id=person:update";
+ public static final int PERSON_IDENTIFIER_SIZE = 10;
+
+ public static final String PERSON_LIST_EDIT_BUTTON_BY_NAME = "xpath=//table[@id='personList']/tbody/tr[normalize-space(td[1]/text()) = '%s']//a[matches(@id, 'personList:\\d+:personEdit')]";
+ public static final String PERSON_LIST_VIEW_BUTTON_BY_NAME = "xpath=//table[@id='personList']/tbody/tr[normalize-space(td[1]/text()) = '%s']//a[matches(@id, 'personList:\\d+:person')]";
+ public static final String PERSON_LIST_RESULT_COUNT = "//table[@id='personList']/tbody/tr";
+
+ public static final String VEHICLE_REGISTRATION = "id=vehicle:registrationField:registration";
+ public static final String VEHICLE_STATE = "id=vehicle:stateField:state";
+ public static final String VEHICLE_MAKE = "id=vehicle:makeField:make";
+ public static final String VEHICLE_MODEL = "id=vehicle:modelField:model";
+ public static final String VEHICLE_YEAR = "id=vehicle:yearField:year";
+ public static final String VEHICLE_LINK = "id=VehicleId";
+ public static final String VEHICLE_SAVE = "id=vehicle:save";
+ public static final String VEHICLE_CANCEL = "id=vehicle:cancel";
+ public static final String VEHICLE_DELETE = "id=vehicle:delete";
+ public static final String VEHICLE_UPDATE = "id=vehicle:update";
+ public static final int VEHICLE_IDENTIFIER_SIZE = 8;
+
+ public static final String ENTITY_CREATE_BUTTON = "id=create";
+ public static final String ENTITY_EDIT = "id=edit";
+ public static final String ENTITY_DONE = "id=done";
+ public static final String ENTITY_SELECT_PARENT_BUTTON = "xpath=//*[contains(@id, 'selectParent')]";
+ public static final String VEHICLE_LIST_EDIT_BUTTON_BY_REGISTRATION = "xpath=//table[@id='vehicleList']/tbody/tr[normalize-space(td[1]/text()) = \"%s\"]//a[matches(@id, 'vehicleList:\\d+:vehicleEdit')]";
+ public static final String VEHICLE_LIST_VIEW_BUTTON_BY_REGISTRATION = "xpath=//table[@id='vehicleList']/tbody/tr[normalize-space(td[1]/text()) = \"%s\"]//a[matches(@id, 'vehicleList:\\d+:vehicle')]";
+ public static final String VEHICLE_LIST_RESULT_COUNT = "//table[@id='vehicleList']/tbody/tr";
+ public static final String VEHICLE_LIST_ROW_BY_OWNER_NAME = "xpath=//table[@id='vehicleList']/tbody/tr[normalize-space(td[1]/text()) = \"%s\"]/td[normalize-space(text()) = \"%s\"]";
+
+ /**
+ * Execute generate-entities.sql script, run ./seam generate-entities, deploy
+ * the application and wait for it to load.
+ *
+ */
+ @BeforeGroups(groups = "generate-entitiesTest")
+ public void generateEntitiesTest()
+ {
+ // open and execute import script
+ InputStream importScript = getClass().getResourceAsStream("/org/jboss/seam/test/functional/seamgen/generate-entities.sql");
+ executeImportScript(importScript);
+
+ seamGen.generateEntities();
+ seamGen.restart();
+ waitForAppToDeploy(HOME_PAGE, PERSON_LINK);
+ }
+
+ /**
+ * Submit new person.
+ */
+ public void createNewPerson(String username, String address, Date birthday, String name)
+ {
+ browser.clickAndWait(PERSON_LINK);
+ browser.clickAndWait(ENTITY_CREATE_BUTTON);
+ fillPersonEditPage(username, address, birthday, name);
+ browser.clickAndWait(PERSON_SAVE);
+ }
+
+ /**
+ * Fill user details. Browser must be navigated to user's detail page before
+ * executing this method. This method does not submit the form.
+ */
+ public void fillPersonEditPage(String username, String address, Date birthday, String name)
+ {
+ browser.type(PERSON_USERNAME, username);
+ browser.type(PERSON_ADDRESS, address);
+ selectDate(birthday);
+ browser.type(PERSON_NAME, name);
+ }
+
+ /**
+ * Select a date using icefaces or richfaces calendar component. Selecting
+ * hardcoded values is only implemented yet.
+ */
+ public void selectDate(Date date)
+ {
+ // TODO
+ final String richFaces = "id=person:birthdateField:birthdateDayCell24";
+ final String iceFaces = "id=person:birthdateField:birthdate_calendar_1569";
+ final String icefacesCalendarButton = "person:birthdateField:birthdate_calendarButton";
+
+ if (browser.isElementPresent(richFaces))
+ {
+ browser.click(richFaces);
+ }
+ else if (browser.isElementPresent(icefacesCalendarButton))
+ {
+ browser.click(icefacesCalendarButton);
+ new Wait()
+ {
+
+ @Override
+ public boolean until()
+ {
+ return browser.isElementPresent(iceFaces);
+ }
+ }.wait("Calendar did not appear.", Long.valueOf(SELENIUM_TIMEOUT));
+ browser.click(iceFaces);
+ }
+ else
+ {
+ throw new RuntimeException("Unable to select date." + browser.getHtmlSource());
+ }
+ }
+
+ /**
+ * Submit new vehicle
+ */
+ public void createNewVehicle(String registration, String state, String make, String model, String year)
+ {
+ browser.clickAndWait(VEHICLE_LINK);
+ browser.clickAndWait(ENTITY_CREATE_BUTTON);
+ fillVehicleEditPage(registration, state, make, model, year);
+ browser.clickAndWait(VEHICLE_SAVE);
+ }
+
+ /**
+ * Fill vehicle details. Browser must be navigated to vehicle's detail page before
+ * executing this method. This method does not submit the form.
+ */
+ public void fillVehicleEditPage(String registration, String state, String make, String model, String year)
+ {
+ browser.type(VEHICLE_REGISTRATION, registration);
+ browser.type(VEHICLE_STATE, state);
+ browser.type(VEHICLE_MAKE, make);
+ browser.type(VEHICLE_MODEL, model);
+ browser.type(VEHICLE_YEAR, year);
+ }
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen;
+
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+/**
+ * This test verifies hot deployment of JavaBean components. This class should
+ * only be used to test WAR packaged Seam applications.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class HotDeploymentNewFormTest extends NewFormTest
+{
+
+ @Override
+ protected void prepareData()
+ {
+ newComponentProperties = new String[] { "hi", "HiLocal", "Hi", "hi", "hiPage" };
+ }
+
+ @Override
+ protected void deployNewComponent()
+ {
+ seamGen.hotDeploy();
+ }
+
+ @Override
+ @Test(groups = { "newFormGroup" }, dependsOnGroups = { "newProjectGroup" })
+ public void testNewComponent()
+ {
+ String username = "admin";
+ String password = "password";
+
+ login(username, password);
+
+ super.testNewComponent();
+
+ assertTrue(isLoggedIn(), "User should be logged in by now. Hot deployment failure.");
+ }
+
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * This test verifies hot deployment of static resources. It modifies home.xhtml
+ * page and verifies that changes are reflected within the running app. All is done
+ * within user session to detect if the whole application was restarted or not.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class HotDeploymentStaticTest extends SeleniumSeamGenTest
+{
+
+ private String newFeature;
+
+ @BeforeClass
+ public void modifyHomePage() throws IOException, InterruptedException
+ {
+ String homePageLocation = WORKSPACE + "/" + APP_NAME + "/view/home.xhtml";
+ newFeature = "Works flawlessly as it is tested by Selenium";
+
+ BufferedReader reader = null;
+ StringBuilder homePageContentBuilder = new StringBuilder();
+ try
+ {
+ reader = new BufferedReader(new InputStreamReader(new FileInputStream(homePageLocation)));
+ // load file content into String
+ String line = reader.readLine();
+ while (line != null)
+ {
+ homePageContentBuilder.append(line);
+ line = reader.readLine();
+ }
+ }
+ finally
+ {
+ reader.close();
+ }
+
+ String homePageContent = homePageContentBuilder.toString();
+
+ // add new item into the feature list
+ homePageContent = homePageContent.replaceAll("<li>Internationalization support</li>", "<li>Internationalization support</li>\n<li>" + newFeature + "</li>");
+
+ // write new content
+ Writer writer = null;
+ try
+ {
+ writer = new OutputStreamWriter(new FileOutputStream(homePageLocation));
+ writer.write(homePageContent);
+ writer.flush();
+ }
+ finally
+ {
+ writer.close();
+ }
+
+ seamGen.deploy();
+ }
+
+ @Test(dependsOnGroups = { "newProjectGroup" })
+ public void hotDeploymentOfFaceletTemplateTest()
+ {
+
+ login();
+
+ assertTrue(browser.isTextPresent(newFeature), "New feature not found. Hot deployment failure.");
+ assertTrue(isLoggedIn(), "Session lost. Hot deployment failure.");
+ }
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+
+/**
+ * This class verifies functionality of "new-action command".
+ * @author Jozef Hartinger
+ *
+ */
+public class NewActionTest extends SeleniumSeamGenTest
+{
+
+ protected String[] newComponentProperties;
+
+ @BeforeClass
+ public void createNewAction() throws InterruptedException {
+ prepareData();
+ generateNewComponent();
+ deployNewComponent();
+ waitForAppToDeploy(getComponentPath(), FOOTER);
+ }
+
+
+ @Test(groups = { "newActionGroup" }, dependsOnGroups = { "newProjectGroup" })
+ public void testNewComponent()
+ {
+ String form = "id=" + newComponentProperties[0] + "Form";
+ String button = form + ":" + newComponentProperties[3];
+
+ browser.open(getComponentPath());
+
+ assertTrue(browser.isElementPresent(FOOTER), "Footer not found.");
+ assertTrue(browser.isElementPresent(form), form + " not found.");
+ assertTrue(browser.isElementPresent(button), button + " not found.");
+
+ browser.clickAndWait(button);
+
+ assertTrue(browser.isElementPresent(MESSAGES));
+ assertTrue(browser.getText(MESSAGES).contains(newComponentProperties[3]));
+ }
+
+ public void generateNewComponent()
+ {
+ seamGen.newAction(newComponentProperties);
+ }
+
+ protected void prepareData() {
+ newComponentProperties = new String[]{ "ping", "PingLocal", "Ping", "ping", "pingPage" };
+ }
+
+ public String getComponentPath() {
+ return "/" + APP_NAME + "/" + newComponentProperties[4] + ".seam";
+ }
+
+ protected void deployNewComponent() {
+ seamGen.restart();
+ }
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+import org.testng.annotations.Test;
+
+/**
+ * This class verifies functionality of "new-action command".
+ * @author Jozef Hartinger
+ *
+ */
+public class NewFormTest extends NewActionTest
+{
+
+ @Override
+ @Test(groups = { "newFormGroup" }, dependsOnGroups = { "newProjectGroup" })
+ public void testNewComponent()
+ {
+
+ String form = "id=" + newComponentProperties[0] + "Form";
+ String button = form + ":" + newComponentProperties[3];
+ String field = form + ":" + "valueField:value";
+ String value = "world";
+
+ browser.open(getComponentPath());
+
+ assertTrue(browser.isElementPresent(FOOTER), "Footer not found.");
+ assertTrue(browser.isElementPresent(form), form + " not found.");
+ assertTrue(browser.isElementPresent(field), field + " not found.");
+ assertTrue(browser.isElementPresent(button), button + " not found.");
+
+ browser.type(field, value);
+ browser.clickAndWait(button);
+
+ assertTrue(browser.isElementPresent(MESSAGES), "Message not found.");
+ assertEquals(browser.getText(MESSAGES), newComponentProperties[3] + " " + value, "Unexpected form output.");
+ }
+
+ @Override
+ protected void prepareData() {
+ newComponentProperties = new String[]{ "hello", "HelloLocal", "Hello", "hello", "helloPage" };
+ }
+
+ @Override
+ public void generateNewComponent()
+ {
+ seamGen.newForm(newComponentProperties);
+ }
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewProjectTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewProjectTest.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewProjectTest.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+
+/**
+ * This class is responsible for creating new project and verifying that deployment
+ * and basic functionality works.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class NewProjectTest extends SeleniumSeamGenTest
+{
+
+ @BeforeGroups(groups = { "newProjectGroup" })
+ public void setup() throws FileNotFoundException, IOException, InterruptedException
+ {
+
+ // save properties
+ seamGenProperties.store(new FileOutputStream(SEAMGEN_PROPERTIES_FILE), "Created by seam-gen functional testsuite.");
+ seamGen.createProject();
+ seamGen.deploy();
+ waitForAppToDeploy(HOME_PAGE, FOOTER);
+ }
+
+ @Test(groups = { "newProjectGroup" })
+ public void validLoginTest()
+ {
+ login();
+ // verify login
+ assertTrue(browser.isElementPresent(LOGOUT), "Logout link expected.");
+ assertTrue(browser.getText(SIGNED_USER).contains(DEFAULT_USERNAME), "Username not found. " + browser.getText(SIGNED_USER) + " found instead.");
+ // logout
+ browser.clickAndWait(LOGOUT);
+ assertTrue(browser.isElementPresent(LOGIN), "Login link expected.");
+ assertTrue(browser.isElementPresent(HOME), "Home link expected.");
+ }
+
+ @Test(groups = { "newProjectGroup" })
+ public void invalidLoginTest()
+ {
+ String username = "badUser";
+ String password = "password";
+
+ login(username, password);
+ // verify login
+ assertTrue(browser.isElementPresent(LOGIN), "User should not be logged in.");
+ assertTrue(browser.getText(MESSAGES).contains(LOGIN_FAILED_MESSAGE), LOGIN_FAILED_MESSAGE + " expected.");
+ }
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/PersonTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/PersonTest.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/PersonTest.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen;
+
+import java.util.Date;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+/**
+ * This test verifies CRUD functionality on the Person table.
+ * @author Jozef Hartinger
+ *
+ */
+public class PersonTest extends GenerateEntitiesTest
+{
+
+ public static final String SEARCH_USERNAME = "xpath=//input[matches(@id, 'personSearch:.+:username')]";
+ public static final String SEARCH_SUBMIT = "personSearch:search";
+ public static final String SEARCH_RESET = "personSearch:reset";
+
+ public static final String VIEW_USERNAME = "xpath=id('username')/div/span[2]";
+ public static final String VIEW_ADDRESS = "xpath=id('address')/div/span[2]";
+ public static final String VIEW_NAME = "xpath=id('name')/div/span[2]";
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = { "newProjectGroup" })
+ public void newPersonTest()
+ {
+ login();
+ String username = "tester";
+ String address = "test address";
+ String name = "John Doe";
+ createNewPerson(username, address, new Date(), name);
+
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully created", "Unexpected confirmation message");
+
+ // search for the person
+ browser.clickAndWait(ENTITY_DONE);
+ int result = search(username);
+ assertEquals(result, 1, "Unexpected count of search results after creating new user");
+ // verify view page
+ browser.clickAndWait(String.format(PERSON_LIST_VIEW_BUTTON_BY_NAME, username));
+ verifyViewPage(username, address, name);
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = { "newProjectGroup" })
+ public void updatePersonTest()
+ {
+ String username = "johny";
+ String address = "updated address";
+ String name = "Test User";
+
+ login();
+ browser.clickAndWait(PERSON_LINK);
+ String editButton = String.format(PERSON_LIST_EDIT_BUTTON_BY_NAME, username);
+ browser.clickAndWait(editButton);
+ // update the entity
+ fillPersonEditPage(username, address, new Date(), name);
+ browser.clickAndWait(PERSON_UPDATE);
+ // verify
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully updated", "Unexpected confirmation message");
+ verifyViewPage(username, address, name);
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = { "newProjectGroup" })
+ public void removePersonTest()
+ {
+ String username = "jane";
+
+ login();
+ browser.clickAndWait(PERSON_LINK);
+ String editButton = String.format(PERSON_LIST_EDIT_BUTTON_BY_NAME, username);
+ browser.clickAndWait(editButton);
+ // delete the person
+ browser.clickAndWait(PERSON_DELETE);
+
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully deleted", "Unexpected confirmation message");
+
+ // search for the user
+ int result = search(username);
+ assertEquals(result, 0, "Unexpected count of search results after removing the user");
+
+ }
+
+ public int search(String pattern)
+ {
+ browser.type(SEARCH_USERNAME, pattern);
+ browser.clickAndWait(SEARCH_SUBMIT);
+ return browser.getXpathCount(PERSON_LIST_RESULT_COUNT).intValue();
+ }
+
+ public void verifyViewPage(String username, String address, String name)
+ {
+ assertEquals(browser.getText(VIEW_USERNAME), username);
+ assertEquals(browser.getText(VIEW_ADDRESS), address);
+ assertEquals(browser.getText(VIEW_NAME), name);
+ }
+
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,198 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.jboss.seam.test.functional.seamgen.utils.SeamGenAdapter;
+import org.openqa.selenium.server.RemoteControlConfiguration;
+import org.openqa.selenium.server.SeleniumServer;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+
+/**
+ * Base class for seam-gen functional tests.
+ * @author Jozef Hartinger
+ */
+public class SeamGenTest
+{
+
+ protected static SeamGenAdapter seamGen;
+ protected static Properties seamGenProperties;
+ protected static Properties ftestProperties = new Properties();
+
+ protected static String SEAM_DIR;
+ protected static String SEAM_FTEST_PROPERTIES_FILE;
+ protected static String SEAMGEN_BUILDFILE;
+ protected static String SEAMGEN_PROPERTIES_FILE;
+ protected static String WORKSPACE;
+
+ // container specific properties
+ protected static String CONTAINER;
+ protected static String CONTAINER_LOCATION;
+ protected static int DEPLOY_TIMEOUT;
+
+ protected static boolean ICEFACES;
+ protected static boolean WAR;
+
+ protected static boolean DELETE_PROJECT;
+
+ protected static String TEST_SEAMGEN_PROPERTIES_FILE;
+
+ // Selenium related constants
+ protected static String SELENIUM_HOST;
+ protected static String SELENIUM_BROWSER;
+ protected static String SELENIUM_BROWSER_URL;
+ protected static int SELENIUM_SERVER_PORT;
+ protected static String SELENIUM_SPEED;
+ protected static String SELENIUM_TIMEOUT;
+ protected static long SELENIUM_ICEFACES_WAIT_TIME;
+
+ protected static String OUTPUT_DIR;
+
+ // Test application specific constants
+ protected static String APP_NAME;
+ protected static String HOME_PAGE;
+
+ // Selenium server instance
+ protected static SeleniumServer seleniumServer;
+
+ @BeforeSuite
+ @Parameters("seam.dir")
+ public void beforeSuite(@Optional(".") String seamDir) throws Exception {
+ // Seam location
+ SEAM_DIR = seamDir;
+ SEAM_FTEST_PROPERTIES_FILE = SEAM_DIR + "/src/test/ftest/ftest.properties";
+ SEAMGEN_BUILDFILE = SEAM_DIR + "/seam-gen/build.xml";
+ SEAMGEN_PROPERTIES_FILE = SEAM_DIR + "/seam-gen/build.properties";
+ OUTPUT_DIR = SEAM_DIR + "/test-output/functional-framework/";
+
+ loadFtestProperties();
+ createOutputDir();
+ startSeleniumServer();
+ }
+
+ @AfterSuite
+ public void afterSuite() {
+ seleniumServer.stop();
+ }
+
+ @BeforeTest
+ @Parameters( { "icefaces", "type", "suffix", "explode" })
+ public void setUp(@Optional("false") boolean icefaces, @Optional("ear") String type, @Optional("") String suffix, @Optional("true") boolean explode) throws Exception
+ {
+ ICEFACES = icefaces;
+ WAR = type.equalsIgnoreCase("war");
+ APP_NAME = "seamGenTestApp" + (ICEFACES ? "Ice" : "Rich") + (WAR ? "War" : "Ear") + (explode? "E" : "D") + suffix;
+ HOME_PAGE = "/" + APP_NAME + "/home.seam";
+
+ setSeamGenProperties();
+
+ seamGen = new SeamGenAdapter(SEAMGEN_BUILDFILE);
+ seamGen.setExplode(explode);
+
+ }
+
+ @AfterTest
+ public void tearDown()
+ {
+ if (DELETE_PROJECT)
+ {
+ seamGen.deleteProject();
+ }
+ else
+ {
+ seamGen.undeploy();
+ }
+ }
+
+ private void loadFtestProperties() throws FileNotFoundException, IOException
+ {
+ // load general properties
+ ftestProperties.load(new FileInputStream(SEAM_FTEST_PROPERTIES_FILE));
+
+ WORKSPACE = ftestProperties.getProperty("workspace.home");
+
+ // container specific
+ CONTAINER = ftestProperties.getProperty("container", "jboss5");
+ CONTAINER_LOCATION = ftestProperties.getProperty(CONTAINER + ".home");
+ DEPLOY_TIMEOUT = Integer.parseInt(ftestProperties.getProperty(CONTAINER + ".deploy.waittime")) * 1000; // miliseconds
+ DELETE_PROJECT = Boolean.valueOf(ftestProperties.getProperty("seamgen.delete.project", "false"));
+
+ // load selenium constants
+ SELENIUM_HOST = ftestProperties.getProperty("selenium.host");
+ SELENIUM_BROWSER = ftestProperties.getProperty("selenium.browser");
+ SELENIUM_BROWSER_URL = ftestProperties.getProperty("selenium.browser.url");
+ SELENIUM_SERVER_PORT = Integer.parseInt(ftestProperties.getProperty("selenium.server.port"));
+ SELENIUM_SPEED = ftestProperties.getProperty("selenium.speed");
+ SELENIUM_TIMEOUT = ftestProperties.getProperty("selenium.timeout");
+ SELENIUM_ICEFACES_WAIT_TIME = Long.valueOf(ftestProperties.getProperty("selenium.icefaces.wait.time", "2000"));
+ }
+
+ private void setSeamGenProperties()
+ {
+ seamGenProperties = new Properties();
+
+ String[] propertiesToCopy = { "database.type", "database.exists", "database.drop", "driver.jar", "driver.license.jar", "hibernate.connection.username", "hibernate.connection.password", "hibernate.connection.driver_class", "hibernate.connection.dataSource_class", "hibernate.cache.provider_class", "hibernate.default_catalog.null", "hibernate.default_schema.null", "hibernate.dialect", "hibernate.connection.url", "model.package", "action.package", "test.package", "richfaces.skin", "icefaces.home", "jboss.home" };
+
+ for (String property : propertiesToCopy)
+ {
+ if (ftestProperties.get(property) != null)
+ {
+ seamGenProperties.put(property, ftestProperties.get(property));
+ }
+ }
+
+ // override with ftest.properties
+ seamGenProperties.put("workspace.home", WORKSPACE);
+ seamGenProperties.put("jboss.home", CONTAINER_LOCATION);
+ seamGenProperties.put("icefaces", ICEFACES ? "y" : "n");
+ seamGenProperties.put("project.type", WAR ? "war" : "ear");
+ seamGenProperties.put("project.name", APP_NAME);
+ }
+
+ private void startSeleniumServer() throws Exception
+ {
+ RemoteControlConfiguration rcc = new RemoteControlConfiguration();
+ rcc.setPort(SELENIUM_SERVER_PORT);
+ rcc.setLogOutFileName(OUTPUT_DIR + "/selenium-server.log");
+ seleniumServer = new SeleniumServer(rcc);
+ seleniumServer.start();
+ }
+
+ private void createOutputDir()
+ {
+ File dir = new File(OUTPUT_DIR);
+ if (!dir.exists())
+ {
+ dir.mkdir();
+ }
+ }
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen;
+
+import static org.testng.Assert.assertTrue;
+
+import org.jboss.seam.example.common.test.selenium.SeamSelenium;
+import org.testng.annotations.BeforeMethod;
+
+/**
+ * Base class for Selenium seam-gen tests. Separate browser instance is created
+ * prior to each test method execution. Browser instances are stopped by
+ * SeleniumTestListener.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class SeleniumSeamGenTest extends SeamGenTest
+{
+ // home page
+ public static final String LOGIN = "id=menuLoginId";
+ public static final String LOGOUT = "id=menuLogoutId";
+ public static final String HOME = "id=menuHomeId";
+ public static final String SIGNED_USER = "id=menuWelcomeId";
+ // login page
+ public static final String LOGIN_USERNAME = "id=loginForm:username";
+ public static final String LOGIN_PASSWORD = "id=loginForm:password";
+ public static final String LOGIN_REMEMBER_ME = "id=loginForm:rememberMe";
+ public static final String LOGIN_SUBMIT = "id=loginForm:submit";
+ public static final String LOGIN_FAILED_MESSAGE = "Login failed";
+
+ public static final String MESSAGES = "id=messages";
+ public static final String FOOTER = "xpath=//div[@class = 'footer']";
+ public static final String MESSAGE_WELCOME = "xpath=//h1[text() = 'Welcome to Seam!']";
+
+ public static final String DEFAULT_USERNAME = "admin";
+ public static final String DEFAULT_PASSWORD = "";
+
+ public static SeamSelenium browser;
+
+ /**
+ * Start new browser instance and store it into static variable. Moreover,
+ * open application home page.
+ */
+ public void initBrowser()
+ {
+ browser = startBrowser();
+ browser.open(HOME_PAGE);
+ }
+
+ /**
+ * Create new browser instance.
+ */
+ public SeamSelenium startBrowser()
+ {
+ SeamSelenium newBrowser = new SeamSelenium(SELENIUM_HOST, SELENIUM_SERVER_PORT, SELENIUM_BROWSER, SELENIUM_BROWSER_URL);
+ newBrowser.start();
+ newBrowser.allowNativeXpath("false");
+ newBrowser.setSpeed(SELENIUM_SPEED);
+ newBrowser.setTimeout(SELENIUM_TIMEOUT);
+ if (ICEFACES)
+ {
+ newBrowser.setIcefacesDetection(true);
+ }
+ newBrowser.setIcefacesWaitTime(SELENIUM_ICEFACES_WAIT_TIME);
+ return newBrowser;
+ }
+
+ public void stopBrowser()
+ {
+ browser.stop();
+ }
+
+ public void login(String username, String password)
+ {
+ assertTrue(browser.isElementPresent(LOGIN), "Login link expected.");
+ browser.clickAndWait(LOGIN);
+ browser.type(LOGIN_USERNAME, username);
+ browser.type(LOGIN_PASSWORD, password);
+ browser.clickAndWait(LOGIN_SUBMIT);
+ }
+
+ public void login()
+ {
+ login(DEFAULT_USERNAME, DEFAULT_PASSWORD);
+ }
+
+ public boolean isLoggedIn()
+ {
+ return browser.isElementPresent(SIGNED_USER) && browser.isElementPresent(LOGOUT) && !browser.isElementPresent(LOGIN);
+ }
+
+ public void logout()
+ {
+ browser.clickAndWait(LOGOUT);
+ }
+
+ @BeforeMethod
+ public void beforeMethod()
+ {
+ initBrowser();
+ }
+
+ /**
+ * Wait for application (or it's part) to deploy. Separate Selenium browser
+ * instance is used to poll server for specified URL, waiting for specified
+ * element to appear.
+ */
+ public void waitForAppToDeploy(String url, String element)
+ {
+ int step = 5000;
+ int i = DEPLOY_TIMEOUT;
+
+ SeamSelenium browser = startBrowser();
+
+ browser.open(url);
+ try
+ {
+ while (!browser.isElementPresent(element))
+ {
+ i -= step;
+ if (i <= 0)
+ {
+ throw new RuntimeException("Timeout waiting for " + element + " at " + url);
+ }
+ Thread.sleep(step);
+ browser.open(url); // try again
+ }
+ }
+ catch (InterruptedException ie)
+ {
+ throw new RuntimeException(ie);
+ }
+ finally
+ {
+ browser.stop();
+ }
+ }
+
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/VehicleTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/VehicleTest.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/VehicleTest.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+/**
+ * This class tests CRUD on the Vehicle database table.
+ * @author Jozef Hartinger
+ *
+ */
+public class VehicleTest extends GenerateEntitiesTest
+{
+
+ public static final String SEARCH_REGISTRATION = "xpath=//input[matches(@id, 'vehicleSearch:.+:registration')]";
+ public static final String SEARCH_SUBMIT = "vehicleSearch:search";
+ public static final String SEARCH_RESET = "vehicleSearch:reset";
+
+ public static final String VIEW_REGISTRATION = "xpath=id('registration')/div/span[2]";
+ public static final String VIEW_STATE = "xpath=id('state')/div/span[2]";
+ public static final String VIEW_MAKE = "xpath=id('make')/div/span[2]";
+ public static final String VIEW_MODEL = "xpath=id('model')/div/span[2]";
+ public static final String VIEW_YEAR = "xpath=id('year')/div/span[2]";
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = { "newProjectGroup" })
+ public void newVehicleTest()
+ {
+ login();
+ String registration = "44444444";
+ String state = "SK";
+ String make = "Honda";
+ String model = "Civic";
+ String year = "2008";
+ createNewVehicle(registration, state, make, model, year);
+
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully created", "Unexpected confirmation message");
+
+ // search for the vehicle
+ browser.clickAndWait(ENTITY_DONE);
+ int result = search(registration);
+ assertEquals(result, 1, "Unexpected count of search results after creating new vehicle");
+ // verify view page
+ browser.clickAndWait(String.format(VEHICLE_LIST_VIEW_BUTTON_BY_REGISTRATION, registration));
+ verifyViewPage(registration, state, make, model, year);
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = { "newProjectGroup" }, dependsOnMethods = { "newVehicleTest" })
+ public void updateVehicleTest()
+ {
+ String registration = "11111111";
+ String state = "CZ";
+ String make = "Mazda";
+ String model = "6";
+ String year = "2005";
+
+ login();
+ browser.clickAndWait(VEHICLE_LINK);
+ String editButton = String.format(VEHICLE_LIST_EDIT_BUTTON_BY_REGISTRATION, registration);
+ browser.clickAndWait(editButton);
+ // update the entity
+ fillVehicleEditPage(registration, state, make, model, year);
+ browser.clickAndWait(VEHICLE_UPDATE);
+ // verify
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully updated", "Unexpected confirmation message");
+ verifyViewPage(registration, state, make, model, year);
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = { "newProjectGroup" })
+ public void removeVehicleTest()
+ {
+ String registration = "22222222";
+
+ login();
+ browser.clickAndWait(VEHICLE_LINK);
+ String editButton = String.format(VEHICLE_LIST_EDIT_BUTTON_BY_REGISTRATION, registration);
+ browser.clickAndWait(editButton);
+ // delete the person
+ browser.clickAndWait(VEHICLE_DELETE);
+
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully deleted", "Unexpected confirmation message");
+
+ // search for the user
+ int result = search(registration);
+ assertEquals(result, 0, "Unexpected count of search results after removing the user");
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = { "newProjectGroup" })
+ public void selectVehicleTest()
+ {
+
+ String username = "jharting";
+
+ login();
+ // create new vehicle
+ String registration = "33333333";
+ String state = "SK";
+ String make = "Mazda";
+ String model = "RX-8";
+ String year = "2008";
+ createNewVehicle(registration, state, make, model, year);
+ // select person
+ browser.clickAndWait(ENTITY_EDIT);
+ browser.clickAndWait(ENTITY_SELECT_PARENT_BUTTON);
+ browser.clickAndWait(String.format(PERSON_LIST_VIEW_BUTTON_BY_NAME, username));
+ browser.clickAndWait(VEHICLE_UPDATE);
+ // verify update is OK
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully updated", "Unexpected confirmation message");
+ browser.clickAndWait(ENTITY_DONE);
+ // search for vehicle
+ int result = search(registration);
+ assertEquals(result, 1, "Unexpected count of search results after assigning a vehicle owner");
+ // verify person is assigned to vehicle
+ assertTrue(browser.isElementPresent(String.format(VEHICLE_LIST_ROW_BY_OWNER_NAME, registration, username)), "Person not assigned to vehicle.");
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = { "newProjectGroup" })
+ public void searchTest()
+ {
+ final String searchString = "9999999"; // should return two Audis
+
+ login();
+ browser.clickAndWait(VEHICLE_LINK);
+ assertEquals(search(searchString), 2, "Unexpected number of search results for " + searchString);
+ }
+
+ public int search(String pattern)
+ {
+ browser.type(SEARCH_REGISTRATION, pattern);
+ browser.clickAndWait(SEARCH_SUBMIT);
+ return browser.getXpathCount(VEHICLE_LIST_RESULT_COUNT).intValue();
+ }
+
+ public void verifyViewPage(String registration, String state, String make, String model, String year)
+ {
+ assertEquals(browser.getText(VIEW_REGISTRATION), registration);
+ assertEquals(browser.getText(VIEW_STATE), state);
+ assertEquals(browser.getText(VIEW_MAKE), make);
+ assertEquals(browser.getText(VIEW_MODEL), model);
+ assertEquals(browser.getText(VIEW_YEAR), year);
+ }
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/generate-entities.sql
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/generate-entities.sql (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/generate-entities.sql 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,26 @@
+# This script is executed prior to "generate-entitiesTest" phase of a testsuite to feed the database with test data.
+#
+# by Jozef Hartinger
+#
+
+# drop itentity management tables from previous run
+DROP TABLE IF EXISTS user_account;
+DROP TABLE IF EXISTS user_account_role;
+DROP TABLE IF EXISTS user_permission;
+DROP TABLE IF EXISTS user_role;
+DROP TABLE IF EXISTS user_role_group;
+
+# empty testing tables
+DELETE FROM Vehicle;
+DELETE FROM Person;
+
+# Person table inserts
+INSERT INTO Person (username, name, birthdate, address) values ('johny', 'John Doe', '2009-01-01', 'test address'); # updatePersonTest
+INSERT INTO Person (username, name, birthdate, address) values ('jane', 'Jane Doe', '2009-01-01', 'test address'); # removePersonTest
+INSERT INTO Person (username, name, birthdate, address) values ('jharting', 'Jozef Hartinger', '1987-01-01', 'Purkynova 99, Brno'); # selectVehicleTest
+
+# Vehicle table inserts
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Honda', 'Civic', '2008', '11111111', 'CZ'); # updateVehicleTest
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Nissan', '350z', '2006', '22222222', 'CZ'); # removeVehicleTest
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Audi', 'A5', '2009', '99999991', 'CZ'); # searchTest
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Audi', 'A4', '2009', '99999992', 'CZ'); # searchTest
\ No newline at end of file
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,204 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen.utils;
+
+import java.io.File;
+import java.io.PrintStream;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DefaultLogger;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.input.InputHandler;
+import org.apache.tools.ant.input.InputRequest;
+
+/**
+ * This class wraps seam-gen ant script in order to be easily usable from Java.
+ * Methods of this class corespond to seam-gen targets. Note that deploy and
+ * undeploy methods are using explode variants of the targets if icefaces
+ * variable is set to true which it is by default.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class SeamGenAdapter
+{
+
+ private String buildfile;
+ private DefaultLogger log;
+ private boolean explode = true;
+
+ public SeamGenAdapter(String buildfile)
+ {
+ this(buildfile, System.out, System.err);
+ }
+
+ public SeamGenAdapter(String buildfile, PrintStream out, PrintStream err)
+ {
+ this.buildfile = buildfile;
+ log = new DefaultLogger();
+ log.setOutputPrintStream(out);
+ log.setErrorPrintStream(err);
+ log.setMessageOutputLevel(Project.MSG_INFO);
+ }
+
+ public Project getAntCall()
+ {
+ Project ant = new Project();
+ ant.init();
+ ProjectHelper.configureProject(ant, new File(buildfile));
+ // ant.addBuildListener(log);
+ return ant;
+ }
+
+ public void createProject()
+ {
+ getAntCall().executeTarget("create-project");
+ }
+
+ public void deleteProject()
+ {
+ getAntCall().executeTarget("delete-project");
+ }
+
+ public void newAction(String[] properties)
+ {
+ Project project = getAntCall();
+ project.setInputHandler(getInputHandler(properties));
+ project.executeTarget("new-action");
+ }
+
+ public void newForm(String[] properties)
+ {
+ Project project = getAntCall();
+ project.setInputHandler(getInputHandler(properties));
+ project.executeTarget("new-form");
+ }
+
+ public void generateEntities()
+ {
+ getAntCall().executeTarget("generate-entities");
+ }
+
+ /**
+ * Deploy the application. Using either explode or deploy target, depending
+ * on explode property.
+ */
+ public void deploy()
+ {
+ if (explode)
+ {
+ getAntCall().executeTarget("explode");
+ }
+ else
+ {
+ getAntCall().executeTarget("deploy");
+ }
+ }
+
+ /**
+ * Undeploy the application. Using either unexplode or undeploy target,
+ * depending on explode property.
+ */
+ public void undeploy()
+ {
+ if (explode)
+ {
+ getAntCall().executeTarget("unexplode");
+ }
+ else
+ {
+ getAntCall().executeTarget("undeploy");
+ }
+ }
+
+ public void hotDeploy()
+ {
+ if (explode)
+ {
+ getAntCall().executeTarget("explode");
+ }
+ else
+ {
+ throw new IllegalStateException("Unable to hot deploy non-exploded archive");
+ }
+ }
+
+ public void restart()
+ {
+ getAntCall().executeTarget("restart");
+ }
+
+ public void addIdentityManagement()
+ {
+ getAntCall().executeTarget("add-identity-management");
+ }
+
+ private InputHandler getInputHandler(final String[] properties)
+ {
+ return new InputHandler()
+ {
+ public void handleInput(InputRequest request) throws BuildException
+ {
+ if (request.getPrompt().contains("Enter the Seam component name"))
+ {
+ request.setInput(properties[0]);
+ }
+ else if (request.getPrompt().contains("Enter the local interface name"))
+ {
+ request.setInput(properties[1]);
+ }
+ else if (request.getPrompt().contains("Enter the bean class name"))
+ {
+ request.setInput(properties[2]);
+ }
+ else if (request.getPrompt().contains("Enter the action method name"))
+ {
+ request.setInput(properties[3]);
+ }
+ else if (request.getPrompt().contains("Enter the page name"))
+ {
+ request.setInput(properties[4]);
+ }
+ else
+ {
+ throw new RuntimeException("Unexpected prompt " + request.getPrompt());
+ }
+ }
+ };
+ }
+
+ public boolean isExplode()
+ {
+ return explode;
+ }
+
+ /**
+ * Set "deploy" or "explode" variant of deployment. "Explode" is used by
+ * default.
+ */
+ public void setExplode(boolean explode)
+ {
+ this.explode = explode;
+ }
+
+}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.test.functional.seamgen.utils;
+
+import org.jboss.seam.test.functional.seamgen.SeleniumSeamGenTest;
+import org.testng.ITestContext;
+import org.testng.ITestListener;
+import org.testng.ITestResult;
+
+/**
+ * Test listener. Captures screenshot and HTML source into the output directory
+ * if test fails. Furthermore, this class is responsible for stopping the
+ * browser instance after the test.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class SeleniumTestListener extends SeleniumSeamGenTest implements ITestListener
+{
+
+ public void onFinish(ITestContext arg0)
+ {
+ }
+
+ public void onStart(ITestContext arg0)
+ {
+ }
+
+ public void onTestFailedButWithinSuccessPercentage(ITestResult arg0)
+ {
+ }
+
+ public void onTestFailure(ITestResult arg0)
+ {
+ String logPath = OUTPUT_DIR + APP_NAME + "/" + arg0.getName();
+ browser.captureScreenshot(logPath + ".png");
+ browser.logHTMLContext(logPath + ".html");
+ stopBrowser();
+ }
+
+ public void onTestSkipped(ITestResult arg0)
+ {
+ stopBrowser();
+ }
+
+ public void onTestStart(ITestResult arg0)
+ {
+ }
+
+ public void onTestSuccess(ITestResult arg0)
+ {
+ stopBrowser();
+ }
+}
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java 2009-04-28 07:36:10 UTC (rev 10672)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java 2009-04-28 11:13:00 UTC (rev 10673)
@@ -21,7 +21,12 @@
*/
package org.jboss.seam.example.common.test.selenium;
+import java.io.BufferedWriter;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+
import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.Wait;
/**
* This class slightly enhaces a Selenium API for controlling a browser.
@@ -32,6 +37,11 @@
{
protected String timeout = "30000";
+ private boolean icefacesDetection = false;
+ private long icefacesWaitTime = 1000;
+
+ private final String ICEFACES_CONNECTION_STATUS = "xpath=//div[@class='iceOutConStat connectionStatus']";
+ private final String ICEFACES_IDLE_VISIBLE = "xpath=//div[@class='iceOutConStatInactv connectionStatusInactv'][@style='visibility: visible;']";
public SeamSelenium(String serverHost, int serverPort, String browserStartCommand, String browserURL)
{
@@ -49,11 +59,94 @@
* @param locator
*/
public void clickAndWait(String locator) {
- super.click(locator);
- super.waitForPageToLoad(timeout);
+ click(locator);
+ waitForPageToLoad();
}
+ public String getTimeout()
+ {
+ return timeout;
+ }
+ public void waitForPageToLoad()
+ {
+ waitForPageToLoad(timeout);
+ }
+ @Override
+ public void waitForPageToLoad(String timeout)
+ {
+ if (icefacesDetection && isElementPresent(ICEFACES_CONNECTION_STATUS))
+ {
+ waitForIcefaces(icefacesWaitTime, Long.valueOf(timeout));
+ }
+ else
+ {
+ super.waitForPageToLoad(timeout);
+ }
+ }
+
/**
+ * Switch icefaces detection on/off
+ *
+ * @param icefacesDetection
+ */
+ public void setIcefacesDetection(boolean icefacesDetection)
+ {
+ this.icefacesDetection = icefacesDetection;
+ }
+
+ /**
+ * This wait time will be used when waiting for response after invoking
+ * icefaces action
+ *
+ * @param icefacesWaitTime
+ */
+ public void setIcefacesWaitTime(long icefacesWaitTime)
+ {
+ this.icefacesWaitTime = icefacesWaitTime;
+ }
+
+ /**
+ * Captures a screenshot and stores it into a file. Active windows is
+ * maximized before capturing a screenshot.
+ */
+ @Override
+ public void captureScreenshot(String path)
+ {
+ windowMaximize();
+ super.captureScreenshot(path);
+ }
+ /**
+ * Logs HTML body into a file.
+ *
+ * @param path
+ */
+ public void logHTMLContext(String path)
+ {
+ String source = getHtmlSource();
+ BufferedWriter writer = null;
+ try
+ {
+ writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path)));
+ writer.write(source);
+ writer.flush();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to save HTML body", e);
+ }
+ finally
+ {
+ try
+ {
+ writer.close();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
+ /**
* Simulates a user pressing "back" button and waits for page to load. Default timeout can be changed by setTimeout() method.
*/
public void goBackAndWait() {
@@ -69,4 +162,32 @@
super.waitForPageToLoad(timeout);
}
+ private void waitForIcefaces(Long waitTime, Long timeout)
+ {
+ new Wait()
+ {
+ @Override
+ public boolean until()
+ {
+ return isElementPresent(ICEFACES_IDLE_VISIBLE);
+ }
+ }.wait("Timeout while waiting for icefaces idle state.", timeout);
+ try
+ {
+ Thread.sleep(icefacesWaitTime);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ new Wait()
+ {
+ @Override
+ public boolean until()
+ {
+ return isElementPresent("xpath=//body");
+ }
+ }.wait("Timeout while waiting for document body after icefaces click.", timeout);
+ }
+
}
15 years
Seam SVN: r10672 - in modules/trunk: international and 11 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-28 03:36:10 -0400 (Tue, 28 Apr 2009)
New Revision: 10672
Added:
modules/trunk/international/src/test/java/org/jboss/seam/international/InterpolatorTest.java
modules/trunk/international/src/test/java/org/jboss/seam/international/LocaleProducerTest.java
modules/trunk/international/src/test/java/org/jboss/seam/international/LocaleProducerUnitTest.java
modules/trunk/international/src/test/resources/
modules/trunk/international/src/test/resources/org/
modules/trunk/international/src/test/resources/org/jboss/
modules/trunk/international/src/test/resources/org/jboss/testharness/
modules/trunk/international/src/test/resources/org/jboss/testharness/impl/
modules/trunk/international/src/test/resources/org/jboss/testharness/impl/packaging/
modules/trunk/international/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/
modules/trunk/international/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/
modules/trunk/international/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
modules/trunk/international/src/test/resources/test-suite.xml
Modified:
modules/trunk/el/src/test/java/org/jboss/seam/el/SeamELResolverUnitTest.java
modules/trunk/international/pom.xml
modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java
modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java
Log:
add some tests for EL-related components
Modified: modules/trunk/el/src/test/java/org/jboss/seam/el/SeamELResolverUnitTest.java
===================================================================
--- modules/trunk/el/src/test/java/org/jboss/seam/el/SeamELResolverUnitTest.java 2009-04-28 06:19:42 UTC (rev 10671)
+++ modules/trunk/el/src/test/java/org/jboss/seam/el/SeamELResolverUnitTest.java 2009-04-28 07:36:10 UTC (rev 10672)
@@ -13,7 +13,7 @@
/**
* Verify that the magic properties are properly resolved
- * by the {@link SeamELResolver}.
+ * by the {@link SeamELResolver} on the base objects passed in.
*
* @author Dan Allen
* @see SeamELResolver
@@ -76,6 +76,7 @@
assertEquals(result, 3);
assertTrue(ctx.isPropertyResolved());
}
+
@Test
public void testMapBogusProperty()
Modified: modules/trunk/international/pom.xml
===================================================================
--- modules/trunk/international/pom.xml 2009-04-28 06:19:42 UTC (rev 10671)
+++ modules/trunk/international/pom.xml 2009-04-28 07:36:10 UTC (rev 10672)
@@ -14,31 +14,104 @@
<version>3.0.0-SNAPSHOT</version>
<name>Seam Internationalization Module</name>
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <suiteXmlFiles>
+ <suiteXmlFile>src/test/resources/test-suite.xml</suiteXmlFile>
+ </suiteXmlFiles>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
<dependencies>
+
+ <!-- TODO pull up test dependencies -->
<dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-core-test</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- we don't have a generic javax.ejb 3.1 api yet -->
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-api</artifactId>
+ <version>3.1.0-Alpha1</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>jboss-jaxrpc</artifactId>
+ <groupId>jbossws</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jboss-transaction-api</artifactId>
+ <groupId>org.jboss.javaee</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jboss-jaxrpc</artifactId>
+ <groupId>jboss.jbossws</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seam-el</artifactId>
</dependency>
+
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>jsr299-api</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>webbeans-logging</artifactId>
<!-- provided? -->
</dependency>
+
</dependencies>
</project>
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java 2009-04-28 06:19:42 UTC (rev 10671)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java 2009-04-28 07:36:10 UTC (rev 10672)
@@ -15,14 +15,13 @@
*
* @author Gavin King
*/
+public
@Dependent
-public class Interpolator
+class Interpolator
{
private static final LogProvider log = Logging.getLogProvider(Interpolator.class);
- // QUESTION should this be Manager, then lookup by type?
@Current Expressions expressions;
-
@Current Locale locale;
/**
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java 2009-04-28 06:19:42 UTC (rev 10671)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java 2009-04-28 07:36:10 UTC (rev 10672)
@@ -1,6 +1,6 @@
package org.jboss.seam.international;
-import javax.annotation.Named;
+import javax.context.Dependent;
import javax.inject.Produces;
/**
@@ -10,11 +10,13 @@
*
* @author Gavin King
*/
-public class LocaleProducer
+public
+@Dependent
+class LocaleProducer
{
public
@Produces
- @Named java.util.Locale getLocale()
+ java.util.Locale getLocale()
{
return java.util.Locale.getDefault();
}
Added: modules/trunk/international/src/test/java/org/jboss/seam/international/InterpolatorTest.java
===================================================================
--- modules/trunk/international/src/test/java/org/jboss/seam/international/InterpolatorTest.java (rev 0)
+++ modules/trunk/international/src/test/java/org/jboss/seam/international/InterpolatorTest.java 2009-04-28 07:36:10 UTC (rev 10672)
@@ -0,0 +1,120 @@
+package org.jboss.seam.international;
+
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import javax.el.CompositeELResolver;
+import javax.el.ELContext;
+import org.jboss.seam.el.AbstractELResolver;
+import static org.testng.Assert.*;
+
+import org.jboss.seam.el.Expressions;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.webbeans.test.AbstractWebBeansTest;
+import org.testng.annotations.Test;
+
+/**
+ * Verify that the {@link Interpolator} properly resolves both EL value
+ * expressions and positional substitutions, while also honoring the
+ * {@link Locale} returns by the {@link LocalProducer}.
+ *
+ * @author Dan Allen
+ * @see Interpolator
+ * @see Expressions
+ * @see LocaleProducer
+ */
+@Artifact(addCurrentPackage = false)
+(a)Classes({Interpolator.class, Expressions.class, LocaleProducer.class})
+public class InterpolatorTest extends AbstractWebBeansTest
+{
+ @Override
+ public void beforeMethod()
+ {
+ super.beforeMethod();
+ installTestFixtureELResolver();
+ }
+
+ @Test
+ public void testValueExpressionInterpolation()
+ {
+ String result = getInterpolatorInstance().interpolate("Hey #{name}!");
+ assertEquals(result, "Hey Dan!");
+ }
+
+ @Test
+ public void testParameterSubstitution()
+ {
+ String result = getInterpolatorInstance().interpolate("The two planets between the Earth and the Sun are {0} and {1}.", "Mercury", "Venus");
+ assertEquals(result, "The two planets between the Earth and the Sun are Mercury and Venus.");
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testInterpolateExceedsMaxParameters()
+ {
+ getInterpolatorInstance().interpolate("doesn't matter", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11");
+ }
+
+ @Test
+ public void testMultipleValueExpressionsAndParameters()
+ {
+ String result = getInterpolatorInstance().interpolate("#{name}, meet {0}. {0}, meet #{name}. Everyone, meet {1}.", "Pete", "Gavin");
+ assertEquals(result, "Dan, meet Pete. Pete, meet Dan. Everyone, meet Gavin.");
+ }
+
+ @Test
+ public void testFormatWithProperLocale()
+ {
+ Locale current = Locale.getDefault();
+ try {
+ Calendar cal = Calendar.getInstance();
+ cal.set(2009, 5, 2);
+ Locale.setDefault(Locale.US);
+ String result = getInterpolatorInstance().interpolate("On {0,date} there was a disturbance in Java EE.", cal.getTime());
+ assertEquals(result, "On Jun 2, 2009 there was a disturbance in Java EE.");
+
+ Locale.setDefault(Locale.FRANCE);
+ result = getInterpolatorInstance().interpolate("On {0,date} there was a disturbance in Java EE.", cal.getTime());
+ assertEquals(result, "On 2 juin 2009 there was a disturbance in Java EE.");
+ }
+ finally {
+ Locale.setDefault(current);
+ }
+ }
+
+ private Interpolator getInterpolatorInstance() {
+ return getCurrentManager().getInstanceByType(Interpolator.class);
+ }
+
+ private void installTestFixtureELResolver()
+ {
+ Map<Object, Object> fixture = new HashMap<Object, Object>();
+ fixture.put("name", "Dan");
+ Expressions expressions = getCurrentManager().getInstanceByType(Expressions.class);
+ // FIXME wow this is a hack
+ ((CompositeELResolver) expressions.getELContext().getELResolver()).add(new TestFixtureELResolver(fixture));
+ }
+
+ public class TestFixtureELResolver extends AbstractELResolver
+ {
+ private Map<Object, Object> data;
+
+ public TestFixtureELResolver(Map<Object, Object> data)
+ {
+ this.data = data;
+ }
+
+ @Override
+ public Object getValue(ELContext context, Object base, Object property)
+ {
+ if (base == null && data.containsKey(property))
+ {
+ context.setPropertyResolved(true);
+ return data.get(property);
+ }
+
+ return null;
+ }
+ }
+}
Added: modules/trunk/international/src/test/java/org/jboss/seam/international/LocaleProducerTest.java
===================================================================
--- modules/trunk/international/src/test/java/org/jboss/seam/international/LocaleProducerTest.java (rev 0)
+++ modules/trunk/international/src/test/java/org/jboss/seam/international/LocaleProducerTest.java 2009-04-28 07:36:10 UTC (rev 10672)
@@ -0,0 +1,27 @@
+package org.jboss.seam.international;
+
+import static org.testng.Assert.*;
+
+import java.util.Locale;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.webbeans.test.AbstractWebBeansTest;
+import org.testng.annotations.Test;
+
+/**
+ * Ensure that the {@link LocaleProducer} returns the
+ * default locale when the type {@link Locale} is resolved.
+ *
+ * @author Dan Allen
+ */
+@Artifact(addCurrentPackage = false)
+(a)Classes(LocaleProducer.class)
+public class LocaleProducerTest extends AbstractWebBeansTest
+{
+ @Test
+ public void testDefaultIsJvmDefault()
+ {
+ Locale result = getCurrentManager().getInstanceByType(Locale.class);
+ assertEquals(result.toString(), Locale.getDefault().toString());
+ }
+}
Added: modules/trunk/international/src/test/java/org/jboss/seam/international/LocaleProducerUnitTest.java
===================================================================
--- modules/trunk/international/src/test/java/org/jboss/seam/international/LocaleProducerUnitTest.java (rev 0)
+++ modules/trunk/international/src/test/java/org/jboss/seam/international/LocaleProducerUnitTest.java 2009-04-28 07:36:10 UTC (rev 10672)
@@ -0,0 +1,23 @@
+package org.jboss.seam.international;
+
+import java.util.Locale;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ * Verify that the default {@link LocalProducer} returns the
+ * default locale of the JVM.
+ *
+ * @author Dan Allen
+ */
+public class LocaleProducerUnitTest
+{
+ @Test
+ public void testLocaleIsJvmDefault()
+ {
+ LocaleProducer producer = new LocaleProducer();
+ Locale result = producer.getLocale();
+ assertNotNull(result);
+ assertEquals(result.toString(), Locale.getDefault().toString());
+ }
+}
Added: modules/trunk/international/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
===================================================================
Added: modules/trunk/international/src/test/resources/test-suite.xml
===================================================================
--- modules/trunk/international/src/test/resources/test-suite.xml (rev 0)
+++ modules/trunk/international/src/test/resources/test-suite.xml 2009-04-28 07:36:10 UTC (rev 10672)
@@ -0,0 +1,15 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="Seam International Module Unit Tests" verbose="1">
+ <test name="Seam International 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.international"/>
+ </packages>
+ </test>
+</suite>
15 years
Seam SVN: r10670 - in modules/trunk/faces: src/main/java/org/jboss/seam/faces and 1 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-04-28 02:14:13 -0400 (Tue, 28 Apr 2009)
New Revision: 10670
Added:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/
modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/Converter.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/Validator.java
Modified:
modules/trunk/faces/pom.xml
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesMessages.java
Log:
add faces annotations
Modified: modules/trunk/faces/pom.xml
===================================================================
--- modules/trunk/faces/pom.xml 2009-04-28 06:08:43 UTC (rev 10669)
+++ modules/trunk/faces/pom.xml 2009-04-28 06:14:13 UTC (rev 10670)
@@ -42,7 +42,11 @@
<groupId>org.jboss.webbeans</groupId>
<artifactId>jsr299-api</artifactId>
<scope>provided</scope>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-logging</artifactId>
+ </dependency>
</dependencies>
</project>
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesMessages.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesMessages.java 2009-04-28 06:08:43 UTC (rev 10669)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesMessages.java 2009-04-28 06:14:13 UTC (rev 10670)
@@ -1,9 +1,11 @@
package org.jboss.seam.faces;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import javax.context.ConversationScoped;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -18,6 +20,7 @@
* @author Gavin King
* @author Pete Muir
*/
+@ConversationScoped
public class FacesMessages extends StatusMessages
{
/**
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/Converter.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/Converter.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/Converter.java 2009-04-28 06:14:13 UTC (rev 10670)
@@ -0,0 +1,32 @@
+package org.jboss.seam.faces.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Allows a Seam component to act as a JSF converter. The
+ * annotated class must be a Seam component, and must
+ * implement javax.faces.convert.Converter.
+ *
+ * @author Gavin King
+ *
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+@Documented
+public @interface Converter
+{
+ /**
+ * The JSF converter id. Default to the component name.
+ */
+ String id() default "";
+ /**
+ * If specified, register this component as the default
+ * converter for a type.
+ */
+ Class forClass() default void.class;
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/Validator.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/Validator.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/Validator.java 2009-04-28 06:14:13 UTC (rev 10670)
@@ -0,0 +1,27 @@
+package org.jboss.seam.faces.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Allows a Seam component to act as a JSF validator. The
+ * annotated class must be a Seam component, and must
+ * implement javax.faces.validator.Validator.
+ *
+ * @author Gavin King
+ *
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+@Documented
+public @interface Validator
+{
+ /**
+ * The JSF validator id. Default to the component name.
+ */
+ String id() default "";
+}
15 years
Seam SVN: r10669 - modules/trunk/version-matrix.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-04-28 02:08:43 -0400 (Tue, 28 Apr 2009)
New Revision: 10669
Modified:
modules/trunk/version-matrix/pom.xml
Log:
added more seam modules
Modified: modules/trunk/version-matrix/pom.xml
===================================================================
--- modules/trunk/version-matrix/pom.xml 2009-04-28 06:04:29 UTC (rev 10668)
+++ modules/trunk/version-matrix/pom.xml 2009-04-28 06:08:43 UTC (rev 10669)
@@ -197,12 +197,30 @@
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>seam-faces</artifactId>
+ <version>${seam.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>seam-el</artifactId>
<version>${seam.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>seam-drools</artifactId>
+ <version>${seam.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>seam-persistence</artifactId>
+ <version>${seam.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>seam-international</artifactId>
<version>${seam.version}</version>
</dependency>
15 years
Seam SVN: r10668 - in modules/trunk: el/src and 25 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-28 02:04:29 -0400 (Tue, 28 Apr 2009)
New Revision: 10668
Added:
modules/trunk/el/src/main/java/org/jboss/seam/el/AbstractELResolver.java
modules/trunk/el/src/main/java/org/jboss/seam/el/SeamEL.java
modules/trunk/el/src/test/
modules/trunk/el/src/test/java/
modules/trunk/el/src/test/java/org/
modules/trunk/el/src/test/java/org/jboss/
modules/trunk/el/src/test/java/org/jboss/seam/
modules/trunk/el/src/test/java/org/jboss/seam/el/
modules/trunk/el/src/test/java/org/jboss/seam/el/SeamELResolverUnitTest.java
modules/trunk/el/src/test/resources/
modules/trunk/el/src/test/resources/test-suite.xml
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesResourceLoader.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/
modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/LocaleConfig.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamApplication.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamApplicationFactory.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/el/
modules/trunk/faces/src/main/java/org/jboss/seam/faces/el/SeamFacesELResolver.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/StatusMessagesTranslator.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/
modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/ArrayDataModel.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/ListDataModel.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/MapDataModel.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/SetDataModel.java
modules/trunk/faces/src/main/resources/
modules/trunk/faces/src/main/resources/META-INF/
modules/trunk/faces/src/main/resources/META-INF/faces-config.xml
modules/trunk/international/src/main/java/org/jboss/seam/core/
modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java
modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java
modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceBundle.java
modules/trunk/international/src/test/java/org/
modules/trunk/international/src/test/java/org/jboss/
modules/trunk/international/src/test/java/org/jboss/seam/
modules/trunk/international/src/test/java/org/jboss/seam/international/
Removed:
modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java
modules/trunk/el/src/main/java/org/jboss/seam/el/Interpolator.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/DateConverter.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesManager.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesPage.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/HttpError.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/IsUserInRole.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/Navigator.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/Parameters.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/Redirect.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/Renderer.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/ResourceLoader.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/Selector.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/Switcher.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/UiComponent.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/UserPrincipal.java
modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleConfig.java
modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleSelector.java
modules/trunk/international/src/main/java/org/jboss/seam/international/SeamResourceBundle.java
modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZoneSelector.java
Modified:
modules/trunk/el/pom.xml
modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java
modules/trunk/el/src/main/java/org/jboss/seam/el/JBossELReferenceCache.java
modules/trunk/el/src/main/java/org/jboss/seam/el/SeamELResolver.java
modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java
modules/trunk/el/src/main/java/org/jboss/seam/el/SeamFunctionMapper.java
modules/trunk/faces/pom.xml
modules/trunk/faces/src/main/java/org/jboss/seam/faces/DataModels.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesExpressions.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesMessages.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/Validation.java
modules/trunk/international/pom.xml
modules/trunk/international/src/main/java/org/jboss/seam/international/Messages.java
modules/trunk/international/src/main/java/org/jboss/seam/international/MessagesProducer.java
modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceLoader.java
modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessage.java
modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java
modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZonesProducer.java
modules/trunk/parent/pom.xml
Log:
bring the el, international, and faces modules to a compilable state
several components had to be disabled to achieve, but they will be reintroduced as needed
Modified: modules/trunk/el/pom.xml
===================================================================
--- modules/trunk/el/pom.xml 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/el/pom.xml 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,35 +1,61 @@
-<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>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>seam-parent</artifactId>
- <groupId>org.jboss.seam</groupId>
+ <groupId>org.jboss.seam</groupId>
<version>3.0.0-SNAPSHOT</version>
- </parent>
-
+ </parent>
+
<artifactId>seam-el</artifactId>
<packaging>jar</packaging>
<version>3.0.0-SNAPSHOT</version>
- <name>Seam EL</name>
-
+ <name>Seam EL Module</name>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <suiteXmlFiles>
+ <suiteXmlFile>src/test/resources/test-suite.xml</suiteXmlFile>
+ </suiteXmlFiles>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
<dependencies>
+ <!-- TODO pull up -->
<dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ </dependency>
+ <dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
- </dependency>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.jboss.el</groupId>
<artifactId>jboss-el</artifactId>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>jsr299-api</artifactId>
- </dependency>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>webbeans-logging</artifactId>
+ <!-- provided? -->
</dependency>
</dependencies>
Added: modules/trunk/el/src/main/java/org/jboss/seam/el/AbstractELResolver.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/AbstractELResolver.java (rev 0)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/AbstractELResolver.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.el;
+
+import java.util.Iterator;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+
+/**
+ * <p>An abstract {@link ELResolver} that provides default implementations for
+ * the methods which most implementations never care to override.</p>
+ *
+ * <p>The read operations mostly return <code>null</code> and the write
+ * operation performs no action. Subclasses are expected to provide an
+ * implementation for {@link ELResolver#getValue(javax.el.ELContext,
+ * java.lang.Object, java.lang.Object)}, the only really interesting method.
+ *
+ * @author Dan Allen
+ */
+public abstract class AbstractELResolver extends ELResolver {
+
+ /**
+ * A default implementation that returns <code>null</code> unconditionally.
+ *
+ * @see ELResolver#getCommonPropertyType(javax.el.ELContext, java.lang.Object)
+ */
+ @Override
+ public Class getCommonPropertyType(ELContext context, Object base)
+ {
+ return null;
+ }
+
+ /**
+ * A default implementation that returns <code>null</code> unconditionally.
+ *
+ * @see ELResolver#getFeatureDescriptors(javax.el.ELContext, java.lang.Object)
+ */
+ @Override
+ public Iterator getFeatureDescriptors(ELContext context, Object base)
+ {
+ return null;
+ }
+
+ /**
+ * A default implementation that returns <code>null</code> unconditionally.
+ *
+ * @see ELResolver#getType(javax.el.ELContext, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public Class getType(ELContext context, Object base, Object property)
+ {
+ return null;
+ }
+
+ /**
+ * A default implementation that returns <code>false</code> unconditionally.
+ *
+ * @see ELResolver#isReadOnly(javax.el.ELContext, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ {
+ return false;
+ }
+
+ /**
+ * A default implementation that performs no operation.
+ *
+ * @see ELResolver#setValue(javax.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void setValue(ELContext context, Object base, Object property, Object value)
+ {
+ }
+
+}
Deleted: modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,147 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Id$
- */
-package org.jboss.seam.el;
-
-import java.util.Locale;
-
-import javax.el.ArrayELResolver;
-import javax.el.BeanELResolver;
-import javax.el.CompositeELResolver;
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.el.ExpressionFactory;
-import javax.el.FunctionMapper;
-import javax.el.ListELResolver;
-import javax.el.MapELResolver;
-import javax.el.ResourceBundleELResolver;
-import javax.el.VariableMapper;
-
-import org.jboss.el.ExpressionFactoryImpl;
-import org.jboss.el.lang.FunctionMapperImpl;
-import org.jboss.el.lang.VariableMapperImpl;
-
-/**
- * An instance of JBoss EL.
- *
- * @author Gavin King
- */
-public class EL
-{
- public static final ELResolver EL_RESOLVER = createELResolver();
- public static final ExpressionFactory EXPRESSION_FACTORY = new ExpressionFactoryImpl();
-
- private static ELResolver createELResolver()
- {
- CompositeELResolver resolver = new CompositeELResolver();
- resolver.add(new MapELResolver());
- resolver.add(new ListELResolver());
- resolver.add(new ArrayELResolver());
- resolver.add(new ResourceBundleELResolver());
- resolver.add(new BeanELResolver());
- return resolver;
- }
-
- public static ELContext createELContext()
- {
- return createELContext(EL_RESOLVER, new FunctionMapperImpl());
- }
-
- public static ELContext createELContext(final ELResolver resolver, final FunctionMapper functionMapper)
- {
- return new ELContext()
- {
- final VariableMapperImpl variableMapper = new VariableMapperImpl();
-
- @Override
- public ELResolver getELResolver()
- {
- return resolver;
- }
-
- @Override
- public FunctionMapper getFunctionMapper()
- {
- return functionMapper;
- }
-
- @Override
- public VariableMapper getVariableMapper()
- {
- return variableMapper;
- }
- };
- }
-
- public static ELContext createELContext(final ELContext context, final ELResolver resolver)
- {
- return new ELContext()
- {
- @Override
- public Locale getLocale()
- {
- return context.getLocale();
- }
-
- @Override
- public void setPropertyResolved(boolean value)
- {
- super.setPropertyResolved(value);
- context.setPropertyResolved(value);
- }
-
- @Override
- public void putContext(Class clazz, Object object)
- {
- super.putContext(clazz, object);
- context.putContext(clazz, object);
- }
-
- @Override
- public Object getContext(Class clazz)
- {
- return context.getContext(clazz);
- }
-
- @Override
- public void setLocale(Locale locale)
- {
- super.setLocale(locale);
- context.setLocale(locale);
- }
-
- @Override
- public ELResolver getELResolver()
- {
- return resolver;
- }
-
- @Override
- public FunctionMapper getFunctionMapper()
- {
- return context.getFunctionMapper();
- }
-
- @Override
- public VariableMapper getVariableMapper()
- {
- return context.getVariableMapper();
- }
- };
- }
-}
Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,3 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
package org.jboss.seam.el;
import java.io.Serializable;
@@ -6,9 +29,6 @@
import javax.el.ELContext;
import javax.el.ExpressionFactory;
-import org.jboss.seam.el.EL;
-import org.jboss.seam.el.SeamExpressionFactory;
-
/**
* Factory for EL method and value expressions.
*
@@ -34,7 +54,7 @@
* use JSF's ELContext. Otherwise, use one that we create.
*/
public ELContext getELContext() {
- return EL.createELContext();
+ return SeamEL.createELContext();
}
/**
Deleted: modules/trunk/el/src/main/java/org/jboss/seam/el/Interpolator.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/Interpolator.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/Interpolator.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,171 +0,0 @@
-package org.jboss.seam.el;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.StringTokenizer;
-
-import javax.context.Dependent;
-import javax.inject.Current;
-
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-
-/**
- * Interpolates EL expressions in Strings
- *
- * @author Gavin King
- */
-@Dependent
-public class Interpolator
-{
- private static final LogProvider log = Logging.getLogProvider(Interpolator.class);
-
- @Current Expressions expressions;
- @Current Locale locale;
-
- /**
- * Replace all EL expressions in the form #{...} with their evaluated values.
- *
- * @param string
- * a template
- * @return the interpolated string
- */
- public String interpolate(String string, Object... params)
- {
- if (params == null)
- {
- params = new Object[0];
- }
-
- if (params.length > 10)
- {
- throw new IllegalArgumentException("more than 10 parameters");
- }
-
- if (string.indexOf('#') >= 0 || string.indexOf('{') >= 0)
- {
- string = interpolateExpressions(string, params);
- }
-
- return string;
- }
-
- private String interpolateExpressions(String string, Object... params)
- {
- StringTokenizer tokens = new StringTokenizer(string, "#{}", true);
- StringBuilder builder = new StringBuilder(string.length());
- try
- {
- while (tokens.hasMoreTokens())
- {
- String tok = tokens.nextToken();
-
- if ("#".equals(tok) && tokens.hasMoreTokens())
- {
- String nextTok = tokens.nextToken();
-
- while (nextTok.equals("#") && tokens.hasMoreTokens())
- {
- builder.append(tok);
- nextTok = tokens.nextToken();
- }
-
- if ("{".equals(nextTok))
- {
- String expression = "#{" + tokens.nextToken() + "}";
- try
- {
- Object value = expressions.createValueExpression(expression).getValue();
- if (value != null)
- builder.append(value);
- } catch (Exception e)
- {
- log.warn("exception interpolating string: " + string, e);
- }
- tokens.nextToken(); // the trailing "}"
-
- } else if (nextTok.equals("#"))
- {
- // could be trailing #
- builder.append("#");
-
- } else
- {
- int index;
- try
- {
- index = Integer.parseInt(nextTok.substring(0, 1));
- if (index >= params.length)
- {
- // log.warn("parameter index out of bounds: " + index +
- // " in: " + string);
- builder.append("#").append(nextTok);
- } else
- {
- builder.append(params[index]).append(
- nextTok.substring(1));
- }
- } catch (NumberFormatException nfe)
- {
- builder.append("#").append(nextTok);
- }
- }
- } else if ("{".equals(tok))
- {
- StringBuilder expr = new StringBuilder();
-
- expr.append(tok);
- int level = 1;
-
- while (tokens.hasMoreTokens())
- {
- String nextTok = tokens.nextToken();
- expr.append(nextTok);
-
- if (nextTok.equals("{"))
- {
- ++level;
- } else if (nextTok.equals("}"))
- {
- if (--level == 0)
- {
- try
- {
- if (params.length == 0)
- {
- builder.append(expr.toString());
- } else
- {
- String value = new MessageFormat(expr.toString(),
- locale).format(params);
- builder.append(value);
- }
- } catch (Exception e)
- {
- // if it is a bad message, use the expression itself
- builder.append(expr);
- }
- expr = null;
- break;
- }
- }
- }
-
- if (expr != null)
- {
- builder.append(expr);
- }
- } else
- {
- builder.append(tok);
- }
- }
- } catch (Exception e)
- {
- log.warn("exception interpolating string: " + string, e);
- }
-
- return builder.toString();
- }
-
-}
Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/JBossELReferenceCache.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/JBossELReferenceCache.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/JBossELReferenceCache.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,3 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
package org.jboss.seam.el;
import javax.annotation.PreDestroy;
Copied: modules/trunk/el/src/main/java/org/jboss/seam/el/SeamEL.java (from rev 10658, modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java)
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/SeamEL.java (rev 0)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/SeamEL.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.el;
+
+import java.util.Locale;
+
+import javax.el.ArrayELResolver;
+import javax.el.BeanELResolver;
+import javax.el.CompositeELResolver;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.FunctionMapper;
+import javax.el.ListELResolver;
+import javax.el.MapELResolver;
+import javax.el.ResourceBundleELResolver;
+import javax.el.VariableMapper;
+
+import org.jboss.el.ExpressionFactoryImpl;
+import org.jboss.el.lang.FunctionMapperImpl;
+import org.jboss.el.lang.VariableMapperImpl;
+
+/**
+ * An instance of JBoss EL.
+ *
+ * @author Gavin King
+ */
+public class SeamEL
+{
+ public static final ELResolver EL_RESOLVER = createELResolver();
+ public static final ExpressionFactory EXPRESSION_FACTORY = new ExpressionFactoryImpl();
+
+ private static ELResolver createELResolver()
+ {
+ // I believe this resolver is for use in standalone (not JSF doing the resolving)
+ CompositeELResolver resolver = new CompositeELResolver();
+ resolver.add(new SeamELResolver());
+ resolver.add(new MapELResolver());
+ resolver.add(new ListELResolver());
+ resolver.add(new ArrayELResolver());
+ resolver.add(new ResourceBundleELResolver());
+ resolver.add(new BeanELResolver());
+ return resolver;
+ }
+
+ public static ELContext createELContext()
+ {
+ return createELContext(EL_RESOLVER);
+ }
+
+ public static ELContext createELContext(final ELResolver resolver)
+ {
+ return createELContext(resolver, new FunctionMapperImpl(), new VariableMapperImpl());
+ }
+
+ public static ELContext createELContext(final ELResolver resolver, final FunctionMapper functionMapper, final VariableMapper variableMapper)
+ {
+ return new ELContext()
+ {
+ @Override
+ public ELResolver getELResolver()
+ {
+ return resolver;
+ }
+
+ @Override
+ public FunctionMapper getFunctionMapper()
+ {
+ return functionMapper;
+ }
+
+ @Override
+ public VariableMapper getVariableMapper()
+ {
+ return variableMapper;
+ }
+ };
+ }
+
+ public static ELContext createELContext(final ELContext context, final ELResolver resolver)
+ {
+ return new ELContext()
+ {
+ @Override
+ public Locale getLocale()
+ {
+ return context.getLocale();
+ }
+
+ @Override
+ public void setPropertyResolved(boolean value)
+ {
+ super.setPropertyResolved(value);
+ context.setPropertyResolved(value);
+ }
+
+ @Override
+ public void putContext(Class clazz, Object object)
+ {
+ super.putContext(clazz, object);
+ context.putContext(clazz, object);
+ }
+
+ @Override
+ public Object getContext(Class clazz)
+ {
+ return context.getContext(clazz);
+ }
+
+ @Override
+ public void setLocale(Locale locale)
+ {
+ super.setLocale(locale);
+ context.setLocale(locale);
+ }
+
+ @Override
+ public ELResolver getELResolver()
+ {
+ return resolver;
+ }
+
+ @Override
+ public FunctionMapper getFunctionMapper()
+ {
+ return context.getFunctionMapper();
+ }
+
+ @Override
+ public VariableMapper getVariableMapper()
+ {
+ return context.getVariableMapper();
+ }
+ };
+ }
+}
Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/SeamELResolver.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/SeamELResolver.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/SeamELResolver.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,189 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
package org.jboss.seam.el;
-import org.jboss.seam.util.JSF;
-
import java.util.Collection;
-import java.util.Iterator;
import java.util.Map;
import javax.el.ELContext;
-import javax.el.ELResolver;
-import org.jboss.seam.Namespace;
-import org.jboss.seam.contexts.Context;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.core.Init;
-
/**
- * Resolves Seam components and namespaces. Also
- * allows the use of #{dataModel.size}, #{dataModel.empty},
- * #{collection.size}, #{map.size}, #{map.values}, #{map.keySet},
- * and #{map.entrySet}. Also allows #{sessionContext['name']}.
- *
- * @author Gavin King
+ * <p>An {@link ELResolver} implementation that adds magic properties
+ * to collections and maps and (pending) supports resolving objects in Java EE
+ * contexts.</p>
*
+ * <p>The following is a list of the magic properties add to a collection:</p>
+ *
+ * <ul>
+ * <li>size - the size of the collection</li>
+ * </ul>
+ *
+ * <p>The following is a list of the magic properties add to a map:</p>
+ *
+ * <ul>
+ * <li>size - the size of the map</li>
+ * <li>values - a collection of the map values</li>
+ * <li>keySet - a set of the map keys</li>
+ * <li>entrySet - a set of the map entries (key and value)</li>
+ * </ul>
+ *
+ * <p>Assuming the variable <code>results</code> held a reference to a collection
+ * you could print out its size using the following expression:</p>
+ *
+ * <pre>#{results.size}</pre>
+ *
+ * @author Gavin King
+ * @author Dan Allen
*/
-public class SeamELResolver extends ELResolver
+public class SeamELResolver extends AbstractELResolver
{
-
@Override
- public Class getCommonPropertyType(ELContext context, Object base)
+ public Object getValue(ELContext context, Object base, Object property)
{
- return null;
- }
+ if (base instanceof Collection)
+ {
+ return resolveInCollection(context, (Collection) base, property);
+ }
+ else if (base instanceof Map)
+ {
+ return resolveInMap(context, (Map) base, property);
+ }
+// update JavaDoc after enabling
+// else if (base instanceof Context)
+// {
+// return resolveInContextObject(context, (Context) base, property);
+//
+// }
- @Override
- public Iterator getFeatureDescriptors(ELContext context, Object base)
- {
return null;
}
- @Override
- public Class getType(ELContext context, Object base, Object property)
+ /*
+ private Object resolveInContextObject(ELContext context, Context seamContext, Object property)
{
- return null;
- }
+ if (seamContext.isSet((String) property))
+ {
+ context.setPropertyResolved(true);
+ return seamContext.get((String) property);
+ }
+ else
+ {
+ return null;
+ }
+ }*/
- @Override
- public Object getValue(ELContext context, Object base, Object property)
+ private Object resolveInMap(ELContext context, Map map, Object property)
{
- if (base == null) {
- return resolveBase(context, property);
-
- } else if (base instanceof Namespace) {
- return resolveInNamespace(context, (Namespace) base, property);
-
- } else if (JSF.DATA_MODEL.isInstance(base)) {
- return resolveInDataModel(context, base, property);
-
- } else if (base instanceof Collection) {
- return resolveInCollection(context, (Collection) base, property);
-
- } else if (base instanceof Map) {
- return resolveInMap(context, (Map) base, property);
-
- } else if (base instanceof Context) {
- return resolveInContextObject(context, (Context) base, property);
-
- } else {
+ try
+ {
+ if (map.containsKey(property))
+ {
return null;
- }
- }
+ }
+ }
+ catch (UnsupportedOperationException e)
+ {
+ // eat it
+ }
- private Object resolveInContextObject(ELContext context, Context seamContext, Object property)
- {
- if (seamContext.isSet((String) property)) {
- context.setPropertyResolved(true);
- return seamContext.get((String) property);
- } else {
- return null;
- }
- }
+ if ("size".equals(property))
+ {
+ context.setPropertyResolved(true);
+ return map.size();
+ }
+ else if ("values".equals(property))
+ {
+ context.setPropertyResolved(true);
+ return map.values();
+ }
+ else if ("keySet".equals(property))
+ {
+ context.setPropertyResolved(true);
+ return map.keySet();
+ }
+ else if ("entrySet".equals(property))
+ {
+ context.setPropertyResolved(true);
+ return map.entrySet();
+ }
+ else
+ {
+ return null;
+ }
+ }
- private Object resolveInMap(ELContext context, Map map, Object property) {
- try {
- if (map.containsKey(property)) {
- return null;
- }
- } catch (UnsupportedOperationException e) {
- // eat it
- }
-
- if ("size".equals(property)) {
- context.setPropertyResolved(true);
- return map.size();
-
- } else if ("values".equals(property)) {
- context.setPropertyResolved(true);
- return map.values();
-
- } else if ("keySet".equals(property)) {
- context.setPropertyResolved(true);
- return map.keySet();
-
- } else if ("entrySet".equals(property)) {
- context.setPropertyResolved(true);
- return map.entrySet();
-
- } else {
- return null;
- }
- }
-
private Object resolveInCollection(ELContext context, Collection collection, Object property)
{
- if ("size".equals(property)) {
- context.setPropertyResolved(true);
- return collection.size();
- } else {
- return null;
- }
- }
+ if ("size".equals(property))
+ {
+ context.setPropertyResolved(true);
+ return collection.size();
+ }
+ else
+ {
+ return null;
+ }
+ }
- private Object resolveInDataModel(ELContext context, Object base, Object property)
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property)
{
- if ("size".equals(property)) {
- context.setPropertyResolved(true);
- return JSF.getRowCount(base);
- } else if ("empty".equals(property)) {
- context.setPropertyResolved(true);
- return JSF.getRowCount(base) == 0;
- } else {
- return null;
- }
- }
-
- private Object resolveBase(ELContext context, Object property)
- {
- if (!Contexts.isApplicationContextActive()) {
- // if no Seam contexts, bypass straight through to JSF
- return null;
- }
-
- String key = (String) property;
- Init init = Init.instance();
-
- // look for a component in the root namespace
- Object result = init.getRootNamespace().getComponentInstance(key);
- if (result != null) {
- context.setPropertyResolved(true);
- return result;
- } else {
- // look for a component in the imported namespaces
- for (Namespace ns : init.getGlobalImports()) {
- result = ns.getComponentInstance(key);
- if (result != null) {
- context.setPropertyResolved(true);
- return result;
- }
- }
- }
-
- // look for a namespace
- Namespace namespace = init.getRootNamespace().getChild(key);
- if (namespace != null) {
- context.setPropertyResolved(true);
- }
- return namespace;
- }
-
- private Object resolveInNamespace(ELContext context, Namespace namespace, Object property) {
- Object result = namespace.get((String) property);
- // JBSEAM-3077 if the result is null, it means that there is no component instance bound to this qualified name
- context.setPropertyResolved(true);
- return result;
- }
-
- @Override
- public boolean isReadOnly(ELContext context, Object base, Object property)
- {
- return base != null
- && (JSF.DATA_MODEL.isInstance(base) || (base instanceof Collection) || (base instanceof Map));
- }
-
- @Override
- public void setValue(ELContext context, Object base, Object property, Object value)
- {
- }
-
+ return base instanceof Collection || base instanceof Map;
+ }
}
Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -4,16 +4,21 @@
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
*
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
* $Id$
*/
package org.jboss.seam.el;
@@ -30,7 +35,7 @@
*/
public class SeamExpressionFactory extends ExpressionFactory
{
- public static final ExpressionFactory INSTANCE = new SeamExpressionFactory(EL.EXPRESSION_FACTORY);
+ public static final ExpressionFactory INSTANCE = new SeamExpressionFactory(SeamEL.EXPRESSION_FACTORY);
private final ExpressionFactory expressionFactory;
Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/SeamFunctionMapper.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/SeamFunctionMapper.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/SeamFunctionMapper.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,3 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
package org.jboss.seam.el;
import java.lang.reflect.Method;
@@ -11,7 +34,7 @@
import org.jboss.el.lang.ExtendedFunctionMapper;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
-import org.jboss.seam.security.SecurityFunctions;
+//import org.jboss.seam.security.SecurityFunctions;
/**
* Resolves Seam Security EL functions, s:hasRole() and s:hasPermission()
@@ -34,12 +57,15 @@
static
{
+ /*
+ FIXME where should this class go so that these functions can be loaded?
cacheMethod("hasPermission", SecurityFunctions.class, "hasPermission",
new Class[] {String.class, String.class, Object.class});
cacheMethod("hasPermission", SecurityFunctions.class, "hasPermission",
new Class[] {Object.class, String.class});
cacheMethod("hasRole", SecurityFunctions.class, "hasRole",
- new Class[] { String.class });
+ new Class[] { String.class });
+ */
}
@Override
Added: modules/trunk/el/src/test/java/org/jboss/seam/el/SeamELResolverUnitTest.java
===================================================================
--- modules/trunk/el/src/test/java/org/jboss/seam/el/SeamELResolverUnitTest.java (rev 0)
+++ modules/trunk/el/src/test/java/org/jboss/seam/el/SeamELResolverUnitTest.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,132 @@
+package org.jboss.seam.el;
+
+import static org.testng.Assert.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.FunctionMapper;
+import javax.el.VariableMapper;
+import org.testng.annotations.Test;
+
+/**
+ * Verify that the magic properties are properly resolved
+ * by the {@link SeamELResolver}.
+ *
+ * @author Dan Allen
+ * @see SeamELResolver
+ */
+public class SeamELResolverUnitTest
+{
+ @Test
+ public void testUnhandled()
+ {
+ ELContext ctx = new ELContextImpl(new SeamELResolver());
+
+ Object result = ctx.getELResolver().getValue(ctx, new Object(), "size");
+ assertNull(result);
+ assertFalse(ctx.isPropertyResolved());
+ }
+
+ @Test
+ public void testCollectionSizeProperty()
+ {
+ ELContext ctx = new ELContextImpl(new SeamELResolver());
+ Collection<String> c = createSampleCollection();
+
+ Object result = ctx.getELResolver().getValue(ctx, c, "size");
+ assertEquals(result, 2);
+ assertTrue(ctx.isPropertyResolved());
+
+ ctx = new ELContextImpl(new SeamELResolver());
+ c.add("three");
+
+ result = ctx.getELResolver().getValue(ctx, c, "size");
+ assertEquals(result, 3);
+ assertTrue(ctx.isPropertyResolved());
+ }
+
+ @Test
+ public void testCollectionBogusProperty()
+ {
+ ELContext ctx = new ELContextImpl(new SeamELResolver());
+ Collection<String> c = createSampleCollection();
+
+ Object result = ctx.getELResolver().getValue(ctx, c, "bogus");
+ assertNull(result);
+ assertFalse(ctx.isPropertyResolved());
+ }
+
+ @Test
+ public void testMapSize()
+ {
+ ELContext ctx = new ELContextImpl(new SeamELResolver());
+ Map<String, Integer> m = createSampleMap();
+
+ Object result = ctx.getELResolver().getValue(ctx, m, "size");
+ assertEquals(result, 2);
+ assertTrue(ctx.isPropertyResolved());
+
+ ctx = new ELContextImpl(new SeamELResolver());
+ m.put("three", 3);
+
+ result = ctx.getELResolver().getValue(ctx, m, "size");
+ assertEquals(result, 3);
+ assertTrue(ctx.isPropertyResolved());
+ }
+
+ @Test
+ public void testMapBogusProperty()
+ {
+ ELContext ctx = new ELContextImpl(new SeamELResolver());
+ Map<String, Integer> m = createSampleMap();
+
+ Object result = ctx.getELResolver().getValue(ctx, m, "bogus");
+ assertNull(result);
+ assertFalse(ctx.isPropertyResolved());
+ }
+
+ private Collection<String> createSampleCollection() {
+ Collection<String> c = new ArrayList<String>();
+ c.add("one");
+ c.add("two");
+ return c;
+ }
+
+ private Map<String, Integer> createSampleMap() {
+ Map<String, Integer> m = new LinkedHashMap<String, Integer>();
+ m.put("one", 1);
+ m.put("two", 2);
+ return m;
+ }
+
+ private class ELContextImpl extends ELContext
+ {
+ private ELResolver resolver;
+
+ private ELContextImpl(ELResolver resolver)
+ {
+ this.resolver = resolver;
+ }
+
+ @Override
+ public ELResolver getELResolver()
+ {
+ return resolver;
+ }
+
+ @Override
+ public FunctionMapper getFunctionMapper()
+ {
+ throw new AssertionError();
+ }
+
+ @Override
+ public VariableMapper getVariableMapper()
+ {
+ throw new AssertionError();
+ }
+ }
+}
Added: modules/trunk/el/src/test/resources/test-suite.xml
===================================================================
--- modules/trunk/el/src/test/resources/test-suite.xml (rev 0)
+++ modules/trunk/el/src/test/resources/test-suite.xml 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,15 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="Seam EL Module Unit Tests" verbose="1">
+ <test name="Seam EL 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.el"/>
+ </packages>
+ </test>
+</suite>
Modified: modules/trunk/faces/pom.xml
===================================================================
--- modules/trunk/faces/pom.xml 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/pom.xml 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,36 +1,48 @@
-<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>
+
<parent>
<artifactId>seam-parent</artifactId>
- <groupId>org.jboss.seam</groupId>
+ <groupId>org.jboss.seam</groupId>
<version>3.0.0-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.seam</groupId>
+ </parent>
+
<artifactId>seam-faces</artifactId>
<packaging>jar</packaging>
<version>3.0.0-SNAPSHOT</version>
- <name>Seam Faces</name>
-
+ <name>Seam Faces Module</name>
+
<dependencies>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>seam-el</artifactId>
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>seam-international</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
- </dependency>
+ <scope>provided</scope>
+ </dependency>
<dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>jsr299-api</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- </dependency>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/DataModels.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/DataModels.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/DataModels.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -5,15 +5,12 @@
import java.util.Set;
import javax.faces.model.DataModel;
+import org.jboss.seam.faces.model.ArrayDataModel;
+import org.jboss.seam.faces.model.ListDataModel;
+import org.jboss.seam.faces.model.MapDataModel;
+import org.jboss.seam.faces.model.SetDataModel;
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.framework.Query;
-import org.jboss.seam.jsf.ArrayDataModel;
-import org.jboss.seam.jsf.ListDataModel;
-import org.jboss.seam.jsf.MapDataModel;
-import org.jboss.seam.jsf.SetDataModel;
-
+//import org.jboss.seam.framework.Query;
/**
* Wraps a collection as a JSF {@link DataModel}. May be overridden
* and extended if you don't like the built in collections
@@ -23,7 +20,6 @@
*/
public class DataModels
{
-
/**
* Wrap the value in a DataModel
*
@@ -34,37 +30,30 @@
{
if (value instanceof List)
{
- return new ListDataModel( (List) value );
+ return new ListDataModel((List) value);
}
else if (value instanceof Object[])
{
- return new ArrayDataModel( (Object[]) value );
+ return new ArrayDataModel((Object[]) value);
}
else if (value instanceof Map)
{
- return new MapDataModel( (Map) value );
+ return new MapDataModel((Map) value);
}
else if (value instanceof Set)
{
- return new SetDataModel( (Set) value );
+ return new SetDataModel((Set) value);
}
else
{
throw new IllegalArgumentException("unknown collection type: " + value.getClass());
}
}
-
/**
* Wrap the the Seam Framework {@link Query} in a JSF DataModel
*/
- public DataModel getDataModel(Query query)
- {
- return getDataModel( query.getResultList() );
- }
-
- public static DataModels instance()
- {
- return (DataModels) Component.getInstance(DataModels.class, ScopeType.STATELESS);
- }
-
+// public DataModel getDataModel(Query query)
+// {
+// return getDataModel( query.getResultList() );
+// }
}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/DateConverter.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/DateConverter.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/DateConverter.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,120 +0,0 @@
-package org.jboss.seam.faces;
-
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.ConverterException;
-
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.faces.Converter;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.log.Logging;
-
-/**
- * Provides a default JSF converter for properties of type java.util.Date.
- *
- * <p>This converter is provided to save a developer from having to specify
- * a DateTimeConverter on an input field or page parameter. By default, it
- * assumes the type to be a date (as opposed to a time or date plus time) and
- * uses the short input style adjusted to the Locale of the user. For Locale.US,
- * the input pattern is mm/DD/yy. However, to comply with Y2K, the year is changed
- * from two digits to four (e.g., mm/DD/yyyy).</p>
- * <p>It's possible to override the input pattern globally using component configuration.
- * Here is an example of changing the style to both and setting the date and
- * time style to medium.</p>
- * <pre>
- * org.jboss.seam.faces.dateConverter.type=both
- * org.jboss.seam.faces.dateConverter.dateStyle=medium
- * org.jboss.seam.faces.dateConverter.timeStyle=medium
- * </pre>
- * <p>Alternatively, a fixed pattern can be specified.</p>
- * <pre>
- * org.jboss.seam.faces.dateConverter.pattern=yyyy-mm-DD
- * </pre>
- *
- * @author Dan Allen
- */
-@Converter(forClass = Date.class)
-@Name("org.jboss.seam.faces.dateConverter")
-@Install(precedence = BUILT_IN, classDependencies = "javax.faces.context.FacesContext")
-@BypassInterceptors
-public class DateConverter extends javax.faces.convert.DateTimeConverter {
-
- private Log log = Logging.getLog(DateConverter.class);
-
- private static final String TYPE_DATE = "date";
- private static final String STYLE_SHORT = "short";
- private static final String TWO_DIGIT_YEAR_PATTERN = "yy";
- private static final String FOUR_DIGIT_YEAR_PATTERN = "yyyy";
-
- // constructor is used to initialize converter to allow these values to be overridden using component properties
- public DateConverter() {
- super();
- setType(TYPE_DATE);
- setDateStyle(STYLE_SHORT);
- setTimeStyle(STYLE_SHORT); // default in case developer overrides type to be time or both
- }
-
- @Create
- public void create() {
- // TODO make this work if using "both" for type; requires more analysis of time style
- if (TYPE_DATE.equals(getType()) && STYLE_SHORT.equals(getDateStyle()) && getPattern() == null) {
- // attempt to make the pattern Y2K compliant, which it isn't by default
- DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, getLocale());
- if (dateFormat instanceof SimpleDateFormat) {
- setPattern(((SimpleDateFormat) dateFormat).toPattern().replace(TWO_DIGIT_YEAR_PATTERN, FOUR_DIGIT_YEAR_PATTERN));
- }
- }
- // required since the superclass may access the fields directly
- setTimeZone(getTimeZone());
- setLocale(getLocale());
- }
-
- @Override
- public TimeZone getTimeZone() {
- if (Contexts.isApplicationContextActive()) {
- return org.jboss.seam.international.TimeZone.instance();
- } else {
- // we don't want to use JSF's braindead default (maybe in JSF 2)
- return TimeZone.getDefault();
- }
- }
-
- @Override
- public Locale getLocale() {
- if (Contexts.isApplicationContextActive()) {
- return org.jboss.seam.international.Locale.instance();
- } else {
- return super.getLocale();
- }
- }
-
- @Override
- public Object getAsObject(FacesContext context, UIComponent component,
- String value) throws ConverterException {
- if (log.isDebugEnabled()) {
- log.debug("Converting string '#0' to date for clientId '#1' using Seam's built-in JSF date converter", value, component.getClientId(context));
- }
- return super.getAsObject(context, component, value);
- }
-
- @Override
- public String getAsString(FacesContext context, UIComponent component,
- Object value) throws ConverterException {
- if (log.isDebugEnabled()) {
- log.debug("Converting date '#0' to string for clientId '#1' using Seam's built-in JSF date converter", value, component.getClientId(context));
- }
- return super.getAsString(context, component, value);
- }
-}
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,8 +1,6 @@
//$Id: FacesContext.java 5350 2007-06-20 17:53:19Z gavin $
package org.jboss.seam.faces;
-import javax.annotation.Named;
-import javax.context.ApplicationScoped;
import javax.inject.Produces;
import javax.faces.context.FacesContext;
@@ -11,10 +9,11 @@
*
* @author Gavin King
*/
-@ApplicationScoped
public class FacesContextProducer
{
- @Produces @Named public FacesContext getContext()
+ public
+ @Produces
+ FacesContext getFacesContext()
{
return FacesContext.getCurrentInstance();
}
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesExpressions.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesExpressions.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesExpressions.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -5,19 +5,18 @@
import javax.context.ApplicationScoped;
import javax.el.ELContext;
import javax.faces.context.FacesContext;
+import org.jboss.seam.el.Expressions;
-import org.jboss.seam.contexts.FacesLifecycle;
-import org.jboss.seam.core.Expressions;
-
/**
* Factory for method and value bindings in a JSF environment.
*
* @author Gavin King
*/
+public
@Named
@ApplicationScoped
-public class FacesExpressions extends Expressions
-{
+class FacesExpressions extends Expressions
+{
/**
* Get an appropriate ELContext. If there is an active JSF request,
* use JSF's ELContext. Otherwise, use one that we created.
@@ -30,8 +29,8 @@
@Override
protected boolean isFacesContextActive()
- {
- return FacesContext.getCurrentInstance() != null && FacesLifecycle.getPhaseId() != null;
+ {
+ return FacesContext.getCurrentInstance() != null && FacesContext.getCurrentInstance().getCurrentPhaseId() != null;
}
-
-}
+
+}
\ No newline at end of file
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesManager.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesManager.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesManager.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,316 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.seam.faces;
-
-import static org.jboss.seam.annotations.Install.FRAMEWORK;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseId;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.contexts.FacesLifecycle;
-import org.jboss.seam.core.Conversation;
-import org.jboss.seam.core.Init;
-import org.jboss.seam.core.Interpolator;
-import org.jboss.seam.core.Manager;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-import org.jboss.seam.navigation.ConversationIdParameter;
-import org.jboss.seam.navigation.Pages;
-import org.jboss.seam.pageflow.Pageflow;
-
-/**
- * An extended conversation manager for the JSF environment.
- *
- * @author Gavin King
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- */
-(a)Scope(ScopeType.EVENT)
-@Name("org.jboss.seam.core.manager")
-@Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
-@BypassInterceptors
-public class FacesManager extends Manager
-{
- private static final LogProvider log = Logging.getLogProvider(FacesManager.class);
-
-
-
- private boolean controllingRedirect;
-
- /**
- * Temporarily promote a temporary conversation to
- * a long running conversation for the duration of
- * a browser redirect. After the redirect, the
- * conversation will be demoted back to a temporary
- * conversation. Handle any changes to the conversation
- * id, due to propagation via natural id.
- */
- public void beforeRedirect(String viewId)
- {
- beforeRedirect();
-
- FacesContext facesContext = FacesContext.getCurrentInstance();
- String currentViewId = Pages.getViewId(facesContext);
- if ( viewId!=null && currentViewId!=null )
- {
- ConversationIdParameter currentPage = Pages.instance().getPage(currentViewId).getConversationIdParameter();
- ConversationIdParameter targetPage = Pages.instance().getPage(viewId).getConversationIdParameter();
- if ( isDifferentConversationId(currentPage, targetPage) )
- {
- updateCurrentConversationId( targetPage.getConversationId() );
- }
- }
- }
-
- public void interpolateAndRedirect(String url)
- {
- Map<String, Object> parameters = new HashMap<String, Object>();
- int loc = url.indexOf('?');
- if (loc>0)
- {
- StringTokenizer tokens = new StringTokenizer( url.substring(loc), "?=&" );
- while ( tokens.hasMoreTokens() )
- {
- String name = tokens.nextToken();
- String value = Interpolator.instance().interpolate( tokens.nextToken() );
- parameters.put(name, value);
- }
- url = url.substring(0, loc);
- }
- redirect(url, parameters, true, true);
- }
-
- @Override
- protected void storeConversationToViewRootIfNecessary()
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if ( facesContext!=null && FacesLifecycle.getPhaseId()==PhaseId.RENDER_RESPONSE )
- {
- FacesPage.instance().storeConversation();
- }
- }
-
- @Override
- protected String generateInitialConversationId()
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- String viewId = Pages.getViewId(facesContext);
- if ( viewId!=null )
- {
- return Pages.instance().getPage(viewId)
- .getConversationIdParameter()
- .getInitialConversationId( facesContext.getExternalContext().getRequestParameterMap() );
- }
- else
- {
- return super.generateInitialConversationId();
- }
- }
-
- public void redirectToExternalURL(String url) {
- try {
- FacesContext.getCurrentInstance().getExternalContext().redirect(url);
- } catch (IOException e) {
- throw new RedirectException(e);
- }
- }
-
- /**
- * Redirect to the given view id, encoding the conversation id
- * into the request URL.
- *
- * @param viewId the JSF view id
- */
- @Override
- public void redirect(String viewId)
- {
- redirect(viewId, null, true, true);
- }
-
- public void redirect(String viewId, Map<String, Object> parameters,
- boolean includeConversationId)
- {
- redirect(viewId, parameters, includeConversationId, true);
- }
-
- /**
- * Redirect to the given view id, after encoding parameters and conversation
- * id into the request URL.
- *
- * @param viewId the JSF view id
- * @param parameters request parameters to be encoded (possibly null)
- * @param includeConversationId determines if the conversation id is to be encoded
- */
- public void redirect(String viewId, Map<String, Object> parameters,
- boolean includeConversationId, boolean includePageParams)
- {
- if (viewId == null)
- {
- throw new RedirectException("cannot redirect to a null viewId");
- }
- FacesContext context = FacesContext.getCurrentInstance();
- String url = context.getApplication().getViewHandler().getActionURL(context, viewId);
- if (parameters!=null)
- {
- url = encodeParameters(url, parameters);
- }
-
- if (includePageParams)
- {
- url = Pages.instance().encodePageParameters(FacesContext.getCurrentInstance(),
- url, viewId, parameters==null ? Collections.EMPTY_SET : parameters.keySet());
- }
-
- if (includeConversationId)
- {
- beforeRedirect(viewId);
- url = encodeConversationId(url, viewId);
- }
- redirect(viewId, context, url);
- }
-
- /**
- * Redirect to the given view id, after encoding the given conversation
- * id into the request URL.
- *
- * @param viewId the JSF view id
- * @param conversationId an id of a long-running conversation
- */
- @Override
- public void redirect(String viewId, String conversationId)
- {
- if (viewId == null)
- {
- throw new RedirectException("cannot redirect to a null viewId");
- }
- FacesContext context = FacesContext.getCurrentInstance();
- String url = context.getApplication().getViewHandler().getActionURL(context, viewId);
- url = encodeConversationId(url, viewId, conversationId);
- redirect(viewId, context, url);
- }
-
- private void redirect(String viewId, FacesContext context, String url)
- {
- url = Pages.instance().encodeScheme(viewId, context, url);
- if ( log.isDebugEnabled() )
- {
- log.debug("redirecting to: " + url);
- }
- ExternalContext externalContext = context.getExternalContext();
- controllingRedirect = true;
- try
- {
- Contexts.getEventContext().set(REDIRECT_FROM_MANAGER, "");
- externalContext.redirect( externalContext.encodeActionURL(url) );
- }
- catch (IOException ioe)
- {
- throw new RedirectException(ioe);
- }
- finally
- {
- Contexts.getEventContext().remove(REDIRECT_FROM_MANAGER);
- controllingRedirect = false;
- }
- context.responseComplete();
- }
-
- /**
- * Called by the Seam Redirect Filter when a redirect is called.
- * Appends the conversationId parameter if necessary.
- *
- * @param url the requested URL
- * @return the resulting URL with the conversationId appended
- */
- public String appendConversationIdFromRedirectFilter(String url, String viewId)
- {
- boolean appendConversationId = !controllingRedirect;
- if (appendConversationId)
- {
- beforeRedirect(viewId);
- url = encodeConversationId(url, viewId);
- }
- return url;
- }
-
- /**
- * If a page description is defined, remember the description and
- * view id for the current page, to support conversation switching.
- * Called just before the render phase.
- */
- public void prepareBackswitch(FacesContext facesContext)
- {
-
- Conversation conversation = Conversation.instance();
-
- //stuff from jPDL takes precedence
- org.jboss.seam.pageflow.Page page =
- Manager.instance().isLongRunningConversation() &&
- Init.instance().isJbpmInstalled() &&
- Pageflow.instance().isInProcess() && Pageflow.instance().isStarted() ?
- Pageflow.instance().getPage() : null;
-
- if (page==null)
- {
- //handle stuff defined in pages.xml
- Pages pages = Pages.instance();
- if (pages!=null) //for tests
- {
- String viewId = Pages.getViewId(facesContext);
- org.jboss.seam.navigation.Page pageEntry = pages.getPage(viewId);
- if ( pageEntry.isSwitchEnabled() )
- {
- conversation.setViewId(viewId);
- }
- if ( pageEntry.hasDescription() )
- {
- conversation.setDescription( pageEntry.renderDescription() );
- }
- else if(pages.hasDescription(viewId))
- {
- conversation.setDescription( pages.renderDescription(viewId) );
- }
- conversation.setTimeout( pages.getTimeout(viewId) );
- conversation.setConcurrentRequestTimeout( pages.getConcurrentRequestTimeout(viewId) );
- }
- }
- else
- {
- //use stuff from the pageflow definition
- if ( page.isSwitchEnabled() )
- {
- conversation.setViewId( Pageflow.instance().getPageViewId() );
- }
- if ( page.hasDescription() )
- {
- conversation.setDescription( page.getDescription() );
- }
- conversation.setTimeout( page.getTimeout() );
- }
-
- flushConversationMetadata();
-
- }
-
- public static FacesManager instance()
- {
- return (FacesManager) Manager.instance();
- }
-
-}
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesMessages.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesMessages.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesMessages.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,8 +1,5 @@
package org.jboss.seam.faces;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -11,16 +8,8 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.international.StatusMessage;
import org.jboss.seam.international.StatusMessages;
-import org.jboss.seam.util.Strings;
/**
* A Seam component that propagates FacesMessages across redirects
@@ -29,59 +18,43 @@
* @author Gavin King
* @author Pete Muir
*/
-(a)Scope(ScopeType.CONVERSATION)
-(a)Name(StatusMessages.COMPONENT_NAME)
-@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
-@BypassInterceptors
public class FacesMessages extends StatusMessages
{
-
/**
- * Called by Seam to transfer messages from FacesMessages to JSF
+ * Called by Seam to transfer messages from Seam status messages to real JSF messages
*/
- public void beforeRenderResponse()
+ public void beforeRenderView()
{
- for (StatusMessage statusMessage: getMessages())
+ for (StatusMessage statusMessage : getMessages())
{
- FacesContext.getCurrentInstance().addMessage( null, toFacesMessage(statusMessage) );
+ FacesContext.getCurrentInstance().addMessage(null, toFacesMessage(statusMessage));
}
- for ( Map.Entry<String, List<StatusMessage>> entry: getKeyedMessages().entrySet() )
+ for (Map.Entry<String, List<StatusMessage>> entry : getKeyedMessages().entrySet())
{
- for ( StatusMessage statusMessage: entry.getValue() )
+ for (StatusMessage statusMessage : entry.getValue())
{
String clientId = getClientId(entry.getKey());
- FacesContext.getCurrentInstance().addMessage( clientId, toFacesMessage(statusMessage) );
+ FacesContext.getCurrentInstance().addMessage(clientId, toFacesMessage(statusMessage));
}
}
clear();
}
-
+
/**
- * Called by Seam to transfer any messages added in the phase just processed
- * to the FacesMessages component.
- *
- * A task runner is used to allow the messages access to outjected values.
- */
- public static void afterPhase()
- {
- runTasks();
- }
-
- /**
* Convert a StatusMessage to a FacesMessage
*/
private static FacesMessage toFacesMessage(StatusMessage statusMessage)
{
- if (!Strings.isEmpty(statusMessage.getSummary()))
+ if (statusMessage.getSummary() != null && statusMessage.getSummary().length() > 0)
{
- return new FacesMessage(toSeverity(statusMessage.getSeverity()), statusMessage.getSummary(), statusMessage.getDetail() );
+ return new FacesMessage(toSeverity(statusMessage.getSeverity()), statusMessage.getSummary(), statusMessage.getDetail());
}
else
{
return null;
}
}
-
+
/**
* Convert a StatusMessage.Severity to a FacesMessage.Severity
*/
@@ -89,19 +62,19 @@
{
switch (severity)
{
- case ERROR:
- return FacesMessage.SEVERITY_ERROR;
- case FATAL:
- return FacesMessage.SEVERITY_FATAL;
- case INFO:
- return FacesMessage.SEVERITY_INFO;
- case WARN:
- return FacesMessage.SEVERITY_WARN;
- default:
- return null;
+ case ERROR:
+ return FacesMessage.SEVERITY_ERROR;
+ case FATAL:
+ return FacesMessage.SEVERITY_FATAL;
+ case INFO:
+ return FacesMessage.SEVERITY_INFO;
+ case WARN:
+ return FacesMessage.SEVERITY_WARN;
+ default:
+ return null;
}
}
-
+
/**
* Convert a FacesMessage.Severity to a StatusMessage.Severity
*/
@@ -128,229 +101,36 @@
return null;
}
}
-
+
/**
* Calculate the JSF client ID from the provided widget ID
*/
private String getClientId(String id)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
- return getClientId( facesContext.getViewRoot(), id, facesContext);
+ return getClientId(facesContext.getViewRoot(), id, facesContext);
}
private static String getClientId(UIComponent component, String id, FacesContext facesContext)
{
String componentId = component.getId();
- if (componentId!=null && componentId.equals(id))
+ if (componentId != null && componentId.equals(id))
{
return component.getClientId(facesContext);
}
else
{
Iterator iter = component.getFacetsAndChildren();
- while ( iter.hasNext() )
+ while (iter.hasNext())
{
UIComponent child = (UIComponent) iter.next();
String clientId = getClientId(child, id, facesContext);
- if (clientId!=null) return clientId;
+ if (clientId != null)
+ {
+ return clientId;
+ }
}
return null;
}
}
-
- /**
- * Get all faces messages that have already been added
- * to the context.
- *
- */
- public List<FacesMessage> getCurrentMessages()
- {
- List<FacesMessage> result = new ArrayList<FacesMessage>();
- Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages();
- while ( iter.hasNext() )
- {
- result.add( iter.next() );
- }
- return result;
- }
-
- /**
- * Get all faces global messages that have already been added
- * to the context.
- *
- */
- public List<FacesMessage> getCurrentGlobalMessages()
- {
- List<FacesMessage> result = new ArrayList<FacesMessage>();
- Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages(null);
- while ( iter.hasNext() )
- {
- result.add( iter.next() );
- }
- return result;
- }
-
- /**
- * Get all faces messages that have already been added
- * to the control.
- *
- */
- public List<FacesMessage> getCurrentMessagesForControl(String id)
- {
- String clientId = getClientId(id);
- List<FacesMessage> result = new ArrayList<FacesMessage>();
- Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages(clientId);
- while ( iter.hasNext() )
- {
- result.add( iter.next() );
- }
- return result;
- }
-
- /**
- * Utility method to create a FacesMessage from a Severity, messageTemplate
- * and params.
- *
- * This method interpolates the parameters provided
- */
- public static FacesMessage createFacesMessage(javax.faces.application.FacesMessage.Severity severity, String messageTemplate, Object... params)
- {
- return createFacesMessage(severity, null, messageTemplate, params);
- }
-
- /**
- * Utility method to create a FacesMessage from a Severity, key,
- * defaultMessageTemplate and params.
- *
- * This method interpolates the parameters provided
- */
- public static FacesMessage createFacesMessage(javax.faces.application.FacesMessage.Severity severity, String key, String defaultMessageTemplate, Object... params)
- {
- StatusMessage message = new StatusMessage(toSeverity(severity), key, null, defaultMessageTemplate, null);
- message.interpolate(params);
- return toFacesMessage(message);
- }
-
- /**
- * Add a FacesMessage that will be used
- * the next time a page is rendered.
- *
- * Deprecated, use a method in {@link StatusMessages} instead
- */
- @Deprecated
- public void add(FacesMessage facesMessage)
- {
- if (facesMessage!=null)
- {
- add(toSeverity(facesMessage.getSeverity()), null, null, facesMessage.getSummary(), facesMessage.getDetail());
- }
- }
-
- /**
- * Create a new status message, with the messageTemplate is as the message.
- *
- * You can also specify the severity, and parameters to be interpolated
- *
- * Deprecated, use {@link #add(org.jboss.seam.international.StatusMessage.Severity, String, Object...)}
- * instead
- */
- @Deprecated
- public void add(javax.faces.application.FacesMessage.Severity severity, String messageTemplate, Object... params)
- {
- add(toSeverity(severity), messageTemplate, params);
- }
-
-
- /**
- * Create a new status message, with the messageTemplate is as the message.
- *
- * A severity of INFO will be used, and you can specify paramters to be
- * interpolated
- *
- * Deprecated, use {@link #addToControl(String, org.jboss.seam.international.StatusMessage.Severity, String, Object...)}
- * instead
- */
- @Deprecated
- public void addToControl(String id, javax.faces.application.FacesMessage.Severity severity, String messageTemplate, Object... params)
- {
- addToControl(id, toSeverity(severity), messageTemplate, params);
- }
-
- /**
- * Add a status message, looking up the message in the resource bundle
- * using the provided key.
- *
- * You can also specify the severity, and parameters to be interpolated
- *
- * Deprecated, use {@link #addFromResourceBundle(org.jboss.seam.international.StatusMessage.Severity, String, Object...)}
- * instead
- */
- @Deprecated
- public void addFromResourceBundle(javax.faces.application.FacesMessage.Severity severity, String key, Object... params)
- {
- addFromResourceBundle(toSeverity(severity), key, params);
- }
-
- /**
- * Add a status message, looking up the message in the resource bundle
- * using the provided key.
- *
- * You can also specify the severity, and parameters to be interpolated
- *
- * Deprecated, use {@link #addFromResourceBundleOrDefault(javax.faces.application.FacesMessage.Severity, String, String, Object...)}
- * instead
- */
- @Deprecated
- public void addFromResourceBundleOrDefault(javax.faces.application.FacesMessage.Severity severity, String key, String defaultMessageTemplate, Object... params)
- {
- addFromResourceBundleOrDefault(toSeverity(severity), key, defaultMessageTemplate, params);
- }
-
- /**
- * Create a new status message, looking up the message in the resource bundle
- * using the provided key.
- *
- * The message will be added to the widget specified by the ID. The algorithm
- * used determine which widget the id refers to is determined by the view
- * layer implementation in use.
- *
- * You can also specify the severity, and parameters to be interpolated
- *
- * Deprecated, use {@link #addToControlFromResourceBundle(String, org.jboss.seam.international.StatusMessage.Severity, String, Object...)}
- * instead
- */
- @Deprecated
- public void addToControlFromResourceBundle(String id, javax.faces.application.FacesMessage.Severity severity, String key, Object... params)
- {
- addToControlFromResourceBundle(id, toSeverity(severity), key, params);
- }
-
- /**
- * Add a status message, looking up the message in the resource bundle
- * using the provided key. If the message is found, it is used, otherwise,
- * the defaultMessageTemplate will be used.
- *
- * The message will be added to the widget specified by the ID. The algorithm
- * used determine which widget the id refers to is determined by the view
- * layer implementation in use.
- *
- * You can also specify the severity, and parameters to be interpolated
- *
- * Deprecated, use {@link #addToControlFromResourceBundleOrDefault(String, org.jboss.seam.international.StatusMessage.Severity, String, String, Object...)}
- * instead
- */
- @Deprecated
- public void addToControlFromResourceBundleOrDefault(String id, javax.faces.application.FacesMessage.Severity severity, String key, String defaultMessageTemplate, Object... params)
- {
- addToControlFromResourceBundleOrDefault(id, toSeverity(severity), key, defaultMessageTemplate, params);
- }
-
- public static FacesMessages instance()
- {
- if ( !Contexts.isConversationContextActive() )
- {
- throw new IllegalStateException("No active conversation context");
- }
- return (FacesMessages) Component.getInstance(StatusMessages.COMPONENT_NAME, ScopeType.CONVERSATION);
- }
}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesPage.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesPage.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesPage.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,173 +0,0 @@
-package org.jboss.seam.faces;
-
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.io.Serializable;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.core.Init;
-import org.jboss.seam.core.Manager;
-import org.jboss.seam.pageflow.Pageflow;
-import org.jboss.seam.web.Session;
-
-/**
- * Book-keeping component that persists information
- * about the conversation associated with the current
- * page.
- *
- * @author Gavin King
- *
- */
-@Name("org.jboss.seam.faces.facesPage")
-@BypassInterceptors
-@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
-(a)Scope(ScopeType.PAGE)
-public class FacesPage implements Serializable
-{
- private static final long serialVersionUID = 4807114041808347239L;
- private String pageflowName;
- private Integer pageflowCounter;
- private String pageflowNodeName;
-
- private String conversationId;
- private boolean conversationIsLongRunning;
-
- //private Map<String, Object> pageParameters;
-
- public String getConversationId()
- {
- return conversationId;
- }
-
- public void discardTemporaryConversation()
- {
- conversationId = null;
- conversationIsLongRunning = false;
- }
-
- public void discardNestedConversation(String outerConversationId)
- {
- conversationId = outerConversationId;
- conversationIsLongRunning = true;
- }
-
- public void storeConversation(String conversationId)
- {
- this.conversationId = conversationId;
- conversationIsLongRunning = true;
- }
-
- public void storePageflow()
- {
- if ( Init.instance().isJbpmInstalled() )
- {
- Pageflow pageflow = Pageflow.instance();
- if ( pageflow.isInProcess() /*&& !pageflow.getProcessInstance().hasEnded()*/ && Manager.instance().isLongRunningConversation() )
- {
- pageflowName = pageflow.getSubProcessInstance().getProcessDefinition().getName();
- pageflowNodeName = pageflow.getNode().getName();
- pageflowCounter = pageflow.getPageflowCounter();
- }
- else
- {
- pageflowName = null;
- pageflowNodeName = null;
- pageflowCounter = null;
- }
- }
- }
-
- public static FacesPage instance()
- {
- if ( !Contexts.isPageContextActive() )
- {
- throw new IllegalStateException("No page context active");
- }
- return (FacesPage) Component.getInstance(FacesPage.class, ScopeType.PAGE);
- }
-
- public boolean isConversationLongRunning()
- {
- return conversationIsLongRunning;
- }
-
- public Integer getPageflowCounter()
- {
- return pageflowCounter;
- }
-
- public String getPageflowName()
- {
- return pageflowName;
- }
-
- public String getPageflowNodeName()
- {
- return pageflowNodeName;
- }
-
- public void storeConversation()
- {
- Manager manager = Manager.instance();
-
- //we only need to execute this code when we are in the
- //RENDER_RESPONSE phase, ie. not before redirects
-
- Session session = Session.getInstance();
- boolean sessionInvalid = session!=null && session.isInvalid();
- if ( !sessionInvalid && manager.isLongRunningConversation() )
- {
- storeConversation( manager.getCurrentConversationId() );
- }
- else if ( !sessionInvalid && manager.isNestedConversation() )
- {
- discardNestedConversation( manager.getParentConversationId() );
- }
- else
- {
- discardTemporaryConversation();
- }
-
- /*if ( !sessionInvalid && Init.instance().isClientSideConversations() )
- {
- // if we are using client-side conversations, put the
- // map containing the conversation context variables
- // into the view root (or remove it for a temp
- // conversation context)
- Contexts.getConversationContext().flush();
- }*/
-
- }
-
- /*public Map<String, Object> getPageParameters()
- {
- return pageParameters==null ? Collections.EMPTY_MAP : pageParameters;
- }
-
- public void setPageParameters(Map<String, Object> pageParameters)
- {
- this.pageParameters = pageParameters.isEmpty() ? null : pageParameters;
- }
-
- /**
- * Used by test harness
- *
- * @param name the page parameter name
- * @param value the value
- */
- /*public void setPageParameter(String name, Object value)
- {
- if (pageParameters==null)
- {
- pageParameters = new HashMap<String, Object>();
- }
- pageParameters.put(name, value);
- }*/
-
-}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesResourceLoader.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesResourceLoader.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesResourceLoader.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,70 @@
+package org.jboss.seam.faces;
+
+import java.io.InputStream;
+import java.net.URL;
+import javax.faces.context.FacesContext;
+import javax.inject.Current;
+import javax.servlet.ServletContext;
+import org.jboss.seam.international.ResourceLoader;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
+/**
+ * Extend the standard {@link ResourceLoader} and attempt to first load
+ * the resource from the web context root.
+ *
+ * @author Dan Allen
+ */
+public class FacesResourceLoader extends ResourceLoader
+{
+ private static final LogProvider log = Logging.getLogProvider(FacesResourceLoader.class);
+ @Current
+ FacesContext facesContext;
+
+ @Override
+ protected URL getResource(String path, String relativePath)
+ {
+ ServletContext servletContext = getServletContext();
+ if (servletContext != null)
+ {
+ try
+ {
+ URL url = servletContext.getResource(path);
+ log.debug("Loaded resource from servlet context: " + url);
+ return url;
+ }
+ catch (Exception e)
+ {
+ // swallow
+ }
+ }
+
+ return super.getResource(path, relativePath);
+ }
+
+ @Override
+ protected InputStream getResourceAsStream(String path, String relativePath)
+ {
+ ServletContext servletContext = getServletContext();
+ if (servletContext != null)
+ {
+ try
+ {
+ InputStream stream = servletContext.getResourceAsStream(path);
+ log.debug("Loaded resource stream from servlet context: " + path);
+ return stream;
+ }
+ catch (Exception e)
+ {
+ // swallow
+ }
+ }
+
+ return super.getResourceAsStream(path, relativePath);
+ }
+
+ private ServletContext getServletContext()
+ {
+ return (ServletContext) facesContext.getExternalContext().getContext();
+ }
+}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/HttpError.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/HttpError.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/HttpError.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,76 +0,0 @@
-//$Id: HttpError.java 5350 2007-06-20 17:53:19Z gavin $
-package org.jboss.seam.faces;
-
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-
-/**
- * Convenient HTTP errors
- *
- * @author Gavin King
- */
-(a)Scope(ScopeType.APPLICATION)
-@BypassInterceptors
-@Name("org.jboss.seam.faces.httpError")
-@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
-public class HttpError
-{
- /**
- * Send a HTTP error as the response
- */
- public void send(int code)
- {
- try
- {
- getResponse().sendError(code);
- }
- catch (IOException ioe)
- {
- throw new IllegalStateException(ioe);
- }
- FacesContext.getCurrentInstance().responseComplete();
- }
-
- /**
- * Send a HTTP error as the response
- */
- public void send(int code, String message)
- {
- try
- {
- getResponse().sendError(code, message);
- }
- catch (IOException ioe)
- {
- throw new IllegalStateException(ioe);
- }
- FacesContext.getCurrentInstance().responseComplete();
- }
-
- private static HttpServletResponse getResponse()
- {
- return (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
- }
-
- public static HttpError instance()
- {
- if ( !Contexts.isApplicationContextActive() )
- {
- throw new IllegalStateException("No active application scope");
- }
- return (HttpError) Component.getInstance(HttpError.class, ScopeType.APPLICATION);
- }
-
-}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/IsUserInRole.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/IsUserInRole.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/IsUserInRole.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,37 +0,0 @@
-package org.jboss.seam.faces;
-
-import static org.jboss.seam.annotations.Install.FRAMEWORK;
-
-import javax.faces.context.FacesContext;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-
-/**
- * Manager component for a map of roles assigned
- * to the current user, as exposed via the JSF
- * ExternalContext.
- *
- * @author Gavin King
- */
-(a)Scope(ScopeType.APPLICATION)
-@BypassInterceptors
-@Name("org.jboss.seam.web.isUserInRole")
-@Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
-public class IsUserInRole extends org.jboss.seam.web.IsUserInRole
-{
- @Override
- protected Boolean isUserInRole(String role)
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if ( facesContext != null )
- {
- return facesContext.getExternalContext().isUserInRole(role);
- }
-
- return super.isUserInRole(role);
- }
-}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/Navigator.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/Navigator.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/Navigator.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,109 +0,0 @@
-package org.jboss.seam.faces;
-
-import java.util.Map;
-
-import javax.faces.application.FacesMessage.Severity;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-import org.jboss.seam.navigation.Pages;
-import org.jboss.seam.util.Strings;
-
-public abstract class Navigator
-{
- private static final LogProvider log = Logging.getLogProvider(Navigator.class);
-
- /**
- * Send an error.
- */
- protected void error(int code, String message)
- {
- if ( log.isDebugEnabled() ) log.debug("sending error: " + code);
- org.jboss.seam.faces.HttpError httpError = org.jboss.seam.faces.HttpError.instance();
- if (message==null)
- {
- httpError.send(code);
- }
- else
- {
- httpError.send(code, message);
- }
- }
-
- protected void redirectExternal(String url) {
- FacesManager.instance().redirectToExternalURL(url);
- }
-
- protected void redirect(String viewId, Map<String, Object> parameters)
- {
- redirect(viewId, parameters, true);
- }
-
- /**
- * Redirect to the view id.
- */
- protected void redirect(String viewId, Map<String, Object> parameters, boolean includePageParams)
- {
- if ( Strings.isEmpty(viewId) )
- {
- viewId = Pages.getCurrentViewId();
- }
- if ( log.isDebugEnabled() ) log.debug("redirecting to: " + viewId);
- FacesManager.instance().redirect(viewId, parameters, true, includePageParams);
- }
-
- /**
- * Render the view id.
- */
- protected void render(String viewId)
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if ( !Strings.isEmpty(viewId) )
- {
- UIViewRoot viewRoot = facesContext.getApplication().getViewHandler()
- .createView(facesContext, viewId);
- facesContext.setViewRoot(viewRoot);
- }
- else
- {
- viewId = Pages.getViewId(facesContext); //just for the log message
- }
- if ( log.isDebugEnabled() ) log.debug("rendering: " + viewId);
- facesContext.renderResponse();
- }
-
- protected static String getDisplayMessage(Exception e, String message)
- {
- if ( Strings.isEmpty(message) && e.getMessage()!=null )
- {
- return e.getMessage();
- }
- else
- {
- return message;
- }
- }
-
- @SuppressWarnings("deprecation")
- protected static void addFacesMessage(String message, Severity severity, String control, Object... params)
- {
- if ( Contexts.isConversationContextActive() )
- {
- if ( !Strings.isEmpty(message) )
- {
- if ( Strings.isEmpty(control) )
- {
- FacesMessages.instance().add(severity, message, params);
- }
- else
- {
- FacesMessages.instance().addToControl(control, severity, message, params);
- }
- }
- }
- }
-
-}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/Parameters.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/Parameters.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/Parameters.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,67 +0,0 @@
-package org.jboss.seam.faces;
-
-import static org.jboss.seam.annotations.Install.FRAMEWORK;
-
-import java.util.Map;
-
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-
-/**
- * Access to request parameters in the JSF environment.
- *
- * @author Gavin King
- *
- */
-@Name("org.jboss.seam.web.parameters")
-@BypassInterceptors
-(a)Scope(ScopeType.STATELESS)
-@Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
-public class Parameters extends org.jboss.seam.web.Parameters
-{
-
- @Override
- protected Object convertRequestParameter(String requestParameter, Class type)
- {
- if ( String.class.equals(type) ) return requestParameter;
-
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (facesContext==null)
- {
- throw new IllegalStateException("No FacesContext associated with current thread, cannot convert request parameter type");
- }
- else
- {
- Converter converter = facesContext.getApplication().createConverter(type);
- if (converter==null)
- {
- throw new IllegalArgumentException("no converter for type: " + type);
- }
- UIViewRoot viewRoot = facesContext.getViewRoot();
- return converter.getAsObject(
- facesContext,
- viewRoot==null ? new UIViewRoot() : viewRoot, //have to pass something here, or get a totally useless NPE from JSF
- requestParameter );
- }
- }
-
- @Override
- public Map<String, String[]> getRequestParameters()
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if ( facesContext != null )
- {
- return facesContext.getExternalContext().getRequestParameterValuesMap();
- }
-
- return super.getRequestParameters();
- }
-
-}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/Redirect.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/Redirect.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/Redirect.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,204 +0,0 @@
-package org.jboss.seam.faces;
-
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.PerNestedConversation;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.core.AbstractMutable;
-import org.jboss.seam.core.Conversation;
-import org.jboss.seam.navigation.Pages;
-
-/**
- * Convenient API for performing browser redirects with
- * parameters.
- *
- * @author Gavin King
- */
-@Name("org.jboss.seam.faces.redirect")
-@BypassInterceptors
-(a)Scope(ScopeType.CONVERSATION)
-@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
-@PerNestedConversation
-public class Redirect extends AbstractMutable implements Serializable
-{
- private static final long serialVersionUID = 6947384474861235210L;
- private String viewId;
- private Map<String, Object> parameters = new HashMap<String, Object>();
- private boolean conversationPropagationEnabled = true;
- private boolean conversationBegun;
-
- /**
- * Get the JSF view id to redirect to
- */
- public String getViewId()
- {
- return viewId;
- }
-
- /**
- * Set the JSF view id to redirect to
- *
- * @param viewId any JSF view id
- */
- public void setViewId(String viewId)
- {
- setDirty(this.viewId, viewId);
- this.viewId = viewId;
- }
-
- /**
- * Get all the request parameters that have been set
- */
- public Map<String, Object> getParameters()
- {
- return parameters;
- }
-
- /**
- * Set a request parameter value (to set a multi-valued
- * request parameter, pass an array or collection as
- * the value)
- */
- public void setParameter(String name, Object value)
- {
- Object old = parameters.put(name, value);
- setDirty(old, value);
- }
-
- /**
- * Capture the view id and request parameters from the
- * current request and squirrel them away so we can
- * return here later in the conversation.
- *
- * @deprecated use captureCurrentView()
- */
- public void captureCurrentRequest()
- {
- parameters.clear();
- FacesContext context = FacesContext.getCurrentInstance();
- parameters.putAll( context.getExternalContext().getRequestParameterMap() );
- viewId = Pages.getViewId(context);
- setDirty();
- }
-
- /**
- * Capture the view id, request parameters and page parameters (which take
- * precedence) from the current request and squirrel them away so we can
- * return here later in the conversation. If no conversation is active,
- * begin a conversation. The conversation is terminated by {@link
- * Redirect#returnToCapturedView()} if begun by this method.
- *
- * @see Redirect#returnToCapturedView()
- */
- public void captureCurrentView()
- {
- FacesContext context = FacesContext.getCurrentInstance();
-
- // If this isn't a faces request then just return
- if (context == null) return;
-
- // first capture all request parameters
- parameters.putAll( context.getExternalContext().getRequestParameterMap() );
- // then preserve page parameters, overwriting request parameters with same names
- parameters.putAll( Pages.instance().getStringValuesFromPageContext(context) );
-
- // special case only needed for actionMethod if decide not to capture all request parameters
- //if (context.getExternalContext().getRequestParameterMap().containsKey("actionMethod"))
- //{
- // parameters.put("actionMethod", context.getExternalContext().getRequestParameterMap().get("actionMethod"));
- //}
-
- viewId = Pages.getViewId(context);
- conversationBegun = Conversation.instance().begin(true, false);
- setDirty();
- //if the request ends with an exception,
- //the conversation context never gets
- //flushed....
- Contexts.getConversationContext().flush();
- }
-
- /**
- * Should the conversation be propagated across the redirect?
- * @return true by default
- */
- public boolean isConversationPropagationEnabled()
- {
- return conversationPropagationEnabled;
- }
-
- /**
- * Note that conversations are propagated by default
- */
- public void setConversationPropagationEnabled(boolean conversationPropagationEnabled)
- {
- this.conversationPropagationEnabled = conversationPropagationEnabled;
- }
-
- /**
- * Perform the redirect
- */
- public void execute()
- {
- FacesManager.instance().redirect(viewId, parameters, conversationPropagationEnabled, true);
- }
-
- /**
- * Redirect to the captured view, and end any conversation
- * that began in captureCurrentView().
- *
- *@see Redirect#captureCurrentView()
- */
- public boolean returnToCapturedView()
- {
- if (viewId!=null)
- {
- if (conversationBegun)
- {
- Conversation.instance().end();
- }
- execute();
- return true;
- }
- else
- {
- return false;
- }
- }
-
- //TODO: replacement for Conversation.endAndRedirect()
- /*public boolean returnToParentView()
- {
- Manager manager = Manager.instance();
- String viewId = manager.getParentConversationViewId();
- if (viewId==null)
- {
- return false;
- }
- else
- {
- manager.redirect(viewId);
- return true;
- }
- }*/
-
- public static Redirect instance()
- {
- if ( !Contexts.isConversationContextActive() )
- {
- throw new IllegalStateException("No active conversation context");
- }
- return (Redirect) Component.getInstance(Redirect.class, ScopeType.CONVERSATION);
- }
-}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/Renderer.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/Renderer.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/Renderer.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,23 +0,0 @@
-package org.jboss.seam.faces;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-
-/**
- * A component for direct rendering of
- * templates. Especially useful with
- * Seam Mail.
- *
- */
-@Name("org.jboss.seam.faces.renderer")
-@Install(false)
-public abstract class Renderer
-{
- public abstract String render(String viewId);
-
- public static Renderer instance()
- {
- return (Renderer) Component.getInstance(Renderer.class);
- }
-}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/ResourceLoader.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/ResourceLoader.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/ResourceLoader.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,56 +0,0 @@
-package org.jboss.seam.faces;
-
-import static org.jboss.seam.annotations.Install.FRAMEWORK;
-
-import java.io.InputStream;
-import java.net.URL;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.util.FacesResources;
-
-/**
- * Access to application resources in tye JSF environment.
- *
- * @author Gavin King
- *
- */
-(a)Scope(ScopeType.STATELESS)
-@BypassInterceptors
-@Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
-@Name("org.jboss.seam.core.resourceLoader")
-public class ResourceLoader extends org.jboss.seam.core.ResourceLoader
-{
-
- @Override
- public InputStream getResourceAsStream(String resource)
- {
- javax.faces.context.FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
- if (context!=null)
- {
- return FacesResources.getResourceAsStream( resource, context.getExternalContext() );
- }
- else
- {
- return super.getResourceAsStream(resource);
- }
- }
-
- @Override
- public URL getResource(String resource)
- {
- javax.faces.context.FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
- if (context!=null)
- {
- return FacesResources.getResource( resource, context.getExternalContext() );
- }
- else
- {
- return super.getResource(resource);
- }
- }
-
-}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/Selector.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/Selector.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/Selector.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,122 +0,0 @@
-package org.jboss.seam.faces;
-
-import java.io.Serializable;
-
-import javax.faces.context.FacesContext;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jboss.seam.core.AbstractMutable;
-
-/**
- * Support for selector objects which remember their selection as a cookie
- *
- * @author Gavin King
- */
-public abstract class Selector extends AbstractMutable implements Serializable
-{
- public static final int DEFAULT_MAX_AGE = 31536000; // 1 year in seconds
- private boolean cookieEnabled;
- private int cookieMaxAge = DEFAULT_MAX_AGE;
- private String cookiePath= "/";
-
- /**
- * Is the cookie enabled?
- * @return false by default
- */
- public boolean isCookieEnabled()
- {
- return cookieEnabled;
- }
- public void setCookieEnabled(boolean cookieEnabled)
- {
- setDirty(this.cookieEnabled, cookieEnabled);
- this.cookieEnabled = cookieEnabled;
- }
- /**
- * The max age of the cookie
- * @return 1 year by default
- */
- public int getCookieMaxAge()
- {
- return cookieMaxAge;
- }
- public void setCookieMaxAge(int cookieMaxAge)
- {
- this.cookieMaxAge = cookieMaxAge;
- }
-
- public String getCookiePath()
- {
- return cookiePath;
- }
-
- public void setCookiePath(String cookiePath)
- {
- this.cookiePath = cookiePath;
- }
-
- /**
- * Override to define the cookie name
- */
- protected abstract String getCookieName();
-
- /**
- * Get the value of the cookie
- */
- protected String getCookieValueIfEnabled()
- {
- return isCookieEnabled() ?
- getCookieValue() : null;
- }
-
- protected Cookie getCookie()
- {
- FacesContext ctx = FacesContext.getCurrentInstance();
- if (ctx != null)
- {
- return (Cookie) ctx.getExternalContext().getRequestCookieMap()
- .get( getCookieName() );
- }
- else
- {
- return null;
- }
- }
-
- protected String getCookieValue()
- {
- Cookie cookie = getCookie();
- return cookie==null ? null : cookie.getValue();
- }
-
- protected void clearCookieValue()
- {
- Cookie cookie = getCookie();
- if ( cookie!=null )
- {
- HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
- cookie.setValue(null);
- cookie.setPath(cookiePath);
- cookie.setMaxAge(0);
- response.addCookie(cookie);
- }
- }
-
- /**
- * Set the cookie
- */
- protected void setCookieValueIfEnabled(String value)
- {
- FacesContext ctx = FacesContext.getCurrentInstance();
-
- if ( isCookieEnabled() && ctx != null)
- {
- HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();
- Cookie cookie = new Cookie( getCookieName(), value );
- cookie.setMaxAge( getCookieMaxAge() );
- cookie.setPath(cookiePath);
- response.addCookie(cookie);
- }
- }
-}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/Switcher.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/Switcher.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/Switcher.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,125 +0,0 @@
-package org.jboss.seam.faces;
-
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.faces.model.SelectItem;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.core.ConversationEntries;
-import org.jboss.seam.core.ConversationEntry;
-import org.jboss.seam.core.Manager;
-import org.jboss.seam.web.Session;
-
-/**
- * Support for the conversation switcher drop-down menu.
- *
- * @author Gavin King
- */
-(a)Scope(ScopeType.PAGE)
-@Name("org.jboss.seam.faces.switcher")
-@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
-@BypassInterceptors
-public class Switcher implements Serializable
-{
-
- private static final long serialVersionUID = -6403911073853051938L;
- private List<SelectItem> selectItems;
- private String conversationIdOrOutcome;
- private String resultingConversationIdOrOutcome;
-
- @Create
- public void createSelectItems()
- {
- ConversationEntries conversationEntries = ConversationEntries.getInstance();
- if (conversationEntries==null)
- {
- selectItems = Collections.EMPTY_LIST;
- }
- else
- {
- Set<ConversationEntry> orderedEntries = new TreeSet<ConversationEntry>();
- orderedEntries.addAll( conversationEntries.getConversationEntries() );
- selectItems = new ArrayList<SelectItem>( conversationEntries.size() );
- for ( ConversationEntry entry: orderedEntries )
- {
- if ( entry.isDisplayable() && !Session.instance().isInvalid() )
- {
- selectItems.add( new SelectItem( entry.getId(), entry.getDescription() ) );
- }
- }
- }
- }
-
- public List<SelectItem> getSelectItems()
- {
- return selectItems;
- }
-
- private String getLongRunningConversationId()
- {
- Manager manager = Manager.instance();
- if ( manager.isLongRunningConversation() )
- {
- return manager.getCurrentConversationId();
- }
- else if ( manager.isNestedConversation() )
- {
- return manager.getParentConversationId();
- }
- else
- {
- //TODO: is there any way to set it to the current outcome, instead of null?
- return null;
- }
- }
-
- public String getConversationIdOrOutcome()
- {
- return resultingConversationIdOrOutcome==null ?
- getLongRunningConversationId() :
- resultingConversationIdOrOutcome;
- }
-
- public void setConversationIdOrOutcome(String selectedId)
- {
- this.conversationIdOrOutcome = selectedId;
- }
-
- public String select()
- {
-
- boolean isOutcome = conversationIdOrOutcome==null ||
- (!Character.isDigit(conversationIdOrOutcome.charAt(0)) && conversationIdOrOutcome.indexOf(':') < 0);
-
- String actualOutcome;
- if (isOutcome)
- {
- resultingConversationIdOrOutcome = conversationIdOrOutcome;
- actualOutcome = conversationIdOrOutcome;
- }
- else
- {
- ConversationEntry ce = ConversationEntries.instance().getConversationEntry(conversationIdOrOutcome);
- if (ce!=null)
- {
- resultingConversationIdOrOutcome = ce.getId();
- ce.redirect();
- }
- actualOutcome = null;
- }
- return actualOutcome;
- }
-
-}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/UiComponent.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/UiComponent.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/UiComponent.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,81 +0,0 @@
-package org.jboss.seam.faces;
-
-import static org.jboss.seam.ScopeType.STATELESS;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.util.AbstractMap;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Unwrap;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-
-/**
- * Access to UIComponents in the current view, by id.
- *
- * @author Gavin King
- *
- */
-@Name("org.jboss.seam.faces.uiComponent")
-@BypassInterceptors
-@Scope(STATELESS)
-@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
-public class UiComponent
-{
-
- @Unwrap
- public Map<String, UIComponent> getViewComponents()
- {
- return new AbstractMap<String, UIComponent>()
- {
-
- @Override
- public boolean containsKey(Object key) {
- return get(key) != null;
- }
-
-
- @Override
- public Set<Map.Entry<String, UIComponent>> entrySet()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public UIComponent get(Object key)
- {
- if ( !(key instanceof String) ) return null;
- try
- {
- FacesContext context = FacesContext.getCurrentInstance();
-
- if (context == null) {
- return null;
- }
-
- UIViewRoot viewRoot = context.getViewRoot();
-
- if (viewRoot == null)
- {
- return null;
- }
-
- return viewRoot.findComponent( (String) key );
- }
- catch (IllegalArgumentException iae)
- {
- return null;
- }
- }
-
- };
- }
-
-}
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/UserPrincipal.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/UserPrincipal.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/UserPrincipal.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,30 +0,0 @@
-package org.jboss.seam.faces;
-
-import java.security.Principal;
-
-import javax.annotation.Named;
-import javax.context.ApplicationScoped;
-import javax.faces.context.FacesContext;
-
-/**
- * Manager component for the current user Principal
- * exposed via the JSF ExternalContext.
- *
- * @author Gavin King
- */
-@Named
-@ApplicationScoped
-public class UserPrincipal extends org.jboss.seam.web.UserPrincipal
-{
- @Unwrap @Override
- public Principal getUserPrincipal()
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if ( facesContext != null )
- {
- return facesContext.getExternalContext().getUserPrincipal();
- }
-
- return super.getUserPrincipal();
- }
-}
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/Validation.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/Validation.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/Validation.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -10,10 +10,11 @@
/**
* Allows the application to determine whether the JSF validation
* phase completed successfully, or if a validation failure
- * occurred.
+ * occurred. This functionality is actually provided by JSF 2 now.
+ * What this class does is raise a {@link ValidationFailedEvent}
+ * so that observers can react accordingly.
*
* @author Gavin king
- *
*/
@Named
public class Validation
@@ -25,8 +26,8 @@
public void afterProcessValidations(FacesContext facesContext)
{
- failed = facesContext.getRenderResponse();
- if (failed)
+ failed = facesContext.isValidationFailed();
+ if (failed)
{
manager.fireEvent(new ValidationFailedEvent());
}
Copied: modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/LocaleConfig.java (from rev 10661, modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleConfig.java)
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/LocaleConfig.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/LocaleConfig.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,128 @@
+package org.jboss.seam.faces.application;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.context.ApplicationScoped;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+import javax.inject.Initializer;
+
+/**
+ * FIXME update docs
+ * Configures the JSF locale support from the Seam container.
+ *
+ * <p>
+ * This component merely passes on configuration settings to the JSF runtime, so
+ * you still have to option of configure the locale support in the JSF
+ * configuration file. However, if you enable this component, it will overwrite
+ * any settings from that file.
+ * </p>
+ *
+ * <code>
+ * <i18n:locale-config default-locale="en" supported-locales="en fr de"/>
+ * </code>
+ *
+ * @author Dan Allen
+ */
+@ApplicationScoped
+public class LocaleConfig
+{
+ private String defaultLocale;
+
+ private List<String> supportedLocales;
+
+ @Initializer
+ public void initLocaleConfig()
+ {
+ Application application = getApplication();
+ if (application == null)
+ {
+ return;
+ }
+
+ String defaultAsString = getDefaultLocale();
+ if (defaultAsString != null)
+ {
+ application.setDefaultLocale(getLocaleFromString(defaultAsString));
+ }
+
+ List<String> supportedAsStrings = getSupportedLocales();
+ int numSupported = supportedAsStrings != null ? supportedAsStrings.size() : 0;
+ if (numSupported > 0)
+ {
+ // use set to prevent duplicates, yet retain order just to be nice
+ Set<java.util.Locale> locales = new LinkedHashSet<java.util.Locale>(numSupported);
+ for (String supportedAsString : supportedAsStrings)
+ {
+ locales.add(getLocaleFromString(supportedAsString));
+ }
+ application.setSupportedLocales(locales);
+ }
+ }
+
+ public String getDefaultLocale()
+ {
+ return defaultLocale;
+ }
+
+ public void setDefaultLocale(String defaultLocale)
+ {
+ this.defaultLocale = defaultLocale;
+ }
+
+ public List<String> getSupportedLocales()
+ {
+ return supportedLocales;
+ }
+
+ public void setSupportedLocales(List<String> supportedLocales)
+ {
+ this.supportedLocales = supportedLocales;
+ }
+
+ private java.util.Locale getLocaleFromString(String localeString)
+ {
+ if (localeString == null || localeString.length() < 2)
+ {
+ throw new IllegalArgumentException("Invalid locale string: " + localeString);
+ }
+
+ StringTokenizer tokens = new StringTokenizer(localeString, "-_");
+ String language = tokens.hasMoreTokens() ? tokens.nextToken() : null;
+ String country = tokens.hasMoreTokens() ? tokens.nextToken() : null;
+ String variant = tokens.hasMoreTokens() ? tokens.nextToken() : null;
+ if (variant != null && variant.length() > 0)
+ {
+ return new java.util.Locale(language, country, variant);
+ }
+ else if (country != null && country.length() > 0)
+ {
+ return new java.util.Locale(language, country);
+ }
+ else
+ {
+ return new java.util.Locale(language);
+ }
+ }
+
+ private Application getApplication()
+ {
+ try
+ {
+ ApplicationFactory factory = (ApplicationFactory) FactoryFinder
+ .getFactory(FactoryFinder.APPLICATION_FACTORY);
+ return factory.getApplication();
+ }
+ catch (IllegalStateException e)
+ {
+ // just in case, for units and the like
+ // if we can't do it, it just wan't meant to be
+ return null;
+ }
+ }
+
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamApplication.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamApplication.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamApplication.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.faces.application;
+
+import javax.el.ExpressionFactory;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationWrapper;
+import org.jboss.seam.el.SeamExpressionFactory;
+
+/**
+ * Proxies the JSF Application object, and adds all kinds
+ * of tasty extras.
+ *
+ * @author Gavin King
+ */
+public class SeamApplication extends ApplicationWrapper {
+
+ protected Application delegate;
+
+ public SeamApplication(Application delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public Application getWrapped() {
+ return delegate;
+ }
+
+ @Override
+ public ExpressionFactory getExpressionFactory() {
+ // TODO need to push SeamFacesELResolver into SeamEL composite resolver
+ return SeamExpressionFactory.INSTANCE;
+ }
+
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamApplicationFactory.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamApplicationFactory.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamApplicationFactory.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.faces.application;
+
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+
+/**
+ * Factory for SeamApplication (how could you possibly
+ * have figured that out without JavaDoc?)
+ *
+ * @see SeamApplication
+ * @author Gavin King
+ */
+public class SeamApplicationFactory extends ApplicationFactory {
+
+ private final ApplicationFactory delegate;
+
+ public SeamApplicationFactory(ApplicationFactory delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public Application getApplication()
+ {
+ return new SeamApplication(delegate.getApplication());
+ }
+
+ @Override
+ public void setApplication(Application application)
+ {
+ this.delegate.setApplication(application);
+ }
+
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/el/SeamFacesELResolver.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/el/SeamFacesELResolver.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/el/SeamFacesELResolver.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.faces.el;
+
+import javax.el.ELContext;
+import javax.faces.model.DataModel;
+import org.jboss.seam.el.AbstractELResolver;
+
+/**
+ * <p>An {@link ELResolver} implementation that adds magic properties
+ * to a JSF DataModel object.</p>
+ *
+ * <p>The following is a list of the magic properties:</p>
+ *
+ * <ul>
+ * <li>size - the size of the wrapped data</li>
+ * <li>empty - a boolean indicating whether the wrapped data is empty</li>
+ * </ul>
+ *
+ * <p>Assuming the variable <code>results</code> held a reference to a JSF
+ * DataModel, you could print out its size using the following expression:</p>
+ *
+ * <pre>#{results.size}</pre>
+ *
+ * @author Gavin King
+ * @author Dan Allen
+ */
+public class SeamFacesELResolver extends AbstractELResolver {
+
+ @Override
+ public Object getValue(ELContext context, Object base, Object property)
+ {
+ if (base instanceof DataModel)
+ {
+ return resolveInDataModel(context, base, property);
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ {
+ return (base instanceof DataModel);
+ }
+
+ private Object resolveInDataModel(ELContext context, Object base, Object property)
+ {
+ if ("size".equals(property))
+ {
+ context.setPropertyResolved(true);
+ return ((DataModel) base).getRowCount();
+ }
+ else if ("empty".equals(property))
+ {
+ context.setPropertyResolved(true);
+ return ((DataModel) base).getRowCount() == 0;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/StatusMessagesTranslator.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/StatusMessagesTranslator.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/StatusMessagesTranslator.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,38 @@
+package org.jboss.seam.faces.lifecycle;
+
+import java.beans.Introspector;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ComponentSystemEvent;
+import javax.faces.event.ComponentSystemEventListener;
+import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.international.StatusMessages;
+
+/**
+ * A {@link ComponentSystemEventListener} that observes the PreRenderViewEvent and
+ * transposes Seam StatusMessage objects into FacesMessage objects
+ * and stores them in the FacesContext.
+ *
+ * @author Dan Allen
+ */
+public class StatusMessagesTranslator implements ComponentSystemEventListener {
+
+ public void processEvent(ComponentSystemEvent preRenderViewEvent) throws AbortProcessingException
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ FacesMessages facesMessages = (FacesMessages) context.getApplication().getExpressionFactory()
+ .createValueExpression(getBeanExpression(StatusMessages.class), FacesMessages.class).getValue(context.getELContext());
+ facesMessages.beforeRenderView();
+ }
+
+ private String getBeanName(Class beanClass)
+ {
+ return beanClass.getPackage() + "." + Introspector.decapitalize(beanClass.getSimpleName());
+ }
+
+ private String getBeanExpression(Class beanClass)
+ {
+ return "#{" + getBeanName(beanClass) + "}";
+ }
+
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/ArrayDataModel.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/ArrayDataModel.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/ArrayDataModel.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,40 @@
+//$Id: ArrayDataModel.java 5372 2007-06-21 05:27:29Z gavin $
+package org.jboss.seam.faces.model;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/**
+ * A JSF DataModel for arrays.
+ *
+ * @author Gavin King
+ */
+public class ArrayDataModel extends javax.faces.model.ArrayDataModel implements
+ Serializable
+{
+ private static final long serialVersionUID = -1369792328129853864L;
+
+ public ArrayDataModel()
+ {
+ }
+
+ public ArrayDataModel(Object[] array)
+ {
+ super(array);
+ }
+
+ private void writeObject(ObjectOutputStream oos) throws IOException
+ {
+ oos.writeObject(getWrappedData());
+ oos.writeInt(getRowIndex());
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException,
+ ClassNotFoundException
+ {
+ this.setWrappedData(ois.readObject());
+ this.setRowIndex(ois.readInt());
+ }
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/ListDataModel.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/ListDataModel.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/ListDataModel.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,40 @@
+//$Id: ListDataModel.java 5372 2007-06-21 05:27:29Z gavin $
+package org.jboss.seam.faces.model;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * A JSF DataModel for lists - yes, I know, JSF has one, but its not
+ * serializable (go figure).
+ *
+ * @author Gavin King
+ */
+public class ListDataModel extends javax.faces.model.ListDataModel implements Serializable
+{
+ private static final long serialVersionUID = 5156131434571541698L;
+
+ public ListDataModel()
+ {
+ }
+
+ public ListDataModel(List list)
+ {
+ super(list);
+ }
+
+ private void writeObject(ObjectOutputStream oos) throws IOException
+ {
+ oos.writeObject(getWrappedData());
+ oos.writeInt(getRowIndex());
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException
+ {
+ this.setWrappedData(ois.readObject());
+ this.setRowIndex(ois.readInt());
+ }
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/MapDataModel.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/MapDataModel.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/MapDataModel.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,154 @@
+//$Id: MapDataModel.java 7579 2008-03-14 12:08:54Z pete.muir(a)jboss.org $
+package org.jboss.seam.faces.model;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.model.DataModelEvent;
+import javax.faces.model.DataModelListener;
+
+/**
+ * A JSF DataModel for maps.
+ *
+ * @author Gavin King
+ */
+public class MapDataModel extends javax.faces.model.DataModel implements
+ Serializable
+{
+ private static final long serialVersionUID = -4888962547222002402L;
+ private int rowIndex = -1;
+ private Map data;
+ private transient List<Map.Entry> entries;
+
+ public MapDataModel()
+ {
+ }
+
+ public MapDataModel(Map map)
+ {
+ if (map == null)
+ {
+ throw new IllegalArgumentException("null map data");
+ }
+ setWrappedData(map);
+ }
+
+ @Override
+ public int getRowCount()
+ {
+ if (entries == null)
+ {
+ return -1;
+ }
+ return entries.size();
+ }
+
+ /**
+ * Returns a Map.Entry
+ */
+ @Override
+ public Object getRowData()
+ {
+ if (entries == null)
+ {
+ return null;
+ }
+ if (!isRowAvailable())
+ {
+ throw new IllegalArgumentException("row is unavailable");
+ }
+ return entries.get(rowIndex);
+ }
+
+ @Override
+ public int getRowIndex()
+ {
+ return rowIndex;
+ }
+
+ @Override
+ public Object getWrappedData()
+ {
+ return new AbstractMap()
+ {
+ @Override
+ public Set entrySet()
+ {
+ return new AbstractSet()
+ {
+ @Override
+ public Iterator iterator()
+ {
+ return entries.iterator();
+ }
+
+ @Override
+ public int size()
+ {
+ return entries.size();
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public boolean isRowAvailable()
+ {
+ return entries != null &&
+ rowIndex >= 0 &&
+ rowIndex < entries.size();
+ }
+
+ @Override
+ public void setRowIndex(int newRowIndex)
+ {
+ if (newRowIndex < -1)
+ {
+ throw new IllegalArgumentException("illegal rowIndex " + newRowIndex);
+ }
+ int oldRowIndex = rowIndex;
+ rowIndex = newRowIndex;
+ if (entries != null && oldRowIndex != newRowIndex)
+ {
+ Object data = isRowAvailable() ? getRowData() : null;
+ DataModelEvent event = new DataModelEvent(this, newRowIndex, data);
+ DataModelListener[] listeners = getDataModelListeners();
+ for (int i = 0; i < listeners.length; i++)
+ {
+ listeners[i].rowSelected(event);
+ }
+ }
+ }
+
+ @Override
+ public void setWrappedData(Object data)
+ {
+ this.data = (Map) data;
+ entries = data == null ? null : new ArrayList(((Map) data).entrySet());
+ setRowIndex(data != null ? 0 : -1);
+ }
+
+ private void writeObject(ObjectOutputStream oos) throws IOException
+ {
+ oos.writeInt(rowIndex);
+ oos.writeObject(data);
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException,
+ ClassNotFoundException
+ {
+ rowIndex = ois.readInt();
+ data = (Map) ois.readObject();
+ entries = data == null ? null : new ArrayList(data.entrySet());
+ }
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/SetDataModel.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/SetDataModel.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/model/SetDataModel.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,139 @@
+//$Id: SetDataModel.java 7577 2008-03-14 11:47:09Z pete.muir(a)jboss.org $
+package org.jboss.seam.faces.model;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.model.DataModelEvent;
+import javax.faces.model.DataModelListener;
+
+/**
+ * A JSF DataModel for sets.
+ *
+ * @author Gavin King
+ */
+public class SetDataModel extends javax.faces.model.DataModel implements
+ Serializable
+{
+ private static final long serialVersionUID = -616367764778689337L;
+ private int rowIndex = -1;
+ private List entries;
+
+ public SetDataModel()
+ {
+ }
+
+ public SetDataModel(Set set)
+ {
+ if (set == null)
+ {
+ throw new IllegalArgumentException("null set data");
+ }
+ setWrappedData(set);
+ }
+
+ @Override
+ public int getRowCount()
+ {
+ if (entries == null)
+ {
+ return -1;
+ }
+ return entries.size();
+ }
+
+ @Override
+ public Object getRowData()
+ {
+ if (entries == null)
+ {
+ return null;
+ }
+ if (!isRowAvailable())
+ {
+ throw new IllegalArgumentException("row is unavailable");
+ }
+ return entries.get(rowIndex);
+ }
+
+ @Override
+ public int getRowIndex()
+ {
+ return rowIndex;
+ }
+
+ @Override
+ public Object getWrappedData()
+ {
+ return new AbstractSet()
+ {
+ @Override
+ public Iterator iterator()
+ {
+ return entries.iterator();
+ }
+
+ @Override
+ public int size()
+ {
+ return entries.size();
+ }
+ };
+ }
+
+ @Override
+ public boolean isRowAvailable()
+ {
+ return entries != null &&
+ rowIndex >= 0 &&
+ rowIndex < entries.size();
+ }
+
+ @Override
+ public void setRowIndex(int newRowIndex)
+ {
+ if (newRowIndex < -1)
+ {
+ throw new IllegalArgumentException("illegal rowIndex " + newRowIndex);
+ }
+ int oldRowIndex = rowIndex;
+ rowIndex = newRowIndex;
+ if (entries != null && oldRowIndex != newRowIndex)
+ {
+ Object data = isRowAvailable() ? getRowData() : null;
+ DataModelEvent event = new DataModelEvent(this, newRowIndex, data);
+ DataModelListener[] listeners = getDataModelListeners();
+ for (int i = 0; i < listeners.length; i++)
+ {
+ listeners[i].rowSelected(event);
+ }
+ }
+ }
+
+ @Override
+ public void setWrappedData(Object data)
+ {
+ entries = data == null ? null : new ArrayList((Set) data);
+ setRowIndex(data != null ? 0 : -1);
+ }
+
+ private void writeObject(ObjectOutputStream oos) throws IOException
+ {
+ oos.writeInt(rowIndex);
+ oos.writeObject(entries);
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException,
+ ClassNotFoundException
+ {
+ rowIndex = ois.readInt();
+ entries = (List) ois.readObject();
+ }
+}
Added: modules/trunk/faces/src/main/resources/META-INF/faces-config.xml
===================================================================
--- modules/trunk/faces/src/main/resources/META-INF/faces-config.xml (rev 0)
+++ modules/trunk/faces/src/main/resources/META-INF/faces-config.xml 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0"
+ id="seam-faces">
+
+ <ordering>
+ <after>web-beans</after>
+ </ordering>
+
+ <factory>
+ <application-factory>org.jboss.seam.faces.application.SeamApplicationFactory</application-factory>
+ </factory>
+
+ <application>
+ <el-resolver>org.jboss.seam.el.SeamELResolver</el-resolver>
+ <el-resolver>org.jboss.seam.faces.el.SeamFacesELResolver</el-resolver>
+ <system-event-listener>
+ <system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
+ <system-event-listener-class>org.jboss.seam.faces.lifecycle.StatusMessagesTranslator</system-event-listener-class>
+ </system-event-listener>
+ </application>
+
+</faces-config>
Modified: modules/trunk/international/pom.xml
===================================================================
--- modules/trunk/international/pom.xml 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/international/pom.xml 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,48 +1,44 @@
-<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>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>seam-parent</artifactId>
- <groupId>org.jboss.seam</groupId>
+ <groupId>org.jboss.seam</groupId>
<version>3.0.0-SNAPSHOT</version>
- </parent>
-
+ </parent>
+
<artifactId>seam-international</artifactId>
<packaging>jar</packaging>
<version>3.0.0-SNAPSHOT</version>
- <name>Seam Internationalization</name>
+ <name>Seam Internationalization Module</name>
<dependencies>
<dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>seam-el</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>jsr299-api</artifactId>
- </dependency>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>webbeans-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-faces</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-el</artifactId>
- </dependency>
+ <!-- provided? -->
+ </dependency>
</dependencies>
</project>
Added: modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java (rev 0)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,182 @@
+package org.jboss.seam.international;
+
+import org.jboss.seam.el.*;
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+import javax.context.Dependent;
+import javax.inject.Current;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
+/**
+ * Interpolates EL expressions in Strings
+ *
+ * @author Gavin King
+ */
+@Dependent
+public class Interpolator
+{
+ private static final LogProvider log = Logging.getLogProvider(Interpolator.class);
+
+ // QUESTION should this be Manager, then lookup by type?
+ @Current Expressions expressions;
+
+ @Current Locale locale;
+
+ /**
+ * Replace all EL expressions in the form #{...} with their evaluated
+ * values.
+ *
+ * @param string a template
+ * @return the interpolated string
+ */
+ public String interpolate(String string, Object... params)
+ {
+ if (params == null)
+ {
+ params = new Object[0];
+ }
+
+ if (params.length > 10)
+ {
+ throw new IllegalArgumentException("The number of parameters supplied (" + params.length + ") to the interpolator exceeds the limit of 10 parameters.");
+ }
+
+ if (string.indexOf('#') >= 0 || string.indexOf('{') >= 0)
+ {
+ string = interpolateExpressions(string, params);
+ }
+
+ return string;
+ }
+
+ private String interpolateExpressions(String string, Object... params)
+ {
+ StringTokenizer tokens = new StringTokenizer(string, "#{}", true);
+ StringBuilder builder = new StringBuilder(string.length());
+ try
+ {
+ while (tokens.hasMoreTokens())
+ {
+ String tok = tokens.nextToken();
+
+ if ("#".equals(tok) && tokens.hasMoreTokens())
+ {
+ String nextTok = tokens.nextToken();
+
+ while (nextTok.equals("#") && tokens.hasMoreTokens())
+ {
+ builder.append(tok);
+ nextTok = tokens.nextToken();
+ }
+
+ if ("{".equals(nextTok))
+ {
+ String expression = "#{" + tokens.nextToken() + "}";
+ try
+ {
+ Object value = expressions.createValueExpression(expression).getValue();
+ if (value != null)
+ {
+ builder.append(value);
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn("exception interpolating string: " + string, e);
+ }
+ tokens.nextToken(); // the trailing "}"
+
+ }
+ else if (nextTok.equals("#"))
+ {
+ // could be trailing #
+ builder.append("#");
+
+ }
+ else
+ {
+ int index;
+ try
+ {
+ index = Integer.parseInt(nextTok.substring(0, 1));
+ if (index >= params.length)
+ {
+ //log.warn("parameter index out of bounds: " + index + " in: " + string);
+ builder.append("#").append(nextTok);
+ }
+ else
+ {
+ builder.append(params[index]).append(nextTok.substring(1));
+ }
+ }
+ catch (NumberFormatException nfe)
+ {
+ builder.append("#").append(nextTok);
+ }
+ }
+ }
+ else if ("{".equals(tok))
+ {
+ StringBuilder expr = new StringBuilder();
+
+ expr.append(tok);
+ int level = 1;
+
+ while (tokens.hasMoreTokens())
+ {
+ String nextTok = tokens.nextToken();
+ expr.append(nextTok);
+
+ if (nextTok.equals("{"))
+ {
+ ++level;
+ }
+ else if (nextTok.equals("}"))
+ {
+ if (--level == 0)
+ {
+ try
+ {
+ if (params.length == 0)
+ {
+ builder.append(expr.toString());
+ }
+ else
+ {
+ String value = new MessageFormat(expr.toString(), locale).format(params);
+ builder.append(value);
+ }
+ }
+ catch (Exception e)
+ {
+ // if it is a bad message, use the expression itself
+ builder.append(expr);
+ }
+ expr = null;
+ break;
+ }
+ }
+ }
+
+ if (expr != null)
+ {
+ builder.append(expr);
+ }
+ }
+ else
+ {
+ builder.append(tok);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn("exception interpolating string: " + string, e);
+ }
+
+ return builder.toString();
+ }
+}
Deleted: modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleConfig.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleConfig.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleConfig.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,128 +0,0 @@
-package org.jboss.seam.international;
-
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import javax.context.ApplicationScoped;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.ApplicationFactory;
-import javax.inject.Initializer;
-import org.jboss.seam.international.util.Strings;
-
-/**
- * Configures the JSF locale support from the Seam container.
- *
- * <p>
- * This component merely passes on configuration settings to the JSF runtime, so
- * you still have to option of configure the locale support in the JSF
- * configuration file. However, if you enable this component, it will overwrite
- * any settings from that file.
- * </p>
- *
- * <code>
- * <i18n:locale-config default-locale="en" supported-locales="en fr de"/>
- * </code>
- *
- * @author Dan Allen
- */
-@ApplicationScoped
-public class LocaleConfig
-{
- private String defaultLocale;
-
- private List<String> supportedLocales;
-
- @Initializer
- public void initLocaleConfig()
- {
- Application application = getApplication();
- if (application == null)
- {
- return;
- }
-
- String defaultAsString = getDefaultLocale();
- if (defaultAsString != null)
- {
- application.setDefaultLocale(getLocaleFromString(defaultAsString));
- }
-
- List<String> supportedAsStrings = getSupportedLocales();
- int numSupported = supportedAsStrings != null ? supportedAsStrings.size() : 0;
- if (numSupported > 0)
- {
- // use set to prevent duplicates, yet retain order just to be nice
- Set<java.util.Locale> locales = new LinkedHashSet<java.util.Locale>(numSupported);
- for (String supportedAsString : supportedAsStrings)
- {
- locales.add(getLocaleFromString(supportedAsString));
- }
- application.setSupportedLocales(locales);
- }
- }
-
- public String getDefaultLocale()
- {
- return defaultLocale;
- }
-
- public void setDefaultLocale(String defaultLocale)
- {
- this.defaultLocale = defaultLocale;
- }
-
- public List<String> getSupportedLocales()
- {
- return supportedLocales;
- }
-
- public void setSupportedLocales(List<String> supportedLocales)
- {
- this.supportedLocales = supportedLocales;
- }
-
- private java.util.Locale getLocaleFromString(String localeString)
- {
- if (localeString == null || localeString.length() < 2)
- {
- throw new IllegalArgumentException("Invalid locale string: " + localeString);
- }
-
- StringTokenizer tokens = new StringTokenizer(localeString, "-_");
- String language = tokens.hasMoreTokens() ? tokens.nextToken() : null;
- String country = tokens.hasMoreTokens() ? tokens.nextToken() : null;
- String variant = tokens.hasMoreTokens() ? tokens.nextToken() : null;
- if (Strings.isEmpty(variant))
- {
- return new java.util.Locale(language, country, variant);
- }
- else if (Strings.isEmpty(country))
- {
- return new java.util.Locale(language, country);
- }
- else
- {
- return new java.util.Locale(language);
- }
- }
-
- private Application getApplication()
- {
- try
- {
- ApplicationFactory factory = (ApplicationFactory) FactoryFinder
- .getFactory(FactoryFinder.APPLICATION_FACTORY);
- return factory.getApplication();
- }
- catch (IllegalStateException e)
- {
- // just in case, for units and the like
- // if we can't do it, it just wan't meant to be
- return null;
- }
- }
-
-}
Added: modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java (rev 0)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,21 @@
+package org.jboss.seam.international;
+
+import javax.annotation.Named;
+import javax.inject.Produces;
+
+/**
+ * Producer component for the current locale. This base
+ * implementation simply returns the server default
+ * locale.
+ *
+ * @author Gavin King
+ */
+public class LocaleProducer
+{
+ public
+ @Produces
+ @Named java.util.Locale getLocale()
+ {
+ return java.util.Locale.getDefault();
+ }
+}
\ No newline at end of file
Deleted: modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleSelector.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleSelector.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleSelector.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,197 +0,0 @@
-package org.jboss.seam.international;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.StringTokenizer;
-
-import javax.annotation.Named;
-import javax.context.SessionScoped;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ValueChangeEvent;
-import javax.faces.model.SelectItem;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.Produces;
-import javax.inject.manager.Manager;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
-
-import org.jboss.seam.faces.Selector;
-import org.jboss.seam.international.events.LocaleSelectedEvent;
-import org.jboss.seam.international.util.Strings;
-
-/**
- * Selects the current user's locale
- *
- * @author Gavin King
- */
-@Named
-@SessionScoped
-public class LocaleSelector extends Selector
-{
- private static final long serialVersionUID = -6087667065688208261L;
-
- @Current Manager manager;
- @Current HttpServletRequest request;
-
- private String language;
- private String country;
- private String variant;
-
- @Initializer
- public void initLocale()
- {
- String localeString = getCookieValueIfEnabled();
- if (localeString!=null) setLocaleString(localeString);
- }
-
- @Override
- protected String getCookieName()
- {
- return "org.jboss.seam.core.Locale";
- }
-
- /**
- * Force the resource bundle to reload, using the current locale,
- * and raise the org.jboss.seam.localeSelected event.
- */
- public void select()
- {
- FacesContext.getCurrentInstance().getViewRoot().setLocale( getLocale() );
- //Contexts.removeFromAllContexts("org.jboss.seam.core.resourceBundle");
- Contexts.removeFromAllContexts("org.jboss.seam.international.messages");
-
- setCookieValueIfEnabled( getLocaleString() );
-
- manager.fireEvent(new LocaleSelectedEvent(getLocaleString()));
- }
-
- public void select(ValueChangeEvent event)
- {
- setLocaleString( (String) event.getNewValue() );
- select();
- }
-
- /**
- * Set the language and force resource bundle reload, useful for quick action links:
- * <tt><h:commandLink value="DE" action="#{localeSelector.selectLanguage('de')}"/>"/></tt>
- */
- public void selectLanguage(String language) {
- setLanguage(language);
- select();
- }
-
- public Locale calculateLocale(Locale jsfLocale)
- {
- if ( !Strings.isEmpty(variant) )
- {
- return new java.util.Locale(language, country, variant);
- }
- else if ( !Strings.isEmpty(country) )
- {
- return new java.util.Locale(language, country);
- }
- else if ( !Strings.isEmpty(language) )
- {
- return new java.util.Locale(language);
- }
- else
- {
- return jsfLocale;
- }
- }
-
- public void setLocale(Locale locale)
- {
- language = Strings.nullIfEmpty( locale.getLanguage() );
- country = Strings.nullIfEmpty( locale.getCountry() );
- variant = Strings.nullIfEmpty( locale.getVariant() );
- }
-
- public String getLocaleString()
- {
- return getLocale().toString();
- }
-
- public void setLocaleString(String localeString)
- {
- StringTokenizer tokens = new StringTokenizer(localeString, "-_");
- language = tokens.hasMoreTokens() ? tokens.nextToken() : null;
- country = tokens.hasMoreTokens() ? tokens.nextToken() : null;
- variant = tokens.hasMoreTokens() ? tokens.nextToken() : null;
- }
-
- public List<SelectItem> getSupportedLocales()
- {
- List<SelectItem> selectItems = new ArrayList<SelectItem>();
- Iterator<Locale> locales = FacesContext.getCurrentInstance().getApplication().getSupportedLocales();
- while ( locales.hasNext() )
- {
- Locale locale = locales.next();
- if ( !Strings.isEmpty( locale.getLanguage() ) )
- {
- selectItems.add( new SelectItem( locale.toString(), locale.getDisplayName(locale) ) );
- }
- }
- return selectItems;
- }
-
- /**
- * Get the selected locale
- */
- @Produces public Locale getLocale()
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (facesContext!=null)
- {
- //Note: this does a double dispatch back to LocaleSelector.calculateLocale()
- return facesContext.getApplication().getViewHandler().calculateLocale(facesContext);
- }
-
- if (request!=null)
- {
- return calculateLocale( request.getLocale() );
- }
-
- return calculateLocale( Locale.getDefault() );
- }
-
- public String getCountry()
- {
- if (country==null) return getLocale().getCountry();
- return country;
- }
-
- public void setCountry(String country)
- {
- setDirty(this.country, country);
- this.country = country;
- }
-
- public String getLanguage()
- {
- if (language==null) return getLocale().getLanguage();
- return language;
- }
-
- public void setLanguage(String language)
- {
- setDirty(this.language, language);
- this.language = language;
- }
-
- public String getVariant()
- {
- if (variant==null) return getLocale().getVariant();
- return variant;
- }
-
- public void setVariant(String variant)
- {
- setDirty(this.variant, variant);
- this.variant = variant;
- }
-
-}
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/Messages.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/Messages.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/Messages.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -25,5 +25,4 @@
@Inherited
public @interface Messages
{
-
}
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/MessagesProducer.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/MessagesProducer.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/MessagesProducer.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,108 +1,117 @@
-package org.jboss.seam.international;
-
-import java.util.AbstractMap;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-import javax.context.RequestScoped;
-import javax.inject.Current;
-import javax.inject.Produces;
-
-/**
- * Factory for a Map that contains interpolated messages defined in the
- * Seam ResourceBundle.
- *
- * @see org.jboss.seam.core.SeamResourceBundle
- *
- * @author Gavin King
- */
-public class MessagesProducer
-{
- //TODO: now we have ELResolver, it doesn't *have* to be a Map...
-
- @Current ResourceBundle bundle;
-
- protected Map createMap()
- {
- // AbstractMap uses the implementation of entrySet to perform all its
- // operations - for a resource bundle this is very inefficient for keys
- return new AbstractMap<String, String>()
- {
- @Override
- public String get(Object key)
- {
- if (key instanceof String)
- {
- String resourceKey = (String) key;
- String resource=null;
- if (bundle!=null)
- {
- try
- {
- resource = bundle.getString(resourceKey);
- }
- catch (MissingResourceException mre)
- {
- //Just swallow
- }
- }
- return resource==null ? resourceKey : resource;
- }
- else
- {
- return null;
- }
- }
-
- @Override
- public Set<Map.Entry<String, String>> entrySet()
- {
- Enumeration<String> keys = bundle.getKeys();
- Map<String, String> map = new HashMap<String, String>();
- while ( keys.hasMoreElements() )
- {
- String key = keys.nextElement();
- map.put( key, get(key) );
- }
- return Collections.unmodifiableSet(map.entrySet());
- }
-
- @Override
- public boolean containsKey(Object key)
- {
- return get(key) != null;
- }
-
- @Override
- public Set<String> keySet()
- {
- Enumeration<String> keys = bundle.getKeys();
- return new HashSet<String>(Collections.list(keys));
- }
-
- @Override
- public int size()
- {
- return keySet().size();
- }
-
- };
- }
-
- /**
- * Create the Map and cache it in the EVENT scope. No need to cache
- * it in the SESSION scope, since it is inexpensive to create.
- *
- * @return a Map that interpolates messages in the Seam ResourceBundle
- */
- @Produces @RequestScoped @Messages public Map<String, String> getMessages()
- {
- return createMap();
- }
-}
+package org.jboss.seam.international;
+
+import java.util.AbstractMap;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.inject.Current;
+import javax.inject.Produces;
+
+/**
+ * Factory for a Map that contains interpolated messages defined in the
+ * Seam ResourceBundle.
+ *
+ * @see SeamResourceBundle
+ *
+ * @author Gavin King
+ */
+public class MessagesProducer
+{
+ //TODO: now we have ELResolver, it doesn't *have* to be a Map...
+
+ @Current ResourceBundle bundle;
+
+ protected Map createMap()
+ {
+ // AbstractMap uses the implementation of entrySet to perform all its
+ // operations - for a resource bundle this is very inefficient for keys
+ return new AbstractMap<String, String>()
+ {
+ // FIXME disable temporarily
+ //private java.util.ResourceBundle bundle = ResourceBundleProducer.getBundle();
+ private java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("messages");
+
+ @Override
+ public String get(Object key)
+ {
+ if (key instanceof String)
+ {
+ String resourceKey = (String) key;
+ String resource=null;
+ if (bundle!=null)
+ {
+ try
+ {
+ resource = bundle.getString(resourceKey);
+ }
+ catch (MissingResourceException mre)
+ {
+ //Just swallow
+ }
+ }
+ return resource==null ? resourceKey : resource;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Override
+ public Set<Map.Entry<String, String>> entrySet()
+ {
+ Enumeration<String> keys = bundle.getKeys();
+ Map<String, String> map = new HashMap<String, String>();
+ while ( keys.hasMoreElements() )
+ {
+ String key = keys.nextElement();
+ map.put( key, get(key) );
+ }
+ return Collections.unmodifiableSet(map.entrySet());
+ }
+
+ @Override
+ public boolean containsKey(Object key)
+ {
+ return get(key) != null;
+ }
+
+ @Override
+ public Set<String> keySet()
+ {
+ Enumeration<String> keys = bundle.getKeys();
+ return new HashSet<String>(Collections.list(keys));
+ }
+
+ @Override
+ public int size()
+ {
+ return keySet().size();
+ }
+
+ };
+ }
+
+ /**
+ * Create the Map and cache it in the request scope. No need to cache
+ * it in the session scope, since it is inexpensive to create.
+ *
+ * @return a Map that interpolates messages in the Seam ResourceBundle
+ */
+ @Produces
+ @Named("org.jboss.seam.international.messages")
+ @RequestScoped
+ @Messages public Map<String, String> getMessages()
+ {
+ return createMap();
+ }
+
+}
Added: modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceBundle.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceBundle.java (rev 0)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceBundle.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -0,0 +1,24 @@
+package org.jboss.seam.international;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import javax.inject.BindingType;
+
+/**
+ * The binding type for the Seam resource bundle.
+ *
+ * @author Dan Allen
+ */
+public
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@Inherited
+@interface ResourceBundle {
+}
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceLoader.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceLoader.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceLoader.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,89 +1,186 @@
-package org.jboss.seam.international;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Locale;
-import java.util.MissingResourceException;
-
-import javax.context.Dependent;
-import javax.inject.Current;
-import javax.servlet.ServletContext;
-
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-import org.jboss.seam.international.util.Resources;
-import org.jboss.seam.international.util.Strings;
-
-/**
- * Access to application resources and resource bundles.
- *
- * @author Gavin King
- *
- */
-@Dependent
-public class ResourceLoader
-{
- private static final LogProvider log = Logging.getLogProvider(ResourceLoader.class);
-
- private String[] bundleNames = {"messages"};
-
- @Current ServletContext servletContext;
- @Current Locale locale;
-
- /**
- * The configurable list of delegate resource bundle names
- *
- * @return an array of resource bundle names
- */
- public String[] getBundleNames()
- {
- return bundleNames;
- }
-
- public void setBundleNames(String[] bundleNames)
- {
- this.bundleNames = bundleNames;
- }
-
- public InputStream getResourceAsStream(String resource)
- {
- return Resources.getResourceAsStream( resource, servletContext );
- }
-
- public URL getResource(String resource)
- {
- return Resources.getResource( resource, servletContext );
- }
-
- /**
- * Load a resource bundle by name (may be overridden by subclasses
- * who want to use non-standard resource bundle types).
- *
- * @param bundleName the name of the resource bundle
- * @return an instance of java.util.ResourceBundle
- */
- public java.util.ResourceBundle loadBundle(String bundleName)
- {
- try
- {
- java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(
- bundleName, locale,
- Thread.currentThread().getContextClassLoader()
- );
- log.debug("loaded resource bundle: " + bundleName);
- return bundle;
- }
- catch (MissingResourceException mre)
- {
- log.debug("resource bundle missing: " + bundleName);
- return null;
- }
- }
-
- @Override
- public String toString()
- {
- String concat = bundleNames==null ? "" : Strings.toString( ", ", (Object[]) bundleNames );
- return "ResourceBundle(" + concat + ")";
- }
-}
+package org.jboss.seam.international;
+
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import javax.context.Dependent;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
+/**
+ * Access to application resources and resource bundles.
+ *
+ * @author Gavin King
+ */
+@Dependent
+public class ResourceLoader
+{
+ private static final LogProvider log = Logging.getLogProvider(ResourceLoader.class);
+
+ private String[] bundleNames = { "messages" };
+
+ @Current Manager manager;
+
+ /**
+ * The configurable list of delegate resource bundle names
+ *
+ * @return an array of resource bundle names
+ */
+ public String[] getBundleNames()
+ {
+ return bundleNames;
+ }
+
+ public void setBundleNames(String[] bundleNames)
+ {
+ this.bundleNames = bundleNames;
+ }
+
+ public InputStream getResourceAsStream(String resource)
+ {
+ String relativePath = resource;
+ if (resource.startsWith("/"))
+ {
+ relativePath = resource.substring(1);
+ }
+ else
+ {
+ resource = "/" + resource;
+ }
+
+ return getResourceAsStream(resource, relativePath);
+ }
+
+ public URL getResource(String resource)
+ {
+ String relativePath = resource;
+ if (resource.startsWith("/"))
+ {
+ relativePath = resource.substring(1);
+ }
+ else
+ {
+ resource = "/" + resource;
+ }
+
+ return getResource(resource, relativePath);
+ }
+
+ /**
+ * Load a resource bundle by name (may be overridden by subclasses
+ * who want to use non-standard resource bundle types).
+ *
+ * @param bundleName the name of the resource bundle
+ * @return an instance of java.util.ResourceBundle
+ */
+ public java.util.ResourceBundle loadBundle(String bundleName)
+ {
+ try
+ {
+ java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(
+ bundleName,
+ manager.getInstanceByType(Locale.class),
+ Thread.currentThread().getContextClassLoader()
+ );
+ log.debug("loaded resource bundle: " + bundleName);
+ return bundle;
+ }
+ catch (MissingResourceException mre)
+ {
+ log.debug("resource bundle missing: " + bundleName);
+ return null;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder report = new StringBuilder("bundleNames = {");
+ boolean first = true;
+ if (bundleNames != null)
+ {
+ for (Object bundleName : bundleNames)
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ report.append(", ");
+ }
+ report.append(bundleName);
+ }
+ }
+ report.append("}");
+
+ return "ResourceBundle(" + report + ")";
+ }
+
+ protected InputStream getResourceAsStream(String path, String relativePath)
+ {
+ InputStream stream = null;
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ if (classLoader != null)
+ {
+ stream = classLoader.getResourceAsStream(relativePath);
+ if (stream != null)
+ {
+ log.debug("Loaded resource from context classloader: " + relativePath);
+ return stream;
+ }
+ }
+
+ stream = getClass().getResourceAsStream(path);
+ if (stream != null)
+ {
+ log.debug("Loaded resource from Seam classloader: " + path);
+ return stream;
+ }
+
+ stream = getClass().getClassLoader().getResourceAsStream(relativePath);
+ if (stream != null)
+ {
+ log.debug("Loaded resource from Seam classloader: " + relativePath);
+ return stream;
+ }
+
+ return stream;
+ }
+
+ protected URL getResource(String path, String relativePath)
+ {
+ URL url = null;
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ if (classLoader != null)
+ {
+ url = classLoader.getResource(relativePath);
+ if (url != null)
+ {
+ log.debug("Loaded resource from context classloader: " + url);
+ return url;
+ }
+ }
+
+ url = getClass().getResource(path);
+ if (url != null)
+ {
+ log.debug("Loaded resource from Seam classloader: " + url);
+ return url;
+ }
+
+ url = getClass().getClassLoader().getResource(relativePath);
+ if (url != null)
+ {
+ log.debug("Loaded resource from Seam classloader: " + url);
+ return url;
+ }
+
+ return url;
+ }
+
+}
Deleted: modules/trunk/international/src/main/java/org/jboss/seam/international/SeamResourceBundle.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/SeamResourceBundle.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/SeamResourceBundle.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,158 +0,0 @@
-package org.jboss.seam.international;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.inject.Current;
-
-import org.jboss.seam.el.Interpolator;
-
-/**
- * The Seam resource bundle which searches for resources in delegate resource
- * bundles specified in pages.xml, and a configurable list of delegate resource
- * bundles specified in components.xml.
- *
- * @see ResourceLoader
- * @author Gavin King
- *
- */
-public class SeamResourceBundle extends java.util.ResourceBundle
-{
- private Map<Locale, List<ResourceBundle>> bundleCache = new ConcurrentHashMap<Locale, List<ResourceBundle>>();
-
- @Current Locale locale;
- @Current Interpolator interpolator;
- @Current ResourceLoader resourceLoader;
-
- /**
- * Get an instance for the current Seam Locale
- *
- * @see Locale
- *
- * @return a SeamResourceBundle
- */
- public java.util.ResourceBundle getBundle()
- {
- return java.util.ResourceBundle.getBundle(SeamResourceBundle.class.getName(), locale);
- }
-
-
- public java.util.ResourceBundle getBundleNamed(String bundleName)
- {
- return java.util.ResourceBundle.getBundle(bundleName, locale);
- }
-
-
- private List<java.util.ResourceBundle> getBundlesForCurrentLocale()
- {
- List<ResourceBundle> bundles = bundleCache.get(locale);
- if ( bundles==null )
- {
- bundles = loadBundlesForCurrentLocale();
- bundleCache.put(locale, bundles);
- }
- return bundles;
-
- }
-
- private List<ResourceBundle> loadBundlesForCurrentLocale()
- {
- List<ResourceBundle> bundles = new ArrayList<ResourceBundle>();
- for (String bundleName : resourceLoader.getBundleNames())
- {
- ResourceBundle bundle = resourceLoader.loadBundle(bundleName);
- if (bundle != null) bundles.add(bundle);
- }
- ResourceBundle bundle = resourceLoader.loadBundle("ValidatorMessages");
- if (bundle != null)
- {
- bundles.add(bundle);
- }
- bundle = resourceLoader.loadBundle("org/hibernate/validator/resources/DefaultValidatorMessages");
- if (bundle != null) bundles.add(bundle);
- bundle = resourceLoader.loadBundle("javax.faces.Messages");
- if (bundle != null) bundles.add(bundle);
- return Collections.unmodifiableList(bundles);
- }
-
- @Override
- public Enumeration<String> getKeys()
- {
- List<java.util.ResourceBundle> pageBundles = getPageResourceBundles();
- List<ResourceBundle> bundles = getBundlesForCurrentLocale();
- Enumeration<String>[] enumerations = new Enumeration[bundles.size() + pageBundles.size()];
-
- int i = 0;
- for (java.util.ResourceBundle bundle: pageBundles) {
- enumerations[i++] = bundle.getKeys();
- }
-
- for (ResourceBundle bundle: bundles) {
- enumerations[i++] = bundle.getKeys();
- }
-
- return new EnumerationEnumeration<String>(enumerations);
- }
-
- @Override
- protected Object handleGetObject(String key)
- {
- List<java.util.ResourceBundle> pageBundles = getPageResourceBundles();
- for (java.util.ResourceBundle pageBundle : pageBundles)
- {
- try
- {
- return interpolate(pageBundle.getObject(key));
- }
- catch (MissingResourceException mre) {}
- }
-
- for (java.util.ResourceBundle littleBundle : getBundlesForCurrentLocale())
- {
- try
- {
- return interpolate( littleBundle.getObject(key) );
- }
- catch (MissingResourceException mre) {}
- }
-
- return null; // superclass is responsible for throwing MRE
- }
-
- private Object interpolate(Object message)
- {
- return message!=null && message instanceof String ?
- interpolator.interpolate( (String) message ) :
- message;
- }
-
- private List<java.util.ResourceBundle> getPageResourceBundles()
- {
- // TODO: oops! A hard dependency to JSF!
- String viewId = Pages.getCurrentViewId();
- if (viewId != null)
- {
- // we can't cache these bundles, since the viewId
- // may change in the middle of a request
- return Pages.instance().getResourceBundles(viewId);
- }
- else
- {
- return Collections.EMPTY_LIST;
- }
- }
-
- @Override
- public Locale getLocale()
- {
- return locale;
- }
-
-}
\ No newline at end of file
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessage.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessage.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessage.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -4,10 +4,6 @@
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import javax.inject.Current;
-
-import org.jboss.seam.el.Interpolator;
-import org.jboss.seam.core.SeamResourceBundle;
import org.jboss.seam.international.util.Strings;
/**
@@ -15,30 +11,26 @@
* in the view layer
*
* @author Pete Muir
- *
*/
public class StatusMessage implements Serializable
{
- @Current Interpolator interpolator;
-
/**
* The severity of the status message
*
*/
public enum Severity
{
- INFO,
- WARN,
- ERROR,
+ INFO,
+ WARN,
+ ERROR,
FATAL;
}
-
private String summaryTemplate;
private String summary;
private String detailTemplate;
private String detail;
private Severity severity = Severity.INFO;
-
+
/**
* Create a status message, looking up the message in the resource bundle
* using the provided key. If the message is found, it is used, otherwise,
@@ -49,18 +41,18 @@
{
this.summaryTemplate = getBundleMessage(key, defaultMessageTemplate);
this.detailTemplate = getBundleMessage(detailKey, defaultMessageDetailTemplate);
- if ( !Strings.isEmpty(summaryTemplate) )
+ if (!Strings.isEmpty(summaryTemplate))
{
this.severity = severity;
}
}
-
+
public boolean isEmpty()
{
return Strings.isEmpty(summary) && Strings.isEmpty(summaryTemplate);
}
-
- public void interpolate(Object... params)
+
+ public void interpolate(Interpolator interpolator, Object... params)
{
if (!Strings.isEmpty(summaryTemplate))
{
@@ -80,7 +72,7 @@
{
return summary;
}
-
+
/**
* Get the message severity
*/
@@ -88,38 +80,42 @@
{
return severity;
}
-
+
public String getDetail()
{
return detail;
}
-
+
public static String getBundleMessage(String key, String defaultMessageTemplate)
{
String messageTemplate = defaultMessageTemplate;
- if ( key!=null )
+ if (key != null)
{
- ResourceBundle resourceBundle = SeamResourceBundle.getBundle();
- if ( resourceBundle!=null )
+ //FIXME disable temporarily
+ //ResourceBundle resourceBundle = ResourceBundleProducer.getBundle();
+ ResourceBundle resourceBundle = ResourceBundle.getBundle("messages");
+ if (resourceBundle != null)
{
try
{
String bundleMessage = resourceBundle.getString(key);
- if (bundleMessage!=null)
+ if (bundleMessage != null)
{
messageTemplate = bundleMessage;
}
}
- catch (MissingResourceException mre) {} //swallow
+ catch (MissingResourceException mre)
+ {
+ //swallow
+ }
}
}
return messageTemplate;
}
-
+
@Override
public String toString()
{
- return "[" + severity + "] " + summary + " (" + detail +")";
+ return "[" + severity + "] " + summary + " (" + detail + ")";
}
-
}
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -9,6 +9,10 @@
import java.util.List;
import java.util.Map;
+import javax.annotation.Named;
+import javax.context.ConversationScoped;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
import javax.validation.ConstraintViolation;
import org.jboss.seam.international.StatusMessage.Severity;
@@ -17,29 +21,32 @@
* a concrete implementation.
*
* @author Pete Muir
- *
*/
-public abstract class StatusMessages implements Serializable
+public
+@Named("org.jboss.seam.international.statusMessages")
+@ConversationScoped
+class StatusMessages implements Serializable
{
private static final long serialVersionUID = -5395975397632138270L;
-
- public static final String COMPONENT_NAME = "org.jboss.seam.international.statusMessages";
-
+
private List<StatusMessage> messages = new ArrayList<StatusMessage>();
+
private Map<String, List<StatusMessage>> keyedMessages = new HashMap<String, List<StatusMessage>>();
-
+
private transient List<Runnable> tasks;
+ protected @Current Manager manager;
+
protected List<StatusMessage> getMessages()
{
return messages;
}
-
+
protected Map<String, List<StatusMessage>> getKeyedMessages()
{
return keyedMessages;
}
-
+
/**
* Clear all status messages
*/
@@ -48,17 +55,17 @@
messages.clear();
keyedMessages.clear();
}
-
+
public void clearKeyedMessages(String id)
{
keyedMessages.remove(id);
}
-
+
public void clearGlobalMessages()
{
messages.clear();
}
-
+
/**
* Add a status message, looking up the message in the resource bundle
* using the provided key. If the message is found, it is used, otherwise,
@@ -73,19 +80,16 @@
{
messages.add(message);
getTasks().add(
- new Runnable()
+ new Runnable()
+ {
+ public void run()
{
-
- public void run()
- {
- message.interpolate(params);
- }
-
+ message.interpolate(manager.getInstanceByType(Interpolator.class), params);
}
- );
+ });
}
}
-
+
/**
* Add a status message, looking up the message in the resource bundle
* using the provided key. If the message is found, it is used, otherwise,
@@ -102,7 +106,7 @@
{
final StatusMessage message = new StatusMessage(severity, key, null, messageTemplate, null);
if (!message.isEmpty())
- {
+ {
if (keyedMessages.containsKey(id))
{
keyedMessages.get(id).add(message);
@@ -114,17 +118,14 @@
keyedMessages.put(id, list);
}
getTasks().add(
- new Runnable()
+ new Runnable()
+ {
+ public void run()
{
-
- public void run()
- {
- message.interpolate(params);
- }
-
+ message.interpolate(manager.getInstanceByType(Interpolator.class), params);
}
- );
- }
+ });
+ }
}
/**
@@ -306,7 +307,7 @@
*/
public void add(ConstraintViolation[] cvs)
{
- for (ConstraintViolation cv: cvs)
+ for (ConstraintViolation cv : cvs)
{
add(cv);
}
@@ -320,7 +321,7 @@
*/
public void addToControls(ConstraintViolation[] cvs)
{
- for (ConstraintViolation cv: cvs)
+ for (ConstraintViolation cv : cvs)
{
addToControl(cv);
}
@@ -332,7 +333,7 @@
*/
public void add(ConstraintViolation cv)
{
- add( WARN, cv.getMessage() );
+ add(WARN, cv.getMessage());
}
/**
@@ -344,7 +345,7 @@
public void addToControl(ConstraintViolation cv)
{
String propertyName = cv.getPropertyPath().substring(cv.getPropertyPath().lastIndexOf(".") + 1);
- addToControl( propertyName, cv );
+ addToControl(propertyName, cv);
}
/**
@@ -355,9 +356,9 @@
*/
public void addToControl(String id, ConstraintViolation cv)
{
- addToControl( id, WARN, cv.getMessage() );
+ addToControl(id, WARN, cv.getMessage());
}
-
+
private List<Runnable> getTasks()
{
if (tasks == null)
@@ -366,14 +367,16 @@
}
return tasks;
}
-
+
protected void doRunTasks()
{
- if (tasks!=null)
+ if (tasks != null)
{
- for (Runnable task: tasks) task.run();
+ for (Runnable task : tasks)
+ {
+ task.run();
+ }
tasks.clear();
}
}
-
}
Deleted: modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZoneSelector.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZoneSelector.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZoneSelector.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -1,95 +0,0 @@
-package org.jboss.seam.international;
-
-import javax.annotation.Named;
-import javax.context.SessionScoped;
-import javax.faces.event.ValueChangeEvent;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.Produces;
-import javax.inject.manager.Manager;
-
-import org.jboss.seam.faces.Selector;
-import org.jboss.seam.international.events.TimeZoneSelectedEvent;
-
-/**
- * Selects the current user's time zone, defaulting
- * to the server time zone.
- *
- * @author Gavin King
- */
-@SessionScoped
-public class TimeZoneSelector extends Selector
-{
- private static final long serialVersionUID = -5013819375360015369L;
-
- private String id;
-
- @Current Manager manager;
-
- @Initializer
- public void initTimeZone()
- {
- String timeZoneId = getCookieValueIfEnabled();
- if (timeZoneId!=null) setTimeZoneId(timeZoneId);
- }
-
- @Override
- protected String getCookieName()
- {
- return "org.jboss.seam.core.TimeZone";
- }
-
- /**
- * Force the resource bundle to reload, using the current locale,
- * and raise the org.jboss.seam.timeZoneSelected event
- */
- public void select()
- {
- setCookieValueIfEnabled( getTimeZoneId() );
-
- manager.fireEvent(new TimeZoneSelectedEvent(getTimeZoneId()));
- }
-
- public void select(ValueChangeEvent event)
- {
- selectTimeZone( (String) event.getNewValue() );
- }
-
- public void selectTimeZone(String timeZoneId)
- {
- setTimeZoneId(timeZoneId);
- select();
- }
-
- public void setTimeZone(java.util.TimeZone timeZone)
- {
- setTimeZoneId( timeZone.getID() );
- }
-
- public void setTimeZoneId(String id)
- {
- setDirty(this.id, id);
- this.id = id;
- }
-
- public String getTimeZoneId()
- {
- return id;
- }
-
- /**
- * Get the selected timezone
- */
- @Produces @Named public java.util.TimeZone getTimeZone()
- {
- if (id==null)
- {
- return java.util.TimeZone.getDefault();
- }
- else
- {
- return java.util.TimeZone.getTimeZone( getTimeZoneId() );
- }
- }
-
-}
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZonesProducer.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZonesProducer.java 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZonesProducer.java 2009-04-28 06:04:29 UTC (rev 10668)
@@ -52,7 +52,10 @@
});
}
- @Produces @ApplicationScoped @TimeZones public List<TimeZone> getTimeZones() {
+ @Produces
+ @ApplicationScoped
+ @TimeZones
+ public List<TimeZone> getTimeZones() {
return timeZones;
}
Modified: modules/trunk/parent/pom.xml
===================================================================
--- modules/trunk/parent/pom.xml 2009-04-28 05:40:43 UTC (rev 10667)
+++ modules/trunk/parent/pom.xml 2009-04-28 06:04:29 UTC (rev 10668)
@@ -2,11 +2,6 @@
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>
-
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-parent</artifactId>
- <packaging>pom</packaging>
- <version>3.0.0-SNAPSHOT</version>
<parent>
<groupId>org.jboss.seam</groupId>
@@ -14,6 +9,10 @@
<version>3.0.0-SNAPSHOT</version>
</parent>
+ <artifactId>seam-parent</artifactId>
+ <packaging>pom</packaging>
+ <version>3.0.0-SNAPSHOT</version>
+
<name>JBoss Seam</name>
<url>http://www.seamframework.org</url>
15 years
Seam SVN: r10667 - modules/trunk/jsf-upgrade-tool.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-28 01:40:43 -0400 (Tue, 28 Apr 2009)
New Revision: 10667
Modified:
modules/trunk/jsf-upgrade-tool/pom.xml
Log:
JSF version moved to version-matrix
Modified: modules/trunk/jsf-upgrade-tool/pom.xml
===================================================================
--- modules/trunk/jsf-upgrade-tool/pom.xml 2009-04-28 05:40:23 UTC (rev 10666)
+++ modules/trunk/jsf-upgrade-tool/pom.xml 2009-04-28 05:40:43 UTC (rev 10667)
@@ -43,7 +43,7 @@
<rules>
<requireProperty>
<property>jboss.home</property>
- <message>Please set the JBOSS_HOME environment variable or set the jboss.home property in an active profile in your Maven 2 settings configuration</message>
+ <message>Please set the JBOSS_HOME environment variable or set the jboss.home property in an active profile in the Maven 2 settings.xml file</message>
</requireProperty>
<requireFilesExist>
<files>
@@ -90,13 +90,11 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>2.0.0-PR2</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>2.0.0-PR2</version>
</dependency>
</dependencies>
15 years
Seam SVN: r10666 - modules/trunk/version-matrix.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-28 01:40:23 -0400 (Tue, 28 Apr 2009)
New Revision: 10666
Modified:
modules/trunk/version-matrix/pom.xml
Log:
set JSF version to 2.0.0-PR2_1
don't need Facelets dependency
use properties for org.jboss.seam groupId
Modified: modules/trunk/version-matrix/pom.xml
===================================================================
--- modules/trunk/version-matrix/pom.xml 2009-04-28 02:45:45 UTC (rev 10665)
+++ modules/trunk/version-matrix/pom.xml 2009-04-28 05:40:23 UTC (rev 10666)
@@ -120,13 +120,13 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_10</version>
+ <version>2.0.0-PR2_1</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_10</version>
+ <version>2.0.0-PR2_1</version>
</dependency>
<dependency>
@@ -136,12 +136,6 @@
</dependency>
<dependency>
- <groupId>com.sun.facelets</groupId>
- <artifactId>jsf-facelets</artifactId>
- <version>1.1.15.B1</version>
- </dependency>
-
- <dependency>
<groupId>javax.el</groupId>
<artifactId>el-ri</artifactId>
<version>1.2</version>
@@ -196,19 +190,19 @@
</dependency>
<dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-el</artifactId>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>seam-bpm</artifactId>
<version>${seam.version}</version>
</dependency>
<dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-bpm</artifactId>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>seam-el</artifactId>
<version>${seam.version}</version>
</dependency>
<dependency>
- <groupId>org.jboss.seam</groupId>
+ <groupId>${project.groupId}</groupId>
<artifactId>seam-international</artifactId>
<version>${seam.version}</version>
</dependency>
15 years