[cai18n-dev] [GIT] Compiler assisted internalization library branch, master, updated. v0.1-2-g1fec687

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Fri Aug 28 13:21:22 CEST 2009


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Compiler assisted internalization library".

The branch, master has been updated
       via  1fec687141367be578aea7dfbdedae5fad92f8cb (commit)
       via  29c2fe5918033438a9fe7f5d71f0e1a4c0fa2953 (commit)
      from  398d827991fe13d96c27ee5ee8f539e79af5894a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=cai18n.git;a=commit;h=1fec687141367be578aea7dfbdedae5fad92f8cb
http://github.com/ceki/cai18n/commit/1fec687141367be578aea7dfbdedae5fad92f8cb

commit 1fec687141367be578aea7dfbdedae5fad92f8cb
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Fri Aug 28 12:02:05 2009 +0200

    minor doc improvements

diff --git a/cai18n-site/src/site/pages/manual.html b/cai18n-site/src/site/pages/manual.html
index 622947a..a274a08 100644
--- a/cai18n-site/src/site/pages/manual.html
+++ b/cai18n-site/src/site/pages/manual.html
@@ -113,10 +113,12 @@ String blue = mc.getMessage(Colors.BLUE);  </pre>
 
   <h2>Verification as a test case</h2>
 
-  <p>You can quickly and easily check for mismatches between a given
-  enum type and the corresponding resource bundles.</p>
+  <p>A convenient and low hassle method for checking for mismatches
+  between a given enum type and the corresponding resource bundles is
+  through Junit test cases.</p>
 
-  <p>Here is the unit test</p>
+  <p>Here is a sample Junit test for the Colors enum discussed
+  above.</p>
 
   <pre class="prettyprint source">
 package foo.aPackage;
