commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r493507 [2/2] - in /jakarta/commons/sandbox/i18n/trunk: src/examples/ src/examples/org/apache/i18n/examples/ src/java/org/apache/commons/i18n/ src/java/org/apache/commons/i18n/bundles/ src/resources/ src/test/ src/test/org/apache/commons/i1...
Date Sat, 06 Jan 2007 16:49:25 GMT
Modified: jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/JdbcMessageProviderTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/JdbcMessageProviderTest.java?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/JdbcMessageProviderTest.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/JdbcMessageProviderTest.java Sat Jan  6 08:49:24 2007
@@ -1,170 +1,170 @@
-package org.apache.commons.i18n;
-
-import junit.framework.TestCase;
-
-import java.sql.DriverManager;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.dbcp.BasicDataSource;
-
-/**
- * @author Mattias Jiderhamn
- */
-public class JdbcMessageProviderTest extends TestCase {
-
-    private static Connection getNewConnection() throws SQLException {
-        return DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
-    }
-
-    public void setUp() throws Exception {
-        /* Make sure en_US is the default Locale for tests */
-        Locale.setDefault(Locale.US);
-
-        Class.forName("org.hsqldb.jdbcDriver"); // Load HSQLDB database driver
-        Connection conn = getNewConnection();
-        Statement stmt = conn.createStatement();
-        stmt.execute(
-                "CREATE TABLE messages ( " +
-                "  'id' VARCHAR(30), " +
-                "  'language' VARCHAR(2), " +
-                "  'title' VARCHAR(100), " +
-                "  'text' VARCHAR(100)" +
-                ")");
-        stmt.execute(
-                "INSERT INTO messages VALUES (" +
-                "  'helloWorld', 'en', " +
-                "  'Hello World', 'I wish you a merry christmas!'" +
-                ")"
-        );
-        stmt.execute(
-                "INSERT INTO messages VALUES (" +
-                "  'helloWorld', 'de', " +
-                "  'Hallo Welt', 'Ich wünsche Dir alles Gute und ein frohes Fest!'" +
-                ")"
-        );
-        stmt.close();
-        conn.close();
-    }
-
-    public void tearDown() throws Exception {
-        Connection conn = getNewConnection();
-        conn.createStatement().execute(
-                "DROP TABLE messages"
-        );
-        conn.close();
-    }
-
-    public void testConstructors() throws Exception {
-        // Connection constructor
-        Connection conn = DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
-        JdbcMessageProvider jdbcMessageProvider = new JdbcMessageProvider(conn, "messages", "id", "language");
-        conn.close();
-        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.ENGLISH));
-
-        // DataSource constructor
-        BasicDataSource dataSource = new BasicDataSource();
-        dataSource.setUrl("jdbc:hsqldb:.");
-        dataSource.setUsername("sa");
-        dataSource.setPassword("");
-        jdbcMessageProvider = new JdbcMessageProvider(dataSource, "messages", "id", "language");
-        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.ENGLISH));
-        
-        // Map/Properties constructor
-        Properties props = new Properties();
-        props.setProperty("jdbc.connect.driver", "org.hsqldb.jdbcDriver");
-        props.setProperty("jdbc.connect.url", "jdbc:hsqldb:.");
-        props.setProperty("jdbc.connect.login", "sa");
-        props.setProperty("jdbc.connect.password", "");
-
-        props.setProperty("jdbc.sql.table", "messages");
-        props.setProperty("jdbc.sql.key.column", "id");
-        props.setProperty("jdbc.sql.locale.column", "language");
-        jdbcMessageProvider = new JdbcMessageProvider(props);
-        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.ENGLISH));
-
-        // Test install
-        MessageManager.addMessageProvider("messages", jdbcMessageProvider);
-        assertEquals("Hello World", MessageManager.getText("helloWorld", "title", null, Locale.ENGLISH));
-    }
-
-    public void testGetText() throws Exception {
-        Connection conn = DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
-        JdbcMessageProvider jdbcMessageProvider = new JdbcMessageProvider(conn, "messages", "id", "language");
-        conn.close();
-
-        // Explicit default locale
-        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.ENGLISH));
-        assertEquals("I wish you a merry christmas!", jdbcMessageProvider.getText("helloWorld", "text", Locale.ENGLISH));
-
-        // Default locale with country
-        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.US));
-        assertEquals("I wish you a merry christmas!", jdbcMessageProvider.getText("helloWorld", "text", Locale.US));
-
-        // Default locale with country and variant
-        Locale scottish = new Locale("en", "", "scottish");
-        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", scottish));
-        assertEquals("I wish you a merry christmas!", jdbcMessageProvider.getText("helloWorld", "text", scottish));
-
-        assertEquals("Hallo Welt", jdbcMessageProvider.getText("helloWorld", "title", Locale.GERMAN));
-        assertEquals("Ich wünsche Dir alles Gute und ein frohes Fest!", jdbcMessageProvider.getText("helloWorld", "text", Locale.GERMAN));
-
-        // Default locale with country
-        assertEquals("Hallo Welt", jdbcMessageProvider.getText("helloWorld", "title", Locale.GERMANY));
-        assertEquals("Ich wünsche Dir alles Gute und ein frohes Fest!", jdbcMessageProvider.getText("helloWorld", "text", Locale.GERMANY));
-
-        // Test use of defaule
-        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.JAPANESE));
-        assertEquals("I wish you a merry christmas!", jdbcMessageProvider.getText("helloWorld", "text", Locale.JAPANESE));
-        
-        // Test non-existent
-        assertNull(jdbcMessageProvider.getText("helloWorld", "foobar", Locale.ENGLISH));
-        assertNull(jdbcMessageProvider.getText("foo", "bar", Locale.ENGLISH));
-    }
-
-    public void testGetEntries() throws Exception {
-        Connection conn = DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
-        JdbcMessageProvider jdbcMessageProvider = new JdbcMessageProvider(conn, "messages", "id", "language");
-        conn.close();
-
-        // Explicit default locale
-        Map entries = jdbcMessageProvider.getEntries("helloWorld", Locale.ENGLISH);
-        assertEquals("No of entries", 2, entries.size());
-        assertEquals("Hello World", (String)entries.get("title"));
-        assertEquals("I wish you a merry christmas!", (String)entries.get("text"));
-
-        // Default locale with country
-        entries = jdbcMessageProvider.getEntries("helloWorld", Locale.US);
-        assertEquals("No of entries", 2, entries.size());
-        assertEquals("Hello World", (String)entries.get("title"));
-        assertEquals("I wish you a merry christmas!", (String)entries.get("text"));
-
-        // Default locale with country and variant
-        Locale scottish = new Locale("en", "", "scottish");
-        entries = jdbcMessageProvider.getEntries("helloWorld", scottish);
-        assertEquals("No of entries", 2, entries.size());
-        assertEquals("Hello World", (String)entries.get("title"));
-        assertEquals("I wish you a merry christmas!", (String)entries.get("text"));
-
-        entries = jdbcMessageProvider.getEntries("helloWorld", Locale.GERMAN);
-        assertEquals("No of entries", 2, entries.size());
-        assertEquals("Hallo Welt", (String)entries.get("title"));
-        assertEquals("Ich wünsche Dir alles Gute und ein frohes Fest!", (String)entries.get("text"));
-
-        // Default locale with country
-        entries = jdbcMessageProvider.getEntries("helloWorld", Locale.GERMANY);
-        assertEquals("No of entries", 2, entries.size());
-        assertEquals("Hallo Welt", (String)entries.get("title"));
-        assertEquals("Ich wünsche Dir alles Gute und ein frohes Fest!", (String)entries.get("text"));
-
-        // Test use of defaule
-        entries = jdbcMessageProvider.getEntries("helloWorld", Locale.JAPANESE);
-        assertEquals("No of entries", 2, entries.size());
-        assertEquals("Hello World", (String)entries.get("title"));
-        assertEquals("I wish you a merry christmas!", (String)entries.get("text"));
-    }
-}
+package org.apache.commons.i18n;
+
+import junit.framework.TestCase;
+
+import java.sql.DriverManager;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.dbcp.BasicDataSource;
+
+/**
+ * @author Mattias Jiderhamn
+ */
+public class JdbcMessageProviderTest extends TestCase {
+
+    private static Connection getNewConnection() throws SQLException {
+        return DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
+    }
+
+    public void setUp() throws Exception {
+        /* Make sure en_US is the default Locale for tests */
+        Locale.setDefault(Locale.US);
+
+        Class.forName("org.hsqldb.jdbcDriver"); // Load HSQLDB database driver
+        Connection conn = getNewConnection();
+        Statement stmt = conn.createStatement();
+        stmt.execute(
+                "CREATE TABLE messages ( " +
+                "  'id' VARCHAR(30), " +
+                "  'language' VARCHAR(2), " +
+                "  'title' VARCHAR(100), " +
+                "  'text' VARCHAR(100)" +
+                ")");
+        stmt.execute(
+                "INSERT INTO messages VALUES (" +
+                "  'helloWorld', 'en', " +
+                "  'Hello World', 'I wish you a merry christmas!'" +
+                ")"
+        );
+        stmt.execute(
+                "INSERT INTO messages VALUES (" +
+                "  'helloWorld', 'de', " +
+                "  'Hallo Welt', 'Ich wünsche Dir alles Gute und ein frohes Fest!'" +
+                ")"
+        );
+        stmt.close();
+        conn.close();
+    }
+
+    public void tearDown() throws Exception {
+        Connection conn = getNewConnection();
+        conn.createStatement().execute(
+                "DROP TABLE messages"
+        );
+        conn.close();
+    }
+
+    public void testConstructors() throws Exception {
+        // Connection constructor
+        Connection conn = DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
+        JdbcMessageProvider jdbcMessageProvider = new JdbcMessageProvider(conn, "messages", "id", "language");
+        conn.close();
+        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.ENGLISH));
+
+        // DataSource constructor
+        BasicDataSource dataSource = new BasicDataSource();
+        dataSource.setUrl("jdbc:hsqldb:.");
+        dataSource.setUsername("sa");
+        dataSource.setPassword("");
+        jdbcMessageProvider = new JdbcMessageProvider(dataSource, "messages", "id", "language");
+        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.ENGLISH));
+        
+        // Map/Properties constructor
+        Properties props = new Properties();
+        props.setProperty("jdbc.connect.driver", "org.hsqldb.jdbcDriver");
+        props.setProperty("jdbc.connect.url", "jdbc:hsqldb:.");
+        props.setProperty("jdbc.connect.login", "sa");
+        props.setProperty("jdbc.connect.password", "");
+
+        props.setProperty("jdbc.sql.table", "messages");
+        props.setProperty("jdbc.sql.key.column", "id");
+        props.setProperty("jdbc.sql.locale.column", "language");
+        jdbcMessageProvider = new JdbcMessageProvider(props);
+        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.ENGLISH));
+
+        // Test install
+        MessageManager.addMessageProvider("messages", jdbcMessageProvider);
+        assertEquals("Hello World", MessageManager.getText("helloWorld", "title", null, Locale.ENGLISH));
+    }
+
+    public void testGetText() throws Exception {
+        Connection conn = DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
+        JdbcMessageProvider jdbcMessageProvider = new JdbcMessageProvider(conn, "messages", "id", "language");
+        conn.close();
+
+        // Explicit default locale
+        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.ENGLISH));
+        assertEquals("I wish you a merry christmas!", jdbcMessageProvider.getText("helloWorld", "text", Locale.ENGLISH));
+
+        // Default locale with country
+        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.US));
+        assertEquals("I wish you a merry christmas!", jdbcMessageProvider.getText("helloWorld", "text", Locale.US));
+
+        // Default locale with country and variant
+        Locale scottish = new Locale("en", "", "scottish");
+        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", scottish));
+        assertEquals("I wish you a merry christmas!", jdbcMessageProvider.getText("helloWorld", "text", scottish));
+
+        assertEquals("Hallo Welt", jdbcMessageProvider.getText("helloWorld", "title", Locale.GERMAN));
+        assertEquals("Ich wünsche Dir alles Gute und ein frohes Fest!", jdbcMessageProvider.getText("helloWorld", "text", Locale.GERMAN));
+
+        // Default locale with country
+        assertEquals("Hallo Welt", jdbcMessageProvider.getText("helloWorld", "title", Locale.GERMANY));
+        assertEquals("Ich wünsche Dir alles Gute und ein frohes Fest!", jdbcMessageProvider.getText("helloWorld", "text", Locale.GERMANY));
+
+        // Test use of defaule
+        assertEquals("Hello World", jdbcMessageProvider.getText("helloWorld", "title", Locale.JAPANESE));
+        assertEquals("I wish you a merry christmas!", jdbcMessageProvider.getText("helloWorld", "text", Locale.JAPANESE));
+        
+        // Test non-existent
+        assertNull(jdbcMessageProvider.getText("helloWorld", "foobar", Locale.ENGLISH));
+        assertNull(jdbcMessageProvider.getText("foo", "bar", Locale.ENGLISH));
+    }
+
+    public void testGetEntries() throws Exception {
+        Connection conn = DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
+        JdbcMessageProvider jdbcMessageProvider = new JdbcMessageProvider(conn, "messages", "id", "language");
+        conn.close();
+
+        // Explicit default locale
+        Map entries = jdbcMessageProvider.getEntries("helloWorld", Locale.ENGLISH);
+        assertEquals("No of entries", 2, entries.size());
+        assertEquals("Hello World", (String)entries.get("title"));
+        assertEquals("I wish you a merry christmas!", (String)entries.get("text"));
+
+        // Default locale with country
+        entries = jdbcMessageProvider.getEntries("helloWorld", Locale.US);
+        assertEquals("No of entries", 2, entries.size());
+        assertEquals("Hello World", (String)entries.get("title"));
+        assertEquals("I wish you a merry christmas!", (String)entries.get("text"));
+
+        // Default locale with country and variant
+        Locale scottish = new Locale("en", "", "scottish");
+        entries = jdbcMessageProvider.getEntries("helloWorld", scottish);
+        assertEquals("No of entries", 2, entries.size());
+        assertEquals("Hello World", (String)entries.get("title"));
+        assertEquals("I wish you a merry christmas!", (String)entries.get("text"));
+
+        entries = jdbcMessageProvider.getEntries("helloWorld", Locale.GERMAN);
+        assertEquals("No of entries", 2, entries.size());
+        assertEquals("Hallo Welt", (String)entries.get("title"));
+        assertEquals("Ich wünsche Dir alles Gute und ein frohes Fest!", (String)entries.get("text"));
+
+        // Default locale with country
+        entries = jdbcMessageProvider.getEntries("helloWorld", Locale.GERMANY);
+        assertEquals("No of entries", 2, entries.size());
+        assertEquals("Hallo Welt", (String)entries.get("title"));
+        assertEquals("Ich wünsche Dir alles Gute und ein frohes Fest!", (String)entries.get("text"));
+
+        // Test use of defaule
+        entries = jdbcMessageProvider.getEntries("helloWorld", Locale.JAPANESE);
+        assertEquals("No of entries", 2, entries.size());
+        assertEquals("Hello World", (String)entries.get("title"));
+        assertEquals("I wish you a merry christmas!", (String)entries.get("text"));
+    }
+}

