[seam-commits] Seam SVN: r12918 - in modules/international/trunk: api/src/main/java/org/jboss/seam/international/status/builder and 6 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Jun 1 13:04:07 EDT 2010


Author: lincolnthree
Date: 2010-06-01 13:04:05 -0400 (Tue, 01 Jun 2010)
New Revision: 12918

Added:
   modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/
   modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/BundleTemplateMessageImpl.java
   modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/Interpolator.java
   modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/TemplateMessageImpl.java
   modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/BundleTemplateMessageImplTest.java
   modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/TemplateMessageImplTest.java
Removed:
   modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/Interpolator.java
   modules/international/trunk/api/src/test/java/org/
   modules/international/trunk/impl/src/test/java/org/jboss/seam/international/status/
   modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/BundleTemplateMessageTest.java
   modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/TemplateMessageTest.java
Modified:
   modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/MessageFactory.java
   modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/Messages.java
   modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/BundleTemplateMessage.java
   modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/TemplateMessage.java
   modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/MessagesTest.java
Log:
Messages API is now fully decoupled from the IMPL.

Modified: modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/MessageFactory.java
===================================================================
--- modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/MessageFactory.java	2010-06-01 09:53:55 UTC (rev 12917)
+++ modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/MessageFactory.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -23,6 +23,9 @@
 
 import java.io.Serializable;
 
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
 import javax.inject.Inject;
 
 import org.jboss.seam.international.status.builder.BundleKey;
@@ -31,7 +34,8 @@
 
 /**
  * A utility for building {@link Message} objects via message templates, or
- * message bundles. See {@link TemplateMessage} or {@link BundleTemplateMessage}.
+ * message bundles. See {@link TemplateMessage} or {@link BundleTemplateMessage}
+ * .
  * 
  * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
  * 
@@ -41,49 +45,49 @@
    private static final long serialVersionUID = -7899463141244189001L;
 
    @Inject
-   private Bundles bundles;
+   BeanManager manager;
 
    /*
     * Bundle Factory Methods
     */
    public BundleTemplateMessage info(final BundleKey message)
    {
-      return new BundleTemplateMessage(bundles, Level.INFO).text(message);
+      return getContextualInstance(BundleTemplateMessage.class).text(message).level(Level.INFO);
    }
 
    public BundleTemplateMessage info(final BundleKey message, final Object... params)
    {
-      return new BundleTemplateMessage(bundles, Level.INFO).text(message).textParams(params);
+      return getContextualInstance(BundleTemplateMessage.class).text(message).level(Level.INFO).textParams(params);
    }
 
    public BundleTemplateMessage warn(final BundleKey message)
    {
-      return new BundleTemplateMessage(bundles, Level.WARN).text(message);
+      return getContextualInstance(BundleTemplateMessage.class).text(message).level(Level.WARN);
    }
 
    public BundleTemplateMessage warn(final BundleKey message, final Object... params)
    {
-      return new BundleTemplateMessage(bundles, Level.WARN).text(message).textParams(params);
+      return getContextualInstance(BundleTemplateMessage.class).text(message).level(Level.WARN).textParams(params);
    }
 
    public BundleTemplateMessage error(final BundleKey message)
    {
-      return new BundleTemplateMessage(bundles, Level.ERROR).text(message);
+      return getContextualInstance(BundleTemplateMessage.class).text(message).level(Level.ERROR);
    }
 
    public BundleTemplateMessage error(final BundleKey message, final Object... params)
    {
-      return new BundleTemplateMessage(bundles, Level.ERROR).text(message).textParams(params);
+      return getContextualInstance(BundleTemplateMessage.class).text(message).level(Level.ERROR).textParams(params);
    }
 
    public BundleTemplateMessage fatal(final BundleKey message)
    {
-      return new BundleTemplateMessage(bundles, Level.FATAL).text(message);
+      return getContextualInstance(BundleTemplateMessage.class).text(message).level(Level.FATAL);
    }
 
    public BundleTemplateMessage fatal(final BundleKey message, final Object... params)
    {
-      return new BundleTemplateMessage(bundles, Level.FATAL).text(message).textParams(params);
+      return getContextualInstance(BundleTemplateMessage.class).text(message).level(Level.FATAL).textParams(params);
    }
 
    /*
@@ -91,42 +95,68 @@
     */
    public TemplateMessage info(final String message)
    {
-      return new TemplateMessage(Level.INFO).text(message);
+      return getContextualInstance(TemplateMessage.class).text(message).level(Level.INFO);
    }
 
    public TemplateMessage info(final String message, final Object... params)
    {
-      return new TemplateMessage(Level.INFO).text(message).textParams(params);
+      return getContextualInstance(TemplateMessage.class).text(message).level(Level.INFO).textParams(params);
    }
 
    public TemplateMessage warn(final String message)
    {
-      return new TemplateMessage(Level.WARN).text(message);
+      return getContextualInstance(TemplateMessage.class).text(message).level(Level.WARN);
    }
 
    public TemplateMessage warn(final String message, final Object... params)
    {
-      return new TemplateMessage(Level.WARN).text(message).textParams(params);
+      return getContextualInstance(TemplateMessage.class).text(message).level(Level.WARN).textParams(params);
    }
 
    public TemplateMessage error(final String message)
    {
-      return new TemplateMessage(Level.ERROR).text(message);
+      return getContextualInstance(TemplateMessage.class).text(message).level(Level.ERROR);
    }
 
    public TemplateMessage error(final String message, final Object... params)
    {
-      return new TemplateMessage(Level.ERROR).text(message).textParams(params);
+      return getContextualInstance(TemplateMessage.class).text(message).level(Level.ERROR).textParams(params);
    }
 
    public TemplateMessage fatal(final String message)
    {
-      return new TemplateMessage(Level.FATAL).text(message);
+      return getContextualInstance(TemplateMessage.class).text(message).level(Level.FATAL);
    }
 
    public TemplateMessage fatal(final String message, final Object... params)
    {
-      return new TemplateMessage(Level.FATAL).text(message).textParams(params);
+      return getContextualInstance(TemplateMessage.class).text(message).level(Level.FATAL).textParams(params);
    }
 