@@ -187,9 +189,9 @@ public class MyAllInOneColorVerificationTest {
   is unsuprisingly called <em>mvn-cai18n-plugin</em>.
   </p>
 
-  <p><b>At this very early stage, you need to install the
-  <em>maven-cai18n-plugin</em> by running "maven install" from the
-  folder where you unpacked the CAI18N distribution.</b>
+  <p><b>At this very early stage of the CAI18N project, you need to
+  install the <em>maven-cai18n-plugin</em> by running "maven install"
+  from the folder where you unpacked the CAI18N distribution.</b>
   </p>
 
   <p>Using <em>maven-cai18n-plugin</em> is pretty easy. To verify
diff --git a/cai18n-site/src/site/pages/news.html b/cai18n-site/src/site/pages/news.html
index 193b861..7c2af99 100644
--- a/cai18n-site/src/site/pages/news.html
+++ b/cai18n-site/src/site/pages/news.html
@@ -33,9 +33,13 @@
 
     <p>Editing changes attributing original idea for CAI18N to Takeshi
     Kondo, also mentioning the discussion involving Ralph Goers, Ceki
-    Gülcü, Takeshi Kondo and Pete Muir on the slf4j-dev mailing list.
-    usable. </p>
+    G&uuml;lc&uuml;, Takeshi Kondo and Pete Muir on the slf4j-dev
+    mailing list.  usable. </p>
+
+    <p>Added a new section in the manual about verification using
+    Junit test cases.</p>
 
+    <p>Improved javadoc documentaion.</p>
     
     <hr width="80%" align="center" />
 

http://git.qos.ch/gitweb/?p=cai18n.git;a=commit;h=29c2fe5918033438a9fe7f5d71f0e1a4c0fa2953
http://github.com/ceki/cai18n/commit/29c2fe5918033438a9fe7f5d71f0e1a4c0fa2953

commit 29c2fe5918033438a9fe7f5d71f0e1a4c0fa2953
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Fri Aug 28 11:54:52 2009 +0200

    - attribute original idea to Takeshi Kondo
    - added doc on doing verificaion via unit testing
    - preparing release 0.2

diff --git a/cai18n-api/pom.xml b/cai18n-api/pom.xml
index a6d5447..cfa7ce2 100644
--- a/cai18n-api/pom.xml
+++ b/cai18n-api/pom.xml
@@ -5,7 +5,7 @@
   <parent>
     <groupId>ch.qos.cai18n</groupId>
     <artifactId>cai18n-parent</artifactId>
-    <version>0.1</version>
+    <version>0.2</version>
   </parent>
 
   <modelVersion>4.0.0</modelVersion>
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/Cai18nConstants.java b/cai18n-api/src/main/java/ch/qos/cai18n/Cai18nConstants.java
index 7568ff0..794bc49 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/Cai18nConstants.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/Cai18nConstants.java
@@ -1,5 +1,12 @@
 package ch.qos.cai18n;
 
+/**
+ * 
+ * This class defines the shared constants in CAI18N.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ *
+ */
 public class Cai18nConstants {
 
   final public static String CODE_URL_PREFIX = "http://cai18n.qos.ch/codes.html";
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java b/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
index 776bf19..1ee5d1f 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
@@ -25,7 +25,38 @@ import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
- 
+
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
+
+/**
+ * This annotation serves to designate a list of locale names for which resource
+ * bundles exist.
+ * 
+ * <p>
+ * Typical usage is:
+ * 
+ * <pre>
+ * &#064;LocaleNames({&quot;en&quot;, &quot;jp&quot;})
+ * &#064;ResourceBundleName(&quot;colors&quot;);
+ * public class enum Colors {
+ *   RED, WHITE, BLUE; 
+ * }
+ * </pre>
+ * 
+ * <p>
+ * In the above example, @LocaleNames({"en", "jp"}) means that there are English
+ * (en) and Japanese translations for the message codes found the Colors enum.
+ * The name of the corresponding resource bundle named "colors".
+ * 
+ * <p>
+ * Verification tools such {@link MessageCodeVerifier} can thus conclude that
+ * the resource bundle files <em>colors_en.properties</em> and
+ * <em>colors_jp.properties</em> exist and should be checked against the codes
+ * defined in the Colors enum.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ * 
+ */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.TYPE)
 public @interface LocaleNames {
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java b/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java
index d471b5a..8233741 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java
@@ -28,14 +28,40 @@ import java.util.ResourceBundle;
 
 import ch.qos.cai18n.util.AnnotationExtractor;
 
+/**
+ * The default implementation for {@link IMessageConveyor} based on resource
+ * bundles.
+ * 
+ * <p>
+ * See also {@link #getMessage(Enum, Object...)} for details.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
 public class MessageConveyor implements IMessageConveyor {
 
   Locale locale;
 
+  /**
+   * The {@link Locale} associated with this instance.
+   * 
+   * @param locale
+   */
   public MessageConveyor(Locale locale) {
     this.locale = locale;
   }
 
+  /**
+   * Given an enum e, find the corresponding resource bundle and return the
+   * internationalized message defined by the message code 'e'.
+   * 
+   * <p>
+   * The name of the resource bundle is defined via the
+   * {@link ResourceBundleName} annotation whereas the locale was specified in
+   * this MessageConveyor instance's constructor.
+   * 
+   * @param e an enum instance used as message code
+   * 
+   */
   public <E extends Enum<?>> String getMessage(E e, Object... args) {
     String code = e.toString();
 
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java b/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java
index e1e8b3c..788567a 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java
@@ -22,12 +22,43 @@
 package ch.qos.cai18n;
 
 import java.lang.annotation.ElementType;
+
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
+
+/**
+ * This annotation serves to designate the name of the resource bundle
+ * corresponding to an enum type.
+ * 
+ * <p>
+ * Typical usage is:
+ * 
+ * <pre>
+ * &#064;LocaleNames({&quot;en&quot;, &quot;jp&quot;})
+ * &#064;ResourceBundleName(&quot;colors&quot;);
+ * public class enum Colors {
+ *   RED, WHITE, BLUE; 
+ * }
+ * </pre>
+ * 
+ * <p>
+ * In the above example, @ResourceBundleName("colors") means that there exists
+ * resource files with the root name "colors". In conjunction with the
+ * information provided in the @LocaleNames annotation, we can assume that the
+ * files <em>colors_en.properties</em> and <em>colors_jp.properties</em> exist.
+ * 
+ * <p>
+ * Verification tools such as {@link MessageCodeVerifier} can then proceed to
+ * check that the codes defined in the enum type match those in the resource bundles.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ * 
+ */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.TYPE)
 public @interface ResourceBundleName {
   String value();
-} 
+}
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/package.html b/cai18n-api/src/main/java/ch/qos/cai18n/package.html
new file mode 100644
index 0000000..a3a71a7
--- /dev/null
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/package.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+
+<html>
+<head>
+<title></title>
+</head>
+
+<body>
+
+<p>The main package of the CAI18N project.</p>
+
+<p>It contains the {@link IMessageConveyor} interface and the default
+implementation {@link MessageConveyor}.
+
+ 
+</p>
+</body>
+</html>
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/util/package.html b/cai18n-api/src/main/java/ch/qos/cai18n/util/package.html
new file mode 100644
index 0000000..271f684
--- /dev/null
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/util/package.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+
+<html>
+<head>
+<title></title>
+</head>
+
+<body>
+
+<p>Package containing utility classes, used internally by the CAI18N
+project.</p>
+
+ 
+</p>
+</body>
+</html>
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java
index 2f74f53..ddc1a85 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java
@@ -25,19 +25,27 @@ import java.util.Locale;
 
 import ch.qos.cai18n.verifier.Cai18nError.ErrorType;
 
+/**
+ * Simplifies the creation of {@link Cai18nError} instances.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ * 
+ */
 public class ErrorFactory {
 
   final Locale locale;
   final Class<?> enumClass;
   final String resourceBundleName;
-  
-  public ErrorFactory(Class<?> enumClass, Locale locale, String resourceBundleName) {
+
+  public ErrorFactory(Class<?> enumClass, Locale locale,
+      String resourceBundleName) {
     this.locale = locale;
     this.enumClass = enumClass;
     this.resourceBundleName = resourceBundleName;
   }
- 
+
   Cai18nError buildError(ErrorType errorType, String code) {
-    return new Cai18nError(errorType, code, enumClass, locale, resourceBundleName);
+    return new Cai18nError(errorType, code, enumClass, locale,
+        resourceBundleName);
   }
 }
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java
index 7fa7309..19a65d4 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java
@@ -4,6 +4,11 @@ import java.util.List;
 import java.util.Locale;
 
 /**
+ * An interface for verifying that given an enum type, the keys match those
+ * found in the corresponding resource bundles.
+ * 
+ * <p>
+ * See also {@link MessageCodeVerifier} for a concrete implementation.
  * 
  * @author Ceki G&uuml;lc&uuml;
  * 
@@ -38,6 +43,16 @@ public interface IMessageCodeVerifier {
   public List<Cai18nError> verify(Locale locale);
 
   /**
+   * Verify that the keys defined in the enumClass match those found in the
+   * corresponding resource bundle for all locales declared in the enum type
+   * via the {@link @LocaleNames} annotation.
+   * 
+   * @param locale
+   * @return
+   */
+  public List<Cai18nError> verifyAllLocales();
+
+  /**
    * Same as {@link #verify(Locale)} except that the return type is
    * List<String>.
    * 
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java
index 3992b8f..35bd09f 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java
@@ -141,6 +141,29 @@ public class MessageCodeVerifier implements IMessageCodeVerifier {
     return strList;
   }
 
+  /***
+   * Verify all declared locales in one step.
+   */
+  public List<Cai18nError> verifyAllLocales() {
+    List<Cai18nError> errorList = new ArrayList<Cai18nError>();
+    
+    String[] localeNameArray = getLocaleNames();
+    
+    if (localeNameArray == null || localeNameArray.length == 0) {
+      String errMsg = "Missing @LocaleNames annotation in enum type ["
+          + enumTypeAsStr + "]";
+      throw new IllegalStateException(errMsg);
+    }
+    for (String localeName : localeNameArray) {
+      Locale locale = new Locale(localeName);
+      List<Cai18nError> tmpList = verify(locale);
+      errorList.addAll(tmpList);
+    }
+    
+    return errorList;
+  }
+
+  
   /* (non-Javadoc)
    * @see ch.qos.cai18n.verifier.IIMessageCodeVerifier#getLocaleNames()
    */
@@ -154,4 +177,6 @@ public class MessageCodeVerifier implements IMessageCodeVerifier {
     return rbName;
   }
 
+  
+
 }
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/package.html b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/package.html
new file mode 100644
index 0000000..493d9fc
--- /dev/null
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/package.html
@@ -0,0 +1,12 @@
+<html>
+  <head>
+    <title></title>
+  </head>
+  
+  <body>
+  
+    <p>Support classes for verifying that there are no message code
+    mis-matches between resource bundles and the corresponding enum type.</p>
+    
+  </body>
+</html>
diff --git a/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java b/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java
index 3dc468a..f4a59e3 100644
--- a/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java
@@ -22,9 +22,11 @@
 
 package ch.qos.cai18n.sample;
 
+import ch.qos.cai18n.LocaleNames;
 import ch.qos.cai18n.ResourceBundleName;
 
 @ResourceBundleName("colors")
+ at LocaleNames({"en_UK", "fr"})
 public enum Colors {
   RED, BLUE, GREEN;
 }
diff --git a/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyAllInOneColorVerificationTest.java
similarity index 66%
copy from cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java
copy to cai18n-api/src/test/java/ch/qos/cai18n/sample/MyAllInOneColorVerificationTest.java
index 3dc468a..0b0b2ad 100644
--- a/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyAllInOneColorVerificationTest.java
@@ -19,12 +19,32 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-
 package ch.qos.cai18n.sample;
 
-import ch.qos.cai18n.ResourceBundleName;
 
- at ResourceBundleName("colors")
-public enum Colors {
-  RED, BLUE, GREEN;
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Test;
+
+import ch.qos.cai18n.verifier.Cai18nError;
+import ch.qos.cai18n.verifier.IMessageCodeVerifier;
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
+
+/**
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ *
+ */
+public class MyAllInOneColorVerificationTest {
+
+
+  @Test
+  public void all() {
+    IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+    List<Cai18nError> errorList = mcv.verifyAllLocales();
+    assertEquals(0, errorList.size());
+  }
+
 }
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyColorVerificationTest.java
similarity index 60%
copy from cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java
copy to cai18n-api/src/test/java/ch/qos/cai18n/sample/MyColorVerificationTest.java
index 2f74f53..7a3d5aa 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyColorVerificationTest.java
@@ -19,25 +19,33 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-package ch.qos.cai18n.verifier;
+package ch.qos.cai18n.sample;
 
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
 import java.util.Locale;
 
-import ch.qos.cai18n.verifier.Cai18nError.ErrorType;
+import org.junit.Test;
 
-public class ErrorFactory {
+import ch.qos.cai18n.verifier.Cai18nError;
+import ch.qos.cai18n.verifier.IMessageCodeVerifier;
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
 
-  final Locale locale;
-  final Class<?> enumClass;
-  final String resourceBundleName;
-  
-  public ErrorFactory(Class<?> enumClass, Locale locale, String resourceBundleName) {
-    this.locale = locale;
-    this.enumClass = enumClass;
-    this.resourceBundleName = resourceBundleName;
+public class MyColorVerificationTest {
+
+  @Test
+  public void en_UK() {
+    IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+    List<Cai18nError> errorList = mcv.verify(Locale.UK);
+    assertEquals(0, errorList.size());
   }
- 
-  Cai18nError buildError(ErrorType errorType, String code) {
-    return new Cai18nError(errorType, code, enumClass, locale, resourceBundleName);
+
+  @Test
+  public void fr() {
+    IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+    List<Cai18nError> errorList = mcv.verify(Locale.FRANCE);
+    assertEquals(0, errorList.size());
   }
 }
diff --git a/cai18n-site/pom.xml b/cai18n-site/pom.xml
index d170ce6..d664cfa 100644
--- a/cai18n-site/pom.xml
+++ b/cai18n-site/pom.xml
@@ -5,7 +5,7 @@
   <parent>
     <groupId>ch.qos.cai18n</groupId>
     <artifactId>cai18n-parent</artifactId>
-    <version>0.1</version>
+    <version>0.2</version>
   </parent>
 
   <modelVersion>4.0.0</modelVersion>
diff --git a/cai18n-site/src/site/pages/index.html b/cai18n-site/src/site/pages/index.html
index 5b427df..94318e8 100644
--- a/cai18n-site/src/site/pages/index.html
+++ b/cai18n-site/src/site/pages/index.html
@@ -25,7 +25,6 @@
    <p>Compiler Assisted Internationalization, abbreviated as CAI18N,
    is a java library for writing internationalized messages.
    </p>
-
    
    <p>Before you start using CAI18N, we highly recommend that you read
    the two-page <a href="manual.html">CAI18N user manual</a>.
diff --git a/cai18n-site/src/site/pages/manual.html b/cai18n-site/src/site/pages/manual.html
index eec52a8..622947a 100644
--- a/cai18n-site/src/site/pages/manual.html
+++ b/cai18n-site/src/site/pages/manual.html
@@ -21,6 +21,7 @@
     </div>
     <div id="content">
   
+  
 
    <h1>CAI18N Manual</h1>
 
@@ -32,6 +33,16 @@
    ResourceBundles</a>.
    </p>
 
+   <h3>Acknowledgement</h3>
+
+   <p>The original idea behind CAI18N is attributed to Takeshi Kondo. It
+   consolidated into what it is today subsequent to a <a
+   href="http://markmail.org/thread/drcabfc6z42sijdo">discussion</a>
+   involving Ralph Goers, Ceki G&uuml;lc&uuml;, Takeshi Kondo and Pete
+   Muir on the slf4j-dev mailing list.
+   </p>
+
+
    <h3>Core idea</h3>
 
    <p>Instead of using values of type String as the key each message,
@@ -100,6 +111,73 @@ String blue = mc.getMessage(Colors.BLUE);  </pre>
   comes with additional tooling support.
   </p>
 
+  <h2>Verification as a test case</h2>
+
+  <p>You can quickly and easily check for mismatches between a given
+  enum type and the corresponding resource bundles.</p>
+
+  <p>Here is the unit test</p>
+
+  <pre class="prettyprint source">
+package foo.aPackage;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.junit.Test;
+
+import ch.qos.cai18n.verifier.Cai18nError;
+import ch.qos.cai18n.verifier.IMessageCodeVerifier;
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
+
+public class MyColorVerificationTest {
+
+  @Test
+  public void en_UK() {
+    IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+    List&lt;Cai18nError> errorList = mcv.verify(Locale.UK);
+    assertEquals(0, errorList.size());
+  }
+
+  @Test
+  public void fr() {
+    IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+    List&lt;Cai18nError> errorList = mcv.verify(Locale.FRANCE);
+    assertEquals(0, errorList.size());
+  }
+} </pre>
+
+  <p>Instead of a unit test case for each locale, assuming you
+  declared the locales in the enum type via the @LocaleNames
+  annotation, you can verify all locales in one sweeping step.</p>
+
+    <pre class="prettyprint source">
+package foo.aPackage;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.junit.Test;
+
+import ch.qos.cai18n.verifier.Cai18nError;
+import ch.qos.cai18n.verifier.IMessageCodeVerifier;
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
+
+public class MyAllInOneColorVerificationTest {
+
+  // verify all locales in one step
+  @Test
+  public void all() {
+    IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+    List&lt;Cai18nError> errorList = mcv.verifyAllLocales();
+    assertEquals(0, errorList.size());
+  }
+} </pre>
+
 
   <h2>Maven Plugin</h2>
 
@@ -133,7 +211,7 @@ String blue = mc.getMessage(Colors.BLUE);  </pre>
           &lt;id>aNameOfYourChoice&lt;/id>
           &lt;phase>verify&lt;/phase>
           &lt;goals>
-            &lt;goal>check&lt;/goal>
+            &lt;goal>verify&lt;/goal>
           &lt;/goals>
           &lt;configuration>            
             <b>&lt;enumTypes></b>
diff --git a/cai18n-site/src/site/pages/news.html b/cai18n-site/src/site/pages/news.html
index 8f14f60..193b861 100644
--- a/cai18n-site/src/site/pages/news.html
+++ b/cai18n-site/src/site/pages/news.html
@@ -27,6 +27,15 @@
     href="http://www.qos.ch/mailman/listinfo/cai18n-announce">cai18n-announce</a>
     mailing list.</p>
 
+    <hr width="80%" align="center" />
+
+    <h3>28th of August 2009 - Release of CAI18N version 0.2</h3>
+
+    <p>Editing changes attributing original idea for CAI18N to Takeshi
+    Kondo, also mentioning the discussion involving Ralph Goers, Ceki
+    Gülcü, Takeshi Kondo and Pete Muir on the slf4j-dev mailing list.
+    usable. </p>
+
     
     <hr width="80%" align="center" />
 
diff --git a/maven-cai18n-plugin-smoke/pom.xml b/maven-cai18n-plugin-smoke/pom.xml
index 7d4977e..0a3b491 100644
--- a/maven-cai18n-plugin-smoke/pom.xml
+++ b/maven-cai18n-plugin-smoke/pom.xml
@@ -4,7 +4,7 @@
 	<parent>
 		<groupId>ch.qos.cai18n</groupId>
 		<artifactId>cai18n-parent</artifactId>
-		<version>0.1</version>
+		<version>0.2</version>
 	</parent>
 
 	<modelVersion>4.0.0</modelVersion>
@@ -32,7 +32,7 @@
 						<id>countries</id>
 						<phase>verify</phase>
 						<goals>
-							<goal>check</goal>
+							<goal>verify</goal>
 						</goals>
             <configuration>
               <enumTypes>
diff --git a/maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/package.html b/maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/package.html
new file mode 100644
index 0000000..19504e7
--- /dev/null
+++ b/maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/package.html
@@ -0,0 +1,11 @@
+<html>
+  <head>
+    <title></title>
+  </head>
+  
+  <body>
+  
+    <p>Smoke testing the maven plugin.
+    </p>
+  </body>
+</html>
diff --git a/maven-cai18n-plugin/pom.xml b/maven-cai18n-plugin/pom.xml
index efa4b13..9bfcff9 100644
--- a/maven-cai18n-plugin/pom.xml
+++ b/maven-cai18n-plugin/pom.xml
@@ -8,7 +8,7 @@
   <parent>
     <artifactId>cai18n-parent</artifactId>
     <groupId>ch.qos.cai18n</groupId>
-    <version>0.1</version>
+    <version>0.2</version>
   </parent>
 
   <groupId>ch.qos.cai18n.plugins</groupId>
diff --git a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java
deleted file mode 100644
index c7165c5..0000000
--- a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package ch.qos.cai18n;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-
-/**
- * An almost trivial no fuss implementation of a class loader following the
- * child-first delegation model.
- * 
- * @author Ceki Gülcü
- */
-public class ThisFirstClassLoader extends URLClassLoader {
-
-  public ThisFirstClassLoader(URL[] urls) {
-    super(urls);
-  }
-
-  public ThisFirstClassLoader(URL[] urls, ClassLoader parent) {
-    super(urls, parent);
-  }
-
-  public void addURL(URL url) {
-    super.addURL(url);
-  }
-
-  @Override
-  public Class<?> loadClass(String name) throws ClassNotFoundException {
-    return loadClass(name, false);
-  }
-
-  /**
-   * We override the parent-first behavior established by java.lang.Classloader.
-   * 
-   * The implementation is surprisingly straightforward.
-   */
-  protected Class<?> loadClass(String name, boolean resolve)
-      throws ClassNotFoundException {
-
-    if(name.equals("ch.qos.cai18n.verifier.IMessageCodeVerifier")) {
-      return super.loadClass(name, resolve);
-    }
-    
-    // First, check if the class has already been loaded
-    Class<?> c = findLoadedClass(name);
-
-    // if not loaded, search the local (child) resources
-    if (c == null) {
-      try {
-        c = findClass(name);
-      } catch (ClassNotFoundException cnfe) {
-        // ignore
-      }
-    }
-
-    // if we could not find it, delegate to parent
-    // Note that we don't attempt to catch any ClassNotFoundException
-    if (c == null) {
-      if (getParent() != null) {
-        c = getParent().loadClass(name);
-      } else {
-        c = getSystemClassLoader().loadClass(name);
-      }
-    }
-
-    if (resolve) {
-      resolveClass(c);
-    }
-
-    return c;
-  }
-}
diff --git a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/ThisFirstClassLoader.java b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/ThisFirstClassLoader.java
new file mode 100644
index 0000000..12cf782
--- /dev/null
+++ b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/ThisFirstClassLoader.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2009 QOS.ch All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS  IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package ch.qos.cai18n.plugins;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * An almost trivial no fuss implementation of a class loader following the
+ * child-first delegation model.
+ * 
+ * @author Ceki Gülcü
+ */
+public class ThisFirstClassLoader extends URLClassLoader {
+
+  public ThisFirstClassLoader(URL[] urls) {
+    super(urls);
+  }
+
+  public ThisFirstClassLoader(URL[] urls, ClassLoader parent) {
+    super(urls, parent);
+  }
+
+  public void addURL(URL url) {
+    super.addURL(url);
+  }
+
+  @Override
+  public Class<?> loadClass(String name) throws ClassNotFoundException {
+    return loadClass(name, false);
+  }
+
+  /**
+   * We override the parent-first behavior established by java.lang.Classloader.
+   * 
+   * The implementation is surprisingly straightforward.
+   */
+  protected Class<?> loadClass(String name, boolean resolve)
+      throws ClassNotFoundException {
+
+    // Treating IMessageCodeVerifier as a special case is the whole point of the
+    // exercise.
+    if (name.equals("ch.qos.cai18n.verifier.IMessageCodeVerifier")) {
+      return super.loadClass(name, resolve);
+    }
+
+    // First, check if the class has already been loaded
+    Class<?> c = findLoadedClass(name);
+
+    // if not loaded, search the local (child) resources
+    if (c == null) {
+      try {
+        c = findClass(name);
+      } catch (ClassNotFoundException cnfe) {
+        // ignore
+      }
+    }
+
+    // if we could not find it, delegate to parent
+    // Note that we don't attempt to catch any ClassNotFoundException
+    if (c == null) {
+      if (getParent() != null) {
+        c = getParent().loadClass(name);
+      } else {
+        c = getSystemClassLoader().loadClass(name);
+      }
+    }
+
+    if (resolve) {
+      resolveClass(c);
+    }
+
+    return c;
+  }
+}
diff --git a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/VerifyMojo.java
similarity index 95%
rename from maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java
rename to maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/VerifyMojo.java
index f913fd6..9a76142 100644
--- a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java
+++ b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/VerifyMojo.java
@@ -19,7 +19,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-package ch.qos.cai18n;
+package ch.qos.cai18n.plugins;
 
 import java.io.File;
 import java.lang.reflect.Constructor;
@@ -37,12 +37,13 @@ import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 
+import ch.qos.cai18n.Cai18nConstants;
 import ch.qos.cai18n.verifier.IMessageCodeVerifier;
 
 /**
  * Verifies resources bundles in various locales against an enumType
  * 
- * @goal check
+ * @goal verify
  * @phase verify
  * @requiresProject true
  */
diff --git a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/package.html b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/package.html
new file mode 100644
index 0000000..1a26308
--- /dev/null
+++ b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/package.html
@@ -0,0 +1,12 @@
+<html>
+  <head>
+    <title></title>
+  </head>
+  
+  <body>
+  
+    <p>Maven plugin verifying that the codes defined in an enum type
+    match those in the corresponding resource bundles.
+    </p>
+  </body>
+</html>
diff --git a/pom.xml b/pom.xml
index d222ee2..9b5103b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,11 +6,17 @@
   <groupId>ch.qos.cai18n</groupId>
   <artifactId>cai18n-parent</artifactId>
 	<packaging>pom</packaging>
-  <version>0.1</version>
+  <version>0.2</version>
   <name>Compiler assisted internationalization library (CAI18N) - Parent</name>
 
   <url>http://cai18n.qos.ch</url>
-
+  
+  <organization>
+    <name>QOS.ch</name>
+    <url>http://www.qos.ch</url>
+  </organization>
+  <inceptionYear>2009</inceptionYear>
+ 
   <modules>
     <module>cai18n-api</module>
     <module>cai18n-site</module>
@@ -164,9 +170,15 @@
 					</links>
           <groups>
             <group>
-              <title>SLF4J packages</title>
-              <packages>ch.qos.cai18n:ch.qos.cai18n..*</packages>
+              <title>CAI18N API packages</title>
+              <packages>ch.qos.cai18n:ch.qos.cai18n.verifier:ch.qos.cai18n.util</packages>
             </group>
+
+            <group>
+              <title>CAI18N Maven plugin</title>
+              <packages>ch.qos.cai18n.plugins</packages>
+            </group>
+
           </groups>
         </configuration>
       </plugin>

-----------------------------------------------------------------------

Summary of changes:
 cai18n-api/pom.xml                                 |    2 +-
 .../main/java/ch/qos/cai18n/Cai18nConstants.java   |    7 ++
 .../src/main/java/ch/qos/cai18n/LocaleNames.java   |   33 +++++++-
 .../main/java/ch/qos/cai18n/MessageConveyor.java   |   26 ++++++
 .../java/ch/qos/cai18n/ResourceBundleName.java     |   33 +++++++-
 .../src/main/java/ch/qos/cai18n/package.html       |   18 ++++
 .../src/main/java/ch/qos/cai18n/util/package.html  |   16 ++++
 .../java/ch/qos/cai18n/verifier/ErrorFactory.java  |   16 +++-
 .../qos/cai18n/verifier/IMessageCodeVerifier.java  |   15 +++
 .../qos/cai18n/verifier/MessageCodeVerifier.java   |   25 +++++
 .../main/java/ch/qos/cai18n/verifier/package.html  |   12 +++
 .../src/test/java/ch/qos/cai18n/sample/Colors.java |    2 +
 .../MyAllInOneColorVerificationTest.java}          |   33 ++++---
 .../MyColorVerificationTest.java}                  |   30 ++++---
 cai18n-site/pom.xml                                |    2 +-
 cai18n-site/src/site/pages/index.html              |    1 -
 cai18n-site/src/site/pages/manual.html             |   88 +++++++++++++++++-
 cai18n-site/src/site/pages/news.html               |   13 +++
 maven-cai18n-plugin-smoke/pom.xml                  |    4 +-
 .../src/main/java/ch/qos/cai18n/smoke/package.html |   11 +++
 maven-cai18n-plugin/pom.xml                        |    2 +-
 .../java/ch/qos/cai18n/ThisFirstClassLoader.java   |   71 ---------------
 .../qos/cai18n/plugins/ThisFirstClassLoader.java   |   94 ++++++++++++++++++++
 .../ch/qos/cai18n/{ => plugins}/VerifyMojo.java    |    5 +-
 .../main/java/ch/qos/cai18n/plugins/package.html   |   12 +++
 pom.xml                                            |   20 ++++-
 26 files changed, 470 insertions(+), 121 deletions(-)
 create mode 100644 cai18n-api/src/main/java/ch/qos/cai18n/package.html
 create mode 100644 cai18n-api/src/main/java/ch/qos/cai18n/util/package.html
 create mode 100644 cai18n-api/src/main/java/ch/qos/cai18n/verifier/package.html
 copy cai18n-api/src/test/java/ch/qos/cai18n/{util/AnnotationExtractorTest.java => sample/MyAllInOneColorVerificationTest.java} (69%)
 copy cai18n-api/src/test/java/ch/qos/cai18n/{util/AnnotationExtractorTest.java => sample/MyColorVerificationTest.java} (63%)
 create mode 100644 maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/package.html
 delete mode 100644 maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java
 create mode 100644 maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/ThisFirstClassLoader.java
 rename maven-cai18n-plugin/src/main/java/ch/qos/cai18n/{ => plugins}/VerifyMojo.java (95%)
 create mode 100644 maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/package.html


hooks/post-receive
-- 
Compiler assisted internalization library



More information about the cal10n-dev mailing list