Propchange: jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/JdbcMessageProviderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/commons/sandbox/i18n/trunk/src/test/testMessages.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/test/testMessages.xml?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/testMessages.xml (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/testMessages.xml Sat Jan  6 08:49:24 2007
@@ -1,49 +1,49 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<messages>
-    <!-- Feel free to insert your locale or correct mispellings here -->
-    <message id="helloWorld">
-        <locale language="en">
-            <entry key="title">hello world</entry>
-            <entry key="text">hello world, we are in {0}.</entry>
-            <entry key="summary">sample summary to test english messages. Country = {0}, language = {1} and variant = {2}.</entry>
-            <entry key="details">sample deatils to test english messages. Country = {0}, language = {1} and variant = {2}.</entry>
-            <entry key="notTranslated">This entry is not translated to any other languages (XML)</entry>
-        </locale>
-        <locale language="pt" country="br">
-            <entry key="title">olo mundo</entry>
-            <entry key="text">hello mundo, nós estamos no {0}.</entry>
-            <entry key="summary">sample summary to test portuguese messages. Country = {0}, language = {1} and variant = {2}.</entry>
-            <entry key="details">sample deatils to test portuguese messages. Country = {0}, language = {1} and variant = {2}.</entry>
-        </locale>
-        <locale language="es">
-            <entry key="title">hola mundo</entry>
-            <entry key="text">hola mundo, estamos em los {0}.</entry>
-            <entry key="summary">sample summary to test spanish messages. Country = {0}, language = {1} and variant = {2}.</entry>
-            <entry key="details">sample deatils to test spanish messages. Country = {0}, language = {1} and variant = {2}.</entry>
-        </locale>
-        <locale language="it">
-            <entry key="title">ciao mondo</entry>
-            <entry key="text">ciao mondo, siamo negli {0}.</entry>
-            <entry key="summary">sample summary to test italian messages. Country = {0}, language = {1} and variant = {2}.</entry>
-            <entry key="details">sample deatils to test italian messages. Country = {0}, language = {1} and variant = {2}.</entry>
-        </locale>
-        <locale language="fr">
-            <entry key="title">bonjour monde</entry>
-            <entry key="text">bonjour monde, nous sommes aux {0}.</entry>
-            <entry key="summary">sample summary to test francais messages. Country = {0}, language = {1} and variant = {2}.</entry>
-            <entry key="details">sample deatils to test francais messages. Country = {0}, language = {1} and variant = {2}.</entry>
-        </locale>
-        <locale language="du">
-            <entry key="title">hello wereld</entry>
-            <entry key="text">hello wereld, zijn wij in de {0}.</entry>
-            <entry key="summary">sample summary to test dutch messages. Country = {0}, language = {1} and variant = {2}.</entry>
-            <entry key="details">sample deatils to test dutch messages. Country = {0}, language = {1} and variant = {2}.</entry>
-        </locale>
-        <locale language="de">
-            <entry key="title">Hallo Welt</entry>
-            <entry key="text">Wir sind in {0}.</entry>
-            <entry key="summary">sample summary to test german messages. Country = {0}, language = {1} and variant = {2}.</entry>
-            <entry key="details">sample deatils to test german messages. Country = {0}, language = {1} and variant = {2}.</entry>
-        </locale>
-    </message>
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<messages>
+    <!-- Feel free to insert your locale or correct mispellings here -->
+    <message id="helloWorld">
+        <locale language="en">
+            <entry key="title">hello world</entry>
+            <entry key="text">hello world, we are in {0}.</entry>
+            <entry key="summary">sample summary to test english messages. Country = {0}, language = {1} and variant = {2}.</entry>
+            <entry key="details">sample deatils to test english messages. Country = {0}, language = {1} and variant = {2}.</entry>
+            <entry key="notTranslated">This entry is not translated to any other languages (XML)</entry>
+        </locale>
+        <locale language="pt" country="br">
+            <entry key="title">olo mundo</entry>
+            <entry key="text">hello mundo, nós estamos no {0}.</entry>
+            <entry key="summary">sample summary to test portuguese messages. Country = {0}, language = {1} and variant = {2}.</entry>
+            <entry key="details">sample deatils to test portuguese messages. Country = {0}, language = {1} and variant = {2}.</entry>
+        </locale>
+        <locale language="es">
+            <entry key="title">hola mundo</entry>
+            <entry key="text">hola mundo, estamos em los {0}.</entry>
+            <entry key="summary">sample summary to test spanish messages. Country = {0}, language = {1} and variant = {2}.</entry>
+            <entry key="details">sample deatils to test spanish messages. Country = {0}, language = {1} and variant = {2}.</entry>
+        </locale>
+        <locale language="it">
+            <entry key="title">ciao mondo</entry>
+            <entry key="text">ciao mondo, siamo negli {0}.</entry>
+            <entry key="summary">sample summary to test italian messages. Country = {0}, language = {1} and variant = {2}.</entry>
+            <entry key="details">sample deatils to test italian messages. Country = {0}, language = {1} and variant = {2}.</entry>
+        </locale>
+        <locale language="fr">
+            <entry key="title">bonjour monde</entry>
+            <entry key="text">bonjour monde, nous sommes aux {0}.</entry>
+            <entry key="summary">sample summary to test francais messages. Country = {0}, language = {1} and variant = {2}.</entry>
+            <entry key="details">sample deatils to test francais messages. Country = {0}, language = {1} and variant = {2}.</entry>
+        </locale>
+        <locale language="du">
+            <entry key="title">hello wereld</entry>
+            <entry key="text">hello wereld, zijn wij in de {0}.</entry>
+            <entry key="summary">sample summary to test dutch messages. Country = {0}, language = {1} and variant = {2}.</entry>
+            <entry key="details">sample deatils to test dutch messages. Country = {0}, language = {1} and variant = {2}.</entry>
+        </locale>
+        <locale language="de">
+            <entry key="title">Hallo Welt</entry>
+            <entry key="text">Wir sind in {0}.</entry>
+            <entry key="summary">sample summary to test german messages. Country = {0}, language = {1} and variant = {2}.</entry>
+            <entry key="details">sample deatils to test german messages. Country = {0}, language = {1} and variant = {2}.</entry>
+        </locale>
+    </message>
 </messages>

Propchange: jakarta/commons/sandbox/i18n/trunk/src/test/testMessages.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/commons/sandbox/i18n/trunk/src/test/variantTestMessages.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/test/variantTestMessages.xml?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/variantTestMessages.xml (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/variantTestMessages.xml Sat Jan  6 08:49:24 2007
@@ -1,18 +1,18 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<messages>
-    <message id="variants">
-        <locale language="en">
-            <entry key="theKey">hello world</entry>
-        </locale>
-        <!-- For Scottish translations, see http://www.whoohoo.co.uk/main.asp?pageid=scottie&topic=translator -->
-        <locale language="en" country="GB" variant="scottish">
-            <entry key="theKey">Awrite warld</entry>
-        </locale>
-        <locale country="BW">
-            <entry key="theKey">Hello Botswana</entry>
-        </locale>
-        <locale language="en" variant="baby">
-            <entry key="theKey">Ga, ga, ga</entry>
-        </locale>
-    </message>
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<messages>
+    <message id="variants">
+        <locale language="en">
+            <entry key="theKey">hello world</entry>
+        </locale>
+        <!-- For Scottish translations, see http://www.whoohoo.co.uk/main.asp?pageid=scottie&topic=translator -->
+        <locale language="en" country="GB" variant="scottish">
+            <entry key="theKey">Awrite warld</entry>
+        </locale>
+        <locale country="BW">
+            <entry key="theKey">Hello Botswana</entry>
+        </locale>
+        <locale language="en" variant="baby">
+            <entry key="theKey">Ga, ga, ga</entry>
+        </locale>
+    </message>
 </messages>

Propchange: jakarta/commons/sandbox/i18n/trunk/src/test/variantTestMessages.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/commons/sandbox/i18n/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/xdocs/changes.xml?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/sandbox/i18n/trunk/xdocs/changes.xml Sat Jan  6 08:49:24 2007
@@ -1,32 +1,32 @@
-<document>
-  <properties>
-    <title>I18n</title>
-    <author email="dflorey@apache.org">Daniel Florey</author>
-  </properties>
-  <body>
-    <release version="0.5" date="2005-02-18">
-      <action dev="dflorey" type="add">
-        Added localized messages for all log and exception messages in the i18n-component itself
-      </action>              
-      <action dev="dflorey" type="add">
-        Added initial test suite
-      </action>              
-    </release>
-    <release version="0.4" date="2005-02-16">
-      <action dev="dflorey" type="add">
-        Added localized runtime exception and localized error class
-      </action>              
-      <action dev="dflorey" type="update">
-        Moved all message bundles to bundles-subpackage
-      </action>              
-    </release>
-    <release version="0.3" date="2005-02-14">
-      <action dev="dflorey" type="add">
-        Added pluggable message providers
-      </action>              
-      <action dev="dflorey" type="add">
-        Added property file based message provider
-      </action>              
-    </release>
-  </body>
-</document>
+<document>
+  <properties>
+    <title>I18n</title>
+    <author email="dflorey@apache.org">Daniel Florey</author>
+  </properties>
+  <body>
+    <release version="0.5" date="2005-02-18">
+      <action dev="dflorey" type="add">
+        Added localized messages for all log and exception messages in the i18n-component itself
+      </action>              
+      <action dev="dflorey" type="add">
+        Added initial test suite
+      </action>              
+    </release>
+    <release version="0.4" date="2005-02-16">
+      <action dev="dflorey" type="add">
+        Added localized runtime exception and localized error class
+      </action>              
+      <action dev="dflorey" type="update">
+        Moved all message bundles to bundles-subpackage
+      </action>              
+    </release>
+    <release version="0.3" date="2005-02-14">
+      <action dev="dflorey" type="add">
+        Added pluggable message providers
+      </action>              
+      <action dev="dflorey" type="add">
+        Added property file based message provider
+      </action>              
+    </release>
+  </body>
+</document>

Propchange: jakarta/commons/sandbox/i18n/trunk/xdocs/changes.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml (original)
+++ jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml Sat Jan  6 08:49:24 2007
@@ -1,212 +1,212 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<document>
-
- <properties>
-  <title>Examples</title>
-  <author email="commons-dev@jakarta.apache.org">Commons Documentation Team</author>
- </properties>
-
- <body>
- 
-<section name="Examples">
-<p>This page contains some examples showing the capabilities of the i18n-compoenent.
-Most of the examples can be found in the components sources in the example-package.</p>
-</section>
-
-<section name="Using localized exceptions">
-<p>
-The following example shows how to take advantage of detailed error information
-provided by localized exceptions. In the real world it is no good idea to create
-LocalizedExceptions directly, but to create your own subclasses of LocalizedException.</p>
-<source>
-public class LocalizedExceptionExample {
-    private static final Logger logger = Logger
-            .getLogger(LocalizedExceptionExample.class.getName());
-
-    public static void main(String[] args) {
-        // Install the file providing the required messages for this example
-        MessageManager.addMessageProvider("org.apache.commons-i18n.examples",
-                new XMLMessageProvider(Thread.currentThread().getContextClassLoader().getResourceAsStream(
-                        "exampleMessages.xml")));
-
-        // Simulate the locale of the current user in a multi-user environment
-        // such as a web application
-        Locale currentUsersLocale = Locale.GERMAN;
-
-        // This is the real part dealing with localized exceptions
-        try {
-            someMethodThrowingAnException();
-        } catch (LocalizedException exception) {
-            // Retrieve the detailed localized error message
-            ErrorBundle errorMessage = exception.getErrorMessage();
-
-            // Print the summary of this error to the log with level SEVERE
-            // using the VM default locale:
-            logger.log(Level.SEVERE, errorMessage.getSummary(Locale
-                    .getDefault()));
-
-            // Print the details of this error to the log with level FINE
-            // using the VM default locale:
-            logger
-                    .log(Level.FINE, errorMessage.getDetails(Locale
-                            .getDefault()));
-
-            // Provide the title of this error to the user in a highly visible
-            // way
-            // using the current users locale:
-            System.out.println("#### "
-                    + errorMessage.getTitle(currentUsersLocale) + " ####");
-
-            // Provide the text of this error to the user
-            // using the current users locale:
-            System.out.println(errorMessage.getText(currentUsersLocale));
-        }
-    }
-
-    /**
-     * @throws LocalizedException
-     *             is thrown just to show the capabilities of
-     *             LocalizedExceptions
-     */
-    private static void someMethodThrowingAnException()
-            throws LocalizedException {
-        String userCausingTheException = "Daniel";
-        throw new LocalizedException(new ErrorBundle("theCauseOfThisException",
-                new String[]{userCausingTheException}));
-    }
-}
-</source>
-</section>
-
-<section name="Using JDBC provider and qualifying message source">
-<p>
-This example shows how to use qualified message providers, instead of searching
-through all available providers and how to use i18n for messages stored in databases.
-For the sake of the example, we will create an in memory database holding the i18n
-messages using HSQLDB.
-</p>
-<source>
-public class QualifiedJdbcExample {
-    public static void main(String[] args) throws Exception {
-        /////////////////////////////////////////////////////
-        // Prepare example
-        /////////////////////////////////////////////////////
-
-        // Set up in-memory data for the sake of the example
-        prepareTables();
-
-        /////////////////////////////////////////////////////
-        // Example of initialization
-        /////////////////////////////////////////////////////
-
-        // We can initialize JDBC message provider using a properties file
-        Properties props = new Properties();
-        props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("i18n-jdbc.properties"));
-        MessageManager.addMessageProvider("messages", new JdbcMessageProvider(props));
-
-        // We can also initialize JDBC message provider by providing connection (or DataSource)
-        Connection conn = getNewConnection();
-        MessageManager.addMessageProvider("errors", new JdbcMessageProvider(conn, "errors", "id", "language"));
-        conn.close();
-
-        /////////////////////////////////////////////////////
-        // Example of usage
-        /////////////////////////////////////////////////////
-
-        // Simulate the locale of the current user in a multi-user environment
-        // such as a web application
-        Locale currentUsersLocale = new Locale("sv"); // Assume Swedish
-
-        try {
-            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
-
-            // Get i18n text qualifying the message source (i.e. the MessageProvider) to use; messages
-            TextBundle textBundle = new TextBundle("messages", "enterFirstName");
-            System.out.println(textBundle.getText(currentUsersLocale) + ":");
-            String firstName = reader.readLine();
-
-            textBundle = new TextBundle("messages", "enterLastName");
-            System.out.println(textBundle.getText(currentUsersLocale) + ":");
-            String lastName = reader.readLine();
-
-            validateNames(firstName, lastName);
-        }
-        catch(LocalizedRuntimeException lrex) {
-            // Retrieve the detailed localized error message
-            ErrorBundle errorMessage = lrex.getErrorMessage();
-
-            // Print summary and details using the current users locale
-            System.out.println("-- " + errorMessage.getSummary(currentUsersLocale) + " --");
-            System.out.println(errorMessage.getDetails(currentUsersLocale));
-        }
-    }
-
-    private static void validateNames(String firstname, String lastname) {
-        if(firstname.equals(lastname))
-            throw new LocalizedRuntimeException(new ErrorBundle("errors", "identicalNames"));
-    }
-
-    ///////////////////////////////////////////////////////////////////////
-    // Utility methods for the example
-    ///////////////////////////////////////////////////////////////////////
-
-    /**
-     * Create connection to in-memory HSQLDB database
-     * @return
-     * @throws ClassNotFoundException
-     * @throws SQLException
-     */
-    private static Connection getNewConnection() throws ClassNotFoundException, SQLException {
-        Class.forName("org.hsqldb.jdbcDriver"); // Load HSQLDB database driver
-        return DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
-    }
-
-    /**
-     * Create tables and insert messages
-     */
-    private static void prepareTables() throws ClassNotFoundException, SQLException {
-        Connection conn = getNewConnection();
-        Statement stmt = conn.createStatement();
-        stmt.execute(
-                "CREATE TABLE messages ( " +
-                "  'id' VARCHAR(30), " +
-                "  'language' VARCHAR(2), " +
-                "  'text' VARCHAR(100)" +
-                ")");
-        stmt.execute("INSERT INTO messages VALUES ('enterFirstName', 'en', 'Please enter your first name')");
-        stmt.execute("INSERT INTO messages VALUES ('enterLastName', 'en', 'Please enter your last name')");
-        stmt.execute("INSERT INTO messages VALUES ('enterFirstName', 'sv', 'Vänligen ange ditt förnamn')");
-        stmt.execute("INSERT INTO messages VALUES ('enterLastName', 'sv', 'Vänligen ange ditt efternamn')");
-        stmt.execute(
-                "CREATE TABLE errors ( " +
-                "  'id' VARCHAR(30), " +
-                "  'language' VARCHAR(2), " +
-                "  'summary' VARCHAR(100), " +
-                "  'details' VARCHAR(100) " +
-                ")");
-        stmt.execute("INSERT INTO errors VALUES (" +
-                "  'identicalNames', 'en', " +
-                "  'Error! Identical names.', 'You entered the same name as both first name and last name'" +
-                ")");
-        stmt.execute("INSERT INTO errors VALUES (" +
-                "  'identicalNames', 'sv', " +
-                "  'Fel! Identiska namn.', 'Du angav samma namn som både förnamn och efternamn'" +
-                ")");
-        stmt.close();
-        conn.close();
-    }
-}
-</source>
-</section>
-
-<section name="Custom message bundles">
-<p></p>
-</section>
-
-<section name="Implementing a custom message provider">
-<p></p>
-</section>
-
-</body>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<document>
+
+ <properties>
+  <title>Examples</title>
+  <author email="commons-dev@jakarta.apache.org">Commons Documentation Team</author>
+ </properties>
+
+ <body>
+ 
+<section name="Examples">
+<p>This page contains some examples showing the capabilities of the i18n-compoenent.
+Most of the examples can be found in the components sources in the example-package.</p>
+</section>
+
+<section name="Using localized exceptions">
+<p>
+The following example shows how to take advantage of detailed error information
+provided by localized exceptions. In the real world it is no good idea to create
+LocalizedExceptions directly, but to create your own subclasses of LocalizedException.</p>
+<source>
+public class LocalizedExceptionExample {
+    private static final Logger logger = Logger
+            .getLogger(LocalizedExceptionExample.class.getName());
+
+    public static void main(String[] args) {
+        // Install the file providing the required messages for this example
+        MessageManager.addMessageProvider("org.apache.commons-i18n.examples",
+                new XMLMessageProvider(Thread.currentThread().getContextClassLoader().getResourceAsStream(
+                        "exampleMessages.xml")));
+
+        // Simulate the locale of the current user in a multi-user environment
+        // such as a web application
+        Locale currentUsersLocale = Locale.GERMAN;
+
+        // This is the real part dealing with localized exceptions
+        try {
+            someMethodThrowingAnException();
+        } catch (LocalizedException exception) {
+            // Retrieve the detailed localized error message
+            ErrorBundle errorMessage = exception.getErrorMessage();
+
+            // Print the summary of this error to the log with level SEVERE
+            // using the VM default locale:
+            logger.log(Level.SEVERE, errorMessage.getSummary(Locale
+                    .getDefault()));
+
+            // Print the details of this error to the log with level FINE
+            // using the VM default locale:
+            logger
+                    .log(Level.FINE, errorMessage.getDetails(Locale
+                            .getDefault()));
+
+            // Provide the title of this error to the user in a highly visible
+            // way
+            // using the current users locale:
+            System.out.println("#### "
+                    + errorMessage.getTitle(currentUsersLocale) + " ####");
+
+            // Provide the text of this error to the user
+            // using the current users locale:
+            System.out.println(errorMessage.getText(currentUsersLocale));
+        }
+    }
+
+    /**
+     * @throws LocalizedException
+     *             is thrown just to show the capabilities of
+     *             LocalizedExceptions
+     */
+    private static void someMethodThrowingAnException()
+            throws LocalizedException {
+        String userCausingTheException = "Daniel";
+        throw new LocalizedException(new ErrorBundle("theCauseOfThisException",
+                new String[]{userCausingTheException}));
+    }
+}
+</source>
+</section>
+
+<section name="Using JDBC provider and qualifying message source">
+<p>
+This example shows how to use qualified message providers, instead of searching
+through all available providers and how to use i18n for messages stored in databases.
+For the sake of the example, we will create an in memory database holding the i18n
+messages using HSQLDB.
+</p>
+<source>
+public class QualifiedJdbcExample {
+    public static void main(String[] args) throws Exception {
+        /////////////////////////////////////////////////////
+        // Prepare example
+        /////////////////////////////////////////////////////
+
+        // Set up in-memory data for the sake of the example
+        prepareTables();
+
+        /////////////////////////////////////////////////////
+        // Example of initialization
+        /////////////////////////////////////////////////////
+
+        // We can initialize JDBC message provider using a properties file
+        Properties props = new Properties();
+        props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("i18n-jdbc.properties"));
+        MessageManager.addMessageProvider("messages", new JdbcMessageProvider(props));
+
+        // We can also initialize JDBC message provider by providing connection (or DataSource)
+        Connection conn = getNewConnection();
+        MessageManager.addMessageProvider("errors", new JdbcMessageProvider(conn, "errors", "id", "language"));
+        conn.close();
+
+        /////////////////////////////////////////////////////
+        // Example of usage
+        /////////////////////////////////////////////////////
+
+        // Simulate the locale of the current user in a multi-user environment
+        // such as a web application
+        Locale currentUsersLocale = new Locale("sv"); // Assume Swedish
+
+        try {
+            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
+
+            // Get i18n text qualifying the message source (i.e. the MessageProvider) to use; messages
+            TextBundle textBundle = new TextBundle("messages", "enterFirstName");
+            System.out.println(textBundle.getText(currentUsersLocale) + ":");
+            String firstName = reader.readLine();
+
+            textBundle = new TextBundle("messages", "enterLastName");
+            System.out.println(textBundle.getText(currentUsersLocale) + ":");
+            String lastName = reader.readLine();
+
+            validateNames(firstName, lastName);
+        }
+        catch(LocalizedRuntimeException lrex) {
+            // Retrieve the detailed localized error message
+            ErrorBundle errorMessage = lrex.getErrorMessage();
+
+            // Print summary and details using the current users locale
+            System.out.println("-- " + errorMessage.getSummary(currentUsersLocale) + " --");
+            System.out.println(errorMessage.getDetails(currentUsersLocale));
+        }
+    }
+
+    private static void validateNames(String firstname, String lastname) {
+        if(firstname.equals(lastname))
+            throw new LocalizedRuntimeException(new ErrorBundle("errors", "identicalNames"));
+    }
+
+    ///////////////////////////////////////////////////////////////////////
+    // Utility methods for the example
+    ///////////////////////////////////////////////////////////////////////
+
+    /**
+     * Create connection to in-memory HSQLDB database
+     * @return
+     * @throws ClassNotFoundException
+     * @throws SQLException
+     */
+    private static Connection getNewConnection() throws ClassNotFoundException, SQLException {
+        Class.forName("org.hsqldb.jdbcDriver"); // Load HSQLDB database driver
+        return DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
+    }
+
+    /**
+     * Create tables and insert messages
+     */
+    private static void prepareTables() throws ClassNotFoundException, SQLException {
+        Connection conn = getNewConnection();
+        Statement stmt = conn.createStatement();
+        stmt.execute(
+                "CREATE TABLE messages ( " +
+                "  'id' VARCHAR(30), " +
+                "  'language' VARCHAR(2), " +
+                "  'text' VARCHAR(100)" +
+                ")");
+        stmt.execute("INSERT INTO messages VALUES ('enterFirstName', 'en', 'Please enter your first name')");
+        stmt.execute("INSERT INTO messages VALUES ('enterLastName', 'en', 'Please enter your last name')");
+        stmt.execute("INSERT INTO messages VALUES ('enterFirstName', 'sv', 'Vänligen ange ditt förnamn')");
+        stmt.execute("INSERT INTO messages VALUES ('enterLastName', 'sv', 'Vänligen ange ditt efternamn')");
+        stmt.execute(
+                "CREATE TABLE errors ( " +
+                "  'id' VARCHAR(30), " +
+                "  'language' VARCHAR(2), " +
+                "  'summary' VARCHAR(100), " +
+                "  'details' VARCHAR(100) " +
+                ")");
+        stmt.execute("INSERT INTO errors VALUES (" +
+                "  'identicalNames', 'en', " +
+                "  'Error! Identical names.', 'You entered the same name as both first name and last name'" +
+                ")");
+        stmt.execute("INSERT INTO errors VALUES (" +
+                "  'identicalNames', 'sv', " +
+                "  'Fel! Identiska namn.', 'Du angav samma namn som både förnamn och efternamn'" +
+                ")");
+        stmt.close();
+        conn.close();
+    }
+}
+</source>
+</section>
+
+<section name="Custom message bundles">
+<p></p>
+</section>
+
+<section name="Implementing a custom message provider">
+<p></p>
+</section>
+
+</body>
 </document>

Propchange: jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message