+   /**
+    * Get a single CDI managed instance of a specific class. Return only the
+    * first result if multiple beans are available.
+    * <p>
+    * <b>NOTE:</b> Using this method should be avoided at all costs.
+    * 
+    * @param manager The bean manager with which to perform the lookup.
+    * @param type The class for which to return an instance.
+    * @return The managed instance, or null if none could be provided.
+    */
+   @SuppressWarnings("unchecked")
+   private <T extends MessageBuilder> T getContextualInstance(final Class<T> type)
+   {
+      T result = null;
+      Bean<T> bean = (Bean<T>) manager.resolve(manager.getBeans(type));
+      if (bean != null)
+      {
+         CreationalContext<T> context = manager.createCreationalContext(bean);
+         if (context != null)
+         {
+            result = (T) manager.getReference(bean, type, context);
+         }
+      }
+      return result;
+   }
+
 }

Modified: modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/Messages.java
===================================================================
--- modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/Messages.java	2010-06-01 09:53:55 UTC (rev 12917)
+++ modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/Messages.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -36,7 +36,10 @@
 
 /**
  * A convenient way to add messages to be displayed to the user as Feedback,
- * Toast, Alerts, etc...
+ * Toast, Alerts, etc.
+ * <p>
+ * It is the responsibility of the view-layer technology to consume and perform
+ * operations required to display any messages added in this way.
  * 
  * @author <a href="mailto:lincolnbaxter at gmail.com>Lincoln Baxter, III</a>
  * 

Modified: modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/BundleTemplateMessage.java
===================================================================
--- modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/BundleTemplateMessage.java	2010-06-01 09:53:55 UTC (rev 12917)
+++ modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/BundleTemplateMessage.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -21,7 +21,6 @@
  */
 package org.jboss.seam.international.status.builder;
 
-import org.jboss.seam.international.status.Bundles;
 import org.jboss.seam.international.status.Level;
 import org.jboss.seam.international.status.Message;
 import org.jboss.seam.international.status.MessageBuilder;
@@ -59,121 +58,51 @@
  * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
  * 
  */
