[seam-commits] Seam SVN: r12372 - in modules/international/trunk: core and 19 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Fri Apr 2 09:38:52 EDT 2010
Author: kenfinni
Date: 2010-04-02 09:38:51 -0400 (Fri, 02 Apr 2010)
New Revision: 12372
Added:
modules/international/trunk/core/
modules/international/trunk/core/pom.xml
modules/international/trunk/core/src/
modules/international/trunk/core/src/main/
modules/international/trunk/core/src/main/java/
modules/international/trunk/core/src/main/java/org/
modules/international/trunk/core/src/main/java/org/jboss/
modules/international/trunk/core/src/main/java/org/jboss/seam/
modules/international/trunk/core/src/main/java/org/jboss/seam/international/
modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/
modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/AvailableTimeZones.java
modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/DefaultTimeZone.java
modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/DefaultTimeZoneProducer.java
modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/TimeZoneWrapper.java
modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/TimeZones.java
modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/UserTimeZone.java
modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/UserTimeZoneProducer.java
modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/events/
modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/events/TimeZoneSelectedEvent.java
modules/international/trunk/core/src/main/resources/
modules/international/trunk/core/src/main/resources/META-INF/
modules/international/trunk/core/src/main/resources/META-INF/beans.xml
modules/international/trunk/core/src/test/
modules/international/trunk/core/src/test/java/
modules/international/trunk/core/src/test/java/org/
modules/international/trunk/core/src/test/java/org/jboss/
modules/international/trunk/core/src/test/java/org/jboss/seam/
modules/international/trunk/core/src/test/java/org/jboss/seam/international/
modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/
modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/AvailableTimeZoneBean.java
modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/AvailableTimeZonesTest.java
modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/DefaultTimeZoneTest.java
modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/UserTimeZoneTest.java
modules/international/trunk/core/src/test/jboss-resources/
modules/international/trunk/core/src/test/jboss-resources/jndi.properties
modules/international/trunk/core/src/test/resources/
modules/international/trunk/docs/
modules/international/trunk/examples/
Removed:
modules/international/trunk/src/
Modified:
modules/international/trunk/pom.xml
Log:
Restructured International module to follow pattern of others
Property changes on: modules/international/trunk/core
___________________________________________________________________
Name: svn:ignore
+ .settings
.classpath
.project
target
Added: modules/international/trunk/core/pom.xml
===================================================================
--- modules/international/trunk/core/pom.xml (rev 0)
+++ modules/international/trunk/core/pom.xml 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,41 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.seam.international</groupId>
+ <artifactId>seam-international-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.jboss.seam.international</groupId>
+ <artifactId>seam-international-core</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Seam International Core</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-weld-embedded</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/AvailableTimeZones.java
===================================================================
--- modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/AvailableTimeZones.java (rev 0)
+++ modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/AvailableTimeZones.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,65 @@
+package org.jboss.seam.international.timezone;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.TimeZone;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+/**
+ * <p>Seam component that provides a list of time zones, limited to time zones
+ * with IDs in the form Continent/Place, excluding deprecated three-letter time
+ * zone IDs. The time zones returned have a fixed offset from UTC, which takes
+ * daylight savings time into account. For example, Europe/Amsterdam is UTC+1;
+ * in winter this is GMT+1 and in summer GMT+2.</p>
+ *
+ * <p>The time zone objects returned are wrapped in an implementation of
+ * TimeZone that provides a more friendly interface for accessing the time zone
+ * information. In particular, this type provides a more bean-friend property
+ * for the time zone id (id than ID) and provides a convenience property named
+ * label that formats the time zone for display in the UI. This wrapper can be
+ * disabled by setting the component property wrap to false.</p>
+ *
+ * @author Peter Hilton, Lunatech Research
+ * @author Dan Allen
+ */
+ at ApplicationScoped
+public class AvailableTimeZones
+{
+ private static final String TIMEZONE_ID_PREFIXES =
+ "^(Africa|America|Asia|Atlantic|Australia|Europe|Indian|Pacific)/.*";
+
+ private boolean wrap = true;
+
+ @Produces
+ @TimeZones
+ private List<TimeZone> timeZones = null;
+
+ @Inject
+ public void init() {
+ timeZones = new ArrayList<TimeZone>();
+ final String[] timeZoneIds = TimeZone.getAvailableIDs();
+ for (final String id : timeZoneIds) {
+ if (id.matches(TIMEZONE_ID_PREFIXES)) {
+ timeZones.add(wrap ? new TimeZoneWrapper(TimeZone.getTimeZone(id)) : TimeZone.getTimeZone(id));
+ }
+ }
+ Collections.sort(timeZones, new Comparator<TimeZone>() {
+ public int compare(final TimeZone a, final TimeZone b) {
+ return a.getID().compareTo(b.getID());
+ }
+ });
+ }
+
+ public boolean isWrap() {
+ return wrap;
+ }
+
+ public void setWrap(boolean wrap) {
+ this.wrap = wrap;
+ }
+}
Added: modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/DefaultTimeZone.java
===================================================================
--- modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/DefaultTimeZone.java (rev 0)
+++ modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/DefaultTimeZone.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,27 @@
+package org.jboss.seam.international.timezone;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+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.Qualifier;
+
+/**
+ * Default Application TimeZone
+ *
+ * @author Ken Finnigan
+ */
+ at Target( { METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at Qualifier
+ at Inherited
+public @interface DefaultTimeZone
+{
+}
Added: modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/DefaultTimeZoneProducer.java
===================================================================
--- modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/DefaultTimeZoneProducer.java (rev 0)
+++ modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/DefaultTimeZoneProducer.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,32 @@
+package org.jboss.seam.international.timezone;
+
+import java.io.Serializable;
+import java.util.TimeZone;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * Default TimeZone of the application. If configuration of the default
+ * TimeZone is found that will be used, otherwise the JVM default TimeZone
+ * otherwise.
+ *
+ * @author Ken Finnigan
+ */
+
+ at ApplicationScoped
+public class DefaultTimeZoneProducer implements Serializable
+{
+ private static final long serialVersionUID = 6181892144731122500L;
+
+ @Produces @DefaultTimeZone @Named
+ private TimeZone defaultTimeZone;
+
+ @Inject
+ public void init()
+ {
+ defaultTimeZone = TimeZone.getDefault();
+ }
+}
Added: modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/TimeZoneWrapper.java
===================================================================
--- modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/TimeZoneWrapper.java (rev 0)
+++ modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/TimeZoneWrapper.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,104 @@
+package org.jboss.seam.international.timezone;
+
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * A wrapper around a TimeZone that provides a more convenience interface to
+ * access the time zone information in the UI, in particular in the options of
+ * a select menu.
+ *
+ * @author Dan Allen
+ */
+public class TimeZoneWrapper extends TimeZone
+{
+ private static final long serialVersionUID = 8504687846433050650L;
+
+ private static final int MILLISECONDS_PER_HOUR = 1000 * 60 * 60;
+
+ private TimeZone timeZone;
+
+ public TimeZoneWrapper(TimeZone tz) {
+ timeZone = tz;
+ setID(tz.getID());
+ }
+
+ @Override
+ public void setID(String id) {
+ super.setID(id);
+ timeZone = TimeZone.getTimeZone(id);
+ }
+
+ public String getId() {
+ return timeZone.getID();
+ }
+
+ public String getLabel() {
+ StringBuilder label = new StringBuilder(50);
+ label.append(getId().replace("_", " "));
+ label.append(" (UTC");
+ label.append(timeZone.getRawOffset() > 0 ? "+" : "-");
+ if (Math.abs(timeZone.getRawOffset()) < MILLISECONDS_PER_HOUR * 10) {
+ label.append("0");
+ }
+ label.append(Math.abs(timeZone.getRawOffset())/MILLISECONDS_PER_HOUR);
+ label.append(":00)");
+ return label.toString();
+ }
+
+ public TimeZone getTimeZone() {
+ return timeZone;
+ }
+
+ @Override
+ public int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis) {
+ return timeZone.getOffset(era, year, month, day, dayOfWeek, millis);
+ }
+
+ @Override
+ public void setRawOffset(int offset) {
+ timeZone.setRawOffset(offset);
+ }
+
+ @Override
+ public int getRawOffset() {
+ return timeZone.getRawOffset();
+ }
+
+ @Override
+ public boolean useDaylightTime() {
+ return timeZone.useDaylightTime();
+ }
+
+ @Override
+ public boolean inDaylightTime(Date date) {
+ return timeZone.inDaylightTime(date);
+ }
+
+ @Override
+ public Object clone() {
+ return timeZone.clone();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TimeZoneWrapper other = (TimeZoneWrapper) obj;
+ if (timeZone != other.timeZone && (timeZone == null || !timeZone.equals(other.timeZone))) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 79 * hash + (timeZone != null ? timeZone.hashCode() : 0);
+ return hash;
+ }
+}
Added: modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/TimeZones.java
===================================================================
--- modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/TimeZones.java (rev 0)
+++ modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/TimeZones.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,27 @@
+package org.jboss.seam.international.timezone;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+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.Qualifier;
+
+/**
+ * Qualifier for Time Zones
+ *
+ * @author Ken Finnigan
+ */
+ at Target( { METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at Qualifier
+ at Inherited
+public @interface TimeZones
+{
+}
Added: modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/UserTimeZone.java
===================================================================
--- modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/UserTimeZone.java (rev 0)
+++ modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/UserTimeZone.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,27 @@
+package org.jboss.seam.international.timezone;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+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.Qualifier;
+
+/**
+ * User TimeZone
+ *
+ * @author Ken Finnigan
+ */
+ at Target( { METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at Qualifier
+ at Inherited
+public @interface UserTimeZone
+{
+}
Added: modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/UserTimeZoneProducer.java
===================================================================
--- modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/UserTimeZoneProducer.java (rev 0)
+++ modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/UserTimeZoneProducer.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,40 @@
+package org.jboss.seam.international.timezone;
+
+import java.io.Serializable;
+import java.util.TimeZone;
+
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jboss.seam.international.timezone.events.TimeZoneSelectedEvent;
+
+/**
+ * TimeZone for a User Session. Defaults to the TimeZone within
+ * DefaultTimeZone and is altered when it receives the
+ * TimeZoneSelectedEvent.
+ *
+ * @author Ken Finnigan
+ */
+
+ at SessionScoped
+public class UserTimeZoneProducer implements Serializable
+{
+ private static final long serialVersionUID = -9008203923830420841L;
+
+ @Produces @UserTimeZone @Named
+ private TimeZone userTimeZone;
+
+ @Inject
+ public void init(@DefaultTimeZone TimeZone defaultTimeZone)
+ {
+ this.userTimeZone = defaultTimeZone;
+ }
+
+ public void afterTimeZoneUpdate(@Observes TimeZoneSelectedEvent event)
+ {
+ this.userTimeZone = TimeZone.getTimeZone(event.getTimeZoneId());
+ }
+}
Added: modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/events/TimeZoneSelectedEvent.java
===================================================================
--- modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/events/TimeZoneSelectedEvent.java (rev 0)
+++ modules/international/trunk/core/src/main/java/org/jboss/seam/international/timezone/events/TimeZoneSelectedEvent.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,21 @@
+package org.jboss.seam.international.timezone.events;
+
+/**
+ * Event raised when TimeZone selected.
+ *
+ * @author Ken Finnigan
+ */
+public class TimeZoneSelectedEvent
+{
+ private String timeZoneId;
+
+ public TimeZoneSelectedEvent(String timeZoneId)
+ {
+ this.timeZoneId = timeZoneId;
+ }
+
+ public String getTimeZoneId()
+ {
+ return timeZoneId;
+ }
+}
Added: modules/international/trunk/core/src/main/resources/META-INF/beans.xml
===================================================================
Added: modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/AvailableTimeZoneBean.java
===================================================================
--- modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/AvailableTimeZoneBean.java (rev 0)
+++ modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/AvailableTimeZoneBean.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,24 @@
+package org.jboss.seam.international.timezone;
+
+import java.util.List;
+import java.util.TimeZone;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+ at ApplicationScoped
+public class AvailableTimeZoneBean
+{
+ @Inject
+ @TimeZones
+ private List<TimeZone> timeZones;
+
+ public AvailableTimeZoneBean()
+ {
+ }
+
+ public List<TimeZone> getAvailTimeZones()
+ {
+ return timeZones;
+ }
+}
Added: modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/AvailableTimeZonesTest.java
===================================================================
--- modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/AvailableTimeZonesTest.java (rev 0)
+++ modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/AvailableTimeZonesTest.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,52 @@
+package org.jboss.seam.international.timezone;
+
+import java.util.List;
+import java.util.TimeZone;
+
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.international.timezone.events.TimeZoneSelectedEvent;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class AvailableTimeZonesTest
+{
+ @Deployment
+ public static JavaArchive createTestArchive()
+ {
+ return Archives.create("availabletimezonetest.jar", JavaArchive.class).addClasses(AvailableTimeZones.class, AvailableTimeZoneBean.class, TimeZoneWrapper.class, TimeZoneSelectedEvent.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+ }
+
+ @Inject
+ Instance<AvailableTimeZoneBean> availBean;
+ @Inject
+ @TimeZones
+ List<TimeZone> timeZones;
+
+ @Test
+ public void testAvailableTimeZonesProducerViaBean()
+ {
+ Assert.assertNotNull(availBean);
+ List<TimeZone> list = availBean.get().getAvailTimeZones();
+ Assert.assertNotNull(list);
+ Assert.assertTrue(!list.isEmpty());
+ Assert.assertTrue(list.size() > 0);
+ }
+
+ @Test
+ public void testAvailableTimeZonesProducerDirect()
+ {
+ Assert.assertNotNull(timeZones);
+ Assert.assertTrue(!timeZones.isEmpty());
+ Assert.assertTrue(timeZones.size() > 0);
+ }
+}
Added: modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/DefaultTimeZoneTest.java
===================================================================
--- modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/DefaultTimeZoneTest.java (rev 0)
+++ modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/DefaultTimeZoneTest.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,35 @@
+package org.jboss.seam.international.timezone;
+
+import java.util.TimeZone;
+
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class DefaultTimeZoneTest
+{
+ @Deployment
+ public static JavaArchive createTestArchive()
+ {
+ return Archives.create("defaulttimezonetest.jar", JavaArchive.class).addClasses(DefaultTimeZoneProducer.class, DefaultTimeZone.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+ }
+
+ @Inject
+ @DefaultTimeZone
+ TimeZone timeZone;
+
+ @Test
+ public void testDefaultTimeZoneProducerDirect()
+ {
+ Assert.assertNotNull(timeZone);
+ }
+}
Added: modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/UserTimeZoneTest.java
===================================================================
--- modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/UserTimeZoneTest.java (rev 0)
+++ modules/international/trunk/core/src/test/java/org/jboss/seam/international/timezone/UserTimeZoneTest.java 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,55 @@
+package org.jboss.seam.international.timezone;
+
+import java.util.TimeZone;
+
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.international.timezone.events.TimeZoneSelectedEvent;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class UserTimeZoneTest
+{
+ @Deployment
+ public static JavaArchive createTestArchive()
+ {
+ return Archives.create("usertimezonetest.jar", JavaArchive.class).addClasses(UserTimeZoneProducer.class, UserTimeZone.class, TimeZoneSelectedEvent.class, DefaultTimeZone.class, DefaultTimeZoneProducer.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+ }
+
+ @Inject
+ @UserTimeZone
+ TimeZone timeZone;
+ @Inject
+ Event<TimeZoneSelectedEvent> timeZoneEvent;
+ @Inject
+ @UserTimeZone
+ Instance<TimeZone> timeZoneSource;
+
+ @Test
+ public void testUserTimeZoneProducerDirect()
+ {
+ Assert.assertNotNull(timeZone);
+ }
+
+ @Test
+ public void testUserTimeZoneEvent()
+ {
+ TimeZone tijuana = TimeZone.getTimeZone("America/Tijuana");
+ Assert.assertNotNull(timeZone);
+ Assert.assertFalse(timeZone.equals(tijuana));
+ timeZoneEvent.fire(new TimeZoneSelectedEvent("America/Tijuana"));
+ TimeZone tz = timeZoneSource.get();
+ Assert.assertNotNull(tz);
+ Assert.assertTrue(tz.equals(tijuana));
+ }
+}
Added: modules/international/trunk/core/src/test/jboss-resources/jndi.properties
===================================================================
--- modules/international/trunk/core/src/test/jboss-resources/jndi.properties (rev 0)
+++ modules/international/trunk/core/src/test/jboss-resources/jndi.properties 2010-04-02 13:38:51 UTC (rev 12372)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+java.naming.provider.url=jnp://localhost:1099
Modified: modules/international/trunk/pom.xml
===================================================================
--- modules/international/trunk/pom.xml 2010-04-02 08:49:51 UTC (rev 12371)
+++ modules/international/trunk/pom.xml 2010-04-02 13:38:51 UTC (rev 12372)
@@ -1,53 +1,90 @@
-<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>
<version>3.0.0-SNAPSHOT</version>
</parent>
+ <groupId>org.jboss.seam.international</groupId>
+ <artifactId>seam-international-parent</artifactId>
+ <packaging>pom</packaging>
+ <version>3.0.0-SNAPSHOT</version>
+ <name>Seam International Parent</name>
+
+ <modules>
+ <module>core</module>
+ <!--module>docs</module-->
+ <!--module>examples/??</module-->
+ </modules>
+
<properties>
<arquillian.version>1.0.0.Alpha1</arquillian.version>
</properties>
- <artifactId>seam-international</artifactId>
- <packaging>jar</packaging>
- <version>3.0.0-SNAPSHOT</version>
- <name>Seam Internationalization Module</name>
+ <dependencyManagement>
+ <dependencies>
- <dependencies>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>2.2</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <version>1.0.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.0-SP1</version>
+ </dependency>
- <dependency>
- <groupId>javax.enterprise</groupId>
- <artifactId>cdi-api</artifactId>
- <version>1.0-SP1</version>
- </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.10</version>
+ <scope>provided</scope>
+ </dependency>
- <dependency>
- <groupId>org.jboss.arquillian</groupId>
- <artifactId>arquillian-junit</artifactId>
- <version>${arquillian.version}</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ <version>${arquillian.version}</version>
+ <scope>test</scope>
+ </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.container</groupId>
- <artifactId>arquillian-weld-embedded</artifactId>
- <version>${arquillian.version}</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-weld-embedded</artifactId>
+ <version>${arquillian.version}</version>
+ <scope>test</scope>
+ </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.1</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
- </dependencies>
-
+ </dependencies>
+ </dependencyManagement>
+
<scm>
<connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/international/trunk</connection>
<developerConnection>scm:svn:https://svn.jboss.org/repos/seam/modules/international/trunk</developerConnection>
More information about the seam-commits
mailing list