-public class BundleTemplateMessage implements MessageBuilder
+public interface BundleTemplateMessage extends MessageBuilder
 {
-   private final TemplateMessage template;
-   private String textDefault;
-   private BundleKey textKey;
+   /**
+    * Set the template for this message, using the given {@link BundleKey} to
+    * perform a resource lookup.
+    * <p>
+    * Any expressions of the form "{0}, {1} ... {N}" found in the template will
+    * be interpolated; numbers reference the index of any given parameters, and
+    * can be used more than once per template.
+    */
+   public BundleTemplateMessage text(final BundleKey text);
 
-   private final Bundles bundles;
+   /**
+    * Set the default template text.
+    * <p>
+    * If the bundle cannot be loaded for any reason, the builder will fall back
+    * to using provided default template text; if there is no default template,
+    * a string representation of the {@link BundleKey} will be used instead.
+    * <p>
+    * Any expressions of the form "{0}, {1} ... {N}" found in the template will
+    * be interpolated; numbers reference the index of any given parameters, and
+    * can be used more than once per template.
+    */
+   public BundleTemplateMessage textDefault(final String text);
 
-   public BundleTemplateMessage(final Bundles bundles, final Level level)
-   {
-      this.bundles = bundles;
-      this.template = new TemplateMessage(level);
-   }
+   /**
+    * Set the parameters for this builder's template.
+    * <p>
+    * Parameters may be referenced by index in the template or
+    * {@link #textDefault(String)}, using expressions of the form " {0}, {1} ...
+    * {N}". The same parameters will be used when interpolating default text, in
+    * the case when a {@link BundleKey} cannot be resolved.
+    */
+   public BundleTemplateMessage textParams(final Object... textParams);
 
    /**
-    * Produce a {@link Message} object as represented by the current state of
-    * <code>this</code> builder.
+    * Set the targets for this message. If supported by the consuming
+    * view-layer, these targets may control where/how the message is displayed
+    * to the user.
     */
-   public Message build()
-   {
-      String text;
-      try
-      {
-         text = bundles.get(textKey.getBundle()).getString(textKey.getKey());
-      }
-      catch (Exception e)
-      {
-         text = textDefault;
-      }
+   public BundleTemplateMessage targets(final String targets);
 
-      if ((text == null) || "".equals(text))
-      {
-         text = textKey.toString();
-      }
-
-      template.text(text);
-      return template.build();
-   }
-
-   /*
-    * Setters
+   /**
+    * Set the severity, level of importance of this message.
     */
+   public BundleTemplateMessage level(final Level level);
 
-   public BundleTemplateMessage text(final BundleKey text)
-   {
-      this.textKey = text;
-      return this;
-   }
-
-   public BundleTemplateMessage textDefault(final String text)
-   {
-      this.textDefault = text;
-      return this;
-   }
-
-   public BundleTemplateMessage textParams(final Object... textParams)
-   {
-      this.template.textParams(textParams);
-      return this;
-   }
-
-   public BundleTemplateMessage targets(final String targets)
-   {
-      this.template.targets(targets);
-      return this;
-   }
-
-   public BundleTemplateMessage setLevel(final Level level)
-   {
-      this.template.level(level);
-      return this;
-   }
-
-   @Override
-   public int hashCode()
-   {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + ((template == null) ? 0 : template.hashCode());
-      result = prime * result + ((textDefault == null) ? 0 : textDefault.hashCode());
-      result = prime * result + ((textKey == null) ? 0 : textKey.hashCode());
-      return result;
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      if (this == obj)
-         return true;
-      if (obj == null)
-         return false;
-      if (getClass() != obj.getClass())
-         return false;
-      BundleTemplateMessage other = (BundleTemplateMessage) obj;
-      if (template == null)
-      {
-         if (other.template != null)
-            return false;
-      }
-      else if (!template.equals(other.template))
-         return false;
-      if (textDefault == null)
-      {
-         if (other.textDefault != null)
-            return false;
-      }
-      else if (!textDefault.equals(other.textDefault))
-         return false;
-      if (textKey == null)
-      {
-         if (other.textKey != null)
-            return false;
-      }
-      else if (!textKey.equals(other.textKey))
-         return false;
-      return true;
-   }
-}
+}
\ No newline at end of file

Deleted: modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/Interpolator.java
===================================================================
--- modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/Interpolator.java	2010-06-01 09:53:55 UTC (rev 12917)
+++ modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/Interpolator.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., 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.international.status.builder;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Populates an interpolated string using the given template and parameters:
- * <p>
- * <b>For example:</b><br>
- * Template:
- * <code>"This is a {0} template with {1} parameters. Just {1}."</code><br>
- * Parameters: <code>"simple", 2</code><br>
- * Result: <code>"This is a simple template with 2 parameters. Just 2"</code>
- * 
- * 
- * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- * 
- */
-class Interpolator
-{
-   private static final String templateRegex = "\\{(\\d+)\\}";
-   private static final Pattern templatePattern = Pattern.compile(templateRegex);
-
-   /**
-    * Populate a template with the corresponding parameters.
-    */
-   public String populate(final String template, final Object... params)
-   {
-      StringBuffer result = new StringBuffer();
-      if ((template != null) && (params != null))
-      {
-         Matcher matcher = templatePattern.matcher(template);
-         while (matcher.find())
-         {
-            int index = Integer.valueOf(matcher.group(1));
-            Object value = matcher.group();
-
-            if (params.length > index)
-            {
-               if (params[index] != null)
-               {
-                  value = params[index];
-               }
-            }
-            matcher.appendReplacement(result, value.toString());
-         }
-         matcher.appendTail(result);
-      }
-      else if (template != null)
-      {
-         result = new StringBuffer(template);
-      }
-      return result.toString();
-   }
-}

Modified: modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/TemplateMessage.java
===================================================================
--- modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/TemplateMessage.java	2010-06-01 09:53:55 UTC (rev 12917)
+++ modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/TemplateMessage.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -21,16 +21,13 @@
  */
 package org.jboss.seam.international.status.builder;
 
-import java.util.Arrays;
-
 import org.jboss.seam.international.status.Level;
 import org.jboss.seam.international.status.Message;
 import org.jboss.seam.international.status.MessageBuilder;
-import org.jboss.seam.international.status.MutableMessage;
 
 /**
- * This {@link MessageBuilder} implementation creates {@link Message} objects by
- * interpolating templates with values supplied as parameters.
+ * This {@link MessageBuilder} creates {@link Message} objects by interpolating
+ * templates with values supplied as parameters.
  * <p>
  * <b>For example:</b> Given the following {@link Message} m
  * 
@@ -45,139 +42,35 @@
  * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
  * 
  */
-public class TemplateMessage implements MessageBuilder
+public interface TemplateMessage extends MessageBuilder
 {
-   private static final String MESSAGE_IMPL_CLASS = "org.jboss.seam.international.status.MessageImpl";
+   /**
+    * Set the template for this message.
+    * <p>
+    * Any expressions of the form "{0}, {1} ... {N}" found in the template will
+    * be interpolated; numbers reference the index of any given parameters, and
+    * can be used more than once per template.
+    */
+   public TemplateMessage text(final String summary);
 
-   private final Interpolator interpolator = new Interpolator();
+   /**
+    * Set the parameters for this builder's template.
+    * <p>
+    * Parameters may be referenced by index in the template, using expressions
+    * of the form "{0}, {1} ... {N}"
+    */
+   public TemplateMessage textParams(final Object... summaryParams);
 
-   private String summary;
-   private Object[] summaryParams;
-
-   private String targets;
-   private Level level;
-
-   public TemplateMessage(final Level level)
-   {
-      this.level = level;
-   }
-
    /**
-    * Produce a {@link Message} object as represented by the current state of
-    * <code>this</code> builder.
+    * Set the targets for this message. If supported by the consuming
+    * view-layer, these targets may control where/how the message is displayed
+    * to the user.
     */
-   public Message build()
-   {
-      Class<?> type;
-      try
-      {
-         type = Class.forName(MESSAGE_IMPL_CLASS);
-         MutableMessage message = (MutableMessage) type.newInstance();
+   public TemplateMessage targets(final String targets);
 
-         message.setLevel(level);
-         message.setText(interpolator.populate(summary, summaryParams));
-         message.setTargets(targets);
-
-         return message;
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("Unable to create message: " + MESSAGE_IMPL_CLASS, e);
-      }
-   }
-
-   /*
-    * Setters
+   /**
+    * Set the severity, level of importance of this message.
     */
-   public TemplateMessage text(final String summary)
-   {
-      this.summary = summary;
-      return this;
-   }
+   public TemplateMessage level(final Level level);
 
-   public TemplateMessage textParams(final Object... summaryParams)
-   {
-      this.summaryParams = summaryParams;
-      return this;
-   }
-
-   public TemplateMessage targets(final String targets)
-   {
-      this.targets = targets;
-      return this;
-   }
-
-   public TemplateMessage level(final Level level)
-   {
-      this.level = level;
-      return this;
-   }
-
-   @Override
-   public int hashCode()
-   {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + ((level == null) ? 0 : level.hashCode());
-      result = prime * result + ((summary == null) ? 0 : summary.hashCode());
-      result = prime * result + Arrays.hashCode(summaryParams);
-      result = prime * result + ((targets == null) ? 0 : targets.hashCode());
-      return result;
-   }
-
-   @Override
-   public boolean equals(final Object obj)
-   {
-      if (this == obj)
-      {
-         return true;
-      }
-      if (obj == null)
-      {
-         return false;
-      }
-      if (getClass() != obj.getClass())
-      {
-         return false;
-      }
-      TemplateMessage other = (TemplateMessage) obj;
-      if (level == null)
-      {
-         if (other.level != null)
-         {
-            return false;
-         }
-      }
-      else if (!level.equals(other.level))
-      {
-         return false;
-      }
-      if (summary == null)
-      {
-         if (other.summary != null)
-         {
-            return false;
-         }
-      }
-      else if (!summary.equals(other.summary))
-      {
-         return false;
-      }
-      if (!Arrays.equals(summaryParams, other.summaryParams))
-      {
-         return false;
-      }
-      if (targets == null)
-      {
-         if (other.targets != null)
-         {
-            return false;
-         }
-      }
-      else if (!targets.equals(other.targets))
-      {
-         return false;
-      }
-      return true;
-   }
-}
+}
\ No newline at end of file

Copied: modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/BundleTemplateMessageImpl.java (from rev 12917, modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/BundleTemplateMessage.java)
===================================================================
--- modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/BundleTemplateMessageImpl.java	                        (rev 0)
+++ modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/BundleTemplateMessageImpl.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -0,0 +1,163 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.international.status.builder;
+
+import javax.inject.Inject;
+
+import org.jboss.seam.international.status.Bundles;
+import org.jboss.seam.international.status.Level;
+import org.jboss.seam.international.status.Message;
+
+/**
+ * 
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+public class BundleTemplateMessageImpl implements BundleTemplateMessage
+{
+   @Inject
+   TemplateMessage template;
+
+   private String textDefault;
+   private BundleKey textKey;
+
+   @Inject
+   Bundles bundles;
+
+   public Message build()
+   {
+      String text;
+      try
+      {
+         text = bundles.get(textKey.getBundle()).getString(textKey.getKey());
+      }
+      catch (Exception e)
+      {
+         text = textDefault;
+      }
+
+      if ((text == null) || "".equals(text))
+      {
+         text = textKey.toString();
+      }
+
+      template.text(text);
+      return template.build();
+   }
+
+   /*
+    * Setters
+    */
+
+   public BundleTemplateMessageImpl text(final BundleKey text)
+   {
+      this.textKey = text;
+      return this;
+   }
+
+   public BundleTemplateMessage textDefault(final String text)
+   {
+      this.textDefault = text;
+      return this;
+   }
+
+   public BundleTemplateMessageImpl textParams(final Object... textParams)
+   {
+      this.template.textParams(textParams);
+      return this;
+   }
+
+   public BundleTemplateMessage targets(final String targets)
+   {
+      this.template.targets(targets);
+      return this;
+   }
+
+   public BundleTemplateMessage level(final Level level)
+   {
+      this.template.level(level);
+      return this;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((template == null) ? 0 : template.hashCode());
+      result = prime * result + ((textDefault == null) ? 0 : textDefault.hashCode());
+      result = prime * result + ((textKey == null) ? 0 : textKey.hashCode());
+      return result;
+   }
+
+   @Override
+   public boolean equals(final Object obj)
+   {
+      if (this == obj)
+      {
+         return true;
+      }
+      if (obj == null)
+      {
+         return false;
+      }
+      if (getClass() != obj.getClass())
+      {
+         return false;
+      }
+      BundleTemplateMessageImpl other = (BundleTemplateMessageImpl) obj;
+      if (template == null)
+      {
+         if (other.template != null)
+         {
+            return false;
+         }
+      }
+      else if (!template.equals(other.template))
+      {
+         return false;
+      }
+      if (textDefault == null)
+      {
+         if (other.textDefault != null)
+         {
+            return false;
+         }
+      }
+      else if (!textDefault.equals(other.textDefault))
+      {
+         return false;
+      }
+      if (textKey == null)
+      {
+         if (other.textKey != null)
+         {
+            return false;
+         }
+      }
+      else if (!textKey.equals(other.textKey))
+      {
+         return false;
+      }
+      return true;
+   }
+}

Copied: modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/Interpolator.java (from rev 12917, modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/Interpolator.java)
===================================================================
--- modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/Interpolator.java	                        (rev 0)
+++ modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/Interpolator.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.international.status.builder;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Populates an interpolated string using the given template and parameters:
+ * <p>
+ * <b>For example:</b><br>
+ * Template:
+ * <code>"This is a {0} template with {1} parameters. Just {1}."</code><br>
+ * Parameters: <code>"simple", 2</code><br>
+ * Result: <code>"This is a simple template with 2 parameters. Just 2"</code>
+ * 
+ * 
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+class Interpolator
+{
+   private static final String templateRegex = "\\{(\\d+)\\}";
+   private static final Pattern templatePattern = Pattern.compile(templateRegex);
+
+   /**
+    * Populate a template with the corresponding parameters.
+    */
+   public String populate(final String template, final Object... params)
+   {
+      StringBuffer result = new StringBuffer();
+      if ((template != null) && (params != null))
+      {
+         Matcher matcher = templatePattern.matcher(template);
+         while (matcher.find())
+         {
+            int index = Integer.valueOf(matcher.group(1));
+            Object value = matcher.group();
+
+            if (params.length > index)
+            {
+               if (params[index] != null)
+               {
+                  value = params[index];
+               }
+            }
+            matcher.appendReplacement(result, value.toString());
+         }
+         matcher.appendTail(result);
+      }
+      else if (template != null)
+      {
+         result = new StringBuffer(template);
+      }
+      return result.toString();
+   }
+}

Copied: modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/TemplateMessageImpl.java (from rev 12917, modules/international/trunk/api/src/main/java/org/jboss/seam/international/status/builder/TemplateMessage.java)
===================================================================
--- modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/TemplateMessageImpl.java	                        (rev 0)
+++ modules/international/trunk/impl/src/main/java/org/jboss/seam/international/status/builder/TemplateMessageImpl.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -0,0 +1,149 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.international.status.builder;
+
+import java.util.Arrays;
+
+import org.jboss.seam.international.status.Level;
+import org.jboss.seam.international.status.Message;
+import org.jboss.seam.international.status.MessageBuilder;
+import org.jboss.seam.international.status.MessageImpl;
+import org.jboss.seam.international.status.MutableMessage;
+
+/**
+ * 
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+public class TemplateMessageImpl implements MessageBuilder, TemplateMessage
+{
+   private final Interpolator interpolator = new Interpolator();
+
+   private String summary;
+   private Object[] summaryParams;
+
+   private String targets;
+   private Level level;
+
+   public Message build()
+   {
+      MutableMessage message = new MessageImpl();
+
+      message.setLevel(level);
+      message.setText(interpolator.populate(summary, summaryParams));
+      message.setTargets(targets);
+
+      return message;
+   }
+
+   public TemplateMessageImpl text(final String summary)
+   {
+      this.summary = summary;
+      return this;
+   }
+
+   public TemplateMessageImpl textParams(final Object... summaryParams)
+   {
+      this.summaryParams = summaryParams;
+      return this;
+   }
+
+   public TemplateMessage targets(final String targets)
+   {
+      this.targets = targets;
+      return this;
+   }
+
+   public TemplateMessage level(final Level level)
+   {
+      this.level = level;
+      return this;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((level == null) ? 0 : level.hashCode());
+      result = prime * result + ((summary == null) ? 0 : summary.hashCode());
+      result = prime * result + Arrays.hashCode(summaryParams);
+      result = prime * result + ((targets == null) ? 0 : targets.hashCode());
+      return result;
+   }
+
+   @Override
+   public boolean equals(final Object obj)
+   {
+      if (this == obj)
+      {
+         return true;
+      }
+      if (obj == null)
+      {
+         return false;
+      }
+      if (getClass() != obj.getClass())
+      {
+         return false;
+      }
+      TemplateMessageImpl other = (TemplateMessageImpl) obj;
+      if (level == null)
+      {
+         if (other.level != null)
+         {
+            return false;
+         }
+      }
+      else if (!level.equals(other.level))
+      {
+         return false;
+      }
+      if (summary == null)
+      {
+         if (other.summary != null)
+         {
+            return false;
+         }
+      }
+      else if (!summary.equals(other.summary))
+      {
+         return false;
+      }
+      if (!Arrays.equals(summaryParams, other.summaryParams))
+      {
+         return false;
+      }
+      if (targets == null)
+      {
+         if (other.targets != null)
+         {
+            return false;
+         }
+      }
+      else if (!targets.equals(other.targets))
+      {
+         return false;
+      }
+      return true;
+   }
+}

Modified: modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/MessagesTest.java
===================================================================
--- modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/MessagesTest.java	2010-06-01 09:53:55 UTC (rev 12917)
+++ modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/MessagesTest.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -34,6 +34,8 @@
 import org.jboss.seam.international.status.Messages;
 import org.jboss.seam.international.status.MutableMessage;
 import org.jboss.seam.international.status.builder.BundleKey;
+import org.jboss.seam.international.status.builder.BundleTemplateMessageImpl;
+import org.jboss.seam.international.status.builder.TemplateMessageImpl;
 import org.jboss.shrinkwrap.api.ArchivePaths;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
@@ -54,7 +56,7 @@
    @Deployment
    public static JavaArchive createTestArchive()
    {
-      return ShrinkWrap.create("test.jar", JavaArchive.class).addClasses(Messages.class, MessageFactory.class, Bundles.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+      return ShrinkWrap.create("test.jar", JavaArchive.class).addClasses(Messages.class, MessageFactory.class, BundleTemplateMessageImpl.class, TemplateMessageImpl.class, Bundles.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
    }
 
    @Inject

Copied: modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/BundleTemplateMessageImplTest.java (from rev 12917, modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/BundleTemplateMessageTest.java)
===================================================================
--- modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/BundleTemplateMessageImplTest.java	                        (rev 0)
+++ modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/BundleTemplateMessageImplTest.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.international.test.status.builder;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.international.status.Bundles;
+import org.jboss.seam.international.status.MessageFactory;
+import org.jboss.seam.international.status.builder.BundleTemplateMessageImpl;
+import org.jboss.seam.international.status.builder.TemplateMessage;
+import org.jboss.seam.international.status.builder.TemplateMessageImpl;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+ at RunWith(Arquillian.class)
+public class BundleTemplateMessageImplTest
+{
+   @Deployment
+   public static Archive<?> createTestArchive()
+   {
+      return ShrinkWrap.create("test.jar", JavaArchive.class).addClasses(MessageFactory.class, BundleTemplateMessageImpl.class, TemplateMessageImpl.class, Bundles.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+   }
+
+   @Inject
+   MessageFactory factory;
+
+   @Test
+   public void testParameterizedTemplate() throws Exception
+   {
+      String expected = "There are 5 cars, and they are all green; green is the best color.";
+      TemplateMessage builder = factory.info("There are {0} cars, and they are all {1}; {1} is the best color.", 5, "green");
+      assertEquals(expected, builder.build().getText());
+   }
+
+   @Test
+   public void testParameterizedTemplateInsertsParamNumbersIfNotEnoughParamValues() throws Exception
+   {
+      String expected = "There are 5 cars, and they are all {1}; {1} is the best color.";
+      TemplateMessage builder = factory.warn("There are {0} cars, and they are all {1}; {1} is the best color.", 5);
+      assertEquals(expected, builder.build().getText());
+   }
+
+   @Test
+   public void testPlainTextTemplate() throws Exception
+   {
+      String expected = "There are 5 cars, and they are all green; green is the best color.";
+      TemplateMessage builder = factory.error("There are 5 cars, and they are all green; green is the best color.");
+      assertEquals(expected, builder.build().getText());
+   }
+
+   @Test
+   public void testPlainTextTemplateWithParamsIsUnmodified() throws Exception
+   {
+      String expected = "There are 5 cars, and they are all green; green is the best color.";
+      TemplateMessage builder = factory.fatal("There are 5 cars, and they are all green; green is the best color.", "blue", "red", 6);
+      assertEquals(expected, builder.build().getText());
+   }
+}

Deleted: modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/BundleTemplateMessageTest.java
===================================================================
--- modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/BundleTemplateMessageTest.java	2010-06-01 09:53:55 UTC (rev 12917)
+++ modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/BundleTemplateMessageTest.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., 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.international.test.status.builder;
-
-import static org.junit.Assert.assertEquals;
-
-import javax.inject.Inject;
-
-import org.jboss.arquillian.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.international.status.Bundles;
-import org.jboss.seam.international.status.MessageFactory;
-import org.jboss.seam.international.status.builder.TemplateMessage;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ArchivePaths;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- * 
- */
- at RunWith(Arquillian.class)
-public class BundleTemplateMessageTest
-{
-   @Deployment
-   public static Archive<?> createTestArchive()
-   {
-      return ShrinkWrap.create("test.jar", JavaArchive.class).addClasses(MessageFactory.class, Bundles.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
-   }
-
-   @Inject
-   MessageFactory factory;
-
-   @Test
-   public void testParameterizedTemplate() throws Exception
-   {
-      String expected = "There are 5 cars, and they are all green; green is the best color.";
-      TemplateMessage builder = factory.info("There are {0} cars, and they are all {1}; {1} is the best color.", 5, "green");
-      assertEquals(expected, builder.build().getText());
-   }
-
-   @Test
-   public void testParameterizedTemplateInsertsParamNumbersIfNotEnoughParamValues() throws Exception
-   {
-      String expected = "There are 5 cars, and they are all {1}; {1} is the best color.";
-      TemplateMessage builder = factory.warn("There are {0} cars, and they are all {1}; {1} is the best color.", 5);
-      assertEquals(expected, builder.build().getText());
-   }
-
-   @Test
-   public void testPlainTextTemplate() throws Exception
-   {
-      String expected = "There are 5 cars, and they are all green; green is the best color.";
-      TemplateMessage builder = factory.error("There are 5 cars, and they are all green; green is the best color.");
-      assertEquals(expected, builder.build().getText());
-   }
-
-   @Test
-   public void testPlainTextTemplateWithParamsIsUnmodified() throws Exception
-   {
-      String expected = "There are 5 cars, and they are all green; green is the best color.";
-      TemplateMessage builder = factory.fatal("There are 5 cars, and they are all green; green is the best color.", "blue", "red", 6);
-      assertEquals(expected, builder.build().getText());
-   }
-}

Copied: modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/TemplateMessageImplTest.java (from rev 12917, modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/TemplateMessageTest.java)
===================================================================
--- modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/TemplateMessageImplTest.java	                        (rev 0)
+++ modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/TemplateMessageImplTest.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.international.test.status.builder;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.international.status.MessageFactory;
+import org.jboss.seam.international.status.builder.TemplateMessage;
+import org.jboss.seam.international.status.builder.TemplateMessageImpl;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+ at RunWith(Arquillian.class)
+public class TemplateMessageImplTest
+{
+   @Deployment
+   public static Archive<?> createTestArchive()
+   {
+      return ShrinkWrap.create("test.jar", JavaArchive.class).addClasses(MessageFactory.class, TemplateMessageImpl.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+   }
+
+   @Inject
+   MessageFactory factory;
+
+   @Test
+   public void testParameterizedTemplate() throws Exception
+   {
+      String expected = "There are 5 cars, and they are all green; green is the best color.";
+      TemplateMessage builder = factory.info("There are {0} cars, and they are all {1}; {1} is the best color.", 5, "green");
+      assertEquals(expected, builder.build().getText());
+   }
+
+   @Test
+   public void testParameterizedTemplateInsertsParamNumbersIfNotEnoughParamValues() throws Exception
+   {
+      String expected = "There are 5 cars, and they are all {1}; {1} is the best color.";
+      TemplateMessage builder = factory.warn("There are {0} cars, and they are all {1}; {1} is the best color.", 5);
+      assertEquals(expected, builder.build().getText());
+   }
+
+   @Test
+   public void testPlainTextTemplate() throws Exception
+   {
+      String expected = "There are 5 cars, and they are all green; green is the best color.";
+      TemplateMessage builder = factory.error("There are 5 cars, and they are all green; green is the best color.");
+      assertEquals(expected, builder.build().getText());
+   }
+
+   @Test
+   public void testPlainTextTemplateWithParamsIsUnmodified() throws Exception
+   {
+      String expected = "There are 5 cars, and they are all green; green is the best color.";
+      TemplateMessage builder = factory.fatal("There are 5 cars, and they are all green; green is the best color.", "blue", "red", 6);
+      assertEquals(expected, builder.build().getText());
+   }
+}

Deleted: modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/TemplateMessageTest.java
===================================================================
--- modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/TemplateMessageTest.java	2010-06-01 09:53:55 UTC (rev 12917)
+++ modules/international/trunk/impl/src/test/java/org/jboss/seam/international/test/status/builder/TemplateMessageTest.java	2010-06-01 17:04:05 UTC (rev 12918)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., 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.international.test.status.builder;
-
-import static org.junit.Assert.assertEquals;
-
-import javax.inject.Inject;
-
-import org.jboss.arquillian.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.international.status.Bundles;
-import org.jboss.seam.international.status.MessageFactory;
-import org.jboss.seam.international.status.builder.TemplateMessage;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ArchivePaths;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- * 
- */
- at RunWith(Arquillian.class)
-public class TemplateMessageTest
-{
-   @Deployment
-   public static Archive<?> createTestArchive()
-   {
-      return ShrinkWrap.create("test.jar", JavaArchive.class).addClasses(MessageFactory.class, Bundles.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
-   }
-
-   @Inject
-   MessageFactory factory;
-
-   @Test
-   public void testParameterizedTemplate() throws Exception
-   {
-      String expected = "There are 5 cars, and they are all green; green is the best color.";
-      TemplateMessage builder = factory.info("There are {0} cars, and they are all {1}; {1} is the best color.", 5, "green");
-      assertEquals(expected, builder.build().getText());
-   }
-
-   @Test
-   public void testParameterizedTemplateInsertsParamNumbersIfNotEnoughParamValues() throws Exception
-   {
-      String expected = "There are 5 cars, and they are all {1}; {1} is the best color.";
-      TemplateMessage builder = factory.warn("There are {0} cars, and they are all {1}; {1} is the best color.", 5);
-      assertEquals(expected, builder.build().getText());
-   }
-
-   @Test
-   public void testPlainTextTemplate() throws Exception
-   {
-      String expected = "There are 5 cars, and they are all green; green is the best color.";
-      TemplateMessage builder = factory.error("There are 5 cars, and they are all green; green is the best color.");
-      assertEquals(expected, builder.build().getText());
-   }
-
-   @Test
-   public void testPlainTextTemplateWithParamsIsUnmodified() throws Exception
-   {
-      String expected = "There are 5 cars, and they are all green; green is the best color.";
-      TemplateMessage builder = factory.fatal("There are 5 cars, and they are all green; green is the best color.", "blue", "red", 6);
-      assertEquals(expected, builder.build().getText());
-   }
-}



More information about the seam-commits mailing list